diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 67b4b346b6c..c1cb2e853f1 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -6,8 +6,9 @@ build: analysis: tests: override: - - php-scrutinizer-run - + - command: php-scrutinizer-run + idle_timeout: 8000 + imports: - javascript - php @@ -39,9 +40,11 @@ tools: - build/* - dev/* - doc/* - - test/* + - documents/* - htdocs/includes/* - htdocs/core/class/lessc.class.php + - node_modules/* + - test/* paths: - htdocs/ - scripts/ @@ -181,8 +184,10 @@ tools: - 'build/*' - 'dev/*' - 'doc/*' - - 'test/*' + - 'documents/*' - 'htdocs/includes/*' + - 'node_modules/*' + - 'test/*' paths: { } # Similar code detection @@ -194,8 +199,10 @@ tools: - 'build/*' - 'dev/*' - 'doc/*' - - 'test/*' + - 'documents/*' - 'htdocs/includes/*' + - 'node_modules/*' + - 'test/*' paths: { } # Coding-Style / Bug Detection @@ -209,8 +216,10 @@ tools: - 'build/*' - 'dev/*' - 'doc/*' - - 'test/*' + - 'documents/*' - 'htdocs/includes/*' + - 'node_modules/*' + - 'test/*' paths: { } config: { } path_configs: { } diff --git a/.travis.yml b/.travis.yml index 637ba35995b..6422e33a7e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,9 @@ # from Dolibarr GitHub repository. # For syntax, see https://docs.travis-ci.com/user/languages/php/ -# We use dist: xenial to have php 5.6+ available +# We use dist: bionic = 18.04 os: linux -dist: xenial -#dist: bionic +dist: bionic language: php @@ -18,22 +17,43 @@ services: - mysql - postgresql + +before_install: +- | + echo "Add ondrej PPA" + sudo add-apt-repository -y ppa:ondrej/php + sudo apt-get update + echo "Disabling Xdebug for composer" + export PHP_VERSION_NAME=$(phpenv version-name) + echo $PHP_VERSION_NAME + ls ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/ + cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini + phpenv config-rm xdebug.ini + phpenv rehash + echo + addons: - # Force postgresql to 9.4 (the oldest availablable on xenial) - postgresql: '9.4' + # Force postgresql version + postgresql: '10' apt: sources: - # To use the last version of pgloader, we add repo of postgresql with a name available in http://apt.postgresql.org/pub/repos/apt/ - - pgdg-xenial + - sourceline: 'ppa:ondrej/php' packages: # We need a webserver to test the webservices # Let's install Apache with. - apache2 - # mod_php is not supported by Travis. Add fcgi. We install FPM later on. - - libapache2-mod-fastcgi # We need pgloader for import mysql database into pgsql - pgloader - + - php + - php7.1-pgsql + - php7.1-mysqli + - php7.1-xml + - php7.1-intl + - php8.1-pgsql + - php8.1-mysqli + - php8.1-xml + - php8.1-intl + env: global: # Set to true for very verbose output @@ -44,20 +64,20 @@ jobs: #allow_failures: #- php: nightly include: - - stage: PHP 5.6-7.4 + - stage: PHP 7.0-8.1 if: type = push - php: '5.6' + php: '7.1' env: DB=postgresql - - stage: PHP 5.6-7.4 + - stage: PHP 7.0-8.1 if: type = pull_request OR type = push - php: '7.4.22' + php: '8.1' env: DB=mysql - stage: PHP Dev if: type = push AND branch = develop php: nightly env: DB=mysql - stage: PHP Dev - if: type = push AND branch = 15.0 + if: type = push AND branch = 17.0 php: nightly env: DB=mysql @@ -72,13 +92,6 @@ notifications: on_failure: always use_notice: true -before_install: -- | - echo "Disabling Xdebug for composer" - export PHP_VERSION_NAME=$(phpenv version-name) - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini - phpenv config-rm xdebug.ini - echo install: - | @@ -94,13 +107,6 @@ install: - | echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" - if [ "$TRAVIS_PHP_VERSION" = '5.6' ]; then - composer -n require phpunit/phpunit ^5 \ - php-parallel-lint/php-parallel-lint ^1 \ - php-parallel-lint/php-console-highlighter ^0 \ - php-parallel-lint/php-var-dump-check ~0.4 \ - squizlabs/php_codesniffer ^3 - fi if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then composer -n require phpunit/phpunit ^6 \ php-parallel-lint/php-parallel-lint ^1 \ @@ -108,7 +114,7 @@ install: php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi - if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '7.4.22' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then composer -n require phpunit/phpunit ^7 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -116,8 +122,8 @@ install: squizlabs/php_codesniffer ^3 fi # phpunit 9 is required for php 8 - if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - composer -n require --ignore-platform-reqs phpunit/phpunit ^7 \ + if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-var-dump-check ~0.4 \ @@ -246,17 +252,22 @@ before_script: - echo "Setting up Apache + FPM" + # setup link for php legacy + - sudo ln -s ~/.phpenv/versions/$(phpenv version-name)/bin/php /bin/php + # install apache web server + - sudo apt-get install apache2 php-fpm php-mysql php-pgsql php-gd php-ldap php-xml php-mbstring libapache2-mod-php # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - | - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '7.4.22' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf fi - - sudo a2enmod rewrite actions fastcgi alias + - sudo a2enmod proxy_fcgi rewrite setenvif cgi alias - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars - - sudo chown -R travis:travis /var/lib/apache2/fastcgi + #- sudo chown -R travis:travis /var/lib/apache2/fastcgi + # start php-fpm - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm # configure apache virtual hosts - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf @@ -284,7 +295,7 @@ script: set -e #parallel-lint --exclude htdocs/includes --blame . # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then + if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ @@ -299,7 +310,7 @@ script: # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$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 @@ -310,7 +321,7 @@ script: # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$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 @@ -471,6 +482,9 @@ after_script: ls $TRAVIS_BUILD_DIR/documents #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log + echo "After script - Output last lines of apache error.log" + sudo ls /var/log/apache2 + sudo tail -n 50 /var/log/apache2/travis_error_log after_success: - | @@ -479,16 +493,16 @@ after_success: after_failure: - | echo Failure detected, so we show samples of log to help diagnose - # This part of code is executed only if previous command that fails are enclosed with set +e - # Upgrade log files + # This part of code is executed only if the command that fails are enclosed with set +e + # Show upgrade log files for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` do echo "Debugging informations for file $ficlog" #cat $ficlog done - # Apache log file + # Show Apache log file echo "Debugging informations for file apache error.log" - sudo cat /var/log/apache2/travis_error_log + sudo tail -n 50 /var/log/apache2/travis_error_log if [ "$DEBUG" = true ]; then # Dolibarr log file echo "Debugging informations for file dolibarr.log (latest 50 lines)" diff --git a/.tx/config b/.tx/config index ca169bfcc50..494ba41613d 100644 --- a/.tx/config +++ b/.tx/config @@ -98,6 +98,12 @@ source_file = htdocs/langs/en_US/cron.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.datapolicy] +file_filter = htdocs/langs//datapolicy.lang +source_file = htdocs/langs/en_US/datapolicy.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.deliveries] file_filter = htdocs/langs//deliveries.lang source_file = htdocs/langs/en_US/deliveries.lang diff --git a/COPYRIGHT b/COPYRIGHT index 83d054d63be..46e2f093900 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -13,7 +13,7 @@ The Dolibarr images resources (available in the doc directory) is distributed un The name Dolibarr is a trademark initially registered by Laurent Destailleur and ceased to the Dolibarr foundation. You can use the name Dolibarr -for your own need as long as you follow the rules defined on the page https://wiki.dolibarr.org/index.php/Rules_to_use_the_brand_name_%22Dolibarr%22 +for your own need as long as you follow the rules defined on the page https://wiki.dolibarr.org/index.php/Rules_to_use_the_brand_name_%22Dolibarr%22 The use of the name DoliStore is also restricted to the same rules defined on https://wiki.dolibarr.org/index.php/Rules_to_use_the_brand_name_%22Dolibarr%22 @@ -31,10 +31,11 @@ Mobiledetect 2.8.39 MIT License Yes NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency ParseDown 1.6 MIT License Yes Markdown parser -PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files +PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers +PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files -php-iban 4.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP +php-iban 4.1.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests PSR/Logs 1.0 MIT License Yes Library for logs (used by DebugBar) diff --git a/ChangeLog b/ChangeLog index 9a5513031e9..e1030fa18de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ English Dolibarr ChangeLog For users: --------------- +NEW Minimal PHP version is now PHP 7.0 instead of PHP 5.6 + ... @@ -28,9 +30,9 @@ Following changes may create regressions for some external modules, but were nec For users: --------------- -NEW: PHP 8.1 compatibility: - Warning: Application works correctly with PHP8 and 8.1 but you may experience a lot of PHP warning into the PHP server log files (depending - on the PHP setup). Removal of all PHP warnings on server side is planned for v17. +NEW: PHP 8.0 and 8.1 compatibility: + Warning!! Application works correctly with PHP 8.0 and 8.1 but you will experience a lot of PHP warnings into the PHP server + log files (depending on your PHP setup). Removal of all PHP warnings on server side is planned for v17. NEW: Support for recurring purchase invoices. NEW: #20292 Include German public holidays NEW: Can show ZATCA QR-Code on PDFs @@ -53,72 +55,62 @@ NEW: Add column "Total HT" to products array on document creation card NEW: Add configuration for text color of button action NEW: Add entity filter in exports NEW: Show the event block on recurring invoices #20870 -NEW: Add filter "opportunity status" on statistics of projects. NEW: Add firstname, lastname and max number of attendees for module "Event Organization" NEW: Add margin info in proposal and order list NEW: Add massaction "Edit Extrafield" for Product NEW: Add more fields to detect duplicate during import of thirdparties NEW: Add option to foce delivery on email for purchase order receipt to yes -NEW: Add param boder table for md theme -NEW: Add param color button action NEW: Add possibility to create contract from invoice NEW: Add possibility with constant MAIN_LOGIN_BADCHARUNAUTHORIZED to define bad character unauthorized into login name NEW: Add private and public notes on tax files. -NEW: Add status "Obsolete" to KM articles NEW: Add substitutions "user numbers" NEW: allow a ticket to be automatically marked as read when created from backend. NEW: allow cut&paste as real numeric value to excel NEW: A public form to send a message and create a lead is available NEW: automatically set totally received status in reception NEW: Auto set invoice paid when adding credit not and remain to pay is 0 -NEW: Availibility dictionnary has a new column unit and number -NEW: Can change value of AWP during the inventory NEW: Can enter price with tax for predefined products on purchase objects NEW: Can filter on a thirdparty on product statistics NEW: Can removed doc templates from setup page of thirdparty -NEW: Can set the parent company during the creation of thirdparty (action=add of societe/card.php) NEW: Can use ! to make a search that exclude a string -NEW: Change in theme colors does not need to use the refresh button NEW: clean values and amount in FEC import NEW: const MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND for mailing mass action NEW: Contact filter project list NEW: Create contract from invoice -NEW: create third-party with contact if not found on public ticket +NEW: Database: Can store the session into database (instead of beeing managed by PHP) +NEW: Database: Some core tables are created only at module activation NEW: Default value for MAIN_SECURITY_CSRF_WITH_TOKEN is now 2 (GET are also protected agains CSRF attacks) NEW: deposit payment terms: add field into dictionary admin page to define default percentage of deposit. NEW: Dictionaries - add possibility to manage countries in EEC +NEW: Dictionaries - Availibility dictionnary has a new column unit and number NEW: Display errors in a message box after generating documents -NEW: Display physical and virtual stock of the products when creating OF from a BOM -NEW: Display product ref in "Object link" product tab for BOM NEW: Enhance the import. Can use 'auto' for the ref (import of orders) NEW: Events on Proposal to Return to Draft NEW: Page to list expense report payments NEW: JS inventory autocalc input NEW: language support for more emailing target selectors NEW: leave requests: add field into type dictionary to block request if balance is negative -NEW: MAIN_MAIL_AUTOCOPY_TO can accept several email and special keys -NEW: MAIN_SEARCH_CAT_OR_BY_DEFAULT const for search by category NEW: Mass action "Close shipments" -NEW: Module BOM - Add tabs for nets Bom -NEW: Module BOM - Add the possibility to add sub-BOMs to BOM -NEW: Module Recruitment - Add a public page with all list of open job positions. +NEW: Module BOM - add tabs for nets Bom +NEW: Module BOM - add the possibility to add sub-BOMs to BOM +NEW: Module Recruitment - Add a public page with list of all open job positions. NEW: Module Recruitment - Add a tab with list of application on the jobposition file. -NEW: Module Website - supports now the multicompany module -NEW: More mode for THEME_TOPMENU_DISABLE_IMAGE (2, 3, ...) NEW: Add option to move checkbox column as first column on Thirdparty list (only few screens) -NEW: on redirect of page in website module, GET parameters are kept. -NEW: optional display warning icons on ticket list NEW: payment conditions enabling semi-automatic deposit creation (Issue #18439) NEW: possibility to consume multiple batch NEW: Reverse movement product consumption NEW: Send email to the supplier order contact NEW: add permission to report time on timesheet -NEW: SEPA XML - option to place payment Type Info at Credit transfer Transaction level -NEW: Some core tables are created only at module activation +NEW: Knowledge Management - add status "Obsolete" to KM articles NEW: MRP - split consumption line on MO +NEW: MRP - display physical and virtual stock of the products when creating OF from a BOM +NEW: MRP - display product ref in "Object link" product tab for BOM +NEW: Projects - add filter "opportunity status" on statistics of projects. NEW: Proposals - option update prices on proposal cloning -NEW: stock filter in reassort lists -NEW: stock limit in stock export CSV +NEW: SEPA XML - option to place payment Type Info at Credit transfer Transaction level +NEW: Stocks - stock filter in reassort lists +NEW: Stocks - stock limit in stock export CSV +NEW: Stocks - Inventory - can change value of AWP during the inventory NEW: Supplier order - Show ref supplier of reception in linked object block NEW: support user_modif in order NEW: Surveys - Show number of votes into the label of tab "Results" of a survey @@ -128,20 +120,28 @@ NEW: TakePOS - show product reference NEW: TakePOS - add constant to hide categories NEW: TakePOS - add constant to show category description NEW: TakePOS - add constant to show only the products in stock +NEW: Themes - add param color button action +NEW: Themes - Change in theme colors does not need to use the refresh button +NEW: Themes - more mode for THEME_TOPMENU_DISABLE_IMAGE (2, 3, ...) +NEW: Themes - MD - add param border table for md theme +NEW: Third-Parties - Add rules "customer accountancy code" is mandatory to validate invoice +NEW: Third-Parties - Can set the parent company during the creation of thirdparty (action=add of societe/card.php) +NEW: Tickets - create Third-party with contact if not found on public ticket NEW: Tickets - option to default check "notify tier at creation" NEW: Tickets - Trigger: allow to automatically send messages on new tickets +NEW: Tickets - optional display warning icons on ticket list +NEW: Websites Module - supports now the multicompany module +NEW: Websites Module - on redirect of page in website module, GET parameters are kept. NEW: The backup tools has an "lowmemory" option for mysqldump on large database NEW: The 'reposition' class works on ajax constantonoff that make redirects -NEW: Thirdparty - Add rules "customer accountancy code" is mandatory to validate invoice NEW: thumbnail field in product list NEW: total mark rate in list NEW: uncheck "send message" by default on a ticket when private messages has been checked NEW: VAT Report by month - Show detail by rate and also by code -NEW: Can store the session into database (instead of beeing managed by PHP) NEW: Added MMK currency (Myanmar Kyat) NEW: On a form to send an email, we show all emails of contacts of object - Modules + Modules state NEW: Module Partnership Management NEW: Module Event Organization Management @@ -164,7 +164,7 @@ NEW: Creation of the function select_bom() used to display bom select list NEW: Add trigger and event on completely received status change NEW: Add utility function send backup by mail NEW: add WordPress OAuth to save a token (not SSO) -NEW: A module can embed a sql script run at each Dolibarr upgrade +NEW: A module can embed a SQL script run at each Dolibarr upgrade NEW: Add param to keep the robot=index meta tag on public pages NEW: Add method hintindex() in database handlers. NEW: add modifications for new function "$db->prefix()" @@ -209,9 +209,11 @@ NEW: TakePOS - add hook doaction in TakePOS invoice Config Options: NEW: Add hidden option on contract PDF line to hide qty and price -NEW: Option INVOICEREC_SET_AUTOFILL_DATE_START/END -NEW: Option MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND to send last document in mass mailing action - +NEW: Option MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND to send last document in mass mailing action +NEW: Option MAIN_API_DEBUG to save API logs into a file +NEW: Option MAIN_MAIL_AUTOCOPY_TO can accept several email and special keys +NEW: Option MAIN_SEARCH_CAT_OR_BY_DEFAULT const for search by category +NEW: Option INVOICEREC_SET_AUTOFILL_DATE_START/END WARNING: diff --git a/build/exe/doliwamp/README.md b/build/exe/doliwamp/README.md index be8cf1f3ac5..8f9878bfa29 100644 --- a/build/exe/doliwamp/README.md +++ b/build/exe/doliwamp/README.md @@ -9,3 +9,5 @@ The build of .exe files need to have some windows executable files already insta If you have technical knowledge in web administration and plan to share your server instance (Apache, Mysql or PHP) with other projects than Dolibarr or want to use Dolibarr other components (PostgreSQL), you should not use this assistant and make a manual installation of Dolibarr on your existing server by downloading the standard package (.tgz or .zip file). + +!!! See file ../makepack-howto.txt diff --git a/build/exe/doliwamp/config.inc.php.install b/build/exe/doliwamp/config.inc.php.install index 6ad04752766..544cb116c7e 100644 --- a/build/exe/doliwamp/config.inc.php.install +++ b/build/exe/doliwamp/config.inc.php.install @@ -1,5 +1,4 @@ = 4.1.2, in libraries/tbl_properties.inc.php $cfg['AttributeTypes'] = array( diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 10cc1561011..beeec222c2a 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -582,6 +582,17 @@ begin end; end; + if browser = 'iexplore.exe' then + begin + if FileExists (pfPath+'/Microsoft/Edge/Application/msedge.exe') then + begin + if MsgBox(CustomMessage('MicrosoftEdgeDetected'),mbConfirmation,MB_YESNO) = IDYES then + begin + browser := pfPath+'/Microsoft/Edge/Application/msedge.exe'; + end; + end; + end; + if browser = 'iexplore.exe' then begin if FileExists (pfPath+'/Internet Explorer/iexplore.exe') then diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index be88302cd1d..7bc42a0bf88 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -8,13 +8,13 @@ of Dolibarr. There is a chapter for BETA version and a chapter for RELEASE versi Prerequisites to build tgz, debian and rpm packages: > apt-get install perl tar dpkg dpatch p7zip-full rpm zip php-cli -Prerequisites to build autoexe DoliWamp package: +Prerequisites to build autoexe DoliWamp package from Linux (solution seems broken since Ubuntu 20.04): > apt-get install wine q4wine > Launch "wine cmd" to check a drive Z: pointing to / exists. > Install InnoSetup For example by running isetup-5.5.8.exe (https://www.jrsoftware.org) https://files.jrsoftware.org/is/5/ > Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB - For example by running wampserver3.2.0_x64.exe (https://www.wampserver.com). + For example by running wampserver3.2.6_x64.exe (https://www.wampserver.com). See file build/exe/doliwamp.iss to know the doliwamp version currently setup. > Add path to ISCC into PATH windows var: Launch wine cmd, then regedit and add entry int HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATH @@ -25,9 +25,21 @@ Prerequisites to build autoexe DoliWamp package: ***** Prerequisites For Windows ***** -Install Perl -Install WampServer-3.2.*-64.exe -isetup-5.5.8.exe +Prerequisites to build autoexe DoliWamp package from Windows: + +> Install Perl for Windwos (https://strawberryperl.com/) +> Install isetup-5.5.8.exe (https://www.jrsoftware.org) +> Install WampServer-3.2.*-64.exe (Apache 2.4.51, PHP 7.3.33, MariaDB 10.6.5 for example. Version must match the values found into doliwamp.iss) +> Install GIT for Windows (https://git-scm.com/ => You must choose option "Add Git bash profile", "Git commit as-is") +> Install Dolibarr verions: + git clone https://github.com/dolibarr/dolibarr + +> Add the path of PHP (C:\wamp64\bin\php\php7.3.33) and InnoSetup (C:\Program Files (x86)\Inno Setup 5) into the %PATH% of Windows. + +> Create a config file c:\dolibarr\dolibarr\htdocs\conf\conf.php with content + { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapier/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapier/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -84,7 +84,7 @@ const getFallbackRealAction = (z, bundle) => { // // For the test poll, you should get some real data, to aid the setup process. // const module = bundle.inputData.module; // const options = { -// url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/actions', +// url: bundle.authData.url + '/api/index.php/zapier/getactionschoices/actions', // }; // return z.request(options).then((response) => JSON.parse(response.content)); diff --git a/dev/examples/zapier/triggers/contact.js b/dev/examples/zapier/triggers/contact.js index 2ba3bd226f8..ef83970e0b5 100644 --- a/dev/examples/zapier/triggers/contact.js +++ b/dev/examples/zapier/triggers/contact.js @@ -10,7 +10,7 @@ const subscribeHook = (z, bundle) => { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapier/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapier/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -76,7 +76,7 @@ const getFallbackRealContact = (z, bundle) => { // const getModulesChoices = (z/*, bundle*/) => { // // For the test poll, you should get some real data, to aid the setup process. // const options = { -// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// url: bundle.authData.url + '/api/index.php/zapier/getmoduleschoices', // }; // return z.request(options).then((response) => JSON.parse(response.content)); @@ -94,7 +94,7 @@ const getFallbackRealContact = (z, bundle) => { // // For the test poll, you should get some real data, to aid the setup process. // const module = bundle.inputData.module; // const options = { -// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// url: url: bundle.authData.url + '/api/index.php/zapier/getactionschoices/thirparty`, // }; // return z.request(options).then((response) => JSON.parse(response.content)); diff --git a/dev/examples/zapier/triggers/member.js b/dev/examples/zapier/triggers/member.js index 3385cdca625..68f80b30009 100644 --- a/dev/examples/zapier/triggers/member.js +++ b/dev/examples/zapier/triggers/member.js @@ -10,7 +10,7 @@ const subscribeHook = (z, bundle) => { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapier/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapier/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -76,7 +76,7 @@ const getFallbackRealMember = (z, bundle) => { // const getModulesChoices = (z/*, bundle*/) => { // // For the test poll, you should get some real data, to aid the setup process. // const options = { -// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// url: bundle.authData.url + '/api/index.php/zapier/getmoduleschoices', // }; // return z.request(options).then((response) => JSON.parse(response.content)); @@ -94,7 +94,7 @@ const getFallbackRealMember = (z, bundle) => { // // For the test poll, you should get some real data, to aid the setup process. // const module = bundle.inputData.module; // const options = { -// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// url: url: bundle.authData.url + '/api/index.php/zapier/getactionschoices/thirparty`, // }; // return z.request(options).then((response) => JSON.parse(response.content)); diff --git a/dev/examples/zapier/triggers/order.js b/dev/examples/zapier/triggers/order.js index 061ce218d10..2265c4da288 100644 --- a/dev/examples/zapier/triggers/order.js +++ b/dev/examples/zapier/triggers/order.js @@ -10,7 +10,7 @@ const subscribeHook = (z, bundle) => { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapier/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapier/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -74,7 +74,7 @@ const getFallbackRealOrder = (z, bundle) => { // // For the test poll, you should get some real data, to aid the setup process. // const module = bundle.inputData.module; // const options = { -// url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/orders', +// url: bundle.authData.url + '/api/index.php/zapier/getactionschoices/orders', // }; // return z.request(options).then((response) => JSON.parse(response.content)); diff --git a/dev/examples/zapier/triggers/thirdparty.js b/dev/examples/zapier/triggers/thirdparty.js index 76194acbc9a..6c477b1174f 100644 --- a/dev/examples/zapier/triggers/thirdparty.js +++ b/dev/examples/zapier/triggers/thirdparty.js @@ -10,7 +10,7 @@ const subscribeHook = (z, bundle) => { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapier/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapier/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -83,7 +83,7 @@ const getFallbackRealThirdparty = (z, bundle) => { // const getModulesChoices = (z/*, bundle*/) => { // // For the test poll, you should get some real data, to aid the setup process. // const options = { -// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// url: bundle.authData.url + '/api/index.php/zapier/getmoduleschoices', // }; // return z.request(options).then((response) => JSON.parse(response.content)); @@ -102,7 +102,7 @@ const getFallbackRealThirdparty = (z, bundle) => { // // For the test poll, you should get some real data, to aid the setup process. // const module = bundle.inputData.module; // const options = { -// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// url: url: bundle.authData.url + '/api/index.php/zapier/getactionschoices/thirparty`, // }; // return z.request(options).then((response) => JSON.parse(response.content)); diff --git a/dev/examples/zapier/triggers/ticket.js b/dev/examples/zapier/triggers/ticket.js index c642099bd55..ee5a3f8efd7 100644 --- a/dev/examples/zapier/triggers/ticket.js +++ b/dev/examples/zapier/triggers/ticket.js @@ -10,7 +10,7 @@ const subscribeHook = (z, bundle) => { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapier/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapier/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -76,7 +76,7 @@ const getFallbackRealTicket = (z, bundle) => { // const getModulesChoices = (z/*, bundle*/) => { // // For the test poll, you should get some real data, to aid the setup process. // const options = { -// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// url: bundle.authData.url + '/api/index.php/zapier/getmoduleschoices', // }; // return z.request(options).then((response) => JSON.parse(response.content)); @@ -97,7 +97,7 @@ const getFallbackRealTicket = (z, bundle) => { // // For the test poll, you should get some real data, to aid the setup process. // const module = bundle.inputData.module; // const options = { -// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// url: url: bundle.authData.url + '/api/index.php/zapier/getactionschoices/thirparty`, // }; // return z.request(options).then((response) => JSON.parse(response.content)); diff --git a/dev/examples/zapier/triggers/user.js b/dev/examples/zapier/triggers/user.js index 92209bb8651..a706bb9a3d6 100644 --- a/dev/examples/zapier/triggers/user.js +++ b/dev/examples/zapier/triggers/user.js @@ -10,7 +10,7 @@ const subscribeHook = (z, bundle) => { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapier/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapier/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -73,7 +73,7 @@ const getFallbackRealUser = (z, bundle) => { // const getModulesChoices = (z/*, bundle*/) => { // // For the test poll, you should get some real data, to aid the setup process. // const options = { -// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// url: bundle.authData.url + '/api/index.php/zapier/getmoduleschoices', // }; // return z.request(options).then((response) => JSON.parse(response.content)); @@ -93,7 +93,7 @@ const getFallbackRealUser = (z, bundle) => { // // For the test poll, you should get some real data, to aid the setup process. // const module = bundle.inputData.module; // const options = { -// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// url: url: bundle.authData.url + '/api/index.php/zapier/getactionschoices/thirparty`, // }; // return z.request(options).then((response) => JSON.parse(response.content)); diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-limitpublic.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-limitpublic.conf new file mode 100644 index 00000000000..45b4a9b8084 --- /dev/null +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-limitpublic.conf @@ -0,0 +1,20 @@ +# Fail2Ban configuration file +# +# Regexp to catch known spambots and software alike. Please verify +# that it is your intent to block IPs which were driven by +# above mentioned bots. + + +[Definition] + +# To test, you can inject this example into log +# echo `date +'%Y-%m-%d %H:%M:%S'`" INFO 1.2.3.4 --- Access to GET /public/clicktodial/cidlookup.php" >> /mypath/documents/dolibarr.log +# +# then +# fail2ban-client status web-dol-passforgotten +# +# To test rule file on a existing log file +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-limitpublic.conf + +failregex = ^ [A-Z\s]+ \s+--- Access to .*/public/ +ignoreregex = diff --git a/dev/setup/fail2ban/jail.local b/dev/setup/fail2ban/jail.local index bd506e20812..733987aa45c 100644 --- a/dev/setup/fail2ban/jail.local +++ b/dev/setup/fail2ban/jail.local @@ -8,21 +8,35 @@ enabled = true port = http,https filter = web-dolibarr-rulespassforgotten -logpath = >> /mypath/documents/documents/dolibarr.log +logpath = /mypath/documents/documents/dolibarr.log action = %(action_mw)s bantime = 4320000 ; 50 days findtime = 86400 ; 1 day maxretry = 10 + [web-dol-bruteforce] ; rule against bruteforce hacking (login + api) enabled = true port = http,https filter = web-dolibarr-rulesbruteforce -logpath = >> /mypath/documents/documents/dolibarr.log +logpath = /mypath/documents/documents/dolibarr.log action = %(action_mw)s bantime = 86400 ; 1 day findtime = 3600 ; 1 hour maxretry = 10 + +[web-dol-limitpublic] + +; rule to add rate limit on some public pages +enabled = true +port = http,https +filter = web-dolibarr-limitpublic +logpath = /mypath/documents/documents/dolibarr.log +action = %(action_mw)s +bantime = 86400 ; 1 day +findtime = 86400 ; 1 day +maxretry = 500 + diff --git a/dev/tools/test/namespacemig/main.inc.php b/dev/tools/test/namespacemig/main.inc.php index d46d8e38c1c..e013e6af1da 100644 --- a/dev/tools/test/namespacemig/main.inc.php +++ b/dev/tools/test/namespacemig/main.inc.php @@ -1,5 +1,4 @@ hasRight('accounting', 'chartofaccount'); if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index c1bc435145f..02921a78cb2 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -32,6 +32,7 @@ * \brief Page to administer model of chart of accounts */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -78,7 +79,7 @@ $search_country_id = GETPOST('search_country_id', 'int'); if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 7876712fe51..36b9f3a8b93 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -23,6 +23,7 @@ * \brief Card of accounting account */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; @@ -48,7 +49,7 @@ $label = GETPOST('label', 'alpha'); if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index e65572eafd3..7b86902e009 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -22,6 +22,7 @@ * \brief Page to assign mass categories to accounts */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; @@ -44,7 +45,7 @@ if ($cat_id == 0) { } // Security check -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index ea613ea38cd..3a6664b8b44 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -22,6 +22,7 @@ * \brief Page to administer data tables */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -42,7 +43,7 @@ $rowid = GETPOST('rowid', 'alpha'); $code = GETPOST('code', 'alpha'); // Security access -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } @@ -885,9 +886,11 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co $fieldname = 'country'; if ($context == 'add') { $fieldname = 'country_id'; - print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + $preselectcountrycode = GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : $mysoc->country_code; + print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); } else { - print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code); + print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); } print ''; } elseif ($fieldlist[$field] == 'country_id') { diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index 437ff1b7116..5ad23febb36 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -22,6 +22,7 @@ * \brief Setup page to configure accounting expert module */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -31,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $langs->loadLangs(array("compta", "admin", "accountancy")); // Security check -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index bfc1fd29316..9a3b63adcc3 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan")); // Security check -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index d0a0ab671d4..23a16340c0b 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; $langs->loadLangs(array("compta", "bills", "admin", "accountancy")); // Security access -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 6a6135dad40..301a3def70e 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -21,6 +21,7 @@ * \brief Setup page to configure fiscal year */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index f6e765caf13..d798b6baa5f 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -22,6 +22,7 @@ * \brief Page to show a fiscal year */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php'; diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 77ec988143a..1cc6fcba958 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -21,6 +21,7 @@ * \brief Page to show info of a fiscal year */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index af569e08ae3..22d39dea7d0 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -29,6 +29,7 @@ * \brief Setup page to configure accounting expert module */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -38,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other")); // Security access -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 3ea90e283ce..8d350afbb07 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -26,6 +26,7 @@ if (!defined('CSRFCHECK_WITH_TOKEN')) { define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -45,7 +46,7 @@ $rowid = GETPOST('rowid', 'alpha'); $code = GETPOST('code', 'alpha'); // Security access -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index cc0d4de9f31..c9f78596bcd 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -23,6 +23,7 @@ * \brief List of accounting sub-account (auxiliary accounts) */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -47,7 +48,7 @@ $search_type = GETPOST('search_type', 'int'); if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->chartofaccount)) { +if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); } diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 324c9c767b4..cb479a1dc59 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -24,6 +24,7 @@ * \brief Balance of book keeping */ +// Load Dolibarr environment require '../../main.inc.php'; // Class diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 15dba808e00..e120606b927 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -25,6 +25,7 @@ * \brief Page to show book-entry */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 4ba5f0aa9be..c374f5ba9fe 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -25,6 +25,7 @@ * \brief List operation of book keeping */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -479,8 +480,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Bookkeeping'; $objectlabel = 'Bookkeeping'; - $permissiontoread = $user->rights->societe->lire; - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoread = $user->hasRight('societe', 'lire'); + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -652,21 +653,28 @@ if (!empty($sortfield)) { // Export into a file with format defined into setup (FEC, CSV, ...) // Must be after definition of $sql if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) { - // TODO Replace the fetchAll to get all ->line followed by call to ->export(). It consumew too much memory on large export. Replace this with the query($sql) and loop on each line to export them. + // TODO Replace the fetchAll to get all ->line followed by call to ->export(). It consumes too much memory on large export. + // Replace this with the query($sql) and loop on each line to export them. $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1)); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - // Export files + // Export files then exit $accountancyexport = new AccountancyExport($db); + + $mimetype = $accountancyexport->getMimeType($formatexportset); + + top_httphead($mimetype, 1); + + // Output data on screen $accountancyexport->export($object->lines, $formatexportset); $notifiedexportdate = GETPOST('notifiedexportdate', 'alpha'); $notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha'); if (!empty($accountancyexport->errors)) { - setEventMessages('', $accountancyexport->errors, 'errors'); + dol_print_error('', '', $accountancyexport->errors); } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { // Specify as export : update field date_export or date_validated $error = 0; @@ -700,11 +708,10 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex if (!$error) { $db->commit(); - // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExportedOrValidated"), null, 'mesgs'); } else { $error++; $db->rollback(); - setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated"), null, 'errors'); + dol_print_error('', $langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated")); } } exit; @@ -860,8 +867,8 @@ if ($optioncss != '') { print ''; } print ''; -print ''; -print ''; +print ''; +print ''; print ''; if (count($filter)) { @@ -882,7 +889,7 @@ if (empty($reshook)) { $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; if (!empty($user->rights->accounting->mouvements->export)) { - $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); + $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); } $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); @@ -982,14 +989,14 @@ if (!empty($arrayfields['t.subledger_account']['checked'])) { print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount'); print ''; } else { - print ''; + print ''; } print ''; } // Label operation if (!empty($arrayfields['t.label_operation']['checked'])) { print ''; - print ''; + print ''; print ''; } // Debit @@ -1007,7 +1014,7 @@ if (!empty($arrayfields['t.credit']['checked'])) { // Lettering code if (!empty($arrayfields['t.lettering_code']['checked'])) { print ''; - print ''; + print ''; print '
'.$langs->trans("NotReconciled").''; print ''; } @@ -1115,10 +1122,10 @@ if (!empty($arrayfields['t.tms']['checked'])) { print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['t.date_export']['checked'])) { - print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['t.date_validated']['checked'])) { - print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['t.import_key']['checked'])) { print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4b5f0d9bad6..e417f21832c 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -25,6 +25,7 @@ * \brief List operation of ledger ordered by account number */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -394,8 +395,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Bookkeeping'; $objectlabel = 'Bookkeeping'; - $permissiontoread = $user->rights->societe->lire; - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoread = $user->hasRight('societe', 'lire'); + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 7657e997ff6..7ae48c749c2 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -785,12 +785,13 @@ class AccountancyCategory // extends CommonObject } /** - * Return list of custom groups that are active + * Return list of custom groups. * * @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups + * @param int $active 1= active, 0=not active * @return array|int Array of groups or -1 if error */ - public function getCats($categorytype = -1) + public function getCats($categorytype = -1, $active = 1) { global $conf, $mysoc; @@ -801,7 +802,7 @@ class AccountancyCategory // extends CommonObject $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type, c.sens"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; - $sql .= " WHERE c.active = 1"; + $sql .= " WHERE c.active = " . (int) $active; $sql .= " AND c.entity = ".$conf->entity; if ($categorytype >= 0) { $sql .= " AND c.category_type = 1"; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index e4af034b1f4..390aaa9ed4a 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -286,6 +286,28 @@ class AccountancyExport } + /** + * Return the MIME type of a file + * + * @param int $formatexportset Id of export format + * @return string MIME type. + */ + public function getMimeType($formatexportset) + { + $mime = 'text/csv'; + + switch ($formatexportset) { + case self::$EXPORT_TYPE_FEC: + $mime = 'text/tab-separated-values'; + break; + default: + $mime = 'text/csv'; + break; + } + + return $mime; + } + /** * Function who chose which export to use with the default config, and make the export into a file * diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index bf487d47c2c..95296624145 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -811,9 +811,9 @@ class AccountingAccount extends CommonObject $suggestedaccountingaccountfor = ''; 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) - if ($type=='customer' && !empty($product->accountancy_code_sell)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell)) { $code_p = $product->accountancy_code_sell; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) { $code_p = $product->accountancy_code_buy; } $suggestedid = $accountingAccount['dom']; @@ -821,36 +821,36 @@ class AccountingAccount extends CommonObject } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with VAT - if ($type=='customer' && !empty($product->accountancy_code_sell)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell)) { $code_p = $product->accountancy_code_sell; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) { $code_p = $product->accountancy_code_buy; } $suggestedid = $accountingAccount['dom']; $suggestedaccountingaccountfor = 'eecwithvat'; } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number - if ($type=='customer' && !empty($product->accountancy_code_sell)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell)) { $code_p = $product->accountancy_code_sell; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) { $code_p = $product->accountancy_code_buy; } $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) { // European intravat sale - if ($type=='customer' && !empty($product->accountancy_code_sell_intra)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell_intra)) { $code_p = $product->accountancy_code_sell_intra; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy_intra)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy_intra)) { $code_p = $product->accountancy_code_buy_intra; } $suggestedid = $accountingAccount['intra']; $suggestedaccountingaccountfor = 'eec'; } else { // Foreign sale - if ($type=='customer' && !empty($product->accountancy_code_sell_export)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell_export)) { $code_p = $product->accountancy_code_sell_export; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy_export)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy_export)) { $code_p = $product->accountancy_code_buy_export; } $suggestedid = $accountingAccount['export']; @@ -870,12 +870,12 @@ class AccountingAccount extends CommonObject // Manage Deposit if ($factureDet->desc == "(DEPOSIT)" || $facture->type == $facture::TYPE_DEPOSIT) { $accountdeposittoventilated = new self($this->db); - if ($type=='customer') { + if ($type == 'customer') { $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); - } elseif ($type=='supplier') { + } elseif ($type == 'supplier') { $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT, 1); } - if ($result < 0) { + if (isset($result) && $result < 0) { return -1; } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0cc8ab4e8d9..95ba38d20bb 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -169,6 +169,16 @@ class BookKeeping extends CommonObject */ public $piece_num; + /** + * @var integer|string date of movement validated & lock + */ + public $date_validation; + + /** + * @var integer|string date of movement who are noticed like exported + */ + public $date_export; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ @@ -788,8 +798,7 @@ class BookKeeping extends CommonObject $this->piece_num = $obj->piece_num; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_export = $this->db->jdate($obj->date_export); - $this->date_validation = $this->db->jdate($obj->date_validated); - $this->date_validation = $this->db->jdate($obj->date_validation); + $this->date_validation = isset($obj->date_validated) ? $this->db->jdate($obj->date_validated) : ''; } $this->db->free($resql); @@ -901,7 +910,8 @@ class BookKeeping extends CommonObject } // Affichage par compte comptable if (!empty($option)) { - $sql .= ' AND t.subledger_account IS NOT NULL'; + $sql .= " AND t.subledger_account IS NOT NULL"; + $sql .= " AND t.subledger_account <> ''"; $sortfield = 't.subledger_account'.($sortfield ? ','.$sortfield : ''); $sortorder = 'ASC'.($sortfield ? ','.$sortfield : ''); } else { @@ -1123,14 +1133,13 @@ class BookKeeping extends CommonObject /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * - * @return int <0 if KO, >0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @return int <0 if KO, >0 if OK */ public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { @@ -1151,7 +1160,7 @@ class BookKeeping extends CommonObject foreach ($filter as $key => $value) { if ($key == 't.doc_date') { $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; - } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { + } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=' || $key == 't.doc_date>' || $key == 't.doc_date<') { $sqlwhere[] = $key."'".$this->db->idate($value)."'"; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key."'".$this->db->escape($value)."'"; diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index c4b5540fcc8..da4f5eecd25 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -21,6 +21,7 @@ * \brief Home closure page */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 06db5cedd0e..472dce11e37 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -26,6 +26,7 @@ * \brief Home customer journalization page */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index d0b25bdffd2..5064003c7ff 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -24,6 +24,7 @@ * \brief Home expense report ventilation */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 2745ab4784a..bd7d6273848 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -44,7 +44,7 @@ if ($user->socid > 0) { if (!isModEnabled('accounting')) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } */ @@ -79,7 +79,7 @@ if (GETPOST('addbox')) { * View */ -$help_url = ''; +$help_url = 'EN:Module_Double_Entry_Accounting#Setup'; llxHeader('', $langs->trans("AccountancyArea"), $help_url); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 34faba7e27c..d2b37c11a87 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -294,9 +294,7 @@ if ($action == 'writebookkeeping') { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - $companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur']; - $companystatic->code_client = $tabcompany[$key]['code_client']; $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->fournisseur = 1; @@ -636,9 +634,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! foreach ($tabfac as $key => $val) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - $companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur']; - $companystatic->code_client = $tabcompany[$key]['code_client']; $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->fournisseur = 1; @@ -767,7 +763,7 @@ if (empty($action) || $action == 'view') { $periodlink = ''; $exportlink = ''; $builddate = dol_now(); - $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; + $description = $langs->trans("DescJournalOnlyBindedVisible").'
'; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description .= $langs->trans("DepositsAreNotIncluded"); } else { @@ -847,9 +843,7 @@ if (empty($action) || $action == 'view') { foreach ($tabfac as $key => $val) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - $companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur']; - $companystatic->code_client = $tabcompany[$key]['code_client']; $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->fournisseur = 1; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 107dda05f4a..675c900680d 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -30,6 +30,7 @@ * \brief Page with sells journal */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -310,9 +311,7 @@ if ($action == 'writebookkeeping') { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->code_compta = $tabcompany[$key]['code_compta']; - $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur']; $companystatic->code_client = $tabcompany[$key]['code_client']; - $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->client = 3; $invoicestatic->id = $key; @@ -600,9 +599,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->code_compta = $tabcompany[$key]['code_compta']; - $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur']; $companystatic->code_client = $tabcompany[$key]['code_client']; - $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->client = 3; $invoicestatic->id = $key; @@ -790,9 +787,7 @@ if (empty($action) || $action == 'view') { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->code_compta = $tabcompany[$key]['code_compta']; - $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur']; $companystatic->code_client = $tabcompany[$key]['code_client']; - $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->client = 3; $invoicestatic->id = $key; diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index d737925f2c3..b56271850e5 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -21,6 +21,7 @@ * \brief Page of a journal */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -51,7 +52,7 @@ if ($result > 0) { } elseif ($result < 0) { dol_print_error('', $object->error, $object->errors); } elseif ($result == 0) { - accessforbidden($langs->trans('ErrorRecordNotFound')); + accessforbidden('ErrorRecordNotFound'); } $hookmanager->initHooks(array('globaljournal', $object->nature.'journal')); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 449b13f1039..2237b4347ca 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -24,6 +24,7 @@ * \brief Home supplier journalization page */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 2ffed8b8d97..c94084358bd 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -30,6 +30,7 @@ * \brief Page to setup the module Foundation */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; diff --git a/htdocs/adherents/admin/member_emails.php b/htdocs/adherents/admin/member_emails.php index c55d44d391f..4f942d1f6a8 100644 --- a/htdocs/adherents/admin/member_emails.php +++ b/htdocs/adherents/admin/member_emails.php @@ -29,6 +29,7 @@ * \brief Page to setup the module Foundation */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; diff --git a/htdocs/adherents/admin/member_extrafields.php b/htdocs/adherents/admin/member_extrafields.php index 210e6213d6f..5776828c078 100644 --- a/htdocs/adherents/admin/member_extrafields.php +++ b/htdocs/adherents/admin/member_extrafields.php @@ -24,6 +24,7 @@ * \brief Page to setup extra fields of members */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -81,14 +82,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '

'; diff --git a/htdocs/adherents/admin/member_type_extrafields.php b/htdocs/adherents/admin/member_type_extrafields.php index c643d6e15d4..ac796a4d3ab 100644 --- a/htdocs/adherents/admin/member_type_extrafields.php +++ b/htdocs/adherents/admin/member_type_extrafields.php @@ -27,6 +27,7 @@ * \brief Page to setup extra fields of members */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -84,14 +85,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print "
"; diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 41ea43c4cec..26c39df5b63 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -24,6 +24,7 @@ * \brief File of main public page for member module */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -58,6 +59,7 @@ if ($action == 'update') { $public = GETPOST('MEMBER_ENABLE_PUBLIC'); $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2); $editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT'); + $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC'); $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int'); $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09'); @@ -65,6 +67,7 @@ if ($action == 'update') { $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); if ($forcetype < 0) { $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); @@ -236,6 +239,13 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1); print "\n"; + // SHow counter of validated members publicly + print ''; + print $langs->trans("MemberCountersArePublic"); + print ''; + print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (!empty($conf->global->MEMBER_COUNTERS_ARE_PUBLIC) ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1); + print "\n"; + // Jump to an online payment page print ''; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 204ba1b8f20..ef1daf0b6c8 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -26,6 +26,7 @@ * \brief Page of members events */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 696520f79d4..4b0eed154c0 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2012 Philippe Grand + * Copyright (C) 2012-2022 Philippe Grand * * 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 @@ -124,7 +124,7 @@ if (!empty($this->control->tpl['action_delete'])) { if (empty($user->socid)) { echo '
'; - if ($user->rights->adherent->creer) { + if ($user->hasRight('adherent', 'creer')) { echo ''.$langs->trans('Modify').''; } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6816023f8de..e0f6b693eb7 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -110,10 +110,10 @@ if ($id > 0 || !empty($ref)) { } // Define variables to determine what the current user can do on the members -$canaddmember = $user->rights->adherent->creer; +$canaddmember = $user->hasRight('adherent', 'creer'); // Define variables to determine what the current user can do on the properties of a member if ($id) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->hasRight('adherent', 'creer'); } // Security check @@ -246,7 +246,7 @@ if (empty($reshook)) { } } - if ($action == 'update' && !$cancel && $user->rights->adherent->creer) { + if ($action == 'update' && !$cancel && $user->hasRight('adherent', 'creer')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate = ''; @@ -421,7 +421,7 @@ if (empty($reshook)) { } } - if ($action == 'add' && $user->rights->adherent->creer) { + if ($action == 'add' && $user->hasRight('adherent', 'creer')) { if ($canvas) { $object->canvas = $canvas; } @@ -629,7 +629,7 @@ if (empty($reshook)) { } } - if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { + if ($user->hasRight('adherent', 'creer') && $action == 'confirm_valid' && $confirm == 'yes') { $error = 0; $db->begin(); @@ -854,7 +854,7 @@ if (empty($reshook)) { } } - if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { + if ($user->hasRight('adherent', 'creer') && $action == 'confirm_add_spip' && $confirm == 'yes') { if (!count($object->errors)) { if (!$mailmanspip->add_to_spip($object)) { setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors'); @@ -867,7 +867,7 @@ if (empty($reshook)) { // Actions to build doc $upload_dir = $conf->adherent->dir_output; - $permissiontoadd = $user->rights->adherent->creer; + $permissiontoadd = $user->hasRight('adherent', 'creer'); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails @@ -1222,7 +1222,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Type print ''.$langs->trans("Type").''; - if ($user->rights->adherent->creer) { + if ($user->hasRight('adherent', 'creer')) { print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $object->typeid), 0, 0, 0, '', 0, 0, 0, '', '', 1); } else { print $adht->getNomUrl(1); @@ -1351,7 +1351,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; // Default language - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; print img_picto('', 'language').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); print ''; @@ -1799,7 +1799,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("DateOfBirth").''.dol_print_date($object->birth, 'day').''; // Default language - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''.$langs->trans("DefaultLang").''; //$s=picto_from_langcode($object->default_lang); @@ -1820,7 +1820,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Third party Dolibarr if (isModEnabled('societe')) { print ''; - $editenable = $user->rights->adherent->creer; + $editenable = $user->hasRight('adherent', 'creer'); print $form->editfieldkey('LinkedToDolibarrThirdParty', 'thirdparty', '', $object, $editenable); print ''; if ($action == 'editthirdparty') { @@ -1857,7 +1857,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Login Dolibarr - Link to user print ''; - $editenable = $user->rights->adherent->creer && $user->rights->user->user->creer; + $editenable = $user->hasRight('adherent', 'creer') && $user->rights->user->user->creer; print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, $editenable); print ''; if ($action == 'editlogin') { @@ -1901,7 +1901,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Send card by email // TODO Remove this to replace with a template /* - if ($user->rights->adherent->creer) { + if ($user->hasRight('adherent', 'creer')) { if (Adherent::STATUS_VALIDATED == $object->statut) { if ($object->email) print ''.$langs->trans("SendCardByMail")."\n"; else print ''.$langs->trans("SendCardByMail")."\n"; @@ -1913,7 +1913,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { }*/ // Modify - if (!empty($user->rights->adherent->creer)) { + if ($user->hasRight('adherent', 'creer')) { print ''.$langs->trans("Modify").''."\n"; } else { print ''.$langs->trans("Modify").''."\n"; @@ -1921,7 +1921,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Validate if (Adherent::STATUS_DRAFT == $object->statut) { - if ($user->rights->adherent->creer) { + if ($user->hasRight('adherent', 'creer')) { print ''.$langs->trans("Validate").''."\n"; } else { print ''.$langs->trans("Validate").''."\n"; @@ -1930,7 +1930,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Reactivate if (Adherent::STATUS_RESILIATED == $object->statut || Adherent::STATUS_EXCLUDED == $object->statut) { - if ($user->rights->adherent->creer) { + if ($user->hasRight('adherent', 'creer')) { print ''.$langs->trans("Reenable")."\n"; } else { print ''.$langs->trans("Reenable").''."\n"; @@ -2022,7 +2022,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $filedir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member'); $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed = $user->rights->adherent->lire; - $delallowed = $user->rights->adherent->creer; + $delallowed = $user->hasRight('adherent', 'creer'); print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object); $somethingshown = $formfile->numoffiles; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4918bac8fc8..0aa1af68afc 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -335,8 +335,8 @@ class Adherent extends CommonObject 'public' => array('type' => 'smallint(6)', 'label' => 'Public', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 145), 'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => -1, 'position' => 150), 'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>-1, 'position'=> 153), - 'note_private' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155), - 'note_public' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160), + 'note_public' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155), + 'note_private' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160), 'datevalid' => array('type' => 'datetime', 'label' => 'DateValidation', 'enabled' => 1, 'visible' => -1, 'position' => 165), 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 170), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 175), @@ -1405,7 +1405,7 @@ class Adherent extends CommonObject $this->email = $obj->email; $this->url = $obj->url; - $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); + $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : array()); $this->photo = $obj->photo; $this->statut = $obj->statut; @@ -1867,10 +1867,10 @@ class Adherent extends CommonObject $outputlangs = $langs; $newlang = ''; $lang_id = GETPOST('lang_id'); - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && !empty($lang_id)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) { $newlang = $lang_id; } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $customer->default_lang; } if (!empty($newlang)) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 12735e70211..4516b132982 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -397,7 +397,7 @@ class AdherentType extends CommonObject $this->description = $this->db->escape($this->note_public); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { if ($this->setMultiLangs($user) < 0) { $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -2; @@ -509,7 +509,7 @@ class AdherentType extends CommonObject $this->vote = $obj->vote; // multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $this->getMultiLangs(); } diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index d30e851b9a2..35ab65e9d82 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Xebax Christy * Copyright (C) 2017 Regis Houssin * Copyright (C) 2020 Thibault FOUCART - * Copyright (C) 2020 FrƩdƩric France + * Copyright (C) 2020 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 @@ -286,7 +286,7 @@ class Members extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) { throw new RestException(401); } // Check mandatory fields @@ -311,7 +311,7 @@ class Members extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) { throw new RestException(401); } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index f969017146b..0512ea46b20 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -173,7 +173,7 @@ class Subscriptions extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) { throw new RestException(401); } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index c8282179fe5..bce8227ab57 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -25,6 +25,7 @@ * \ingroup societe */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -87,10 +88,10 @@ if ($id > 0 || !empty($ref)) { } // Define variables to determine what the current user can do on the members -$canaddmember = $user->rights->adherent->creer; +$canaddmember = $user->hasRight('adherent', 'creer'); // Define variables to determine what the current user can do on the properties of a member if ($id) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->hasRight('adherent', 'creer'); } $permissiontoadd = $canaddmember; @@ -186,8 +187,8 @@ if ($id > 0) { print dol_get_fiche_end(); $modulepart = 'member'; - $permissiontoadd = $user->rights->adherent->creer; - $permtoedit = $user->rights->adherent->creer; + $permissiontoadd = $user->hasRight('adherent', 'creer'); + $permtoedit = $user->hasRight('adherent', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; print "

"; diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index 0a7073f96b0..a97a0a74d28 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -23,6 +23,7 @@ * \brief Export page htpasswd of the membership file */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index db87e514cb5..7f09bccb3d3 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -22,6 +22,7 @@ * \brief Page fiche LDAP adherent */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; @@ -62,10 +63,10 @@ if ($id > 0 || !empty($ref)) { } // Define variables to determine what the current user can do on the members -$canaddmember = $user->rights->adherent->creer; +$canaddmember = $user->hasRight('adherent', 'creer'); // Define variables to determine what the current user can do on the properties of a member if ($id) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->hasRight('adherent', 'creer'); } // Security check diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index ec02bff77d3..4c80627d70e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -232,7 +232,7 @@ if (empty($reshook)) { } // Close - if ($massaction == 'close' && $user->rights->adherent->creer) { + if ($massaction == 'close' && $user->hasRight('adherent', 'creer')) { $tmpmember = new Adherent($db); $error = 0; $nbclose = 0; @@ -262,7 +262,7 @@ if (empty($reshook)) { } // Create external user - if ($massaction == 'createexternaluser' && $user->rights->adherent->creer && $user->rights->user->user->creer) { + if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->rights->user->user->creer) { $tmpmember = new Adherent($db); $error = 0; $nbcreated = 0; @@ -302,7 +302,7 @@ if (empty($reshook)) { $objectlabel = 'Members'; $permissiontoread = $user->rights->adherent->lire; $permissiontodelete = $user->rights->adherent->supprimer; - $permissiontoadd = $user->rights->adherent->creer; + $permissiontoadd = $user->hasRight('adherent', 'creer'); $uploaddir = $conf->adherent->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -350,7 +350,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; } -if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) { +if ((!empty($search_categ) && ($search_categ > 0 || $search_categ == -2)) || !empty($catid)) { // We need this table joined to the select in order to filter by categ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; } @@ -617,16 +617,16 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); -if ($user->rights->adherent->creer) { +if ($user->hasRight('adherent', 'creer')) { $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Resiliate"); } if ($user->rights->adherent->supprimer) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if ($user->rights->societe->creer) { +if (isModEnabled('category') && $user->rights->adherent->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } -if ($user->rights->adherent->creer && $user->rights->user->user->creer) { +if ($user->hasRight('adherent', 'creer') && $user->rights->user->user->creer) { $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { @@ -635,7 +635,7 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; -if ($user->rights->adherent->creer) { +if ($user->hasRight('adherent', 'creer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 7e445e41a37..ea5e22fe153 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -51,7 +51,7 @@ if ($result > 0) { } -$permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('adherent', 'creer'); // Used by the include of actions_setnotes.inc.php // Fetch object if ($id > 0 || !empty($ref)) { @@ -71,10 +71,10 @@ if ($id > 0 || !empty($ref)) { } // Define variables to determine what the current user can do on the members -$canaddmember = $user->rights->adherent->creer; +$canaddmember = $user->hasRight('adherent', 'creer'); // Define variables to determine what the current user can do on the properties of a member if ($id) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->hasRight('adherent', 'creer'); } $hookmanager->initHooks(array('membernote')); @@ -155,7 +155,7 @@ if ($id) { $cssclass = 'titlefield'; - $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php + $permission = $user->hasRight('adherent', 'creer'); // Used by the include of notes.tpl.php include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 63deec867ef..f632a1ea9c7 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -21,6 +21,7 @@ * \brief Page with statistics on members */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 3490f61d006..bb65a1047a8 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -21,6 +21,7 @@ * \brief Page with geographical statistics on members */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 0854b94bff2..11447dcd8bb 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -23,6 +23,7 @@ * \brief Page of subscription members statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 5779fe036d9..db40a8ad465 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -27,6 +27,7 @@ * \brief tab for Adding, editing, deleting a member's memberships */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -112,10 +113,10 @@ if ($id > 0 || !empty($ref)) { } // Define variables to determine what the current user can do on the members -$canaddmember = $user->rights->adherent->creer; +$canaddmember = $user->hasRight('adherent', 'creer'); // Define variables to determine what the current user can do on the properties of a member if ($id) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->hasRight('adherent', 'creer'); } // Security check @@ -594,7 +595,7 @@ if ($rowid > 0) { print ''; - if ($action != 'editthirdparty' && $user->rights->adherent->creer) { + if ($action != 'editthirdparty' && $user->hasRight('adherent', 'creer')) { print ''; } print '
'; print $langs->trans("LinkedToDolibarrThirdParty"); print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'
'; @@ -636,7 +637,7 @@ if ($rowid > 0) { print ''; - if ($action != 'editlogin' && $user->rights->adherent->creer) { + if ($action != 'editlogin' && $user->hasRight('adherent', 'creer')) { print '\n"; // Date of payment diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 439541dff05..215635757c2 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -22,6 +22,7 @@ * \brief Page to add/edit/remove a member subscription */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -267,7 +268,7 @@ if ($rowid && $action != 'edit') { // Confirmation to delete subscription if ($action == 'delete') { - //$formquestion=array(); + $formquestion=array(); //$formquestion['text']=''.$langs->trans("ThisWillAlsoDeleteBankRecord").''; $text = $langs->trans("ConfirmDeleteSubscription"); if (isModEnabled("banque") && !empty($conf->global->ADHERENT_BANK_USE)) { @@ -350,7 +351,7 @@ if ($rowid && $action != 'edit') { print '
'; if ($user->rights->adherent->cotisation->creer) { - if (!$bankline->rappro) { + if (!empty($bankline->rappro)) { print '"; } else { print '"; diff --git a/htdocs/adherents/subscription/info.php b/htdocs/adherents/subscription/info.php index 9eb431320cd..5faf1d31760 100644 --- a/htdocs/adherents/subscription/info.php +++ b/htdocs/adherents/subscription/info.php @@ -22,6 +22,7 @@ * \brief Page with information of subscriptions of a member */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index c19fa40c2bc..1523bd4ee90 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -23,6 +23,7 @@ * \brief list of subscription */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index b6463e006a9..c26a9d13536 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -29,6 +29,7 @@ * \brief Member's type setup */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -753,7 +754,7 @@ if ($rowid > 0) { // Actions print '
'; print ''; print ''; print ''; print ''; print '
'; print $langs->trans("LinkedToDolibarrUser"); print ''; if ($user->rights->user->user->creer) { print 'id.'">'.img_edit($langs->trans('SetLinkToUser'), 1).''; @@ -1072,7 +1073,7 @@ if ($rowid > 0) { // Payment mode print '
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200'); + print $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200', 1); print "
'; - if ($user->rights->adherent->creer) { + if ($user->hasRight('adherent', 'creer')) { print ''.img_edit().''; } if ($user->rights->adherent->supprimer) { diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index d7650a8de2b..058e36fe1bd 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -22,6 +22,7 @@ * \brief Page fiche LDAP members types */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index d7d062a1e5f..5e1db1233b8 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -25,6 +25,7 @@ * \brief Member translation page */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 902206c7874..1b5a0e5d0fe 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -25,6 +25,7 @@ * \brief Vcard tab of a member */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -53,10 +54,10 @@ if ($id > 0 || !empty($ref)) { } // Define variables to determine what the current user can do on the members -$canaddmember = $user->rights->adherent->creer; +$canaddmember = $user->hasRight('adherent', 'creer'); // Define variables to determine what the current user can do on the properties of a member if ($id) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->hasRight('adherent', 'creer'); } // Security check diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index e48ce5f2382..a98b9984009 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -21,6 +21,7 @@ * \brief Setup page to configure accountant / auditor */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/admin/accounting.php b/htdocs/admin/accounting.php index ebe0712b03a..fba458936b8 100644 --- a/htdocs/admin/accounting.php +++ b/htdocs/admin/accounting.php @@ -21,6 +21,7 @@ * \brief Setup page to configure accounting module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index e9708d8c005..c62101ab70b 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -25,6 +25,7 @@ * \brief Autocreate actions for agenda module setup page */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 13f8ad246a0..cade3a90e71 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of agenda */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -86,15 +87,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 6e0a6e9085f..86701344ba4 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -25,6 +25,7 @@ * \brief Page to setup external calendars for agenda module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 1014d40de50..7b057a0693c 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -26,6 +26,7 @@ * \brief Autocreate actions for agenda module setup page */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 166c24f2188..76c717b669d 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -21,6 +21,7 @@ * \brief Page to setup agenda reminder options */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index e3f2c7307f7..499d7233ed0 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -24,6 +24,7 @@ * \brief Page to setup miscellaneous options of agenda module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 1382ef49983..3626eec4455 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of bank */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -82,14 +83,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/admin/bankline_extrafields.php b/htdocs/admin/bankline_extrafields.php index d86733e4e24..06f1267343a 100644 --- a/htdocs/admin/bankline_extrafields.php +++ b/htdocs/admin/bankline_extrafields.php @@ -85,14 +85,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 4957d5fb513..96dd7affdba 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -24,6 +24,7 @@ * \brief Page to setup barcode module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; @@ -31,10 +32,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; // Load translation files required by the page $langs->load("admin"); +// Security Check Access if (!$user->admin) { accessforbidden(); } +// Get Parameters $action = GETPOST('action', 'aZ09'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index b19db5a3d5e..a35aef780d2 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -21,6 +21,7 @@ * \brief Setup page of module BOM */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php index 0691f91b592..7b77702eea4 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of BOM */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -81,14 +82,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 1bc5f67239e..c5234e314ce 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -23,6 +23,7 @@ * \brief Page to setup boxes */ +// Load Dolibarr environment require '../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 396d44625a7..cf93155b814 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -25,6 +25,7 @@ * \brief Page to setup the bank module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 8b8f2c6c921..3174b5bc091 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -23,6 +23,7 @@ * \brief Page to setup module ClickToDial */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -35,8 +36,8 @@ if (!$user->admin) { $action = GETPOST('action', 'aZ09'); -if (!in_array('clicktodial', $conf->modules)) { - accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name"))); +if (!isModEnabled('clicktodial')) { + accessforbidden($langs->transnoentitiesnoconv("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name"))); } diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 4bffad16ee3..b218a91385b 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -31,6 +31,7 @@ * \brief Setup page of module Order */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php index cf887b6b454..277d61e1b2f 100644 --- a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php +++ b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php @@ -30,6 +30,7 @@ * \brief Page to setup extra fields of reception */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -91,14 +92,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print "
"; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index af44c18bee6..55d87673a98 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -27,6 +27,7 @@ * \brief Setup page to configure company/foundation */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/admin/company_socialnetworks.php b/htdocs/admin/company_socialnetworks.php index 1f2d102b644..20d86f4aa59 100644 --- a/htdocs/admin/company_socialnetworks.php +++ b/htdocs/admin/company_socialnetworks.php @@ -28,6 +28,7 @@ * \brief Setup page to configure company social networks */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index 7bb291d521e..afc23f3ff63 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -27,6 +27,7 @@ * \brief Page to setup accountancy module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php deleted file mode 100644 index 6eaeb0bf233..00000000000 --- a/htdocs/admin/confexped.php +++ /dev/null @@ -1,146 +0,0 @@ - - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2011-2016 Juanjo Menent ù - * Copyright (C) 2015 Claudio Aschieri - * - * 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/admin/confexped.php - * \ingroup produit - * \brief Page to setup sending module - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array('admin', 'sendings', 'deliveries')); - -if (!$user->admin) { - accessforbidden(); -} - -$action = GETPOST('action', 'aZ09'); - - -/* - * Actions - */ - -// Shipment note -if (isModEnabled('expedition') && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { - // This option should always be set to on when module is on. - dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); -} -/* -if ($action == 'activate_sending') -{ - dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); - header("Location: confexped.php"); - exit; -} -if ($action == 'disable_sending') -{ - dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity); - header("Location: confexped.php"); - exit; -} -*/ - -// Delivery note -if ($action == 'activate_delivery') { - dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this - dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity); - header("Location: confexped.php"); - exit; -} elseif ($action == 'disable_delivery') { - dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity); - header("Location: confexped.php"); - exit; -} - - -/* - * View - */ - -$dir = DOL_DOCUMENT_ROOT."/core/modules/expedition/"; -$form = new Form($db); - -llxHeader("", $langs->trans("SendingsSetup")); - -$linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); -print '
'; -$head = expedition_admin_prepare_head(); - -print dol_get_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'shipment'); - -// Miscellaneous parameters - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''."\n"; - -// expedition activation/desactivation -print ""; -print ''; -print ''; -print '"; -print ''; - -// Delivery note activate/deactivate Bon de livraison activation/desactivation -print ''; -print ''; -print ''; -print '"; -print ''; -print '
'.$langs->trans("Feature").' '.$langs->trans("Status").'
'.$langs->trans("SendingsAbility").''; -print ''; -print ''.img_picto($langs->trans("Required"), 'switch_on').''; -/*if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) -{ - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; -} -else -{ - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; -}*/ -print "
'; -print $langs->trans("DeliveriesOrderAbility"); -print '
'.info_admin($langs->trans("NoNeedForDeliveryReceipts"), 0, 1); -print '
'; -print ''; - -if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; -} else { - print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; -} - -print "
'; - -print ''; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 1354f418967..e5625b0f975 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -24,6 +24,7 @@ * \brief Admin page to define miscellaneous constants */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 31d0776da6b..98c72ac68dc 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -22,6 +22,7 @@ * \brief Setup page of module Contracts */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index d9825ad6886..d0fd21c80a0 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -21,6 +21,7 @@ * \brief Page to setup DAV server */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; @@ -76,14 +77,14 @@ print ''; $head = dav_admin_prepare_head(); -print dol_get_fiche_head($head, 'webdav', '', -1, 'action'); +print dol_get_fiche_head($head, 'webdav', '', -1, ''); if ($action == 'edit') { print '
'; print ''; print ''; - print ''; + print '
'; print ''; foreach ($arrayofparameters as $key => $val) { @@ -96,7 +97,7 @@ if ($action == 'edit') { $label = $langs->trans($key); if ($key == 'DAV_RESTICT_ON_IP') { $label = $langs->trans("RESTRICT_ON_IP"); - $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); + $tooltiphelp .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); } print $form->textwithpicto($label, $tooltiphelp); print ''; } elseif ($value == 'accountancy_code' || $value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 0695408c16d..1026ea12442 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -26,6 +26,7 @@ * \brief Page to setup GUI display options */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php index 37168baa3d4..432b912e76c 100644 --- a/htdocs/admin/import.php +++ b/htdocs/admin/import.php @@ -29,6 +29,7 @@ * \brief config page module import */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 787a9d6d820..87b49c95468 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -22,11 +22,14 @@ * \brief Home page of setup area */ +// Load Dolibarr environment require '../main.inc.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'companies')); +$action = ''; + if (!$user->admin) { accessforbidden(); } @@ -119,11 +122,12 @@ print '
'; // Add hook to add information $parameters = array(); +$object = new stdClass(); $reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; if (empty($reshook)) { // Show into other - print ''.$langs->trans("SetupDescription5")."
"; + //print ''.$langs->trans("SetupDescription5")."
"; print '
'; // Show logo diff --git a/htdocs/admin/knowledgerecord_extrafields.php b/htdocs/admin/knowledgerecord_extrafields.php index 62580d585c3..13c628be99b 100644 --- a/htdocs/admin/knowledgerecord_extrafields.php +++ b/htdocs/admin/knowledgerecord_extrafields.php @@ -85,14 +85,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 568664b92b7..926f988567b 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -26,6 +26,7 @@ * \brief Page to setup module LDAP */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; @@ -138,7 +139,7 @@ $formldap = new FormLdap($db); print ''; print ''; -print dol_get_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'ldap', '', -1); print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; @@ -119,19 +120,19 @@ if ($action == 'edit') { print ''; print '
'; } else { - print ''; + print '
'; print ''; foreach ($arrayofparameters as $key => $val) { - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print '
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $label = $langs->trans($key); if ($key == 'DAV_RESTICT_ON_IP') { $label = $langs->trans("RESTRICT_ON_IP"); - $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample").''; + $tooltiphelp .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample").''; } print $form->textwithpicto($label, $tooltiphelp); - print ''; + print ''; if ($key == 'DAV_ALLOW_PRIVATE_DIR') { print $langs->trans("AlwaysActive"); } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') { diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 6672f04a1af..dccf777df60 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -24,6 +24,7 @@ * \brief Setup page for debugbar module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index f83b77e67a6..6903571d394 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -26,6 +26,7 @@ * Mandatory fields are stored into $user->default_values[url]['mandatory']['querystring'|'_noquery_'][paramkey]=paramvalue */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -294,6 +295,7 @@ if ($mode != 'focus' && $mode != 'mandatory') { if ($mode != 'sortorder') { $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST unset($substitutionarray['__USER_SIGNATURE__']); + unset($substitutionarray['__SENDEREMAIL_SIGNATURE__']); $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; foreach ($substitutionarray as $key => $val) { $texthelp .= $key.' -> '.$val.'
'; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 6935ec9d521..59c826413aa 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -25,6 +25,7 @@ * \brief Page to setup late delays */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index de26d237d01..a1fef4091ce 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -56,6 +56,39 @@ $type = 'delivery'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +// Shipment note +if (isModEnabled('expedition') && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { + // This option should always be set to on when module is on. + dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); +} +/* + if ($action == 'activate_sending') + { + dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); + header("Location: confexped.php"); + exit; + } + if ($action == 'disable_sending') + { + dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity); + header("Location: confexped.php"); + exit; + } + */ + +// Delivery note +if ($action == 'activate_delivery') { + dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this + dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity); + header("Location: delivery.php"); + exit; +} elseif ($action == 'disable_delivery') { + dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity); + header("Location: delivery.php"); + exit; +} + if ($action == 'updateMask') { $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); $maskdelivery = GETPOST('maskdelivery', 'alpha'); @@ -160,6 +193,7 @@ if ($action == 'setmod') { } + /* * View */ @@ -178,275 +212,295 @@ $head = expedition_admin_prepare_head(); print dol_get_fiche_head($head, 'receivings', $langs->trans("Receivings"), -1, 'shipment'); -// Delivery numbering model - -print load_fiche_titre($langs->trans("DeliveryOrderNumberingModules"), '', ''); - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''."\n"; - -clearstatcache(); - -foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/delivery/"); - - if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) { - $file = substr($file, 0, dol_strlen($file) - 4); - - require_once $dir.$file.'.php'; - - $module = new $file; - - if ($module->isEnabled()) { - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { - continue; - } - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { - continue; - } - - print ''; - - // Show example of numbering module - print ''."\n"; - - print ''; - - $delivery = new Delivery($db); - $delivery->initAsSpecimen(); - - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $delivery); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { - $nextval = $langs->trans($nextval); - } - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } - - print ''; - - print ''; - } - } - } - closedir($handle); - } - } -} - -print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->name."\n"; - print $module->info(); - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); - print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') { - print ''.$langs->trans($tmp).''; - } else { - print $tmp; - } - print '
'; - if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print '
'; - - -/* - * Documents Models for delivery - */ print '
'; -print load_fiche_titre($langs->trans("DeliveryOrderModel"), '', ''); - -// Defini tableau def de modele -$type = "delivery"; -$def = array(); - -$sql = "SELECT nom"; -$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql .= " WHERE type = '".$db->escape($type)."'"; -$sql .= " AND entity = ".$conf->entity; - -$resql = $db->query($sql); -if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } +print '
'.$langs->trans("DeliveriesOrderAbility").'
'; +if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { + print ' '.img_picto($langs->trans("Disabled"), 'switch_off').''; } else { - dol_print_error($db); + print ' '.img_picto($langs->trans("Enabled"), 'switch_on').''; } -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; +print '
'.info_admin($langs->trans("NoNeedForDeliveryReceipts"), 0, 1).''; +print '
'; +print '
'; -clearstatcache(); -foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/delivery/doc/"); - if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); +if (!empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { + // Delivery numbering model - foreach ($filelist as $file) { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + print load_fiche_titre($langs->trans("DeliveryOrderNumberingModules"), '', ''); - require_once $dir.'/'.$file; - $module = new $classname($db); + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { - $modulequalified = 0; - } - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { - $modulequalified = 0; - } + clearstatcache(); - if ($modulequalified) { - print ''; + + // Show example of numbering module + print ''."\n"; + + print ''; - // Active - if (in_array($name, $def)) { - print ""; - } else { - print ""; - } - - // Default - print "'; + $delivery = new Delivery($db); + $delivery->initAsSpecimen(); // Info - $htmltooltip = ''.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $delivery); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { + $nextval = $langs->trans($nextval); + } + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + print ''; - // Preview - print ''; - print ''; } } } + closedir($handle); } } } + + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) { - print $module->info($langs); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/delivery/"); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) { + $file = substr($file, 0, dol_strlen($file) - 4); + + require_once $dir.$file.'.php'; + + $module = new $file; + + if ($module->isEnabled()) { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } + + print '
'.$module->name."\n"; + print $module->info(); + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') { + print ''.$langs->trans($tmp).''; } else { - print $module->description; + print $tmp; + } + print '
'; + if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; } print '\n"; - print 'scandir).'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print "\n"; - print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - if ($conf->global->DELIVERY_ADDON_PDF == "$name") { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; - if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'pdf').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print '
'; + + + /* + * Documents Models for delivery + */ + print '
'; + print load_fiche_titre($langs->trans("DeliveryOrderModel"), '', ''); + + // Defini tableau def de modele + $type = "delivery"; + $def = array(); + + $sql = "SELECT nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " WHERE type = '".$db->escape($type)."'"; + $sql .= " AND entity = ".$conf->entity; + + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } + } else { + dol_print_error($db); + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + clearstatcache(); + + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/delivery/doc/"); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); + + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } + + if ($modulequalified) { + print ''; + + // Active + if (in_array($name, $def)) { + print ""; + } else { + print ""; + } + + // Default + print "'; + + // Info + $htmltooltip = ''.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + print ''; + + // Preview + print ''; + + print ''; + } + } + } + } + } + } + } + + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } + print '\n"; + print 'scandir).'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print "\n"; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + if ($conf->global->DELIVERY_ADDON_PDF == "$name") { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') { + print ''.img_object($langs->trans("Preview"), 'pdf').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; + + // Other Options + print "
"; + print load_fiche_titre($langs->trans("OtherOptions"), '', ''); + + print '
'; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); + $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); + $htmltext = ''.$langs->trans("AvailableVariables").':
'; + foreach ($substitutionarray as $key => $val) { + $htmltext .= $key.'
'; + } + $htmltext .= '
'; + + print '\n"; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; + print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; + $variablename = 'DELIVERY_FREE_TEXT'; + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { + print ''; + } else { + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); + print $doleditor->Create(); + } + print '
'; + print "
'; + + print '
'; + print ''; + print '
'; + + print '
'; } -print '
'; -/* - * Autres Options - */ -print "
"; -print load_fiche_titre($langs->trans("OtherOptions"), '', ''); - -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; - -$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) { - $htmltext .= $key.'
'; -} -$htmltext .= '
'; - -print ''; -print ''; -print ''; -print '\n"; -print ''; - -print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; -print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename = 'DELIVERY_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; -} else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); - print $doleditor->Create(); -} -print '
'; -print ''; -print "
'; - // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/delivery_extrafields.php b/htdocs/admin/delivery_extrafields.php index fa1aa809944..214f209b2be 100644 --- a/htdocs/admin/delivery_extrafields.php +++ b/htdocs/admin/delivery_extrafields.php @@ -27,6 +27,7 @@ * \brief Page to setup extra fields of delivery */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -88,14 +89,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/deliverydet_extrafields.php b/htdocs/admin/deliverydet_extrafields.php index 6fbfbb58884..9c054f5bcfd 100644 --- a/htdocs/admin/deliverydet_extrafields.php +++ b/htdocs/admin/deliverydet_extrafields.php @@ -29,6 +29,7 @@ * \brief Page to setup extra fields of delivery */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -89,14 +90,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ff74273d744..43472c9724c 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -34,6 +34,7 @@ * \brief Page to administer data tables */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -54,13 +55,13 @@ $entity = GETPOST('entity', 'int'); $code = GETPOST('code', 'alpha'); $allowed = $user->admin; -if ($id == 7 && !empty($user->rights->accounting->chartofaccount)) { +if ($id == 7 && $user->hasRight('accounting', 'chartofaccount')) { $allowed = 1; // Tax page allowed to manager of chart account } -if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) { +if ($id == 10 && $user->hasRight('accounting', 'chartofaccount')) { $allowed = 1; // Vat page allowed to manager of chart account } -if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) { +if ($id == 17 && $user->hasRight('accounting', 'chartofaccount')) { $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account } if (!$allowed) { @@ -513,7 +514,7 @@ $tabcond[27] = isModEnabled("societe"); $tabcond[28] = isModEnabled('holiday'); $tabcond[29] = isModEnabled('project'); $tabcond[30] = isModEnabled('label'); -//$tabcond[31]= !empty($conf->accounting->enabled); +//$tabcond[31]= isModEnabled('accounting'); $tabcond[32] = (isModEnabled('holiday') || isModEnabled('hrm')); $tabcond[33] = isModEnabled('hrm'); $tabcond[34] = isModEnabled('hrm'); @@ -842,7 +843,7 @@ if (empty($reshook)) { $_POST["accountancy_code_buy"] = ''; // If empty, we force to null } if ($id == 10 && GETPOSTISSET("code")) { // Spaces are not allowed into code for tax dictionary - $_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', GETPOST("code")); + $_POST["code"] = preg_replace('/[^a-zA-Z0-9_\-\+]/', '', GETPOST("code")); } $tablename = $tabname[$id]; @@ -2076,7 +2077,7 @@ if ($id > 0) { } elseif (in_array($value, array('recuperableonly'))) { $class = "center"; } elseif ($value == 'accountancy_code' || $value == 'accountancy_code_sell' || $value == 'accountancy_code_buy') { - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; $tmpaccountingaccount = new AccountingAccount($db); $tmpaccountingaccount->fetch(0, $valuetoshow, 1); @@ -2086,7 +2087,7 @@ if ($id > 0) { } elseif ($value == 'fk_tva') { foreach ($form->cache_vatrates as $key => $Tab) { if ($form->cache_vatrates[$key]['rowid'] == $valuetoshow) { - $valuetoshow = $form->cache_vatrates[$key]['libtva']; + $valuetoshow = $form->cache_vatrates[$key]['label']; break; } } @@ -2485,7 +2486,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print '
'; - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { $fieldname = $value; $accountancy_account = (!empty($obj->$fieldname) ? $obj->$fieldname : 0); print $formaccounting->select_account($accountancy_account, '.'. $value, 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); diff --git a/htdocs/admin/ecm_directories_extrafields.php b/htdocs/admin/ecm_directories_extrafields.php index ea75c5ea0fc..f820f376995 100644 --- a/htdocs/admin/ecm_directories_extrafields.php +++ b/htdocs/admin/ecm_directories_extrafields.php @@ -28,6 +28,7 @@ * \brief Page to setup extra fields of ecm */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -88,14 +89,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/ecm_files_extrafields.php b/htdocs/admin/ecm_files_extrafields.php index 41a0d714eb9..563f9f58275 100644 --- a/htdocs/admin/ecm_files_extrafields.php +++ b/htdocs/admin/ecm_files_extrafields.php @@ -28,6 +28,7 @@ * \brief Page to setup extra fields of ecm */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -88,14 +89,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 81a1e9d45b5..8dfafb19b63 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -22,6 +22,7 @@ * \brief Page to create/edit/view emailcollector */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; @@ -145,6 +146,7 @@ if (GETPOST('addfilter', 'alpha')) { $emailcollectorfilter->rulevalue = GETPOST('rulevalue', 'alpha'); $emailcollectorfilter->fk_emailcollector = $object->id; $emailcollectorfilter->status = 1; + $result = $emailcollectorfilter->create($user); if ($result > 0) { @@ -234,10 +236,25 @@ if ($action == 'deleteoperation') { } } +if ($action == 'collecttest') { + dol_include_once('/emailcollector/class/emailcollector.class.php'); + + $res = $object->doCollectOneCollector(1); + if ($res > 0) { + $debuginfo = $object->debuginfo; + setEventMessages($object->lastresult, null, 'mesgs'); + } else { + $debuginfo = $object->debuginfo; + setEventMessages($object->error, null, 'errors'); + } + + $action = ''; +} + if ($action == 'confirm_collect') { dol_include_once('/emailcollector/class/emailcollector.class.php'); - $res = $object->doCollectOneCollector(); + $res = $object->doCollectOneCollector(0); if ($res > 0) { $debuginfo = $object->debuginfo; setEventMessages($object->lastresult, null, 'mesgs'); @@ -783,6 +800,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Collect now + print ''; + if (count($object->actions) > 0) { print ''; } else { diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index a41e57266aa..075ece751ce 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -21,6 +21,7 @@ * \brief List page for emailcollector */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; diff --git a/htdocs/admin/eventorganization_confbooth_extrafields.php b/htdocs/admin/eventorganization_confbooth_extrafields.php index f17a2cf91e1..a4b14206c65 100644 --- a/htdocs/admin/eventorganization_confbooth_extrafields.php +++ b/htdocs/admin/eventorganization_confbooth_extrafields.php @@ -21,6 +21,7 @@ * \brief Page to setup extra fields of EventOrganization */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -78,14 +79,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/admin/eventorganization_confboothattendee_extrafields.php b/htdocs/admin/eventorganization_confboothattendee_extrafields.php index 552e814f8de..8830e42dd26 100644 --- a/htdocs/admin/eventorganization_confboothattendee_extrafields.php +++ b/htdocs/admin/eventorganization_confboothattendee_extrafields.php @@ -82,14 +82,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index ceb3c286ac3..4085207642b 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -22,6 +22,7 @@ * \brief Log event setup page */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 0a9009889f8..485ce901e5c 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -28,6 +28,7 @@ * \brief Page d'administration/configuration du module Expedition */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index 948efb6188a..303b0f88167 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -27,6 +27,7 @@ * \brief Page to setup extra fields of expedition */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -88,13 +89,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 41fba691b7f..56a023e1c83 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -29,6 +29,7 @@ * \brief Page to setup extra fields of expedition */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -89,14 +90,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 2418ec3e26c..8c20b493105 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -28,6 +28,7 @@ * \brief Setup page of module ExpenseReport */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 54ce5a9ffea..69f6bf14d61 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of expensereport */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -82,15 +83,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index 10b14f8ee99..b26cefba580 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -24,6 +24,7 @@ * \brief Page to display expense tax ik */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 7c27ee6e408..1ad9cc67e7d 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -25,6 +25,7 @@ * \brief Page to display expense tax ik */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index 0addfcf38f7..3aba8fa8192 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -28,6 +28,7 @@ * \brief config Page module Export */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index d0f08783e22..d46f1897b71 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -28,6 +28,7 @@ * \brief Page to setupe module ExternalRss */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/rssparser.class.php'; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 4a8e54589e9..cdb7794c4d2 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -27,6 +27,7 @@ * \brief Page to setup invoice module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index 350055348f8..dfc145e72b0 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -27,6 +27,7 @@ * \brief Page to setup invoice module */ +// Load Dolibarr environment require '../main.inc.php'; // Libraries diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 3c3cd731a7d..dd4748a99f1 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -24,6 +24,7 @@ * \brief Activation page for the FCKeditor module in the other modules */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/doleditor.lib.php'; @@ -65,9 +66,9 @@ $conditions = array( 'PRODUCTDESC' => (isModEnabled("product") || isModEnabled("service")), 'DETAILS' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande') || isModEnabled('supplier_proposal') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")), 'USERSIGN' => 1, - 'MAILING' => !empty($conf->mailing->enabled), + 'MAILING' => isModEnabled('mailing'), 'MAIL' => (isModEnabled('facture') || isModEnabled("propal") || isModEnabled('commande')), - 'TICKET' => !empty($conf->ticket->enabled), + 'TICKET' => isModEnabled('ticket'), ); // Picto $picto = array( diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 79896d0ed74..4e4438263c3 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -28,6 +28,7 @@ * \brief Setup page of module Interventions */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; @@ -537,7 +538,7 @@ print '' print '
'; print $langs->trans("PrintProductsOnFichinter").' ('.$langs->trans("PrintProductsOnFichinterDetails").')global->FICHINTER_PRINT_PRODUCTS) { +if (getDolGlobalString("FICHINTER_PRINT_PRODUCTS")) { print 'checked '; } print '/>'; @@ -554,7 +555,7 @@ print ''; print $langs->trans("UseServicesDurationOnFichinter"); print ''; -print 'global->FICHINTER_USE_SERVICE_DURATION ? ' checked' : '').'>'; +print ''; print ''; print ''; @@ -570,7 +571,7 @@ print ''; print $langs->trans("UseDurationOnFichinter"); print ''; -print 'global->FICHINTER_WITHOUT_DURATION ? ' checked' : '').'>'; +print ''; print ''; print ''; @@ -586,7 +587,7 @@ print ''; print $langs->trans("UseDateWithoutHourOnFichinter"); print ''; -print 'global->FICHINTER_DATE_WITHOUT_HOUR ? ' checked' : '').'>'; +print ''; print ''; print ''; diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index c002c9059d7..c7373fd02db 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -22,6 +22,7 @@ * \brief Setup page for geoipmaxmind module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 5902402674d..9a60c6b9b84 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -24,6 +24,7 @@ * \brief Setup page of module Contracts */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index 0ef1998d9e7..21fce3d62d6 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -17,7 +17,7 @@ * 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 . + * along with this program. If not, see . */ /** @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of holiday */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -82,14 +83,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index c568e6de39c..838e9bf9a0b 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -624,7 +624,7 @@ if ($action == 'edit') { setEventMessages(null, $object->errors, "errors"); } } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } print '
'; @@ -244,7 +245,8 @@ print ''; print '
'.$langs->trans // Pass print ''; print '
'.$langs->trans("LDAPPassword").''; -print ''; +print ''; +print showValueWithClipboardCPButton(getDolGlobalString('LDAP_ADMIN_PASS'), 0, ' '); print ''.$langs->trans('Password').' (ex: secret)
'; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index fef3882d2ff..6ee7b38e0b8 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -26,6 +26,7 @@ * \brief Page d'administration/configuration du module Ldap */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; @@ -139,10 +140,10 @@ if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -print dol_get_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'contacts', '', -1); -print $langs->trans("LDAPDescContact").'
'; +print ''.$langs->trans("LDAPDescContact").'
'; print '
'; print ''; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 5723183735e..5079d6d2d29 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -26,6 +26,7 @@ * \brief Page to setup LDAP synchronization for groups */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -113,10 +114,10 @@ if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -print dol_get_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'groups', '', -1); -print $langs->trans("LDAPDescGroups").'
'; +print ''.$langs->trans("LDAPDescGroups").'
'; print '
'; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 876c31d79b1..b9461430bf9 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -26,6 +26,7 @@ * \brief Page d'administration/configuration du module Ldap adherent */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -187,10 +188,10 @@ if (!function_exists("ldap_connect")) { print ''; print ''; -print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'members', '', -1); -print $langs->trans("LDAPDescMembers").'
'; +print ''.$langs->trans("LDAPDescMembers").'
'; print '
'; print ''; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 7933b59d5e0..7b3ac57192f 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -26,6 +26,7 @@ * \brief Page to setup LDAP synchronization for members types */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -105,10 +106,10 @@ if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -print dol_get_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'memberstypes', '', -1); -print $langs->trans("LDAPDescMembersTypes").'
'; +print ''.$langs->trans("LDAPDescMembersTypes").'
'; print '
'; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index f395eb88fb4..ad84a5889ed 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -27,6 +27,7 @@ * \brief Page d'administration/configuration du module Ldap */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -177,9 +178,9 @@ print ''; -print dol_get_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'users', '', -1); -print $langs->trans("LDAPDescUsers").'
'; +print ''.$langs->trans("LDAPDescUsers").'
'; print '
'; @@ -500,9 +501,9 @@ if (function_exists("ldap_connect")) { // Remove from required_fields all entries not configured in LDAP (empty) and duplicated $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement"))); - // Get from LDAP database an array of results + // Get from LDAP database an array of results by making a search on + // $filter = '('.ldap_escape(getDolGlobalString('LDAP_KEY_USERS'), '', LDAP_ESCAPE_FILTER).'=*)'; $ldapusers = $ldap->getRecords('*', getDolGlobalString('LDAP_USER_DN'), getDolGlobalString('LDAP_KEY_USERS'), $required_fields, 1); - //$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1); if (is_array($ldapusers)) { $liste = array(); @@ -525,7 +526,7 @@ if (function_exists("ldap_connect")) { print "search: *
\n"; print "userDN: ".getDolGlobalString('LDAP_USER_DN')."
\n"; print "useridentifier: ".getDolGlobalString('LDAP_KEY_USERS')."
\n"; - print "required_fields: ".implode(',', $required_fields)."
\n"; + print "requested fields: ".implode(',', $required_fields)."
\n"; print "=> ".count($liste)." records
\n"; print "\n
"; } else { diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index d644f2bd2f6..3d92dd5023f 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -22,6 +22,7 @@ * \brief Page to setup limits */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index 3c777e1f187..ca95c835ecd 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -22,6 +22,7 @@ * \brief Setup page to configure loan module */ +// Load Dolibarr environment require '../main.inc.php'; // Class diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index da2df89b21a..ab4b747e21c 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -23,6 +23,7 @@ * \brief Page to setup emailing module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index eca17ea8e76..88389f0a4c4 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -27,6 +27,7 @@ * \brief Page to setup the module MailmanSpip (Mailman) */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 2f0f4cd3233..ff24a708797 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -23,6 +23,7 @@ * \brief Page to setup emails sending */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -50,6 +51,7 @@ $substitutionarrayfortest = array( '__USER_LOGIN__' => $user->login, '__USER_EMAIL__' => $user->email, '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails + '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails '__ID__' => 'RecipientIdRecord', //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails '__LASTNAME__' => 'RecipientLastname', diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index dbdf66f8282..d2eabd95e2b 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -23,6 +23,7 @@ * \brief Page to setup emails sending */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -49,6 +50,7 @@ $substitutionarrayfortest = array( //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails '__CHECK_READ__' => (!empty($object) && is_object($object) && is_object($object->thirdparty)) ? '' : '', '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails + '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails '__LOGIN__' => $user->login, '__LASTNAME__' => 'RecipientLastname', '__FIRSTNAME__' => 'RecipientFirstname', diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 3f72fc77c6c..95f57d5dfc5 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -22,6 +22,7 @@ * \brief Page to adminsiter email sender profiles */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -380,14 +381,17 @@ if ($action != 'create') { if ($action == 'edit') { print '
'; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -409,14 +413,17 @@ if ($action != 'create') { print ''; */ print '
'.$langs->trans("Label").'
'.$langs->trans("Email").'
'.$langs->trans("Label").'
'.$langs->trans("Email").''; + print img_picto('', 'email', 'class="pictofixedwidth"'); + print '
'.$langs->trans("Signature").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('signature', (GETPOSTISSET('signature') ? GETPOST('signature', 'restricthtml') : $object->signature), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); print '
'.$langs->trans("User").''; + print img_picto('', 'user', 'class="pictofixedwidth"'); print $form->select_dolusers((GETPOSTISSET('private') ? GETPOST('private', 'int') : $object->private), 'private', 1, null, 0, ($user->admin ? '' : $user->id)); print '
'.$langs->trans("Position").'
'; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d65bcefb11f..02eef8a00d3 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -33,6 +33,7 @@ * \brief Page to administer emails templates */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -185,7 +186,7 @@ if (isModEnabled('adherent') && !empty($user->rights->adherent->lire)) { if (isModEnabled('recruitment') && !empty($user->rights->recruitment->recruitmentjobposition->read)) { $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures')); } -if (isModEnabled("societe") && !empty($user->rights->societe->lire)) { +if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { $elementList['thirdparty'] = img_picto('', 'company', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToThirdparty')); } if (isModEnabled('project')) { @@ -206,7 +207,7 @@ if (isModEnabled("expedition")) { if (isModEnabled("reception")) { $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendReception')); } -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendIntervention')); } if (isModEnabled('supplier_proposal')) { @@ -221,7 +222,7 @@ if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->facture-> if (isModEnabled('contrat') && !empty($user->rights->contrat->lire)) { $elementList['contract'] = img_picto('', 'contract', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendContract')); } -if (!empty($conf->ticket->enabled) && !empty($user->rights->ticket->read)) { +if (isModEnabled('ticket') && !empty($user->rights->ticket->read)) { $elementList['ticket_send'] = img_picto('', 'ticket', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToTicket')); } if (isModEnabled('expensereport') && !empty($user->rights->expensereport->lire)) { @@ -582,7 +583,7 @@ if (!$user->admin) { $sql .= " AND (private = 0 OR (private = 1 AND fk_user = ".((int) $user->id)."))"; // Show only public and private to me $sql .= " AND (active = 1 OR fk_user = ".((int) $user->id).")"; // Show only active or owned by me } -if (empty($conf->global->MAIN_MULTILANGS)) { +if (!getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= " AND (lang = '".$db->escape($langs->defaultlang)."' OR lang IS NULL OR lang = '')"; } if ($search_label) { @@ -705,7 +706,7 @@ if ($action == 'add') { $valuetoshow = $langs->trans("Owner"); } if ($fieldlist[$field] == 'lang') { - $valuetoshow = (empty($conf->global->MAIN_MULTILANGS) ? ' ' : $langs->trans("Language")); + $valuetoshow = (!getDolGlobalInt('MAIN_MULTILANGS') ? ' ' : $langs->trans("Language")); } if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); @@ -1060,21 +1061,57 @@ if ($num) { print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; print ''; } + + // If $acceptlocallinktomedia is true, we can add link media files int email templates (we already can do this into HTML editor of an email). + // Note that local link to a file into medias are replaced with a real link by email in CMailFile.class.php with value $urlwithroot defined like this: + // $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + // $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $acceptlocallinktomedia = getDolGlobalInt('MAIN_DISALLOW_MEDIAS_IN_EMAIL_TEMPLATES') ? 0 : 1; + if ($acceptlocallinktomedia) { + global $dolibarr_main_url_root; + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + + // Parse $newUrl + $newUrlArray = parse_url($urlwithouturlroot); + $hosttocheck = $newUrlArray['host']; + $hosttocheck = str_replace(array('[', ']'), '', $hosttocheck); // Remove brackets of IPv6 + + if (function_exists('gethostbyname')) { + $iptocheck = gethostbyname($hosttocheck); + } else { + $iptocheck = $hosttocheck; + } + + //var_dump($iptocheck.' '.$acceptlocallinktomedia); + if (!filter_var($iptocheck, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { + // If ip of public url is an private network IP, we do not allow this. + $acceptlocallinktomedia = 0; + // TODO Show a warning + } + + if (preg_match('/http:/i', $urlwithouturlroot)) { + // If public url is not a https, we do not allow to add medias link. It will generate security alerts when email will be sent. + $acceptlocallinktomedia = 0; + // TODO Show a warning + } + } + if ($tmpfieldlist == 'content') { print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_6, '90%'); + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%'); print $doleditor->Create(1); } if ($tmpfieldlist == 'content_lines') { print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; $okforextended = true; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); + } + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%'); print $doleditor->Create(1); } print ''; @@ -1206,7 +1243,7 @@ if ($num) { // Status / Active print ''; } elseif ($value == 'lang') { print '
'.$langs->trans("Label").'
'.$langs->trans("Email").'
'.$langs->trans("Label").'
'.$langs->trans("Email").''; + print img_picto('', 'email', 'class="pictofixedwidth"'); + print '
'.$langs->trans("Signature").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); print '
'.$langs->trans("User").''; + print img_picto('', 'user', 'class="pictofixedwidth"'); print $form->select_dolusers((GETPOSTISSET('private') ? GETPOST('private', 'int') : -1), 'private', 1, null, 0, ($user->admin ? '' : $user->id)); print '
'.$langs->trans("Position").'
'; if ($canbedisabled) { - print ''.$actl[$obj->active].''; + print ''.$actl[$obj->active].''; } else { print ''.$actl[$obj->active].''; } @@ -1295,7 +1332,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $selectedlang = GETPOSTISSET('langcode') ?GETPOST('langcode', 'aZ09') : $langs->defaultlang; if ($context == 'edit') { $selectedlang = $obj->{$value}; diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 8b0d78132a0..c48146fc937 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -23,6 +23,7 @@ * \brief Page to setup mails for ticket */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -46,6 +47,7 @@ $substitutionarrayfortest = array( '__LASTNAME__' => 'TESTLastname', '__FIRSTNAME__' => 'TESTFirstname', '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), +'__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails //'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet ); complete_substitutions_array($substitutionarrayfortest, $langs); diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 8034d813c0d..abcb2133e8c 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -23,6 +23,7 @@ * \brief Page to setup menu manager to use */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index d619cd28e91..288cba1c5b9 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -24,6 +24,7 @@ * \brief Tool to edit menus */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 5a155d11411..0396c31eb96 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -24,6 +24,7 @@ * \brief Index page for menu editor */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index dbcc9cfdade..e18e65e47a0 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -30,6 +30,7 @@ if (!defined('NOTOKENRENEWAL')) { } +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -383,15 +384,16 @@ if ($mode == 'feature') { $text .= '

'; $text .= '
'.$langs->trans("AddDataTables").': '; - $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); + $listofsqlfiles1 = dol_dir_list(DOL_DOCUMENT_ROOT.'/install/mysql/tables/', 'files', 0, 'llx.*-'.$moduledir.'\.sql', array('\.key\.sql', '\.sql\.back')); + $listofsqlfiles2 = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); + $sqlfiles = array_merge($listofsqlfiles1, $listofsqlfiles2); + if (count($sqlfiles) > 0) { - $text .= $langs->trans("Yes").' ('; $i = 0; foreach ($sqlfiles as $val) { - $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); + $text .= ($i ? ', ' : '').preg_replace('/\-'.$moduledir.'$/', '', preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name']))); $i++; } - $text .= ')'; } else { $text .= $langs->trans("No"); } @@ -414,7 +416,7 @@ if ($mode == 'feature') { $text .= '
'.$langs->trans("AddData").': '; $filedata = dol_buildpath($moduledir.'/sql/data.sql'); if (dol_is_file($filedata)) { - $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; + $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; } else { $text .= $langs->trans("No"); } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 05f7ed441f7..d011b250730 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -33,6 +33,7 @@ if (!defined('CSRFCHECK_WITH_TOKEN') && (empty($_GET['action']) || $_GET['action define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 2d543cb1faa..36a82e965f4 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -21,6 +21,7 @@ * \brief Setup page of module MRP */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index 768ec487165..cd18b47eec7 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of MOs */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -81,14 +82,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 44b5c104813..d3ad20f68b7 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -26,6 +26,7 @@ * \brief Page to setup notification module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index ade561c4ef1..e50b4f772c6 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -15,7 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ /** @@ -24,6 +23,8 @@ * \brief Setup page to configure oauth access api */ + +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; @@ -36,7 +37,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Load translation files required by the page -$langs->loadLangs(array('admin', 'oauth')); +$langs->loadLangs(array('admin', 'oauth', 'modulebuilder')); // Security check if (!$user->admin) { @@ -84,7 +85,12 @@ if ($action == 'update') { } } if (GETPOSTISSET($constvalue.'_SCOPE')) { - if (!dolibarr_set_const($db, $constvalue.'_SCOPE', GETPOST($constvalue.'_SCOPE'), 'chaine', 0, '', $conf->entity)) { + $scopestring = implode(',', GETPOST($constvalue.'_SCOPE')); + if (!dolibarr_set_const($db, $constvalue.'_SCOPE', $scopestring, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + if (!dolibarr_set_const($db, $constvalue.'_SCOPE', '', 'chaine', 0, '', $conf->entity)) { $error++; } } @@ -110,7 +116,7 @@ $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); -print ''; +print ''; print ''; print ''; @@ -140,22 +146,16 @@ foreach ($list as $key) { } print ''; print ajax_combobox('provider'); -print ' '; +print ' '; print ' '; + +print '
'; +print '
'; + +print dol_get_fiche_end(); + print ''; -print '
'; -print '
'; - - -print '
'; -print ''; -print ''; - -print '
'; -print ''; - -$i = 0; // Define $listinsetup foreach ($conf->global as $key => $val) { @@ -171,112 +171,144 @@ foreach ($conf->global as $key => $val) { } } -// $list is defined into oauth.lib.php to the list of supporter OAuth providers. -foreach ($listinsetup as $key) { - $supported = 0; - $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME - $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array); - $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); - if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { - $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); - } else { - $keyforprovider = ''; - } - $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); - $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) { - $supported = 1; - } - if (!$supported) { - continue; // show only supported - } +if (count($listinsetup) > 0) { + print ''; + print ''; + print ''; - $i++; + print '
'; - // Api Name - $label = $langs->trans($keyforsupportedoauth2array); - print '
'; - print ''; - print ''; - print ''; + $i = 0; - if ($supported) { - $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; - print ''; - print ''; - print ''; - - if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { - print ''; - print ''; - print ''; + // $list is defined into oauth.lib.php to the list of supporter OAuth providers. + foreach ($listinsetup as $key) { + $supported = 0; + $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME + $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array); + $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); + if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { + $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); + } else { + $keyforprovider = ''; } - } else { - print ''; - print ''; - print ''; - print ''; - } + $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); + $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - // Api Id - print ''; - print ''; - print ''; + if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) { + $supported = 1; + } + if (!$supported) { + continue; // show only supported + } - // Api Secret - print ''; - print ''; - print ''; + $i++; - // TODO Move this into token generation - if ($supported) { - if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { + print '
'; - print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"'); - if ($label == $keyforsupportedoauth2array) { - print $supportedoauth2array[$keyforsupportedoauth2array]['name']; - } else { - print $label; - } - if ($keyforprovider) { - print ' ('.$keyforprovider.')'; - } else { - print ' ('.$langs->trans("NoName").')'; - } - print ''; - if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) { - print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']); - } - print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print '
'.$langs->trans("URLOfServiceForAuthorization").''; - print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").'
'; - print '
'; - print '
'; + + // OAUTH service name + $label = $langs->trans($keyforsupportedoauth2array); + print ''; + print ''; + print ''; + print ''; + + if ($supported) { + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; print ''; - print ''; - print ''; + print ''; + + if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { + print ''; + print ''; + print ''; + } } else { print ''; - print ''; - print ''; + print ''; print ''; } + + // Api Id + print ''; + print ''; + print ''; + + // Api Secret + print ''; + print ''; + print ''; + + // TODO Move this into token generation + if ($supported) { + if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { + print ''; + print ''; + print ''; + } else { + $availablescopes = array_flip(explode(',', $supportedoauth2array[$keyforsupportedoauth2array]['availablescopes'])); + $currentscopes = explode(',', getDolGlobalString($key[4])); + $scopestodispay = array(); + foreach ($availablescopes as $keyscope => $valscope) { + if (in_array($keyscope, $currentscopes)) { + $scopestodispay[$keyscope] = 1; + } else { + $scopestodispay[$keyscope] = 0; + } + } + // Api Scope + print ''; + print ''; + print ''; + } + } else { + print ''; + print ''; + print ''; + print ''; + } + + print '
'; + print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"'); + if ($label == $keyforsupportedoauth2array) { + print $supportedoauth2array[$keyforsupportedoauth2array]['name']; + } else { + print $label; + } + if ($keyforprovider) { + print ' ('.$keyforprovider.')'; + } else { + print ' ('.$langs->trans("NoName").')'; + } + print ''; + if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) { + print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']); + } + print '
'.$langs->trans("Scopes").''; - print ''; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; print '
'.$langs->trans("URLOfServiceForAuthorization").''; + print '
'.$langs->trans("Scopes").''; - //print ''; - print $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope']; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").'
'; + print '
'; + print '
'.$langs->trans("Scopes").''; + print ''; + print '
'.$langs->trans("Scopes").''; + foreach ($scopestodispay as $scope => $val) { + print ''; + print ''; + } + print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").'
'."\n"; + + print '
'; } + + print '
'; + + print $form->buttonsSaveCancel("Modify", ''); + + print '
'; } -print '
'."\n"; -print ''; - -print dol_get_fiche_end(); - -print $form->buttonsSaveCancel("Modify", ''); - -print ''; - // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 7de4e146595..fa1fd18f049 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -23,6 +23,7 @@ * \brief Setup page to configure oauth access to login information */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list and $supportedoauth2array @@ -171,7 +172,7 @@ if ($mode == 'setup' && $user->admin) { $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : '')); - $shortscope = $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope']; + $shortscope = ''; if (getDolGlobalString($key[4])) { $shortscope = getDolGlobalString($key[4]); } diff --git a/htdocs/admin/openinghours.php b/htdocs/admin/openinghours.php index b18ebd0c05f..c31e2162156 100644 --- a/htdocs/admin/openinghours.php +++ b/htdocs/admin/openinghours.php @@ -21,6 +21,7 @@ * \brief Setup page to configure opening hours */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index b66f004295d..8ebbce2cc4d 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of order */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -85,14 +86,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 3f8102d076a..e9c0947d6a2 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -27,6 +27,7 @@ * \brief Page to setup extra fields of order */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -86,14 +87,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 089ddbafd23..59da712b266 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -22,6 +22,7 @@ * \brief Page to setup invoices payments */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index eb918086720..f86f6d5c27f 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -25,6 +25,7 @@ * \brief Page to setup payments by credit transfer */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 3468c997a58..d59e2279435 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -25,6 +25,7 @@ * \brief Page to setup PDF options */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; @@ -290,16 +291,16 @@ print $formadmin->select_paper_format($selected, 'MAIN_PDF_FORMAT'); print '
'.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; -print ''; +print ''; print '
'.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; -print ''; +print ''; print '
'.$langs->trans("MAIN_PDF_MARGIN_TOP").''; -print ''; +print ''; print '
'.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; -print ''; +print ''; print '
'; @@ -471,7 +472,7 @@ print ''.$langs->trans("Parameter").''.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").''; -//if (!empty($conf->global->MAIN_MULTILANGS)) +//if (getDolGlobalInt('MAIN_MULTILANGS')) //{ $selected = GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) ? $conf->global->PDF_USE_ALSO_LANGUAGE_CODE : 0); print $formadmin->select_language($selected, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1); diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 979edb47de4..f2f9f83f67c 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -25,6 +25,7 @@ * \brief Page to setup PDF options */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; @@ -103,7 +104,7 @@ print ''; print ''; if (isModEnabled('propal')) { - print load_fiche_titre($langs->trans("Proposal"), '', ''); + print load_fiche_titre($langs->trans("Proposal"), '', 'proposal'); print '
'; print ''; @@ -126,7 +127,7 @@ if (isModEnabled('propal')) { if (isModEnabled('facture')) { - print load_fiche_titre($langs->trans("Invoices"), '', ''); + print load_fiche_titre($langs->trans("Invoices"), '', 'bill'); print '
'; print '
'; @@ -169,6 +170,42 @@ if (isModEnabled('facture')) { print ''; } + + +if (isModEnabled('reception')) { + print load_fiche_titre($langs->trans("Receptions"), '', 'reception'); + + print '
'; + print '
'; + print ''; + + print ''; + + print ''; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $langs->trans("RECEPTION_PDF_HIDE_ORDERED"); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('RECEPTION_PDF_HIDE_ORDERED'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("RECEPTION_PDF_HIDE_ORDERED", $arrval, $conf->global->RECEPTION_PDF_HIDE_ORDERED); + } + print '
'; + print $langs->trans("MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT"); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT", $arrval, $conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT); + } + print '
'; + print '
'; +} + + print '
'; print ''; print '
'; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index d2f0d79e4f3..ef20ab6e205 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -24,6 +24,7 @@ * \brief Page to setup default permissions of a new user */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index c76cccdcc5c..0dad5e887eb 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -25,6 +25,7 @@ * \brief Page to setup Withdrawals */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 408c42cc3a8..c24446fb1bd 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -28,6 +28,7 @@ * \brief Setup page for commercial proposal module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index 2c3a2629a76..f2103d0c97d 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -22,6 +22,7 @@ * \brief Page setup proxy to use for external web access */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 53f0cd9f7f0..a8ae4501ca5 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -24,6 +24,7 @@ * \brief Page to setup receipt printer */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index aa83fca230c..bf87698e5d8 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -28,6 +28,7 @@ * \brief Page to setup extra fields of reception */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -91,14 +92,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - // Creation of an optional field if ($action == 'create') { print "
"; diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index a06760b9da4..c86db66e464 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -21,6 +21,7 @@ * \brief Page to setup reception module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php'; @@ -237,7 +238,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->RECEPTION_ADDON_NUMBER == "$file") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir) ? '&scan_dir='.$module->scandir : '').(!empty($module->name) ? '&label='.urlencode($module->name) : '').'">'; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -344,10 +345,10 @@ foreach ($dirmodels as $reldir) { $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + if (isset($module->version) && $module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { $modulequalified = 0; } - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + if (isset($module->version) && $module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { $modulequalified = 0; } diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index 1d3e29c9cd4..9b421a17a6d 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -22,6 +22,7 @@ * \brief Setup page to configure resource module */ +// Load Dolibarr environment require '../main.inc.php'; // Class diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index 068ae6f02d1..62c1c4cfed2 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -25,6 +25,7 @@ * \brief Page to setup extra fields of resource */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -84,13 +85,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 516197b7a70..02cddbd5d70 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -23,6 +23,7 @@ * \brief Page de configuration du module securite */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -215,6 +216,8 @@ print ''.$langs->trans("Example").''; print ''.$langs->trans("Activated").''; print ''; +$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN')); + foreach ($arrayhandler as $key => $module) { // Show modules according to features level if (!empty($module->version) && $module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { @@ -225,15 +228,16 @@ foreach ($arrayhandler as $key => $module) { } if ($module->isEnabled()) { - print ''; + print ''; + print img_picto('', $module->picto, 'class="width25 size15x"').' '; print ucfirst($key); print "\n"; print $module->getDescription().'
'; - print $langs->trans("MinLength").': '.$module->length; + print $langs->trans("MinLength").': '.$module->length.''; print ''; // Show example of numbering module - print ''; + print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); @@ -245,7 +249,7 @@ foreach ($arrayhandler as $key => $module) { } print ''."\n"; - print ''; + print ''; if ($conf->global->USER_PASSWORD_GENERATED == $key) { //print img_picto('', 'tick'); print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -266,7 +270,6 @@ print ''; //if($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK == 1) // Patter for Password Perso if ($conf->global->USER_PASSWORD_GENERATED == "Perso") { - $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); print '
'; print '
'; @@ -345,7 +348,7 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso") { print ' }'; print ' function generatelink(){'; - print ' return "security.php?action=updatepattern&pattern="+getStringArg();'; + print ' return "security.php?action=updatepattern&token='.newToken().'&pattern="+getStringArg();'; print ' }'; print ' function valuePatternChange(){'; @@ -469,7 +472,9 @@ print ''; print ''; + print ''; + print '
'; if (GETPOST('info', 'int') > 0) { diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 62b91ad55b3..ff0d5780ad4 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -23,6 +23,7 @@ * \brief Security options setup */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -112,7 +113,7 @@ print '
'; // Upload options print '
'; -print ''; +print '
'; print ''; print ''; print ''; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 9e103422b97..bec69a7a6e4 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -23,6 +23,7 @@ * \brief Security options setup */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -61,7 +62,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { dol_print_error($db); } } elseif ($action == 'updateform') { - $res1 = 1; $res2 = 1; $res3 = 1; + $res1 = 1; $res2 = 1; $res3 = 1; $res4 = 1; if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) { $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); } @@ -71,7 +72,10 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) { $res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity); } - if ($res1 && $res2 && $res3) { + if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) { + $res4 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", GETPOST("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 'alphanohtml'), 'int', 0, '', $conf->entity); + } + if ($res1 && $res2 && $res3 && $res4) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } } @@ -185,6 +189,14 @@ print ''; +print ''; +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 19a94d05dd8..391ca42a6d3 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -23,6 +23,7 @@ * \brief Page to setup emails sending */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index 92dba301854..391f459aca3 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -27,6 +27,7 @@ * \brief Page to setup the module MailmanSpip (SPIP) */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index aa337ff1f29..3524111c96e 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -27,6 +27,7 @@ * \brief Setup to admin supplier invoices */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; @@ -392,7 +393,7 @@ foreach ($dirmodels as $reldir) { // Default print '
'.$langs->trans("Parameters").''.$langs->trans("Value").''.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").''; +print ''; +print ' '.strtolower($langs->trans("Posts")); +print '
'; - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") { + if (getDolGlobalString("INVOICE_SUPPLIER_ADDON_PDF") == "$name") { //print img_picto($langs->trans("Default"),'on'); // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 0204f184de7..b5114314eef 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -1,25 +1,25 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2018 Philippe Grand - * - * 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 . - */ +* Copyright (C) 2004-2011 Laurent Destailleur +* Copyright (C) 2005-2011 Regis Houssin +* Copyright (C) 2004 Sebastien Di Cintio +* Copyright (C) 2004 Benoit Mortier +* Copyright (C) 2010-2013 Juanjo Menent +* Copyright (C) 2011-2018 Philippe Grand +* +* 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/admin/supplier_order.php @@ -27,6 +27,7 @@ * \brief Page d'administration-configuration du module Fournisseur */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; @@ -54,8 +55,8 @@ $specimenthirdparty->initAsSpecimen(); /* - * Actions - */ +* Actions +*/ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; @@ -84,7 +85,9 @@ if ($action == 'updateMask') { $commande->thirdparty = $specimenthirdparty; // Search template files - $file = ''; $classname = ''; $filefound = 0; + $file = ''; + $classname = ''; + $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/supplier_order/doc/pdf_".$modele.".modules.php", 0); @@ -194,8 +197,8 @@ if ($action == 'updateMask') { /* - * View - */ +* View +*/ $form = new Form($db); @@ -313,8 +316,8 @@ print '

'; /* - * Documents models for supplier orders - */ +* Documents models for supplier orders +*/ print load_fiche_titre($langs->trans("OrdersModelModule"), '', ''); @@ -369,7 +372,7 @@ foreach ($dirmodels as $reldir) { print "\n"; print ""; - print (empty($module->name) ? $name : $module->name); + print(empty($module->name) ? $name : $module->name); print "\n"; print "\n"; require_once $dir.'/'.$file; @@ -437,8 +440,8 @@ foreach ($dirmodels as $reldir) { print '
'; /* - * Other options - */ +* Other options +*/ print '
'; print ''; @@ -456,7 +459,7 @@ print ''; print $form->textwithpicto($langs->trans("UseDoubleApproval"), $langs->trans("Use3StepsApproval"), 1, 'help').'
'; print $langs->trans("IfSetToYesDontForgetPermission"); print ''; -print ''; +print ''; print ''; print ''; print "\n"; @@ -466,30 +469,30 @@ print "\n"; /* Kept as hidden for the moment if (isModEnabled('banque')) { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '; - if (!empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER'); - } - else - { - if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER)) - { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - } - else - { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; - } - } - print ''; +print ''; +print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '; +if (!empty($conf->use_javascript_ajax)) +{ +print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER'); +} +else +{ +if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER)) +{ +print ''.img_picto($langs->trans("Disabled"),'switch_off').''; +} +else +{ +print ''.img_picto($langs->trans("Enabled"),'switch_on').''; +} +} +print ''; } else { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '.$langs->trans('NotAvailable').''; +print ''; +print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '.$langs->trans('NotAvailable').''; } */ @@ -539,8 +542,8 @@ print '
'; /* - * Notifications - */ +* Notifications +*/ print load_fiche_titre($langs->trans("Notifications"), '', ''); print ''; diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index a41f9fdf80c..86fcccfb8f2 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -23,6 +23,7 @@ * \brief Page to setup supplier invoices payments */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; @@ -74,7 +75,7 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->FACTURE_ADDON_PDF == "$value") { + if (getDolGlobalString("FACTURE_ADDON_PDF") == "$value") { dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity); } } @@ -262,7 +263,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir) ? '&scandir='.$module->scandir : '').'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; } print ''; @@ -288,7 +289,7 @@ foreach ($dirmodels as $reldir) { print '\n"; print "\n"; print '\n"; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 593ad13ff82..fa3702d36b7 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -23,6 +23,7 @@ * along with this program. If not, see . */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 6105e6a716b..d0da90dcad4 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -27,6 +27,7 @@ * \brief Page to setup extra fields of supplierinvoice */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -86,13 +87,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 3bdf8e1e8cc..8fa0f5130c9 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -28,6 +28,7 @@ * \brief Page to setup extra fields of supplierinvoice line */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -88,13 +89,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index e45f8d63cc1..17a2eccbc58 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of supplierorder */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -86,13 +87,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 8fd2516a41d..6e5b8aa0175 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -27,6 +27,7 @@ * \brief Page to setup extra fields of supplierorder line */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -87,13 +88,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 875d024fd65..71f7fd7f875 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -24,6 +24,7 @@ * \brief Setup page for logs module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index de6f0c146f3..a9c87ca61a3 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -24,6 +24,7 @@ * \brief About Dolibarr File page */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php index 2919df67d85..7e2c772183d 100644 --- a/htdocs/admin/system/browser.php +++ b/htdocs/admin/system/browser.php @@ -22,6 +22,7 @@ * \brief Page to show Dolibarr informations */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index fee82d89958..4acb8e0ff59 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -22,6 +22,7 @@ * \brief Page to show all Dolibarr setup (config file and database constants) */ +// Load Dolibarr environment require '../../main.inc.php'; // Load translation files required by the page diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 457d71d98d9..de49bf687a1 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -28,6 +28,7 @@ if (! defined('CSRFCHECK_WITH_TOKEN')) { define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 422e8ab2bc6..8cd1ad3d597 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -23,6 +23,7 @@ * \brief Page with system information of database */ +// Load Dolibarr environment require '../../main.inc.php'; $langs->load("admin"); @@ -64,7 +65,7 @@ print '
'; print '
'; print '
'; print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->PAYMENT_ADDON.'.php' == $file) { // If module is the one used, we show existing errors + if (getDolGlobalString("PAYMENT_ADDON").'.php' == $file) { // If module is the one used, we show existing errors if (!empty($module->error)) { dol_htmloutput_mesg($module->error, '', 'error', 1); } @@ -350,7 +351,7 @@ foreach ($dirmodels as $reldir) { print "\n"; require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); + $module = new $classname($db, new Societe($db)); if (method_exists($module, 'info')) { print $module->info($langs); } else { @@ -382,7 +383,7 @@ foreach ($dirmodels as $reldir) { // Default print ''; - if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name") { + if (getDolGlobalString("SUPPLIER_PAYMENT_ADDON_PDF") == "$name") { //print img_picto($langs->trans("Default"),'on'); // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all print 'scandir).'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; @@ -441,7 +442,7 @@ print "
'; print $langs->trans("GroupPaymentsByModOnReports"); print ''; -print $form->selectyesno("PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", $conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD, 1); +print $form->selectyesno("PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", getDolGlobalString("PAYMENTS_FOURN_REPORT_GROUP_BY_MOD"), 1); print ''; print "
'; print ''."\n"; -print ''."\n"; +print ''."\n"; print '
'.$langs->trans("Tables").'
'.$langs->trans("List").'
'.img_picto('', 'list', 'class="pictofixedwidth"').$langs->trans("List").'
'; print '
'; diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index 87136f2ec6a..1a1fd00ecbb 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -24,6 +24,7 @@ * \brief Page d'info des contraintes d'une table */ +// Load Dolibarr environment require '../../main.inc.php'; $langs->load("admin"); diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 31fa647f403..86c76ca1604 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -22,6 +22,7 @@ * \brief Page to show Dolibarr information */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -410,7 +411,7 @@ foreach ($configfileparameters as $key => $value) { } elseif ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/', ${$newkey})) { print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT'); } elseif ($newkey == 'dolibarr_main_document_root_alt') { - $tmparray = explode(',', ${$newkey}); + $tmparray = explode(',', $dolibarr_main_document_root_alt); $i = 0; foreach ($tmparray as $value2) { if ($i > 0) { @@ -428,7 +429,7 @@ 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, '********'); } else { print '**********'; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 97fab9658c7..7d8233cdc0a 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -24,6 +24,7 @@ * \brief Page to check Dolibarr files integrity */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 9e60ff46bd7..c2ad387d955 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -22,6 +22,7 @@ * \brief File to list all Dolibarr modules */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/admin/system/os.php b/htdocs/admin/system/os.php index d778d60cb3a..c60e1610054 100644 --- a/htdocs/admin/system/os.php +++ b/htdocs/admin/system/os.php @@ -21,6 +21,7 @@ * \brief Page des infos systeme de l'OS */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index f43bc3bf49a..6d7ef8f1863 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -20,6 +20,7 @@ * \brief Page to show Performance information */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -27,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("install", "other", "admin")); +$langs->loadLangs(array("install", "other", "admin", "products")); if (!$user->admin) { accessforbidden(); diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index c9324565e5b..aa09cf0a27c 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -24,6 +24,7 @@ * \brief Page des infos systeme de php */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index ad4befadad6..b0ea7571a2d 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2022 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ * \brief Page to show Security information */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -296,7 +297,7 @@ if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) { -// Menu security +// Menu Home - Setup - Security print '
'; print '
'; @@ -311,11 +312,53 @@ print yn(empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) ? 0 : 1); print '
'; print '
'; +print ''.$langs->trans("DoNotStoreClearPassword").': '; +print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' '; +print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1); +if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) { + print ' ('.$langs->trans("Recommended").' '.yn(1).')'; +} +print '
'; +print '
'; + +/* Already into section conf file */ +/* +$usepassinconfencrypted = 0; +global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass; +if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { + $usepassinconfencrypted = 1; +} +print ''.$langs->trans("MainDbPasswordFileConfEncrypted").': '; +print $usepassinconfencrypted ? img_picto('', 'tick').' ' : img_warning().' '; +print yn($usepassinconfencrypted); +if (empty($usepassinconfencrypted)) { + print ' ('.$langs->trans("Recommended").' '.yn(1).')'; +} +print '
'; +print '
'; +*/ + +/* Password length + +// Stored into $tabconf[0] if module generator is "Perso" or specific to the module generator. +$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN')); + +print ''.$langs->trans("PasswordLength").': '; +print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' '; +print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1); +if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) { + print ' ('.$langs->trans("Recommended").' '.yn(1).')'; +} +print '
'; +print '
'; +*/ print ''.$langs->trans("AntivirusEnabledOnUpload").': '; -print empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? '' : img_picto('', 'tick').' '; +print empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? img_warning().' ' : img_picto('', 'tick').' '; print yn(empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? 0 : 1); -if (!empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { +if (empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { + print ' - '.$langs->trans("Recommended").': '.$langs->trans("DefinedAPathForAntivirusCommandIntoSetup", $langs->transnoentitiesnoconv("Home")." - ".$langs->transnoentitiesnoconv("Setup")." - ".$langs->transnoentitiesnoconv("Security")).''; +} else { print '   - '.$conf->global->MAIN_ANTIVIRUS_COMMAND; if (defined('MAIN_ANTIVIRUS_COMMAND') && !defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) { print ' - '.$langs->trans("ValueIsForcedBySystem").''; @@ -324,6 +367,20 @@ if (!empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { print '
'; print '
'; +$umask = getDolGlobalString('MAIN_UMASK'); + +print ''.$langs->trans("UMask").': '; +if (! in_array($umask, array('600', '660', '0600', '0660'))) { + print img_warning().' '; +} +print $umask; +if (! in_array($umask, array('600', '660', '0600', '0660'))) { + print '   ('.$langs->trans("Recommended").': 0600 | 0660)'; +} +print '
'; +print '
'; + + $securityevent = new Events($db); $eventstolog = $securityevent->eventstolog; @@ -488,10 +545,10 @@ print '
'; print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"default-src 'self'; img-src *;\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"default-src 'self'; style-src: https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src: https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;\")
"; +print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\")
"; print '
'; -print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"default-src 'self'; style-src: https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src: https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;\")
"; print '
'; print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; @@ -506,6 +563,21 @@ print '
'; print '
'; +print load_fiche_titre($langs->trans("LimitsAndMitigation"), '', 'folder'); + +print ''; +print 'For a higher security, we also recommend to implement limits and mitigation on number of endpoints per minutes for the following URL'."
"; +print '
'; + +print '
'; +print 'Login process -> This can be done using a fail2ban rule (see example into dev/setup)'."
"; +print DOL_URL_ROOT.'/passwordforgotten.php (see example into dev/setup)'."
"; +print DOL_URL_ROOT.'/public/* (see example into dev/setup)'."
"; + + + + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/system/web.php b/htdocs/admin/system/web.php index 921fd839109..6ba6829823d 100644 --- a/htdocs/admin/system/web.php +++ b/htdocs/admin/system/web.php @@ -20,6 +20,7 @@ * \brief Page with web server system information */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php index 4e2f881a14c..4453dc694d4 100644 --- a/htdocs/admin/system/xcache.php +++ b/htdocs/admin/system/xcache.php @@ -20,6 +20,7 @@ * \brief Page administration XCache */ +// Load Dolibarr environment require '../../main.inc.php'; $langs->load("admin"); diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php index 8c3a70ff6ec..f6d2e3926b9 100644 --- a/htdocs/admin/system/xdebug.php +++ b/htdocs/admin/system/xdebug.php @@ -20,6 +20,7 @@ * \brief Page administration XDebug */ +// Load Dolibarr environment require '../../main.inc.php'; $langs->load("admin"); diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index fb4b2ec6d72..ccdbedc1f89 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -25,6 +25,7 @@ * \brief Page de configuration du module tax */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; if (isModEnabled('accounting')) { diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f1fbba03840..73491532c56 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -22,6 +22,7 @@ * \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"; @@ -428,7 +429,7 @@ foreach ($dirmodels as $reldir) { // Default print ''; - if ($conf->global->TICKET_ADDON_PDF == $name) { + if (getDolGlobalString("TICKET_ADDON_PDF") == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -540,9 +541,10 @@ print ''; print ''; if (isModEnabled('product')) { + $htmlname = "product_category_id"; print ''.$langs->trans("TicketChooseProductCategory").''; print ''; - $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); + $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, $htmlname); if ($conf->use_javascript_ajax) { print ajax_combobox('select_'.$htmlname); } diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index be75f604542..ccd0c75bd76 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -21,6 +21,7 @@ * \brief Page to setup extra fields of ticket */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -77,12 +78,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} // Creation of an optional field if ($action == 'create') { diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 3e4c088620d..8693da8deb2 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -22,6 +22,7 @@ * \brief Page to public interface of 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"; @@ -381,10 +382,10 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { } // Interface topic - $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; + $url_interface = getDolGlobalString("TICKET_PUBLIC_INTERFACE_TOPIC"); print ''.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; print ''; - print ''; + print ''; print ''; print ''; print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); @@ -403,7 +404,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; // Text to help to enter a ticket - $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); + $public_text_help_message = getDolGlobalString("TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')); print ''.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -415,10 +416,10 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; // Url public interface - $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + $url_interface = getDolGlobalString("TICKET_URL_PUBLIC_INTERFACE"); print ''.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; print ''; - print ''; + print ''; print ''; print ''; print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); @@ -448,7 +449,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; // Text of email after creatio of a ticket - $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); + $mail_mesg_new = getDolGlobalString("TICKET_MESSAGE_MAIL_NEW", $langs->trans('TicketNewEmailBody')); print ''; print $form->textwithpicto($langs->trans("TicketNewEmailBodyLabel"), $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); print ''; @@ -468,7 +469,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ajax_constantonoff('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED", $arrval, $conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED); + print $form->selectarray("TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED", $arrval, getDolGlobalString("TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED")); } print ''; print ''; @@ -477,7 +478,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; print $form->textwithpicto($langs->trans("TicketPublicNotificationNewMessageDefaultEmail"), $langs->trans("TicketPublicNotificationNewMessageDefaultEmailHelp"), 1, 'help'); print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 588cc5ed866..779db36fb2f 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -22,6 +22,7 @@ * \brief Page to export database */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index c409d6a500b..8c7576b8bef 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -26,6 +26,7 @@ if (! defined('CSRFCHECK_WITH_TOKEN')) { define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } +// Load Dolibarr environment require '../../main.inc.php'; // Load translation files required by the page diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 3f3316f6996..8299e2198ee 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -23,6 +23,7 @@ * \brief Page to export a database into a dump file */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 84bbd197a64..35e1194c80e 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -27,6 +27,7 @@ if (! defined('CSRFCHECK_WITH_TOKEN')) { define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php index 4c89ab60989..3941b29ce6e 100644 --- a/htdocs/admin/tools/index.php +++ b/htdocs/admin/tools/index.php @@ -22,6 +22,7 @@ * \brief Page d'accueil de l'espace outils admin */ +// Load Dolibarr environment require '../../main.inc.php'; // Load translation files required by the page diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index da7ae901766..3e04243eb72 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -24,6 +24,7 @@ * \brief List of security events */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index cc9aaa356bc..592362b936f 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -26,6 +26,7 @@ if (! defined('CSRFCHECK_WITH_TOKEN')) { define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index f6ce58a40c0..ee95fd7b44e 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -25,6 +25,7 @@ if (! defined('CSRFCHECK_WITH_TOKEN')) { define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } +// Load Dolibarr environment require '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -33,7 +34,7 @@ $langs->load("admin"); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $choice = GETPOST('choice', 'aZ09'); - +$nbsecondsold = GETPOSTINT('nbsecondsold'); // Define filelog to discard it from purge $filelog = ''; @@ -42,6 +43,7 @@ if (!empty($conf->syslog->enabled)) { $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); } +// Security if (!$user->admin) { accessforbidden(); } @@ -64,7 +66,8 @@ if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'al require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $utils = new Utils($db); - $result = $utils->purgeFiles($choice); + + $result = $utils->purgeFiles($choice, $nbsecondsold); $mesg = $utils->output; setEventMessages($mesg, null, 'mesgs'); @@ -114,8 +117,11 @@ print '>
'; } -if (!empty($user->rights->societe->lire)) { +if ($user->hasRight('societe', 'lire')) { print ''; print '
'; print '
'; diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index da27b8fc50e..9c2850608af 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -37,6 +37,7 @@ if (!defined('NOREQUIREHTML')) { } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php index 60a763635c0..ab2f6b0427f 100644 --- a/htdocs/blockedlog/ajax/check_signature.php +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -37,6 +37,7 @@ if (!defined('NOREQUIREHTML')) { } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index d6e1517344a..15af4a532fa 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -165,7 +165,7 @@ class BlockedLog */ // Donation - if (!empty($conf->don->enabled)) { + if (isModEnabled('don')) { $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE'; $this->trackedevents['DON_DELETE'] = 'logDON_DELETE'; //$this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php new file mode 100644 index 00000000000..9a55c609252 --- /dev/null +++ b/htdocs/bom/ajax/ajax.php @@ -0,0 +1,67 @@ + + * + * 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/bom/ajax/ajax.php + * \brief Ajax component for BOM. + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +include_once '../../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; + + +$action = GETPOST('action', 'aZ09'); +$idproduct = GETPOST('idproduct', 'int'); + + +/* + * View + */ + +top_httphead(); + +if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) { + $product = new Product($db); + $res = $product->fetch($idproduct); + + $cUnit = new CUnits($db); + $fk_unit = $cUnit->getUnitFromCode($product->duration_unit, 'short_label', 'time'); + + echo json_encode($fk_unit); + exit(); +} diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index ac3f672ad33..f133d1bbd4b 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -32,15 +32,16 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("mrp", "other")); +$langs->loadLangs(array('mrp', 'other')); // Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$socid = GETPOST('socid', 'int'); +$ref = GETPOST('ref', 'alpha'); + +$action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); -$socid = GETPOST('socid', 'int'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -50,8 +51,10 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } + $search_agenda_label = GETPOST('search_agenda_label'); +// Load variables for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -74,6 +77,7 @@ $object = new BOM($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomagenda', 'globalcard')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -130,7 +134,7 @@ if ($object->id > 0) { $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Agenda'; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = bomPrepareHead($object); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index db58d8d5a33..09d2b2bcb9d 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -17,9 +17,9 @@ */ /** - * \file htdocs/bom/bom_card.php - * \ingroup bom - * \brief Page to create/edit/view bom + * \file htdocs/bom/bom_card.php + * \ingroup bom + * \brief Page to create/edit/view Bill Of Material */ // Load Dolibarr environment @@ -32,17 +32,18 @@ require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("mrp", "other")); +$langs->loadLangs(array('mrp', 'other')); // Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); +$id = GETPOST('id', 'int'); +$lineid = GETPOST('lineid', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomcard'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); -$lineid = GETPOST('lineid', 'int'); +$backtopage = GETPOST('backtopage', 'alpha'); + // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -54,6 +55,7 @@ $object = new BOM($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -84,6 +86,7 @@ if ($object->id > 0) { $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft); +// Permissions $permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php $permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php @@ -158,14 +161,14 @@ if (empty($reshook)) { $idprod = $bom_child->fk_product; } } else { - $idprod = (int) GETPOST('idprod', 'int'); + $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int')); } $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); - + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -180,20 +183,33 @@ if (empty($reshook)) { $error++; } + // We check if we're allowed to add this bom + $TParentBom=array(); + $object->getParentBomTreeRecursive($TParentBom); + if ($bom_child_id > 0 && !empty($TParentBom) && in_array($bom_child_id, $TParentBom)) { + $n_child = new BOM($db); + $n_child->fetch($bom_child_id); + setEventMessages($langs->transnoentities('BomCantAddChildBom', $n_child->getNomUrl(1), $object->getNomUrl(1)), null, 'errors'); + $error++; + } + if (!$error) { - $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null); + $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } else { unset($_POST['idprod']); + unset($_POST['idprodservice']); unset($_POST['qty']); unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - - $object->fetchLines(); } + + $object->fetchLines(); + + $object->calculateCosts(); } } @@ -207,6 +223,7 @@ if (empty($reshook)) { $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); + $fk_unit = GETPOST('fk_unit', 'alphanohtml'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -217,248 +234,250 @@ if (empty($reshook)) { $bomline = new BOMLine($db); $bomline->fetch($lineid); - $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key); + $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } else { unset($_POST['idprod']); + unset($_POST['idprodservice']); unset($_POST['qty']); unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - - $object->fetchLines(); } + + $object->fetchLines(); + + $object->calculateCosts(); } } -} -/* - * View - */ + /* + * View + */ -$form = new Form($db); -$formfile = new FormFile($db); + $form = new Form($db); + $formfile = new FormFile($db); -$title = $langs->trans('BOM'); -$help_url ='EN:Module_BOM'; -llxHeader('', $title, $help_url); + $title = $langs->trans('BOM'); + $help_url ='EN:Module_BOM'; + llxHeader('', $title, $help_url); -// Part to create -if ($action == 'create') { - print load_fiche_titre($langs->trans("NewBOM"), '', 'bom'); + // Part to create + if ($action == 'create') { + print load_fiche_titre($langs->trans("NewBOM"), '', 'bom'); - print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print dol_get_fiche_head(array(), ''); + print dol_get_fiche_head(array(), ''); - print ''."\n"; + print '
'."\n"; - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - print '
'."\n"; + print ''."\n"; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print $form->buttonsSaveCancel("Create"); + print $form->buttonsSaveCancel("Create"); - print '
'; -} - -// Part to edit record -if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); - - print '
'; - print ''; - print ''; - print ''; - print ''; - - print dol_get_fiche_head(); - - //$object->fields['keyfield']['disabled'] = 1; - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); - - print '
'; -} - -// Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $head = bomPrepareHead($object); - print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + print ''; } - // Confirmation of validation - if ($action == 'validate') { - // We check that object has a temporary ref - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') { - $object->fetch_product(); - $numref = $object->getNextNumRef($object->product); - } else { - $numref = $object->ref; + // Part to edit record + if (($id || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + print dol_get_fiche_head(); + + //$object->fields['keyfield']['disabled'] = 1; + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print $form->buttonsSaveCancel("Create"); + + print '
'; + } + + // Part to show record + if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $head = bomPrepareHead($object); + print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } - $text = $langs->trans('ConfirmValidateBom', $numref); - /*if (!empty($conf->notification->enabled)) - { + // Confirmation of validation + if ($action == 'validate') { + // We check that object has a temporary ref + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') { + $object->fetch_product(); + $numref = $object->getNextNumRef($object->product); + } else { + $numref = $object->ref; + } + + $text = $langs->trans('ConfirmValidateBom', $numref); + /*if (isModEnabled('notification')) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); - }*/ + }*/ - $formquestion = array(); - if (!empty($conf->bom->enabled)) { - $langs->load("mrp"); - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( + $formquestion = array(); + if (isModEnabled('bom')) { + $langs->load("mrp"); + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); - } - - // Confirmation of closing - if ($action == 'close') { - $text = $langs->trans('ConfirmCloseBom', $object->ref); - /*if (!empty($conf->notification->enabled)) - { + // Confirmation of closing + if ($action == 'close') { + $text = $langs->trans('ConfirmCloseBom', $object->ref); + /*if (isModEnabled('notification')) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); - }*/ + }*/ - $formquestion = array(); - if (!empty($conf->bom->enabled)) { - $langs->load("mrp"); - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( + $formquestion = array(); + if (isModEnabled('bom')) { + $langs->load("mrp"); + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220); - } + // Confirmation of reopen + if ($action == 'reopen') { + $text = $langs->trans('ConfirmReopenBom', $object->ref); + /*if (isModEnabled('notification')) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); + }*/ - // Confirmation of reopen - if ($action == 'reopen') { - $text = $langs->trans('ConfirmReopenBom', $object->ref); - /*if (!empty($conf->notification->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); - }*/ - - $formquestion = array(); - if (!empty($conf->bom->enabled)) { - $langs->load("mrp"); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( + $formquestion = array(); + if (isModEnabled('bom')) { + $langs->load("mrp"); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220); - } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - // Clone confirmation - if ($action == 'clone') { - // Create an array for form - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } + // Confirmation of action xxxx + if ($action == 'setdraft') { + $text = $langs->trans('ConfirmSetToDraft', $object->ref); - // Confirmation of action xxxx - if ($action == 'setdraft') { - $text = $langs->trans('ConfirmSetToDraft', $object->ref); + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); + } - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); - } + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; + // Print form confirm + print $formconfirm; - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - /* - // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (isModEnabled('project')) - { + $morehtmlref = '
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (isModEnabled('project')) + { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) @@ -477,7 +496,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (!empty($object->fk_project)) { + if (! empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); $morehtmlref.=$proj->getNomUrl(); @@ -485,76 +504,133 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=''; } } - } - */ - $morehtmlref .= '
'; + } + */ + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; - print ''."\n"; + print '
'; + print '
'; + print '
'; + print '
'."\n"; - // Common attributes - $keyforbreak = 'duration'; - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - $object->calculateCosts(); - print ''; - print ''; + // Common attributes + $keyforbreak = 'duration'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + $object->calculateCosts(); + print ''; + print ''; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - print '
'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''.price($object->total_cost).'
'.$langs->trans("UnitCost").''.price($object->unit_cost).'
'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''.price($object->total_cost).'
'.$langs->trans("UnitCost").''.price($object->unit_cost).'
'; - print '
'; - print '
'; + print ''; + print '
'; + print '
'; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - /* - * Lines - */ + /* + * Lines + */ - if (!empty($object->table_element_line)) { - print '
- - + if (!empty($object->table_element_line)) { + //Products + $res = $object->fetchLinesbytypeproduct(0); + $object->calculateCosts(); + + print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); + + print ' + + - + '; - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } + } + + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + + print "
\n"; + + mrpCollapseBomManagement(); + + + //Services + $filtertype = 1; + $res = $object->fetchLinesbytypeproduct(1); + $object->calculateCosts(); + + print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); + + print '
+ + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + $tagidfortablednd = 'tablelinesservice'; + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add services form + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } } } @@ -568,6 +644,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea mrpCollapseBomManagement(); } + $res = $object->fetchLines(); // Buttons for actions diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index a0390ef5105..29aca029d36 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -17,35 +17,35 @@ */ /** - * \file bom_document.php - * \ingroup bom - * \brief Tab for documents linked to BillOfMaterials + * \file htdocs/bom/bom_document.php + * \ingroup bom + * \brief Tab for documents linked to BillOfMaterials */ // Load Dolibarr environment require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; // Load translation files required by the page $langs->loadLangs(array("mrp", "companies", "other", "mails")); - +// Get parameters $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'bom', $id); +// if ($user->socid > 0) accessforbidden(); +// if ($user->socid > 0) $socid = $user->socid; +// $result = restrictedArea($user, 'bom', $id); -// Get parameters +// Load variables for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index eb78228f068..3374204e22f 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -16,9 +16,9 @@ */ /** - * \file htdocs/bom/bom_list.php - * \ingroup bom - * \brief List page for bom + * \file htdocs/bom/bom_list.php + * \ingroup bom + * \brief List page for BillOfMaterials */ // Load Dolibarr environment @@ -29,8 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; // Load translation files required by the page -$langs->loadLangs(array("mrp", "other")); +$langs->loadLangs(array('mrp', 'other')); +// Get Parameters +$id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? @@ -38,16 +40,14 @@ $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - -$id = GETPOST('id', 'int'); +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php index 668ed29a62e..1b8afa91e52 100644 --- a/htdocs/bom/bom_net_needs.php +++ b/htdocs/bom/bom_net_needs.php @@ -35,20 +35,24 @@ $langs->loadLangs(array("mrp", "other", "stocks")); // Get parameters $id = GETPOST('id', 'int'); $lineid = GETPOST('lineid', 'int'); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomnet_needs'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); - +$backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects $object = new BOM($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; + +// Initialize technical objects for hooks $hookmanager->initHooks(array('bomnetneeds')); // Note that conf->hooks_modules contains array + +// Massaction +$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -73,13 +77,13 @@ if ($object->id > 0) { } - // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft); +// Permissions $permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php $permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php @@ -123,13 +127,11 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); - $title = $langs->trans('BOM'); $help_url ='EN:Module_BOM'; llxHeader('', $title, $help_url); - // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $head = bomPrepareHead($object); diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 9984a1498b8..0c32b8643fb 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -17,9 +17,9 @@ */ /** - * \file bom_note.php - * \ingroup bom - * \brief Car with notes on BillOfMaterials + * \file htdocs/bom/bom_note.php + * \ingroup bom + * \brief Card with notes on BillOfMaterials */ // Load Dolibarr environment @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; $langs->loadLangs(array("mrp", "companies")); // Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -40,9 +40,13 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects $object = new BOM($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; + +// Initialize technical objects for hooks $hookmanager->initHooks(array('bomnote', 'globalcard')); // Note that conf->hooks_modules contains array +// Massactions +$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 1bbd9babfba..d15de486560 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -23,6 +23,8 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -399,6 +401,58 @@ class BOM extends CommonObject return $result; } + /** + * Load object lines in memory from the database by type of product + * + * @param int $typeproduct 0 type product, 1 type service + + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLinesbytypeproduct($typeproduct = 0) + { + $this->lines = array(); + + $objectlineclassname = get_class($this).'Line'; + if (!class_exists($objectlineclassname)) { + $this->error = 'Error, class '.$objectlineclassname.' not found during call of fetchLinesCommon'; + return -1; + } + + $objectline = new $objectlineclassname($this->db); + + $sql = "SELECT ".$objectline->getFieldList('l'); + $sql .= " FROM ".$this->db->prefix().$objectline->table_element." as l"; + $sql .= " LEFT JOIN ".$this->db->prefix()."product as p ON p.rowid = l.fk_product"; + $sql .= " WHERE l.fk_".$this->db->escape($this->element)." = ".((int) $this->id); + $sql .= " AND p.fk_product_type = ". ((int) $typeproduct); + if (isset($objectline->fields['position'])) { + $sql .= $this->db->order('position', 'ASC'); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num_rows = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_rows) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $newline = new $objectlineclassname($this->db); + $newline->setVarsFromFetchObj($obj); + + $this->lines[] = $newline; + } + $i++; + } + + return $num_rows; + } else { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; + } + } + + /** * Load list of objects in memory from the database. * @@ -513,9 +567,10 @@ class BOM extends CommonObject * @param int $position Position of BOM-Line in BOM-Lines * @param int $fk_bom_child Id of BOM Child * @param string $import_key Import Key + * @param string $fk_unit Unit * @return int <0 if KO, Id of created object if OK */ - public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null) + public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit = '') { global $mysoc, $conf, $langs, $user; @@ -583,6 +638,7 @@ class BOM extends CommonObject $this->line->fk_bom_child = $fk_bom_child; $this->line->import_key = $import_key; $this->line->position = $rankToUse; + $this->line->fk_unit = $fk_unit; $result = $this->line->create($user); @@ -612,9 +668,10 @@ class BOM extends CommonObject * @param float $efficiency Efficiency in MO * @param int $position Position of BOM-Line in BOM-Lines * @param string $import_key Import Key + * @param int $fk_unit Unit of line * @return int <0 if KO, Id of updated BOM-Line if OK */ - public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null) + public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null, $fk_unit = 0) { global $mysoc, $conf, $langs, $user; @@ -684,6 +741,9 @@ class BOM extends CommonObject $this->line->efficiency = $efficiency; $this->line->import_key = $import_key; $this->line->position = $rankToUse; + if (!empty($fk_unit)) { + $this->line->fk_unit = $fk_unit; + } $result = $this->line->update($user); @@ -1260,10 +1320,19 @@ class BOM extends CommonObject */ public function calculateCosts() { + global $conf, $hookmanager; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $this->unit_cost = 0; $this->total_cost = 0; + $parameters=array(); + $reshook = $hookmanager->executeHooks('calculateCostsBom', $parameters, $this); // Note that $action and $object may have been modified by hook + + if ($reshook > 0) { + return $hookmanager->resPrint; + } + if (is_array($this->lines) && count($this->lines)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productFournisseur = new ProductFournisseur($this->db); @@ -1272,38 +1341,60 @@ class BOM extends CommonObject foreach ($this->lines as &$line) { $tmpproduct->cost_price = 0; $tmpproduct->pmp = 0; + $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading - if (empty($line->fk_bom_child)) { - $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading - if ($result < 0) { - $this->error = $tmpproduct->error; - return -1; - } - $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); - if (empty($line->unit_cost)) { - if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { - $line->unit_cost = $productFournisseur->fourn_unitprice; + if ($tmpproduct->type == $tmpproduct::TYPE_PRODUCT) { + if (empty($line->fk_bom_child)) { + if ($result < 0) { + $this->error = $tmpproduct->error; + return -1; + } + $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); + if (empty($line->unit_cost)) { + if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { + $line->unit_cost = $productFournisseur->fourn_unitprice; + } + } + + $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); + + $this->total_cost += $line->total_cost; + } else { + $bom_child = new BOM($this->db); + $res = $bom_child->fetch($line->fk_bom_child); + if ($res > 0) { + $bom_child->calculateCosts(); + $line->childBom[] = $bom_child; + $this->total_cost += $bom_child->total_cost * $line->qty; + } else { + $this->error = $bom_child->error; + return -2; } } + } else { + //Convert qty to hour + $unit = measuringUnitString($line->fk_unit, '', '', 1); + $qty = convertDurationtoHour($line->qty, $unit); - $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); + if (isModEnabled('workstation') && !empty($tmpproduct->fk_default_workstation)) { + $workstation = new Workstation($this->db); + $res = $workstation->fetch($tmpproduct->fk_default_workstation); + + if ($res > 0) $line->total_cost = price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); + else { + $this->error = $workstation->error; + return -3; + } + } else { + $line->total_cost = price2num($qty * $tmpproduct->cost_price, 'MT'); + } $this->total_cost += $line->total_cost; - } else { - $bom_child= new BOM($this->db); - $res = $bom_child->fetch($line->fk_bom_child); - if ($res>0) { - $bom_child->calculateCosts(); - $line->childBom[] = $bom_child; - $this->total_cost += $bom_child->total_cost * $line->qty; - } else { - $this->error = $bom_child->error; - return -2; - } } } $this->total_cost = price2num($this->total_cost, 'MT'); + if ($this->qty > 0) { $this->unit_cost = price2num($this->total_cost / $this->qty, 'MU'); } elseif ($this->qty < 0) { @@ -1379,6 +1470,38 @@ class BOM extends CommonObject } } } + + /** + * Recursively retrieves all parent bom in the tree that leads to the $bom_id bom + * + * @param array $TParentBom We put all found parent bom in $TParentBom + * @param int $bom_id ID of bom from which we want to get parent bom ids + * @param int $level Protection against infinite loop + * @return void + */ + public function getParentBomTreeRecursive(&$TParentBom, $bom_id = '', $level = 1) + { + + // Protection against infinite loop + if ($level > 1000) { + return; + } + + if (empty($bom_id)) $bom_id=$this->id; + + $sql = 'SELECT l.fk_bom, b.label + FROM '.MAIN_DB_PREFIX.'bom_bomline l + INNER JOIN '.MAIN_DB_PREFIX.$this->table_element.' b ON b.rowid = l.fk_bom + WHERE fk_bom_child = '.((int) $bom_id); + + $resql = $this->db->query($sql); + if (!empty($resql)) { + while ($res = $this->db->fetch_object($resql)) { + $TParentBom[$res->fk_bom] = $res->fk_bom; + $this->getParentBomTreeRecursive($TParentBom, $res->fk_bom, $level+1); + } + } + } } @@ -1446,6 +1569,7 @@ class BOMLine extends CommonObjectLine 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), 'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), + 'fk_unit' => array('type'=>'integer', 'label'=>'Unit', 'enabled'=>1, 'visible'=>1, 'position'=>120, 'notnull'=>-1,), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 94debfbee7b..df06986362f 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -134,6 +134,8 @@ function bomPrepareHead($object) //); // to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom', 'remove'); + return $head; } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index e895d534fac..0243928116e 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -29,6 +29,8 @@ * $forceall (0 by default, 1 for supplier invoices/orders) */ +require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"; + // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error: this template page cannot be called directly as an URL"; @@ -36,12 +38,18 @@ if (empty($object) || !is_object($object)) { } -global $forceall, $forcetoshowtitlelines; +global $forceall, $forcetoshowtitlelines, $filtertype; if (empty($forceall)) { $forceall = 0; } +if (empty($filtertype)) $filtertype = 0; +if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->STOCK_SUPPORT_SERVICES)) { + $filtertype = -1; +} + +$formproduct = new FormProduct($object->db); // Define colspan for the button 'Add' $colspan = 3; // Columns: total ht + col edit + col delete @@ -53,6 +61,7 @@ $objectline = new BOMLine($this->db); print "\n"; $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); + if ($nolinesbefore) { print ''; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { @@ -62,16 +71,24 @@ if ($nolinesbefore) { print '
'.$langs->trans('AddNewLine').''; print ''; print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; + + if ($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + } + print ''; + print ''; + print ''; + } else { + print ''; + if (isModEnabled('workstation')) print ''; + print ''; } - print ''; - print ''; - print ''; - print ''; + + print ''; print ''; } print ''; @@ -88,25 +105,23 @@ print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { +if ($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $coldisplay++; + print ''; + } + $coldisplay++; - print ''; + + + $coldisplay++; + print ''; + + $coldisplay++; + print ''; + + $coldisplay++; + print ''; +} else { + $coldisplay++; + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; + $cUnit = new CUnits($this->db); + $fk_unit_default = $cUnit->getUnitFromCode('h', 'short_label', 'time'); + print ''; + + $coldisplay++; + print ''; + + $coldisplay++; + print ''; } -$coldisplay++; -print ''; + $coldisplay += $colspan; + print ''; + print ''; -$coldisplay++; -print ''; - -$coldisplay++; -print ''; - -$coldisplay++; -print ''; - -$coldisplay += $colspan; -print ''; -print ''; if (is_object($objectline)) { print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1, 'line'); @@ -175,6 +212,27 @@ jQuery(document).ready(function() { } } }); + + //change unit selected if we change service selected + + $('#idprodservice').change(function(){ + var idproduct = $(this).val(); + + $.ajax({ + url : "" + ,type: 'POST' + ,data: { + 'action': 'getDurationUnitByProduct' + ,'idproduct' : idproduct + } + }).done(function(data) { + + console.log(data); + var data = JSON.parse(data); + $("#fk_unit").val(data).change(); + }); + }); + }); diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index e5f24fa994f..0ce88fa359c 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -31,6 +31,9 @@ * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) */ +require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"; + + // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; @@ -38,12 +41,16 @@ if (empty($object) || !is_object($object)) { } -global $forceall; +global $forceall, $filtertype; if (empty($forceall)) { $forceall = 0; } +if (empty($filtertype)) $filtertype = 0; + +$formproduct = new FormProduct($object->db); + // Define colspan for the button 'Add' $colspan = 3; // Columns: total ht + col edit + col delete @@ -108,28 +115,43 @@ if (($line->info_bits & 2) != 2) { } print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { +if ($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $coldisplay++; + print ''; + } + $coldisplay++; - print ''; + + $coldisplay++; + print ''; + + $coldisplay++; + print ''; + + $coldisplay++; + print ''; +} else { + $coldisplay++; + print ''; + + $coldisplay++; + print ''; + + $coldisplay++; + print ''; } -$coldisplay++; -print ''; - -$coldisplay++; -print ''; - -$coldisplay++; -print ''; - -$coldisplay++; -print ''; - $coldisplay += $colspan; print ''; // Qty -print ''; +print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; +if ($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + } + + // Qty frozen + print ''; + + // Disable stock change + print ''; + + // Efficiency + print ''; + + // Cost + print ''; +} else { + print ''; + + if (isModEnabled('workstation')) print ''; + + // Cost + print ''; } -// Qty frozen -print ''; -// Disable stock change -print ''; -// Efficiency -print ''; - -// Cost -print ''; print ''; // No width to allow autodim diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 61b394a3b0f..e4636081655 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -34,12 +34,17 @@ * $type, $text, $description, $line */ +require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; + // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } +global $filtertype; +if (empty($filtertype)) $filtertype = 0; + global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs; @@ -60,7 +65,9 @@ if (empty($outputalsopricetotalwithtax)) { } // add html5 elements -$domData = ' data-element="'.$line->element.'"'; +if ($filtertype == 1) $domData = ' data-element="'.$line->element.'service"'; +else $domData = ' data-element="'.$line->element.'"'; + $domData .= ' data-id="'.$line->id.'"'; $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; @@ -100,29 +107,54 @@ $coldisplay++; echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price print ''; -if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; } + + print ''; + print ''; + + print ''; +} else { + //UnitƩ + print ''; + + // Work station + if (isModEnabled('workstation')) { + $workstation = new Workstation($object->db); + $res = $workstation->fetch($tmpproduct->fk_default_workstation); + + print ''; + } } - -print ''; -print ''; - -print ''; - $total_cost = 0; print ''; } // Payment mode if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { print ''; } // Channel @@ -1862,8 +1861,10 @@ if ($resql) { $total_ht = 0; $total_margin = 0; + $savnbfield = $totalarray['nbfield']; + $totalarray = array(); + $totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); - $last_num = min($num, $limit); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); @@ -1877,6 +1878,7 @@ if ($resql) { $companystatic->name = $obj->name; $companystatic->name_alias = $obj->alias; $companystatic->client = $obj->client; + $companystatic->fournisseur = $obj->fournisseur; $companystatic->code_client = $obj->code_client; $companystatic->email = $obj->email; $companystatic->phone = $obj->phone; @@ -1893,7 +1895,6 @@ if ($resql) { $generic_commande->statut = $obj->fk_statut; $generic_commande->billed = $obj->billed; $generic_commande->date = $db->jdate($obj->date_commande); - $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated $generic_commande->delivery_date = $db->jdate($obj->date_delivery); $generic_commande->ref_client = $obj->ref_client; $generic_commande->total_ht = $obj->total_ht; @@ -1978,7 +1979,7 @@ if ($resql) { // Third party if (!empty($arrayfields['s.nom']['checked'])) { - print ''; print ""; for ($annee = $year_start; $annee <= $year_end; $annee++) { + $totsorties[$annee] = 0; + $totentrees[$annee] = 0; + $case = sprintf("%04s-%02s", $annee, $mois); print ''; } // Numero @@ -1277,7 +1278,7 @@ if ($resql) { } // Extra fields $element = 'banktransaction'; - if (is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) { + if (!empty($extrafields->attributes[$element]['label']) && is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) { foreach ($extrafields->attributes[$element]['label'] as $key => $val) { if (!empty($arrayfields["ef.".$key]['checked'])) { if (!empty($arrayfields[$key]['checked'])) { diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index 3e40e45b58e..8385dab544c 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -24,6 +24,7 @@ * \brief Page de budget */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 62c4dfa53ec..a923f3a0829 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -29,6 +29,7 @@ * \brief Page to create/view a bank account */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 222f2604af0..6549809b803 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -315,7 +315,7 @@ class Account extends CommonObject 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>157), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>160), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>165), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>170), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>170), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>175), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>180), 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>185), diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 91f514948a6..595d627609b 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -1,5 +1,4 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index c9bc7c649b3..a3fd0b0b15b 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -23,6 +23,7 @@ * \brief Page graph des transactions bancaires */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index a22e32b2595..49edf3c3a1a 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -30,6 +30,7 @@ * \brief Page to edit a bank transaction record */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 362ca3d488f..5f223450ab7 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -26,6 +26,7 @@ * \brief Home page of bank module */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; @@ -69,7 +70,7 @@ if ($user->socid) { } $allowed = 0; -if (!empty($user->rights->accounting->chartofaccount)) { +if ($user->hasRight('accounting', 'chartofaccount')) { $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account } if (!$allowed) { @@ -303,7 +304,7 @@ $arrayofmassactions = array( if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if ($user->rights->banque->modifier) { +if (isModEnabled('category') && $user->rights->banque->modifier) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index ea80f1caab3..8f5e7f29069 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -27,6 +27,7 @@ * \brief Page to show a bank statement report */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index ff38abb32d4..d896c3e6069 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -22,17 +22,20 @@ */ /** - * \file htdocs/compta/bank/transfer.php - * \ingroup banque - * \brief Page de saisie d'un virement + * \file htdocs/compta/bank/transfer.php + * \ingroup bank + * \brief Page for entering a bank transfer */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks", "categories", "multicurrency")); +$langs->loadLangs(array('banks', 'categories', 'multicurrency')); + + $socid = 0; if ($user->socid > 0) { $socid = $user->socid; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 0d76b40a3e2..d3e573f21bf 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -4,6 +4,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2015 Marcos Garcƭa + * Copyright (C) 2022 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,16 +26,20 @@ * \brief Page to estimate future balance */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array('banks', 'categories', 'bills', 'companies')); +$langs->loadLangs(array('banks', 'bills', 'categories', 'companies', 'salaries')); // Security check if (GETPOSTISSET("account") || GETPOSTISSET("ref")) { @@ -58,9 +63,12 @@ $hookmanager->initHooks(array('banktreso', 'globalcard')); * View */ $societestatic = new Societe($db); +$userstatic = new User($db); $facturestatic = new Facture($db); $facturefournstatic = new FactureFournisseur($db); $socialcontribstatic = new ChargeSociales($db); +$salarystatic = new Salary($db); +$vatstatic = new TVA($db); $form = new Form($db); @@ -133,6 +141,27 @@ if (GETPOST("account") || GETPOST("ref")) { $sql .= " ORDER BY dlr ASC"; $sqls[] = $sql; + // Salaries + $sql = " SELECT 'salary' as family, sa.rowid as objid, sa.label as ref, (-1*sa.amount) as total_ttc, sa.dateep as dlr,"; + $sql .= " s.rowid as socid, CONCAT(s.firstname, ' ', s.lastname) as name, 0 as fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."salary as sa"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON sa.fk_user = s.rowid"; + $sql .= " WHERE sa.entity = ".$conf->entity; + $sql .= " AND sa.paye = 0"; // Not paid + $sql .= " AND (sa.fk_account IN (0, ".$object->id.") OR sa.fk_account IS NULL)"; // Id bank account of salary + $sql .= " ORDER BY dlr ASC"; + $sqls[] = $sql; + + // VAT + $sql = " SELECT 'vat' as family, t.rowid as objid, t.label as ref, (-1*t.amount) as total_ttc, t.datev as dlr,"; + $sql .= " 0 as socid, 'noname' as name, 0 as fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; + $sql .= " WHERE t.entity = ".$conf->entity; + $sql .= " AND t.paye = 0"; // Not paid + $sql .= " AND (t.fk_account IN (-1, 0, ".$object->id.") OR t.fk_account IS NULL)"; // Id bank account of vat + $sql .= " ORDER BY dlr ASC"; + $sqls[] = $sql; + // others sql $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -266,6 +295,26 @@ if (GETPOST("account") || GETPOST("ref")) { $totalpayment = -1 * $socialcontribstatic->getSommePaiement(); // Payment already done } + if ($tmpobj->family == 'salary') { + $salarystatic->ref = $tmpobj->ref; + $salarystatic->id = $tmpobj->objid; + $salarystatic->label = $langs->trans("SalaryPayment"); + $ref = $salarystatic->getNomUrl(1, ''); + + $userstatic->id = $tmpobj->socid; + $userstatic->name = $tmpobj->name; + $refcomp = $userstatic->getNomUrl(1); + + $totalpayment = -1 * $salarystatic->getSommePaiement(); // Payment already done + } + if ($tmpobj->family == 'vat') { + $vatstatic->ref = $tmpobj->ref; + $vatstatic->id = $tmpobj->objid; + $vatstatic->type = $tmpobj->type; + $ref = $vatstatic->getNomUrl(1, ''); + + $totalpayment = -1 * $vatstatic->getSommePaiement(); // Payment already done + } $parameters = array('obj' => $tmpobj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment); $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $tmpobject, $action); // Note that $action and $tmpobject may have been modified by hook @@ -293,7 +342,7 @@ if (GETPOST("account") || GETPOST("ref")) { } print ""; print ""; - if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { + if (getDolGlobalString("MULTICOMPANY_INVOICE_SHARING_ENABLED")) { if ($tmpobj->family == 'invoice') { $mc->getInfo($tmpobj->entity); print ""; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 804efd010e3..0b044f8f806 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -22,6 +22,7 @@ * \brief Page of various expenses */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 6cbfd596c44..611d516613b 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -22,6 +22,7 @@ * \brief Page of linked files onto various payment */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index 51442fd20a1..7cca5c7b4ec 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -21,6 +21,7 @@ * \brief Page with info about various payment */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index fe9bb032fa8..93ec0ed20dc 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -24,6 +24,7 @@ * \brief List of various payments */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -418,7 +419,7 @@ if ($resql) { // Payment type if ($arrayfields['type']['checked']) { print ''; } diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 97bca312645..78ba0e2335e 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -27,6 +27,7 @@ * \brief Page to show a cash fence */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 4e86cb21141..5b764cfb730 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -22,6 +22,7 @@ * \brief List page for cashcontrol */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index af61af5e836..a617c99e7af 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -38,6 +38,7 @@ if (!defined('NOBROWSERNOTIF')) { $_GET['optioncss'] = "print"; +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 71ab6dd4961..b5fdd0da597 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -28,6 +28,7 @@ * \brief Page to list payments of special expenses */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index bc1d3790280..cd472c270e3 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -23,6 +23,7 @@ * \brief Show list of customers to add an new invoice */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 8259d40f694..f8e5f3ba03b 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -25,6 +25,7 @@ * \brief Page to show a trip card */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 2a16d6e4f49..77e8b695bf2 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -27,6 +27,7 @@ * \brief Page of linked files onto trip and expenses */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 8af897378f5..a4a782de603 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -23,6 +23,7 @@ * \brief Page list of expenses */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php index e180e104eb4..cfbbf33ab22 100644 --- a/htdocs/compta/deplacement/info.php +++ b/htdocs/compta/deplacement/info.php @@ -22,6 +22,7 @@ * \brief Page to show a trip information */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 2aa03441e9b..cae06774332 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -25,6 +25,7 @@ * \brief Page to list trips and expenses */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 7da90915b18..50848654a71 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -23,6 +23,7 @@ * \brief Page for statistics of module trips and expenses */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacementstats.class.php'; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 42fb64738e1..67f3becb6b5 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -25,6 +25,7 @@ * \brief Page to setup extra fields of customer invoice */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,18 +81,8 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* - * * Creation of an optional field - * */ if ($action == 'create') { @@ -102,9 +93,7 @@ if ($action == 'create') { } /* - * * Edition of an optional field - * */ if ($action == 'edit' && !empty($attrname)) { $langs->load("members"); diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 1c834134f6d..fb5282352fc 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of customer invoice */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,19 +81,8 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); - -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* - * * Creation of an optional field - * */ if ($action == 'create') { @@ -103,9 +93,7 @@ if ($action == 'create') { } /* - * * Edition of an optional field - * */ if ($action == 'edit' && !empty($attrname)) { $langs->load("members"); diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 7b7f62ed94c..5bd66c4f0f7 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of customer invoice */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -81,18 +82,8 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* - * * Creation of an optional field - * */ if ($action == 'create') { @@ -103,9 +94,7 @@ if ($action == 'create') { } /* - * * Edition of an optional field - * */ if ($action == 'edit' && !empty($attrname)) { print "
"; diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 900aab1e10b..01c6abc310a 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of customer invoice */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -81,18 +82,8 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* - * * Creation of an optional field - * */ if ($action == 'create') { @@ -103,9 +94,7 @@ if ($action == 'create') { } /* - * * Edition of an optional field - * */ if ($action == 'edit' && !empty($attrname)) { print "
"; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 031247951e9..33b85f707e9 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -30,6 +30,7 @@ * \brief Page to show predefined invoice */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -541,7 +542,7 @@ if (empty($reshook)) { $desc = ''; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -566,7 +567,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) { @@ -650,8 +651,8 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -857,9 +858,9 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id','aZ09')) + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { $outputlangs = new Translate("", $conf); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index aadaf3895e9..072aa9e67b2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -279,10 +279,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id')) { $newlang = GETPOST('lang_id'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -527,10 +527,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -611,10 +611,10 @@ if (empty($reshook)) { if (empty($error) && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -666,10 +666,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -756,10 +756,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1251,7 +1251,7 @@ if (empty($reshook)) { $object->lines[] = $line; // insert new line in current object // Defined the new fk_parent_line - if ($result > 0) { + if ($result > 0 && $line->product_type == 9) { $fk_parent_line = $result; } } @@ -1772,7 +1772,7 @@ if (empty($reshook)) { } // Defined the new fk_parent_line - if ($result > 0) { + if ($result > 0 && $lines[$i]->product_type == 9) { $fk_parent_line = $result; } } @@ -1963,10 +1963,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($object->lines)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -2181,7 +2181,7 @@ if (empty($reshook)) { $desc = ''; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -2216,7 +2216,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) { @@ -2339,10 +2339,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -2598,10 +2598,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -3192,7 +3192,7 @@ if ($action == 'create') { } else { print ''; print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 2ca72552fa4..dd807b7bb93 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -22,6 +22,7 @@ * \brief Page for tasks statistics */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 3d5c74ff5ed..b25ad6fa202 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -27,6 +27,7 @@ * \brief Page to add new time spent on a task */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; @@ -1059,7 +1060,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser //'builddoc'=>$langs->trans("PDFMerge"), ); } - if ( !empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) { + if ( isModEnabled('ficheinter') && $user->rights->ficheinter->creer) { $langs->load("interventions"); $arrayofmassactions['generateinter'] = $langs->trans("GenerateInter"); } diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index a0e7ea817a7..e8d9f986f91 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -79,12 +79,13 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; // Security check if (empty($conf->agenda->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Agenda not enabled'); } // Not older than diff --git a/htdocs/public/cron/cron_run_jobs_by_url.php b/htdocs/public/cron/cron_run_jobs_by_url.php index fa81b8d8bd7..497c68954db 100644 --- a/htdocs/public/cron/cron_run_jobs_by_url.php +++ b/htdocs/public/cron/cron_run_jobs_by_url.php @@ -75,7 +75,7 @@ $langs->loadLangs(array("admin", "cron", "dict")); // Security check if (empty($conf->cron->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Cron not enabled'); } diff --git a/htdocs/datapolicy/public/index.php b/htdocs/public/datapolicy/index.php similarity index 75% rename from htdocs/datapolicy/public/index.php rename to htdocs/public/datapolicy/index.php index 104b393bf7e..ea19759a87d 100644 --- a/htdocs/datapolicy/public/index.php +++ b/htdocs/public/datapolicy/index.php @@ -1,5 +1,4 @@ * * This program is free software: you can redistribute it and/or modify @@ -19,108 +18,120 @@ /** * \file htdocs/datapolicy/admin/setup.php * \ingroup datapolicy - * \brief datapolicy setup page. + * \brief Page to show the result of updating it Data policiy preferences after an email campaign using sendMailDataPolicyContact() */ if (!defined('NOLOGIN')) { define("NOLOGIN", 1); // This means this output page does not require to be logged. } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test -} if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; $idc = GETPOST('c', 'int'); $ids = GETPOST('s', 'int'); $ida = GETPOST('a', 'int'); -$action = GETPOST('action', 'aZ09'); -$lang = GETPOST('l', 'alpha'); -$code = GETPOST('key', 'alpha'); +$action = GETPOST('action', 'aZ09'); // 1 or 2 +$l = GETPOST('l', 'alpha'); +$securitykey = GETPOST('key', 'alpha'); -$acc = "DATAPOLICIESACCEPT_".$lang; -$ref = "DATAPOLICIESREFUSE_".$lang; -$langs->load('datapolicy@datapolicy', 0, 0, $lang); +$acc = "DATAPOLICIESACCEPT_".$l; +$ref = "DATAPOLICIESREFUSE_".$l; +$langs->load('datapolicy', 0, 0, $l); + + +/* + * Actions + */ if (empty($action) || (empty($idc) && empty($ids) && empty($ida))) { + print 'Missing paramater s, c or a'; return 0; } elseif (!empty($idc)) { $contact = new Contact($db); $contact->fetch($idc); - $check = md5($contact->email); - if ($check != $code) { - $return = $langs->trans('ErrorEmailDATAPOLICIES'); + $check = dol_hash($contact->email, 'md5'); + if ($check != $securitykey) { + $return = $langs->trans('Bad value for key.'); } elseif ($action == 1) { $contact->array_options['options_datapolicy_consentement'] = 1; $contact->array_options['options_datapolicy_opposition_traitement'] = 0; $contact->array_options['options_datapolicy_opposition_prospection'] = 0; - $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time()); + $contact->array_options['options_datapolicy_date'] = dol_now(); - $return = $conf->global->$acc; + $return = getDolGlobalString($acc); } elseif ($action == 2) { $contact->no_email = 1; $contact->array_options['options_datapolicy_consentement'] = 0; $contact->array_options['options_datapolicy_opposition_traitement'] = 1; $contact->array_options['options_datapolicy_opposition_prospection'] = 1; - $contact->array_options['options_datapolicy_date'] = date('Y-m-d', time()); + $contact->array_options['options_datapolicy_date'] = dol_now(); - $return = $conf->global->$ref; + $return = getDolGlobalString($ref); } $contact->update($idc); } elseif (!empty($ids)) { $societe = new Societe($db); $societe->fetch($ids); - $check = md5($societe->email); - if ($check != $code) { - $return = $langs->trans('ErrorEmailDATAPOLICIES'); + $check = dol_hash($societe->email, 'md5'); + if ($check != $securitykey) { + $return = $langs->trans('Bad value for key.'); } elseif ($action == 1) { $societe->array_options['options_datapolicy_consentement'] = 1; $societe->array_options['options_datapolicy_opposition_traitement'] = 0; $societe->array_options['options_datapolicy_opposition_prospection'] = 0; - $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time()); - $return = $conf->global->$acc; + $societe->array_options['options_datapolicy_date'] = dol_now(); + + $return = getDolGlobalString($acc); } elseif ($action == 2) { $societe->array_options['options_datapolicy_consentement'] = 0; $societe->array_options['options_datapolicy_opposition_traitement'] = 1; $societe->array_options['options_datapolicy_opposition_prospection'] = 1; - $societe->array_options['options_datapolicy_date'] = date('Y-m-d', time()); + $societe->array_options['options_datapolicy_date'] = dol_now(); - $return = $conf->global->$ref; + $return = getDolGlobalString($ref); } $societe->update($ids); } elseif (!empty($ida)) { $adherent = new Adherent($db); $adherent->fetch($ida); - $check = md5($adherent->email); - if ($check != $code) { - $return = $langs->trans('ErrorEmailDATAPOLICIES'); + $check = dol_hash($adherent->email, 'md5'); + if ($check != $securitykey) { + $return = $langs->trans('Bad value for key.'); } elseif ($action == 1) { $adherent->array_options['options_datapolicy_consentement'] = 1; $adherent->array_options['options_datapolicy_opposition_traitement'] = 0; $adherent->array_options['options_datapolicy_opposition_prospection'] = 0; - //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time()); - $return = $conf->global->$acc; + //$adherent->array_options['options_datapolicy_date'] = dol_now(); + + $return = getDolGlobalString($acc); } elseif ($action == 2) { $adherent->array_options['options_datapolicy_consentement'] = 0; $adherent->array_options['options_datapolicy_opposition_traitement'] = 1; $adherent->array_options['options_datapolicy_opposition_prospection'] = 1; - //$adherent->array_options['options_datapolicy_date'] = date('Y-m-d', time()); + //$adherent->array_options['options_datapolicy_date'] = dol_now(); - $return = $conf->global->$ref; + $return = getDolGlobalString($ref); } $newuser = new User($db); $adherent->update($newuser); } -header("Content-type: text/html; charset=".$conf->file->character_set_client); + +/* + * View + */ + +top_httphead(); print ''; print "\n"; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 49bde1a2b9b..f7274d5b06b 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -27,9 +27,6 @@ if (!defined('NOLOGIN')) { define('NOLOGIN', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', 1); } @@ -37,6 +34,7 @@ if (!defined('NOIPCHECK')) { define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } +// Load Dolibarr environment require '../../main.inc.php'; require_once '../../core/lib/functions2.lib.php'; @@ -51,7 +49,7 @@ $conf->dol_use_jmobile = GETPOST('dol_use_jmobile', 'int'); // Security check global $dolibarr_main_demo; if (empty($dolibarr_main_demo)) { - accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page', 0, 0, 1); + httponly_accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page'); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context diff --git a/htdocs/public/donations/donateurs_code.php b/htdocs/public/donations/donateurs_code.php index 87db3ee4133..509eb553288 100644 --- a/htdocs/public/donations/donateurs_code.php +++ b/htdocs/public/donations/donateurs_code.php @@ -25,9 +25,6 @@ if (!defined('NOLOGIN')) { define('NOLOGIN', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } @@ -55,12 +52,13 @@ function llxFooterVierge() print ''; } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; // Security check -if (empty($conf->don->enabled)) { - accessforbidden('', 0, 0, 1); +if (!isModEnabled('don')) { + httponly_accessforbidden('Module Donation not enabled'); } diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 7fac6ff323e..1c2bd6cea98 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -68,6 +68,7 @@ function llxFooter() } +// Load Dolibarr environment require '../../main.inc.php'; $mtid = GETPOST('mtid'); diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index cd69132d1a8..a5291d06b7f 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -53,6 +53,7 @@ if (! defined('NOREQUIREAJAX')) { } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index 8bb85022b2e..589bf2c8dac 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -45,6 +45,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -138,7 +139,7 @@ $user->loadDefaultValues(); // Security check if (empty($conf->eventorganization->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Event organization not enabled'); } diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index 8acf3daba78..745c9885647 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -48,6 +48,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -77,7 +78,7 @@ if ($securekeyreceived != $securekeytocompare) { // Security check if (empty($conf->eventorganization->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Event organization not enabled'); } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 2a69b4b0ef0..051506d54ac 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -86,12 +86,11 @@ $langs->loadLangs(array("main", "members", "companies", "install", "other")); // Security check if (empty($conf->adherent->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Membership not enabled'); } if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) { - print $langs->trans("Auto subscription form for public visitors has not been enabled"); - exit; + httponly_accessforbidden("Auto subscription form for public visitors has not been enabled"); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -771,10 +770,14 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW foreach ($measuringUnits->records as $lines) $units[$lines->short_label] = $langs->trans(ucfirst($lines->label)); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy"; + $publiccounters = $conf->global->MEMBER_COUNTERS_ARE_PUBLIC; + + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy, COUNT(a.rowid) AS membercount"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as a"; + $sql .= " ON d.rowid = a.fk_adherent_type AND a.statut>0"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; - $sql .= " AND d.statut=1"; + $sql .= " AND d.statut=1 GROUP BY d.rowid"; $result = $db->query($sql); if ($result) { @@ -790,6 +793,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ''; print ''; print ''; + if ($publiccounters) print ''; print ''; print "\n"; @@ -829,6 +833,8 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW } print ''; print ''; + $membercount = $objp->membercount>0? $objp->membercount: "–"; + if ($publiccounters) print ''; print ''; print ""; $i++; diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index d58b6448edb..ffce8730d8f 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -46,6 +46,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; @@ -53,7 +54,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Security check if (empty($conf->adherent->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Memebership no enabled'); } diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index 178af5fce11..700c0383516 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -45,11 +45,12 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; // Security check if (empty($conf->adherent->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Membership not enabled'); } diff --git a/htdocs/public/notice.php b/htdocs/public/notice.php index d5ac4070ff0..a682abd78c8 100644 --- a/htdocs/public/notice.php +++ b/htdocs/public/notice.php @@ -40,6 +40,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Load Dolibarr environment require '../main.inc.php'; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index c7264ade568..76b26b09a3b 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -45,6 +45,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -81,13 +82,6 @@ $ref = $REF = GETPOST("ref", 'alpha'); if (empty($source)) { $source = 'proposal'; } - -if (!$action) { - if ($source && !$ref) { - print $langs->trans('ErrorBadParameters')." - ref missing"; - exit; - } -} if (!empty($refusepropal)) { $action = "refusepropal"; } @@ -123,15 +117,12 @@ $urlko = preg_replace('/&$/', '', $urlko); // Remove last & $creditor = $mysoc->name; $type = $source; -if ($source == 'proposal') { - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $object = new Propal($db); - $result= $object->fetch(0, $ref, '', $entity); -} else { - accessforbidden('Bad value for source'); - exit; -} +if (!$action) { + if ($source && !$ref) { + httponly_accessforbidden($langs->trans('ErrorBadParameters')." - ref missing", 400, 1); + } +} // Check securitykey $securekeyseed = ''; @@ -139,10 +130,16 @@ if ($source == 'proposal') { $securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN'); } -if (!dol_verifyHash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $entity), $SECUREKEY, '0')) { - http_response_code(403); - print 'Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref); - exit(-1); +if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, '0')) { + httponly_accessforbidden('Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref), 403, 1); +} + +if ($source == 'proposal') { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $object = new Propal($db); + $result= $object->fetch(0, $ref, '', $entity); +} else { + httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source", 400, 1); } @@ -168,6 +165,15 @@ if ($action == 'confirm_refusepropal' && $confirm == 'yes') { $message = 'refused'; setEventMessages("PropalRefused", null, 'warnings'); + if (method_exists($object, 'call_trigger')) { + //customer is not a user !?! so could we use same user as validation ? + $user = new User($db); + $user->fetch($object->user_valid_id); + $result = $object->call_trigger('PROPAL_CLOSE_REFUSED', $user); + if ($result < 0) { + $error++; + } + } } else { $db->rollback(); } @@ -420,6 +426,7 @@ if ($action == "dosign" && empty($cancel)) { dataType: "text", data: { "action" : "importSignature", + "token" : \''.newToken().'\', "signaturebase64" : signature, "ref" : \''.dol_escape_js($REF).'\', "securekey" : \''.dol_escape_js($SECUREKEY).'\', diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 4853eec496e..bd49b6afbe4 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -35,6 +35,7 @@ if (!defined('NOIPCHECK')) { define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; @@ -59,7 +60,7 @@ $canbemodified = ((empty($object->date_fin) || $object->date_fin > dol_now()) && // Security check if (empty($conf->opensurvey->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Survey not enabled'); } @@ -74,7 +75,7 @@ $listofvoters = explode(',', $_SESSION["savevoter"]); // Add comment if (GETPOST('ajoutcomment', 'alpha')) { if (!$canbemodified) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('ErrorForbidden'); } $error = 0; @@ -108,7 +109,7 @@ if (GETPOST('ajoutcomment', 'alpha')) { // Add vote if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp_x for firefox if (!$canbemodified) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('ErrorForbidden'); } //Si le nom est bien entrĆ© @@ -214,7 +215,7 @@ if ($testmodifier) { } if (!$canbemodified) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('ErrorForbidden'); } $idtomodify = GETPOST("idtomodify".$modifier); @@ -232,7 +233,7 @@ if ($testmodifier) { $idcomment = GETPOST('deletecomment', 'int'); if ($idcomment) { if (!$canbemodified) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('ErrorForbidden'); } $resql = $object->deleteComment($idcomment); diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index a50892c9e08..68e9034a761 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -52,6 +52,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; @@ -71,12 +72,11 @@ $langs->loadLangs(array("main", "members", "partnership", "companies", "install" // Security check if (empty($conf->partnership->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Partnership not enabled'); } if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) { - print $langs->trans("Auto subscription form for public visitors has not been enabled"); - exit; + httponly_accessforbidden("Auto subscription form for public visitors has not been enabled"); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index e75435a8b3f..9d5fb5f122f 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -56,6 +56,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -911,14 +912,14 @@ print ''."\n"; print ''."\n"; // Additionnal information for each payment system if (!empty($conf->paypal->enabled)) { - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } if (!empty($conf->paybox->enabled)) { - print ''."\n"; + print ''."\n"; } if (!empty($conf->stripe->enabled)) { - print ''."\n"; + print ''."\n"; } print ''."\n"; print ''."\n"; @@ -1468,6 +1469,7 @@ if ($source == 'contractline') { if ($source == 'member' || $source == 'membersubscription') { $newsource = 'member'; + $tag=""; $found = true; $langs->load("members"); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 606bed0c490..5bf9b6115ed 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -46,6 +46,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -108,7 +109,7 @@ if (!empty($conf->stripe->enabled)) { // Security check if (empty($validpaymentmethod)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('No valid payment mode'); } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 209e931a75b..b8e4e9d4e19 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -50,6 +50,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -138,7 +139,7 @@ if (!empty($conf->stripe->enabled)) { // Security check if (empty($validpaymentmethod)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('No valid payment mode'); } diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index e5dfeb59a8e..dfcfde94b17 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -41,6 +41,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -84,7 +85,7 @@ if ($resultproject < 0) { // Security check if (empty($conf->project->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Project not enabled'); } diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index d984b3346d8..61bbd23ea61 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -50,6 +50,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; @@ -82,7 +83,7 @@ $user->loadDefaultValues(); // Security check if (empty($conf->project->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Project not enabled'); } diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 52193e4fcd4..f42e75b21b1 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -45,6 +45,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -105,7 +106,7 @@ $arrayofconfboothtype = $cactioncomm->liste_array('', 'id', '', 0, "module='boot // Security check if (empty($conf->eventorganization->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Event organization not enabled'); } diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index 05cc8e61a82..f0b9299f980 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -45,6 +45,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -106,7 +107,7 @@ $arrayofconfboothtype = $cactioncomm->liste_array('', 'id', '', 0, "module='conf // Security check if (empty($conf->eventorganization->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Event organization not enabled'); } diff --git a/htdocs/public/project/viewandvote.php b/htdocs/public/project/viewandvote.php index 805eb8cfdd1..1d9fc58c810 100644 --- a/htdocs/public/project/viewandvote.php +++ b/htdocs/public/project/viewandvote.php @@ -41,6 +41,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -91,7 +92,7 @@ if ($resultproject < 0) { // Security check if (empty($conf->eventorganization->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Event organization not enabled'); } diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index 32585c94bb4..bb135d54d50 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -34,6 +34,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; @@ -80,7 +81,7 @@ $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than curren // Security check if (empty($conf->recruitment->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Recruitment not enabled'); } diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index 2eaa51ac2fe..24c0eaf6088 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -34,6 +34,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; @@ -77,7 +78,7 @@ $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than curren // Security check if (empty($conf->recruitment->enabled)) { - accessforbidden('', 0, 0, 1); + httponly_accessforbidden('Module Recruitment not enabled'); } diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 29e22c72de7..dd5b1db148f 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -34,6 +34,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -49,11 +50,6 @@ require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; -if (empty($conf->stripe->enabled)) { - accessforbidden('', 0, 0, 1); -} - - // You can find your endpoint's secret in your webhook settings if (isset($_GET['connect'])) { if (isset($_GET['test'])) { @@ -77,10 +73,12 @@ if (isset($_GET['connect'])) { } } +if (empty($conf->stripe->enabled)) { + httponly_accessforbidden('Module Stripe not enabled'); +} + if (empty($endpoint_secret)) { - print 'Error: Setup of module Stripe not complete for mode '.$service.'. The WEBHOOK_KEY is not defined.'; - http_response_code(400); // PHP 5.4 or greater - exit(); + httponly_accessforbidden('Error: Setup of module Stripe not complete for mode '.dol_escape_htmltag($service).'. The WEBHOOK_KEY is not defined.', 400, 1); } if (!empty($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS)) { @@ -89,9 +87,7 @@ if (!empty($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS)) { $user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); $user->getrights(); } else { - print 'Error: Setup of module Stripe not complete for mode '.$service.'. The STRIPE_USER_ACCOUNT_FOR_ACTIONS is not defined.'; - http_response_code(400); // PHP 5.4 or greater - exit(); + httponly_accessforbidden('Error: Setup of module Stripe not complete for mode '.dol_escape_htmltag($service).'. The STRIPE_USER_ACCOUNT_FOR_ACTIONS is not defined.', 400, 1); } @@ -113,12 +109,9 @@ try { $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret); } catch (\UnexpectedValueException $e) { // Invalid payload - http_response_code(400); // PHP 5.4 or greater - exit(); + httponly_accessforbidden('Invalid payload', 400); } catch (\Stripe\Error\SignatureVerification $e) { - // Invalid signature - http_response_code(400); // PHP 5.4 or greater - exit(); + httponly_accessforbidden('Invalid signature', 400); } // Do something with $event @@ -155,6 +148,7 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $societeName = $conf->global->MAIN_APPLICATION_TITLE; } +top_httphead(); dol_syslog("***** Stripe IPN was called with event->type = ".$event->type); @@ -195,11 +189,10 @@ if ($event->type == 'payout.created') { $ret = $mailfile->sendfile(); - http_response_code(200); // PHP 5.4 or greater return 1; } else { $error++; - http_response_code(500); // PHP 5.4 or greater + http_response_code(500); return -1; } } elseif ($event->type == 'payout.paid') { @@ -287,7 +280,6 @@ if ($event->type == 'payout.created') { $ret = $mailfile->sendfile(); - http_response_code(200); return 1; } else { $error++; @@ -396,4 +388,4 @@ if ($event->type == 'payout.created') { // This event is deprecated. } -http_response_code(200); +// End of page. Default return HTTP code will be 200 diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 609ced5f684..693b7eed59d 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -9,12 +9,6 @@ if (!defined('NOREQUIRESOC')) { if (!defined('NOSTYLECHECK')) { define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test -} //if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu //if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php //if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library @@ -22,6 +16,7 @@ if (!defined("NOLOGIN")) { define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) } +// Load Dolibarr environment require '../../main.inc.php'; // Security diff --git a/htdocs/public/test/test_csrf.php b/htdocs/public/test/test_csrf.php index 43372d22f15..6bb9679d404 100644 --- a/htdocs/public/test/test_csrf.php +++ b/htdocs/public/test/test_csrf.php @@ -9,12 +9,6 @@ if (!defined('NOREQUIRESOC')) { if (!defined('NOSTYLECHECK')) { define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test -} //if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu //if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php //if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library @@ -22,6 +16,7 @@ if (!defined("NOLOGIN")) { define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) } +// Load Dolibarr environment require '../../main.inc.php'; // Security diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index ef6f41df132..1c477c31295 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -14,12 +14,6 @@ if (!defined('NOREQUIRETRAN')) { if (!defined('NOSTYLECHECK')) { define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test -} if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu } @@ -41,6 +35,7 @@ if (!defined("NOSESSION")) { define("NOSESSION", '1'); } +// Load Dolibarr environment require '../../main.inc.php'; // Security diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index c5d25e0871e..acc9151798f 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -5,6 +5,7 @@ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site define('NOSESSION', '1'); }*/ +// Load Dolibarr environment require '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/public/test/test_sessionlock.php b/htdocs/public/test/test_sessionlock.php index 1aea6204b3e..6e022358ba2 100644 --- a/htdocs/public/test/test_sessionlock.php +++ b/htdocs/public/test/test_sessionlock.php @@ -14,12 +14,6 @@ if (!defined('NOREQUIRETRAN')) { if (!defined('NOSTYLECHECK')) { define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test -} if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu } @@ -61,6 +55,7 @@ print '
'; print 'session_status='.session_status().' (before main.inc.php)'; print '
'; +// Load Dolibarr environment require '../../main.inc.php'; // Security diff --git a/htdocs/public/ticket/ajax/ajax.php b/htdocs/public/ticket/ajax/ajax.php index a75c796539c..2b637ce3647 100644 --- a/htdocs/public/ticket/ajax/ajax.php +++ b/htdocs/public/ticket/ajax/ajax.php @@ -33,9 +33,6 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} // Do not check anti CSRF attack test if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 7ebbdb05af3..fa18f855170 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -52,6 +52,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; @@ -90,8 +91,8 @@ if (!empty($conf->global->TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST)) $extrafields->fetch_name_optionals_label($object->table_element); -if (empty($conf->ticket->enabled)) { - accessforbidden('', 0, 0, 1); +if (!isModEnabled('ticket')) { + httponly_accessforbidden('Module Ticket not enabled'); } @@ -231,10 +232,35 @@ if (empty($reshook)) { } if (!$error) { - $object->db->begin(); + $object->type_code = GETPOST("type_code", 'aZ09'); + $object->category_code = GETPOST("category_code", 'aZ09'); + $object->severity_code = GETPOST("severity_code", 'aZ09'); + $object->ip = getUserRemoteIP(); + + $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 1000); + + // Calculate nb of post for IP + $nb_post_ip = 0; + if ($nb_post_max > 0) { // Calculate only if there is a limit to check + $sql = "SELECT COUNT(ref) as nb_tickets"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket"; + $sql .= " WHERE ip = '".$db->escape($object->ip)."'"; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $i++; + $obj = $db->fetch_object($resql); + $nb_post_ip = $obj->nb_tickets; + } + } + } $object->track_id = generate_random_id(16); + $object->db->begin(); + $object->subject = GETPOST("subject", "restricthtml"); $object->message = GETPOST("message", "restricthtml"); $object->origin_email = $origin_email; @@ -300,115 +326,82 @@ if (empty($reshook)) { $object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later - $id = $object->create($user); - if ($id <= 0) { + if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) { $error++; - $errors = ($object->error ? array($object->error) : $object->errors); - array_push($object->errors, $object->error ? array($object->error) : $object->errors); + $errors = array($langs->trans("AlreadyTooMuchPostOnThisIPAdress")); + array_push($object->errors, array($langs->trans("AlreadyTooMuchPostOnThisIPAdress"))); $action = 'create_ticket'; } + if (!$error) { + $id = $object->create($user); + if ($id <= 0) { + $error++; + $errors = ($object->error ? array($object->error) : $object->errors); + array_push($object->errors, $object->error ? array($object->error) : $object->errors); + $action = 'create_ticket'; + } + } + if (!$error && $id > 0) { if ($usertoassign > 0) { $object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0); } - } - if (!$error) { - $object->db->commit(); - $action = "infos_success"; - } else { - $object->db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'create_ticket'; - } + if (!$error) { + $object->db->commit(); + $action = "infos_success"; + } else { + $object->db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create_ticket'; + } - if (!$error) { - $res = $object->fetch($id); - if ($res) { - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $formmail = new FormMail($db); + if (!$error) { + $res = $object->fetch($id); + if ($res) { + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $formmail = new FormMail($db); - // Init to avoid errors - $filepath = array(); - $filename = array(); - $mimetype = array(); + // Init to avoid errors + $filepath = array(); + $filename = array(); + $mimetype = array(); - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; + $attachedfiles = $formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; - // Send email to customer + // Send email to customer - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id); - $message = ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody')).'

'; - $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket').'
'; + $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id); + $message = ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody')).'

'; + $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket').'
'; - $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id; - $infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', ''.$object->track_id.'').'
'; - $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'

'; + $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id; + $infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', ''.$object->track_id.'').'
'; + $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'

'; - $message .= $infos_new_ticket; - $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name)); + $message .= $infos_new_ticket; + $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name)); - $sendto = GETPOST('email', 'alpha'); + $sendto = GETPOST('email', 'alpha'); - $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>'; - $replyto = $from; - $sendtocc = ''; - $deliveryreceipt = 0; - - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { - $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; - $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; - } - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); - if ($mailfile->error || $mailfile->errors) { - setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - } else { - $result = $mailfile->sendfile(); - } - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { - $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; - } - - // Send email to TICKET_NOTIFICATION_EMAIL_TO - $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; - if ($sendto) { - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id); - $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id).'

'; - $message_admin .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; - $message_admin .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; - $message_admin .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; - $message_admin .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; - $message_admin .= '
  • '.$langs->trans('From').' : '.$object->origin_email.'
  • '; - // Extrafields - $extrafields->fetch_name_optionals_label($object->table_element); - if (is_array($object->array_options) && count($object->array_options) > 0) { - foreach ($object->array_options as $key => $value) { - $key = substr($key, 8); // remove "options_" - $message_admin .= '
  • '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value, '', $object->table_element).'
  • '; - } - } - $message_admin .= '
'; - - $message_admin .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; - $message_admin .= '

'.$langs->trans('SeeThisTicketIntomanagementInterface').'

'; - - $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>'; $replyto = $from; + $sendtocc = ''; + $deliveryreceipt = 0; if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); - if ($mailfile->error || $mailfile->errors) { + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); + if ($mailfile->error || !empty($mailfile->errors)) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); } else { $result = $mailfile->sendfile(); @@ -416,32 +409,74 @@ if (empty($reshook)) { if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; } + + // Send email to TICKET_NOTIFICATION_EMAIL_TO + $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + if ($sendto) { + $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id); + $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id).'

'; + $message_admin .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; + $message_admin .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; + $message_admin .= '
  • '.$langs->trans('Category').' : '.$object->category_label.'
  • '; + $message_admin .= '
  • '.$langs->trans('Severity').' : '.$object->severity_label.'
  • '; + $message_admin .= '
  • '.$langs->trans('From').' : '.$object->origin_email.'
  • '; + // Extrafields + $extrafields->fetch_name_optionals_label($object->table_element); + if (is_array($object->array_options) && count($object->array_options) > 0) { + foreach ($object->array_options as $key => $value) { + $key = substr($key, 8); // remove "options_" + $message_admin .= '
  • '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value, '', $object->table_element).'
  • '; + } + } + $message_admin .= '
'; + + $message_admin .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; + $message_admin .= '

'.$langs->trans('SeeThisTicketIntomanagementInterface').'

'; + + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; + $replyto = $from; + + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { + $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; + $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; + } + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); + if ($mailfile->error || !empty($mailfile->errors)) { + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); + } else { + $result = $mailfile->sendfile(); + } + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { + $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO; + } + } } + + // Copy files into ticket directory + $destdir = $conf->ticket->dir_output.'/'.$object->ref; + if (!dol_is_dir($destdir)) { + dol_mkdir($destdir); + } + foreach ($filename as $i => $val) { + dol_move($filepath[$i], $destdir.'/'.$filename[$i], 0, 1); + $formmail->remove_attached_files($i); + } + + //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs'); + + // Make a redirect to avoid to have ticket submitted twice if we make back + $messagetoshow = $langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '{s1}', '{s2}'); + $messagetoshow = str_replace(array('{s1}', '{s2}'), array(''.$object->track_id.'', ''.$object->ref.''), $messagetoshow); + setEventMessages($messagetoshow, null, 'warnings'); + setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings'); + + header("Location: index.php".(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'')); + exit; } - - // Copy files into ticket directory - $destdir = $conf->ticket->dir_output.'/'.$object->ref; - if (!dol_is_dir($destdir)) { - dol_mkdir($destdir); - } - foreach ($filename as $i => $val) { - dol_move($filepath[$i], $destdir.'/'.$filename[$i], 0, 1); - $formmail->remove_attached_files($i); - } - - //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs'); - - // Make a redirect to avoid to have ticket submitted twice if we make back - $messagetoshow = $langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '{s1}', '{s2}'); - $messagetoshow = str_replace(array('{s1}', '{s2}'), array(''.$object->track_id.'', ''.$object->ref.''), $messagetoshow); - setEventMessages($messagetoshow, null, 'warnings'); - setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings'); - - header("Location: index.php".(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'')); - exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); } - } else { - setEventMessages($object->error, $object->errors, 'errors'); } } } diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 6332f063541..84652017b37 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -42,6 +42,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; @@ -58,8 +59,8 @@ $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'aZ09'); $suffix = ""; -if (empty($conf->ticket->enabled)) { - accessforbidden('', 0, 0, 1); +if (!isModEnabled('ticket')) { + httponly_accessforbidden('Module Ticket not enabled'); } diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 7af60f50e83..3fe6253b879 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -43,6 +43,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; @@ -78,8 +79,8 @@ $object = new Ticket($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('ticketpubliclist', 'globalcard')); -if (empty($conf->ticket->enabled)) { - accessforbidden('', 0, 0, 1); +if (!isModEnabled('ticket')) { + httponly_accessforbidden('Module Ticket not enabled'); } diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index de76e2f9904..3f137148a89 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -44,6 +44,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; @@ -72,8 +73,8 @@ if (isset($_SESSION['email_customer'])) { $object = new ActionsTicket($db); -if (empty($conf->ticket->enabled)) { - accessforbidden('', 0, 0, 1); +if (!isModEnabled('ticket')) { + httponly_accessforbidden('Module Ticket not enabled'); } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 5f49f18a23a..7d4d58cbc83 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -33,6 +33,7 @@ * \brief Card of a reception */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; @@ -198,10 +199,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -436,10 +437,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -531,10 +532,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $reception->thirdparty->default_lang; } if (!empty($newlang)) { @@ -666,10 +667,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -751,7 +752,7 @@ if ($action == 'create') { $author = new User($db); $author->fetch($objectsrc->user_author_id); - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { $entrepot = new Entrepot($db); } @@ -1038,7 +1039,7 @@ if ($action == 'create') { print ' / '.$langs->trans("Reset").')'; } print ''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; } if (isModEnabled('productbatch')) { @@ -1172,7 +1173,7 @@ if ($action == 'create') { $warehouseObject = null; - if (!empty($conf->stock->enabled)) { // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection + if (isModEnabled('stock')) { // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection print ''; $stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number @@ -1199,7 +1200,7 @@ if ($action == 'create') { } // Stock - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; } @@ -1737,7 +1738,7 @@ if ($action == 'create') { $var = false; - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); $outputlangs = $langs; $newlang = ''; @@ -1812,7 +1813,7 @@ if ($action == 'create') { // Predefined product or service if ($lines[$i]->fk_product > 0) { // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod = new Product($db); $prod->fetch($lines[$i]->fk_product); $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product->label; @@ -1888,7 +1889,7 @@ if ($action == 'create') { print ' - '.$receptionline_var['qty']; $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); - if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) { + if (isModEnabled('stock') && $receptionline_var['warehouse'] > 0) { $warehousestatic->fetch($receptionline_var['warehouse']); $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); } @@ -1903,7 +1904,7 @@ if ($action == 'create') { if ($action == 'editline' && $lines[$i]->id == $line_id) { // edit mode print '
'.$langs->trans('Qty').''; - print ''; - print $langs->trans('Unit'); - print ''; + print ''; + print $langs->trans('Unit'); + print '' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '' . $form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')) . '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . '' . $form->textwithpicto($langs->trans('Unit'), '').'' . $form->textwithpicto($langs->trans('Workstation'), '') . '' . $form->textwithpicto($langs->trans('TotalCost'), '') . ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'  
'; // Predefined product/service if (isModEnabled("product") || isModEnabled("service")) { - if (!empty($conf->global->BOM_SUB_BOM)) { + if ($filtertype == 1) { + print $langs->trans("Service"); + } elseif (!empty($conf->global->BOM_SUB_BOM)) { print $langs->trans("Product"); } echo ''; - $filtertype = 0; - if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->STOCK_SUPPORT_SERVICES)) { - $filtertype = -1; - } $statustoshow = -1; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer - $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); + $form->select_produits(GETPOST('idprod', 'int'), (($filtertype == 1) ? 'idprodservice' : 'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); } else { - $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); + $form->select_produits(GETPOST('idprod', 'int'), (($filtertype == 1) ? 'idprodservice' : 'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } echo ''; } -if (!empty($conf->global->BOM_SUB_BOM)) { +if (!empty($conf->global->BOM_SUB_BOM) && $filtertype!=1) { print '
'.$langs->trans("or").'
'.$langs->trans("BOM"); // TODO Add component to select a BOM $form->select_bom(); @@ -118,35 +133,57 @@ $coldisplay++; print '
'; print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ' '; + print ''; + print $formproduct->selectMeasuringUnits("fk_unit", "time", $fk_unit_default, 0, 0); + print ''; + print ' '; + print ''; + print ' '; print ''; -print ''; + print ''; + print '
'; -print ''; -print ''; -print ''; -print ' '; -print ''; -print ''; -print '
'; + print ''; + print 'qty_frozen ? ' checked="checked"' : '')) . '>'; + print 'disable_stock_change ? ' checked="checked"' : '')) . '">'; + print ''; + print ''; + print ''; + print $formproduct->selectMeasuringUnits("fk_unit", "time", ($line->fk_unit) ? $line->fk_unit : '', 0, 0); + print ''; + print ''; print 'qty_frozen ? ' checked="checked"' : '')).'>'; -print 'disable_stock_change ? ' checked="checked"' : '')).'">'; -print ''; -print ''; -print ''; $coldisplay += $colspan; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index dff3a38ccd2..5252baf61ca 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -38,6 +38,10 @@ if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } + +global $filtertype; +if (empty($filtertype)) $filtertype = 0; + print "\n"; @@ -53,30 +57,42 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { // Product or sub-bom print ''.$langs->trans('Description'); -if (!empty($conf->global->BOM_SUB_BOM)) { +if (!empty($conf->global->BOM_SUB_BOM) && $filtertype != 1) { print '   '.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'  '; print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; } print ''.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).''.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').''.$langs->trans('Unit').'' . $langs->trans('Unit') . '' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '' . $form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')) . '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'' . $form->textwithpicto($langs->trans('Unit'), '').'' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCostService")).''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''; - $label = $tmpproduct->getLabelOfUnit('long'); - if ($label !== '') { - print $langs->trans($label); +if ($filtertype != 1) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + $label = $tmpproduct->getLabelOfUnit('long'); + if ($label !== '') { + print $langs->trans($label); + } + print ''; + $coldisplay++; + echo $line->qty_frozen ? yn($line->qty_frozen) : ''; print ''; + $coldisplay++; + echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price + print ''; + $coldisplay++; + echo $line->efficiency; + print ''; + $coldisplay++; + + if (!empty($line->fk_unit)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; + $unit = new CUnits($this->db); + $unit->fetch($line->fk_unit); + print (isset($unit->label) ? " ".$langs->trans(ucwords($unit->label))." " : ''); + } + + print ''; + $coldisplay++; + if ($res > 0) echo $workstation->getNomUrl(); + print ''; -$coldisplay++; -echo $line->qty_frozen ? yn($line->qty_frozen) : ''; -print ''; -$coldisplay++; -echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price -print ''; -$coldisplay++; -echo $line->efficiency; -print ''; $coldisplay++; diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index 3d5c8eb3bc0..74b44bd8f9b 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -22,6 +22,7 @@ * \brief Page to setup bookmark module */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 1db3970f614..797bffa187a 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -29,7 +29,7 @@ */ function printDropdownBookmarksList() { - global $conf, $user, $db, $langs; + global $conf, $user, $db, $langs, $sortfield, $sortorder; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -42,13 +42,16 @@ function printDropdownBookmarksList() if (!empty($_SERVER["QUERY_STRING"])) { if (is_array($_GET)) { foreach ($_GET as $key => $val) { - if ($val != '') { - $url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + if (is_array($val)) { + foreach ($val as $tmpsubval) { + $url_param[] = http_build_query(array(dol_escape_htmltag($key).'[]' => dol_escape_htmltag($tmpsubval))); + } + } elseif ($val != '') { + $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); } } } } - global $sortfield, $sortorder; $tmpurl = ''; // No urlencode, all param $url will be urlencoded later if ($sortfield) { @@ -62,10 +65,11 @@ function printDropdownBookmarksList() if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var)) && $val != '' && !array_key_exists($key, $url_param)) { - $url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); } } } + $url .= ($tmpurl ? '?'.$tmpurl : ''); if (!empty($url_param)) { $url .= '&'.implode('&', $url_param); @@ -90,6 +94,7 @@ function printDropdownBookmarksList() $listbtn = ''; $listbtn .= img_picto('', 'edit', 'class="paddingright opacitymedium"').$langs->trans('EditBookmarks').''; + $bookmarkList = ''; // Menu with list of bookmarks $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index bbc92a83ef1..60d615192d0 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -18,23 +18,22 @@ */ /** - * \file htdocs/bookmarks/card.php - * \brief Page display/creation of bookmarks - * \ingroup bookmark + * \file htdocs/bookmarks/card.php + * \ingroup bookmark + * \brief Page display/creation of bookmarks */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; + // Load translation files required by the page $langs->loadLangs(array('bookmarks', 'other')); -// Security check -if (empty($user->rights->bookmark->lire)) { - restrictedArea($user, 'bookmarks'); -} +// Get Parameters $id = GETPOST("id", 'int'); $action = GETPOST("action", "alpha"); $title = (string) GETPOST("title", "alpha"); @@ -45,12 +44,22 @@ $userid = GETPOST("userid", "int"); $position = GETPOST("position", "int"); $backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize Objects $object = new Bookmark($db); if ($id > 0) { $object->fetch($id); } +// Security check +if (empty($user->rights->bookmark->lire)) { + restrictedArea($user, 'bookmarks'); +} + + + + /* * Actions */ @@ -124,6 +133,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') { } + /* * View */ diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 07ea263eeda..47f97e17bbe 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -16,28 +16,26 @@ */ /** - * \file htdocs/bookmarks/list.php - * \brief Page to display list of bookmarks - * \ingroup bookmark + * \file htdocs/bookmarks/list.php + * \ingroup bookmark + * \brief Page to display list of bookmarks */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; // Load translation files required by the page $langs->loadLangs(array('bookmarks', 'admin')); +// Get Parameters $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bookmarklist'; // To manage different context of search - -// Security check -if (empty($user->rights->bookmark->lire)) { - restrictedArea($user, 'bookmarks'); -} +$id = GETPOST("id", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); // Load variable for pagination @@ -58,10 +56,13 @@ if (!$sortorder) { $sortorder = 'ASC'; } -$id = GETPOST("id", 'int'); - +// Initialize Objects $object = new Bookmark($db); +// Security check +restrictedArea($user, 'bookmark'); + +// Permissions $permissiontoread = !empty($user->rights->bookmark->lire); $permissiontoadd = !empty($user->rights->bookmark->creer); $permissiontodelete = !empty($user->rights->bookmark->supprimer); @@ -82,6 +83,7 @@ if ($action == 'delete') { } + /* * View */ diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index f7022477d97..72b7f02f0d2 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -23,6 +23,7 @@ * \brief Categorie admin pages */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 2a1879135d6..7f2fabe4a3a 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -24,6 +24,7 @@ * \brief Page to setup extra fields of category */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -79,13 +80,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 361f2a5f1ce..7f04c6d1005 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -27,6 +27,7 @@ * \brief Page to create a new category */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d5345106093..e59ff070aec 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -315,7 +315,7 @@ class Categories extends DolibarrApi throw new RestException(401); } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) { + } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { throw new RestException(401); @@ -386,7 +386,7 @@ class Categories extends DolibarrApi } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) { throw new RestException(401); } $object = new Adherent($this->db); @@ -466,7 +466,7 @@ class Categories extends DolibarrApi } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) { throw new RestException(401); } $object = new Adherent($this->db); @@ -546,7 +546,7 @@ class Categories extends DolibarrApi } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) { throw new RestException(401); } $object = new Adherent($this->db); @@ -624,7 +624,7 @@ class Categories extends DolibarrApi } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) { throw new RestException(401); } $object = new Adherent($this->db); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b222f70110a..1d7901eca3f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -384,7 +384,7 @@ class Categorie extends CommonObject $this->db->free($resql); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $this->getMultiLangs(); } @@ -636,23 +636,30 @@ class Categorie extends CommonObject } $arraydelete = array( - 'categorie_product' => 'fk_categorie', - 'categorie_fournisseur' => 'fk_categorie', - 'categorie_societe' => 'fk_categorie', - 'categorie_member' => 'fk_categorie', - 'categorie_contact' => 'fk_categorie', - 'categorie_user' => 'fk_categorie', - 'categorie_project' => 'fk_categorie', 'categorie_account' => 'fk_categorie', - 'categorie_website_page' => 'fk_categorie', - 'categorie_warehouse' => 'fk_categorie', 'categorie_actioncomm' => 'fk_categorie', - 'categorie_ticket' => 'fk_categorie', + 'categorie_contact' => 'fk_categorie', + 'categorie_fournisseur' => 'fk_categorie', + 'categorie_knowledgemanagement' => array('field' => 'fk_categorie', 'enabled' => isModEnabled('knowledgemanagement')), + 'categorie_member' => 'fk_categorie', + 'categorie_user' => 'fk_categorie', + 'categorie_product' => 'fk_categorie', + 'categorie_project' => 'fk_categorie', + 'categorie_societe' => 'fk_categorie', + 'categorie_ticket' => array('field' => 'fk_categorie', 'enabled' => isModEnabled('ticket')), + 'categorie_warehouse' => 'fk_categorie', + 'categorie_website_page' => array('field' => 'fk_categorie', 'enabled' => isModEnabled('website')), 'bank_class' => 'fk_categ', 'categorie_lang' => 'fk_category', 'categorie' => 'rowid', ); foreach ($arraydelete as $key => $value) { + if (is_array($value)) { + if (empty($value['enabled'])) { + continue; + } + $value = $value['field']; + } $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; $sql .= " WHERE ".$value." = ".((int) $this->id); if (!$this->db->query($sql)) { @@ -993,7 +1000,7 @@ class Categorie extends CommonObject $categories[$i]['array_options'] = $category_static->array_options; // multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && isset($category_static->multilangs)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && isset($category_static->multilangs)) { $categories[$i]['multilangs'] = $category_static->multilangs; } } @@ -1121,11 +1128,11 @@ class Categorie extends CommonObject // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= ", t.label as label_trans, t.description as description_trans"; } $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'"; } $sql .= " WHERE c.entity IN (".getEntity('category').")"; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 518889b85b3..caacc986cc5 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -25,6 +25,7 @@ * \brief Page d'edition de categorie produit */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 4a9e771416c..babbf23e99a 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -27,6 +27,7 @@ * \brief Home page of category area */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index f5b54f50de9..81685a51e7b 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -23,6 +23,7 @@ * \brief Category info page */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 4e7d5bb8943..bd98afb87f7 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -26,6 +26,7 @@ * \brief Gestion des photos d'une categorie */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 69a27c5cff5..8aecdde63ea 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -25,6 +25,7 @@ * \brief Page of translation of categories */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 0e5da0735ce..194229725c3 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -27,6 +27,7 @@ * \brief Page to show a category card */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; @@ -117,7 +118,7 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'customer'; - } elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { + } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $tmpobject = new Adherent($db); $result = $tmpobject->fetch($removeelem); @@ -563,7 +564,7 @@ if ($type == Categorie::TYPE_PRODUCT) { } } else { print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'products'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -643,7 +644,7 @@ if ($type == Categorie::TYPE_CUSTOMER) { } } else { print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'companies'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -724,7 +725,7 @@ if ($type == Categorie::TYPE_SUPPLIER) { } } else { print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'companies'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -733,7 +734,7 @@ if ($type == Categorie::TYPE_MEMBER) { if ($user->hasRight("adherent", "read")) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $permission = $user->rights->adherent->creer; + $permission = $user->hasRight('adherent', 'creer'); $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($prods < 0) { @@ -768,7 +769,7 @@ if ($type == Categorie::TYPE_MEMBER) { print '
'; $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; - $newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->adherent->creer); + $newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('adherent', 'creer')); print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); print "\n"; @@ -808,7 +809,7 @@ if ($type == Categorie::TYPE_MEMBER) { } } else { print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'members'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -895,7 +896,7 @@ if ($type == Categorie::TYPE_CONTACT) { } } else { print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'contact'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -977,7 +978,7 @@ if ($type == Categorie::TYPE_ACCOUNT) { } } else { print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'bank'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -1060,7 +1061,7 @@ if ($type == Categorie::TYPE_PROJECT) { } } else { print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'project'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -1137,7 +1138,7 @@ if ($type == Categorie::TYPE_USER) { } } else { print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'user'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -1201,7 +1202,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) { } } else { print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'stock'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } @@ -1280,7 +1281,7 @@ if ($type == Categorie::TYPE_TICKET) { } } else { print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'ticket'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + accessforbidden("NotEnoughPermissions", 0, 0); } } diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index 296e0f3852f..746cc019a8b 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -24,6 +24,7 @@ define('NOSCANPOSTFORINJECTION', 1); define('NOSTYLECHECK', 1); +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 14654914dd5..2c008202348 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -25,31 +25,35 @@ */ /** - * \file htdocs/comm/action/card.php - * \ingroup agenda - * \brief Page for event card + * \file htdocs/comm/action/card.php + * \ingroup agenda + * \brief Page for event card */ +// Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + // Load translation files required by the page $langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda", "mails")); +// Get Parameters $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -96,6 +100,7 @@ if ($user->socid) { $error = GETPOST("error"); $donotclearsession = GETPOST('donotclearsession') ?GETPOST('donotclearsession') : 0; +// Initialize Objects $object = new ActionComm($db); $cactioncomm = new CActionComm($db); $contact = new Contact($db); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 571815fb615..45dbbbf12c0 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2355,7 +2355,7 @@ class ActionComm extends CommonObject $nbMailSend = 0; $errorsMsg = array(); - if (empty($conf->agenda->enabled)) { // Should not happen. If module disabled, cron job should not be visible. + if (!isModEnabled('agenda')) { // Should not happen. If module disabled, cron job should not be visible. $langs->load("agenda"); $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda")); return 0; diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 2d57cfe1284..0942e1554a8 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -207,10 +207,10 @@ class CActionComm if ($obj->module == 'propal' && isModEnabled("propal") && !empty($user->rights->propale->lire)) { $qualified = 1; } - if ($obj->module == 'invoice_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (!empty($conf->rights->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire)))) { + if ($obj->module == 'invoice_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (isModEnabled('supplier_invoice') && !empty($user->rights->supplier_invoice->lire)))) { $qualified = 1; } - if ($obj->module == 'order_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (empty($conf->rights->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)))) { + if ($obj->module == 'order_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (!isModEnabled('supplier_order') && !empty($user->rights->supplier_order->lire)))) { $qualified = 1; } if ($obj->module == 'shipping' && isModEnabled("expedition") && !empty($user->rights->expedition->lire)) { @@ -228,7 +228,7 @@ class CActionComm $tmpobject = $regs[1]; $tmpmodule = $regs[2]; //var_dump($user->$tmpmodule); - if ($tmpmodule && isset($conf->$tmpmodule) && !empty($conf->$tmpmodule->enabled) && (!empty($user->rights->$tmpmodule->read) || !empty($user->rights->$tmpmodule->lire) || !empty($user->rights->$tmpmodule->$tmpobject->read) || !empty($user->rights->$tmpmodule->$tmpobject->lire))) { + if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule) && (!empty($user->rights->$tmpmodule->read) || !empty($user->rights->$tmpmodule->lire) || !empty($user->rights->$tmpmodule->$tmpobject->read) || !empty($user->rights->$tmpmodule->$tmpobject->lire))) { $qualified = 1; } } @@ -237,7 +237,7 @@ class CActionComm if (! in_array($obj->type, array('system', 'systemauto', 'module', 'moduleauto'))) { $tmpmodule = $obj->module; //var_dump($tmpmodule); - if ($tmpmodule && isset($conf->$tmpmodule) && !empty($conf->$tmpmodule->enabled)) { + if ($tmpmodule && isset($conf->$tmpmodule) && isModEnabled($tmpmodule)) { $qualified = 1; } } diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index ada742f9742..9a4a4e6a869 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -26,6 +26,7 @@ * \brief Page of documents linked to actions */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e287ccfd2d7..f46b0adc3cb 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -30,6 +30,7 @@ * \brief Home page of calendar events */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 73acc0e7c82..807a8e6f412 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -22,6 +22,7 @@ * \brief Page des informations d'une action */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index b42bf003333..a5aca966530 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -27,10 +27,7 @@ * \brief Page to list actions */ -if (!defined("NOREDIRECTBYMAINTOLOGIN")) { - define('NOREDIRECTBYMAINTOLOGIN', 1); -} - +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -398,7 +395,7 @@ $arrayofmassactions = array( if ($user->rights->agenda->allactions->delete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if ($user->rights->agenda->myactions->create) { +if (isModEnabled('category') && $user->rights->agenda->myactions->create) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index d21b20bbfaf..61092df5665 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -23,20 +23,21 @@ /** - * \file htdocs/comm/action/pertype.php - * \ingroup agenda - * \brief Tab of calendar events per type + * \file htdocs/comm/action/pertype.php + * \ingroup agenda + * \brief Tab of calendar events per type */ +// Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { @@ -51,28 +52,35 @@ $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; -//$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; -$showbirthday = 0; + +// $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; +$showbirthday = 0; // will be hidden here // If not choice done on calendar owner, we filter on user. if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { $filtert = $user->id; } +// Sorting $sortfield = GETPOST('sortfield', 'aZ09comma'); +if (!$sortfield) { + $sortfield = "a.datec"; +} + $sortorder = GETPOST('sortorder', 'aZ09comma'); +if (!$sortorder) { + $sortorder = "ASC"; +} + +// Page $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "a.datec"; -} + + // Security check $socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); @@ -83,6 +91,7 @@ if ($socid < 0) { $socid = ''; } +// Permissions $canedit = 1; if (empty($user->rights->agenda->myactions->read)) { accessforbidden(); @@ -105,6 +114,7 @@ $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GE $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { $actioncode = GETPOST('search_actioncode', 'array', 3); @@ -117,11 +127,12 @@ if (GETPOST('search_actioncode', 'array')) { $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); if ($dateselect > 0) { - $day = GETPOST('dateselectday', 'int'); + $day = GETPOST('dateselectday', 'int'); $month = GETPOST('dateselectmonth', 'int'); - $year = GETPOST('dateselectyear', 'int'); + $year = GETPOST('dateselectyear', 'int'); } +// working hours $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; $tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); @@ -137,6 +148,7 @@ if ($end_h <= $begin_h) { $end_h = $begin_h + 1; } +// working days $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; $tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); @@ -150,19 +162,24 @@ if (empty($mode) && !GETPOSTISSET('mode')) { $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); } +// View by month if (GETPOST('viewcal', 'alpha') && $mode != 'show_day' && $mode != 'show_week' && $mode != 'show_peruser') { $mode = 'show_month'; $day = ''; -} // View by month +} +// View by week if (GETPOST('viewweek', 'alpha') || $mode == 'show_week') { $mode = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); -} // View by week +} +// View by day if (GETPOST('viewday', 'alpha') || $mode == 'show_day') { $mode = 'show_day'; $day = ($day ? $day : date("d")); -} // View by day +} +// View by year if (GETPOST('viewyear', 'alpha') || $mode == 'show_year') { $mode = 'show_year'; -} // View by year +} +// Initialize object $object = new ActionComm($db); // Load translation files required by the page @@ -218,6 +235,7 @@ $parameters = array( 'resourceid' => $resourceid, 'usergroup' => $usergroup, ); + $reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -226,14 +244,14 @@ if ($reshook < 0) { $form = new Form($db); $companystatic = new Societe($db); -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; llxHeader('', $langs->trans("Agenda"), $help_url); $now = dol_now(); $nowarray = dol_getdate($now); -$nowyear = $nowarray['year']; +$nowyear = $nowarray['year']; $nowmonth = $nowarray['mon']; -$nowday = $nowarray['mday']; +$nowday = $nowarray['mday']; // Define list of all external calendars (global setup) @@ -246,7 +264,7 @@ $first_year = $year; $week = $prev['week']; -$day = (int) $day; +$day = (int) $day; $next = dol_get_next_day($day, $month, $year); $next_year = $year + 1; $next_month = $month; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index f28a3b2f719..5c5ef948c30 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -28,6 +28,7 @@ * \brief Tab of calendar events per user */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 4414981b6fb..2cc3f6a7a9d 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -24,6 +24,7 @@ * \brief Page with reports of actions */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index 7a4cfe7a6ea..fa0c9117430 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -24,6 +24,7 @@ * \brief Page to setup extra fields of third party */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -79,13 +80,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print "
"; diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index 91517d456c5..0f904b31407 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -27,6 +27,7 @@ * \brief Page to setup extra fields of order */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -82,13 +83,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 6b3161190d8..f6ae06b1f7f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -32,6 +32,7 @@ * \brief Page to show customer card of a third party */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -59,7 +60,7 @@ if (isModEnabled('contrat')) { if (isModEnabled('adherent')) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; } -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; } @@ -81,10 +82,10 @@ if (isModEnabled('facture')) { if (isModEnabled('project')) { $langs->load("projects"); } -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { $langs->load("interventions"); } -if (!empty($conf->notification->enabled)) { +if (isModEnabled('notification')) { $langs->load("mails"); } @@ -130,7 +131,7 @@ if ($id > 0 && empty($object->id)) { } } if ($object->id > 0) { - if (!($object->client > 0) || empty($user->rights->societe->lire)) { + if (!($object->client > 0) || !$user->hasRight('societe', 'lire')) { accessforbidden(); } } @@ -544,7 +545,7 @@ if ($object->id > 0) { } // Warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) { + if (isModEnabled('stock') && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -1230,7 +1231,7 @@ if ($object->id > 0) { /* * Latest interventions */ - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { + if (isModEnabled('ficheinter') && $user->rights->ficheinter->lire) { $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate, f.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid"; @@ -1563,7 +1564,7 @@ if ($object->id > 0) { print ''; } - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) { + if (isModEnabled('ficheinter') && $user->rights->ficheinter->creer && $object->status == 1) { $langs->load("fichinter"); print ''; } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index d83fdbcb78c..19be738a50e 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -24,6 +24,7 @@ * \brief Liste des contacts */ +// Load Dolibarr environment require '../main.inc.php'; // Load translation files required by the page diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index c2852cd45c9..27f9b91a9d7 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -27,6 +27,7 @@ * \brief Home page of commercial area */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; @@ -39,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; } @@ -103,7 +104,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO $supplierorderstatic = new CommandeFournisseur($db); } -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { $fichinterstatic = new Fichinter($db); } @@ -518,7 +519,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO /* * Draft interventionals */ -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { $sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; @@ -593,7 +594,7 @@ print '
'; /* * Last modified customers or prospects */ -if (isModEnabled("societe") && $user->rights->societe->lire) { +if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -699,7 +700,7 @@ if (isModEnabled("societe") && $user->rights->societe->lire) { /* * Last suppliers */ -if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->societe->lire) { +if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 8f0a2b38c7d..d2e9fc7d0d5 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -26,6 +26,7 @@ if (!defined('NOSTYLECHECK')) { define('NOSTYLECHECK', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index ed1fa3f523e..e59389a87b7 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -28,6 +28,7 @@ if (!defined('NOSTYLECHECK')) { define('NOSTYLECHECK', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -220,6 +221,7 @@ if (empty($reshook)) { $substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER5__'] = $other5; $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + $substitutionarray['__SENDEREMAIL_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__CHECK_READ__'] = ''; $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'&email='.urlencode($obj->email).'&mtid='.$obj->rowid; @@ -475,7 +477,7 @@ if (empty($reshook)) { } } - $trackid = 'emailingtest'; + $trackid = 'emailing-test'; $mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid, '', 'emailing'); $result = $mailfile->sendfile(); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 764455e5f62..1beefca8cf6 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -24,6 +24,7 @@ * \brief Page to define emailing targets */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 9ac09ac529b..d3ebc379b55 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -24,6 +24,7 @@ * \brief Home page for emailing area */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 74d6943a044..86ce2eb70b2 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -22,6 +22,7 @@ * \brief Page with log information for emailing */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 757b6373f3f..13a7e63d364 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -22,6 +22,7 @@ * \brief Liste des mailings */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 0e582946df9..81e5cd0d9d2 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -23,6 +23,7 @@ * \brief Tab to set the price level of a thirdparty */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7b491e71a23..caafb2c7579 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -37,6 +37,7 @@ * \brief Page of commercial proposals card and list */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -54,7 +55,7 @@ if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -if (!empty($conf->variants->enabled)) { +if (isModEnabled('variants')) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } @@ -255,7 +256,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -280,10 +281,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -316,8 +317,28 @@ if (empty($reshook)) { if (!$error) { $result = $object->set_date($user, $datep); + if ($result > 0 && !empty($object->duree_validite) && !empty($object->fin_validite)) { + $datev = $datep + ($object->duree_validite * 24 * 3600); + $result = $object->set_echeance($user, $datev, 1); + } if ($result < 0) { dol_print_error($db, $object->error); + } elseif (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records + if ($ret > 0) { + $object->fetch_thirdparty(); + } + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } elseif ($action == 'setecheance' && $usercancreate) { @@ -326,8 +347,8 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -626,10 +647,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -725,7 +746,7 @@ if (empty($reshook)) { $ret = $deposit->fetch($deposit->id); // Reload to get new records $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($deposit->thirdparty->default_lang); $outputlangs->load('products'); @@ -856,7 +877,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -955,7 +976,7 @@ if (empty($reshook)) { $error++; } - if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') { + if (!$error && isModEnabled('variants') && $prod_entry_mode != 'free') { if ($combinations = GETPOST('combinations', 'array')) { //Check if there is a product with the given combination $prodcomb = new ProductCombination($db); @@ -1112,7 +1133,7 @@ if (empty($reshook)) { $desc = ''; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -1146,7 +1167,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) { @@ -1247,7 +1268,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -1421,7 +1442,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -1675,7 +1696,7 @@ if ($action == 'create') { if ($soc->fk_warehouse > 0) { $warehouse_id = $soc->fk_warehouse; } - if (!empty($conf->stock->enabled) && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (isModEnabled('stock') && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) { $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; } @@ -1721,7 +1742,7 @@ if ($action == 'create') { //$warehouse_id = $soc->warehouse_id; } else { print '
'; - print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'company').$form->select_company('', 'socid', '((s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { print ' - ' - ); + + ' + ); + } } } @@ -2227,7 +2231,7 @@ if ($action == 'create' && $usercancreate) { $text = $langs->trans('ConfirmUnvalidateOrder', $object->ref); $formquestion = array(); - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { + if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -2266,7 +2270,7 @@ if ($action == 'create' && $usercancreate) { $text = $langs->trans('ConfirmCancelOrder', $object->ref); $formquestion = array(); - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { + if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -2320,7 +2324,7 @@ if ($action == 'create' && $usercancreate) { $morehtmlref = '
'; // Ref customer $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1, 'customer'); if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { @@ -2479,7 +2483,7 @@ if ($action == 'create' && $usercancreate) { } // Warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (isModEnabled('stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -2606,7 +2610,7 @@ if ($action == 'create' && $usercancreate) { // TODO How record was recorded OrderMode (llx_c_input_method) // Incoterms - if (!empty($conf->incoterm->enabled)) { + if (isModEnabled('incoterm')) { print '
'; $editenable = $usercancreate; print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); @@ -2693,7 +2697,7 @@ if ($action == 'create' && $usercancreate) { print '
'; // Margin Infos - if (!empty($conf->margin->enabled)) { + if (isModEnabled('margin')) { $formmargin->displayMarginInfos($object); } @@ -2805,7 +2809,7 @@ if ($action == 'create' && $usercancreate) { print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=modif&token='.newToken().'&id='.$object->id, ''); } // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) { // Add hidden condition because this is not a // "workflow" action so should appears somewhere else on @@ -2823,7 +2827,7 @@ if ($action == 'create' && $usercancreate) { } // Create intervention - if (!empty($conf->ficheinter->enabled)) { + if (isModEnabled('ficheinter')) { $langs->load("interventions"); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { @@ -2933,7 +2937,7 @@ if ($action == 'create' && $usercancreate) { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); // Show online payment link - $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) { $useonlinepayment = 0; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 436a0a51114..aa7a7f11a55 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -102,12 +102,6 @@ class Commande extends CommonOrder */ public $ref_client; - /** - * @var string Internal ref for order - * @deprecated - */ - public $ref_int; - /** * @var int Contact ID */ @@ -311,7 +305,6 @@ class Commande extends CommonOrder 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>28), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>20), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'visible'=>-1, 'position'=>25), @@ -330,8 +323,8 @@ class Commande extends CommonOrder 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1), - 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>150), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>155), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>150), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>155), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>160), //'facture' =>array('type'=>'tinyint(4)', 'label'=>'ParentInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>165), 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>170), @@ -521,7 +514,7 @@ class Commande extends CommonOrder if (!$error) { // If stock is incremented on validate order, we must increment it - if ($result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { + if ($result >= 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -649,7 +642,7 @@ class Commande extends CommonOrder } // If stock is decremented on validate order, we must reincrement it - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { + if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { $result = 0; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -834,7 +827,7 @@ class Commande extends CommonOrder dol_syslog(get_class($this)."::cancel", LOG_DEBUG); if ($this->db->query($sql)) { // If stock is decremented on validate order, we must reincrement it - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { + if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -945,7 +938,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande ("; - $sql .= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int"; + $sql .= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client"; $sql .= ", model_pdf, fk_cond_reglement, deposit_percent, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; $sql .= ", fk_shipping_method"; $sql .= ", fk_warehouse"; @@ -964,7 +957,6 @@ class Commande extends CommonOrder $sql .= ", '".$this->db->escape($this->note_public)."'"; $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); - $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); $sql .= ", '".$this->db->escape($this->model_pdf)."'"; $sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : "null"); $sql .= ", ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null"); @@ -1073,7 +1065,7 @@ class Commande extends CommonOrder return -1; } // Defined the new fk_parent_line - if ($result > 0) { + if ($result > 0 && $line->product_type == 9) { $fk_parent_line = $result; } } @@ -1827,7 +1819,7 @@ class Commande extends CommonOrder $sql .= ', c.fk_shipping_method'; $sql .= ', c.fk_warehouse'; $sql .= ', c.fk_projet as fk_project, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; - $sql .= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams'; + $sql .= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams'; $sql .= ', c.fk_incoterms, c.location_incoterms'; $sql .= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc"; $sql .= ", c.module_source, c.pos_source"; @@ -1855,9 +1847,6 @@ class Commande extends CommonOrder if ($ref_ext) { $sql .= " AND c.ref_ext='".$this->db->escape($ref_ext)."'"; } - if ($notused) { - $sql .= " AND c.ref_int='".$this->db->escape($notused)."'"; - } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -1871,7 +1860,6 @@ class Commande extends CommonOrder $this->ref_client = $obj->ref_client; $this->ref_customer = $obj->ref_client; $this->ref_ext = $obj->ref_ext; - $this->ref_int = $obj->ref_int; $this->socid = $obj->fk_soc; $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty @@ -2155,7 +2143,7 @@ class Commande extends CommonOrder $line->fetch_optionals(); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($objp->fk_product) && !empty($loadalsotranslation)) { $tmpproduct = new Product($this->db); $tmpproduct->fetch($objp->fk_product); $tmpproduct->getMultiLangs(); @@ -3662,7 +3650,10 @@ class Commande extends CommonOrder } elseif ($status == self::STATUS_SHIPMENTONPROCESS) { $labelStatus = $langs->transnoentitiesnoconv('StatusOrderSent').$billedtext; $labelStatusShort = $langs->transnoentitiesnoconv('StatusOrderSentShort').$billedtext; - $labelTooltip = $langs->transnoentitiesnoconv("StatusOrderSent").' - '.$langs->transnoentitiesnoconv("DateDeliveryPlanned").dol_print_date($this->date_livraison).$billedtext; + $labelTooltip = $langs->transnoentitiesnoconv("StatusOrderSent"); + if (!empty($this->delivery_date)) { + $labelTooltip .= ' - '.$langs->transnoentitiesnoconv("DateDeliveryPlanned").dol_print_date($this->delivery_date, 'day').$billedtext; + } $statusType = 'status4'; } elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->transnoentitiesnoconv('StatusOrderToBill'); diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 1be1384df30..c353287962e 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -25,6 +25,7 @@ * \brief Onglet de gestion des contacts de commande */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index e181cc03c6a..a6eb116f17d 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -26,6 +26,7 @@ * \brief Show list of customers to add an new invoice from orders */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 501a803b697..c341ae59b4e 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -26,6 +26,7 @@ * \brief Management page of documents attached to an order */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 396052082c5..4442af6a679 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -23,6 +23,7 @@ * \brief Sale Order info page */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 6984255b91c..3b75994ef00 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -792,7 +792,7 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0 || $search_user > 0) { $sql = 'SELECT DISTINCT'; } -$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " country.code as country_code,"; @@ -1283,9 +1283,9 @@ if ($resql) { if ($massaction == 'createbills') { print ''; - print ''; + print '
'; print ''; - print ''; print ''; print ''; print '
'; + print ''; print $langs->trans('DateInvoice'); print ''; @@ -1305,7 +1305,7 @@ if ($resql) { print $langs->trans('ValidateInvoices'); print ''; - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { print $form->selectyesno('validate_invoices', 0, 1, 1); print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; } else { @@ -1320,12 +1320,11 @@ if ($resql) { print '
'; - print '
'; print '
'; print ' '; print ''; print '
'; - print '
'; + print '

'; } if ($sall) { @@ -1371,7 +1370,7 @@ if ($resql) { $moreforfilter .= ''; } // If Stock is enabled - if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (isModEnabled('stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $moreforfilter .= '
'; @@ -1507,13 +1506,13 @@ if ($resql) { // Payment term if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { print '
'; - $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); + print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); print ''; - $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1); + print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1); print ''; + print ''; print $getNomUrl_cache[$obj->socid]; // If module invoices enabled and user with invoice creation permissions @@ -2314,7 +2315,7 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; } - if ($i >= $last_num - 1) { + if ($i >= $imaxinloop - 1) { if (!empty($total_ht)) { $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); } else { @@ -2383,7 +2384,7 @@ if ($resql) { // Show shippable Icon (this creates subloops, so may be slow) if (!empty($arrayfields['shippable']['checked'])) { print ''; - if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) { + if (!empty($show_shippable_command) && isModEnabled('stock')) { if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { $generic_commande->getLinesArray(); // Load array ->lines $generic_commande->loadExpeditions(); // Load array ->expeditions diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 2082e356797..452e58076c7 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -25,6 +25,7 @@ * \brief Fiche de notes sur une commande */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 3e33ddedf57..15642da2d39 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -26,6 +26,7 @@ * \brief Page with customers or suppliers orders statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 4e7ab4802b7..ea371e804f3 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -32,6 +32,7 @@ if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key } } +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -600,7 +601,7 @@ if (isModEnabled('multicompany') && is_object($mc)) { print '
'; // Project filter -if (!empty($conf->projet->enabled)) { +if (isModEnabled('projet')) { $formproject = new FormProjets($db); $langs->load('projects'); print ''.$langs->trans('Project').":"; diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 0332a925f9d..aeb8d164928 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -23,9 +23,6 @@ if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -36,6 +33,7 @@ if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php } +// Load Dolibarr environment require '../main.inc.php'; $langs->load('compta'); diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 09cf9709aee..a07759ad504 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -1,5 +1,4 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 41d58cb35c2..610cf17498c 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -24,6 +24,7 @@ * \brief Page to report input-output of a bank account */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -192,6 +193,9 @@ for ($mois = 1; $mois < 13; $mois++) { print '
".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B")." '; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index d9689202297..c6ec38abded 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -31,6 +31,7 @@ * \brief List of bank transactions */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -1084,7 +1085,7 @@ if ($resql) { } if (!empty($arrayfields['type']['checked'])) { print ''; - $form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100'); + print $form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100', 1); print '".$ref."".$mc->label."'; - $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, 'maxwidth100'); + print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, 'maxwidth100', 1); print '
'.$langs->trans('Customer').''; - print img_picto('', 'company').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); + print img_picto('', 'company').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); // Option to reload page to retrieve customer informations. if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { print ' @@ -145,7 +152,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con - + @@ -192,9 +199,9 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con - + - + @@ -203,6 +210,12 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con + + + + + + diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 7814560be9b..2e8511acf8e 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -96,6 +96,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();} else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} + else if (type == 'pricecy') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();} else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();} else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();} @@ -167,6 +168,9 @@ $help = $extrafields->attributes[$elementtype]['help'][$attrname]; $entitycurrentorall = $extrafields->attributes[$elementtype]['entityid'][$attrname]; $printable = $extrafields->attributes[$elementtype]['printable'][$attrname]; $enabled = $extrafields->attributes[$elementtype]['enabled'][$attrname]; +$css = $extrafields->attributes[$elementtype]['css'][$attrname]; +$cssview = $extrafields->attributes[$elementtype]['cssview'][$attrname]; +$csslist = $extrafields->attributes[$elementtype]['csslist'][$attrname]; if ((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { $param_chain = ''; @@ -279,10 +283,10 @@ if (in_array($type, array_keys($typewecanchangeinto))) { - + - + + + + + + + + + + + + diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 285b7eb30a4..c93501ead18 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -38,14 +38,25 @@ $langs->load("modulebuilder"); '.$langs->trans("DefineHereComplementaryAttributes", empty($textobject) ? '': $textobject).'
'."\n"; -print '
'; +$title = ''.$langs->trans("DefineHereComplementaryAttributes", empty($textobject) ? '': $textobject).'
'."\n"; +//if ($action != 'create' && $action != 'edit') { +$newcardbutton = dolGetButtonTitle($langs->trans('NewAttribute'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=create', '', (($action != 'create' && $action != 'edit') ? 1 : 1)); +/*} else { + $newcardbutton = ''; +}*/ + +print '
'; +print '
'; +print '
'.$title.'
'; +print '
'.$newcardbutton.'
'; +print '
'; +print '
'; // Load $extrafields->attributes $extrafields->fetch_name_optionals_label($elementtype); print '
'; -print '
trans("LabelOrTranslationKey"); ?>
trans("LabelOrTranslationKey"); ?>
trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
trans("Unique"); ?>>
trans("Required"); ?>>
trans("Mandatory"); ?>>
trans("AlwaysEditable"); ?>>
textwithpicto($langs->trans("AlwaysEditable"), $langs->trans("EditableWhenDraftOnly")); ?>>
textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?>
trans("Totalizable"); ?>>
textwithpicto($langs->trans("CssOnEdit"), $langs->trans("HelpCssOnEditDesc")); ?>
textwithpicto($langs->trans("CssOnView"), $langs->trans("HelpCssOnViewDesc")); ?>
textwithpicto($langs->trans("CssOnList"), $langs->trans("HelpCssOnListDesc")); ?>
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
trans("Unique"); ?>>
trans("Required"); ?>>
trans("Mandatory"); ?>>
trans("AlwaysEditable"); ?>>
textwithpicto($langs->trans("AlwaysEditable"), $langs->trans("EditableWhenDraftOnly")); ?>>
textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> @@ -291,8 +295,19 @@ if (in_array($type, array_keys($typewecanchangeinto))) {
textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?>>
textwithpicto($langs->trans("CssOnEdit"), $langs->trans("HelpCssOnEditDesc")); ?>
textwithpicto($langs->trans("CssOnView"), $langs->trans("HelpCssOnViewDesc")); ?>
textwithpicto($langs->trans("CssOnList"), $langs->trans("HelpCssOnListDesc")); ?>
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
'; +print '
'; print ''; print ''; print ''; print ''; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print ''; print ''; +print ''; +print ''; +print ''; if (isModEnabled('multicompany')) { print ''; } @@ -87,14 +101,14 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel // Position print "\n"; // Label - print "\n"; // We don't translate here, we want admin to know what is the key not translated value + print '\n"; // We don't translate here, we want admin to know what is the key not translated value // Label translated print '\n"; // Key - print "\n"; + print '\n"; // Type $typetoshow = $type2label[$extrafields->attributes[$elementtype]['type'][$key]]; - print '\n"; // Size @@ -113,6 +127,13 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel print '\n"; // Summable print '\n"; + // CSS + print '\n"; + // CSS view + print '\n"; + // CSS list + print '\n"; + // Multicompany if (isModEnabled('multicompany')) { print ''; } + // Actions print '"; } } else { - $colspan = 14; + $colspan = 17; if (isModEnabled('multicompany')) { $colspan++; } diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index 07595012466..8f27d747fab 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -243,7 +243,7 @@ print ''."\n"; // Customer Default Langauge -if (!empty($conf->global->MAIN_MULTILANGS)) { +if (getDolGlobalInt('MAIN_MULTILANGS')) { print ''; print ''; print ''; @@ -144,10 +156,20 @@ foreach ($object->fields as $key => $val) { $rightpart .= ' tdtop'; } $rightpart.= '">'; + $labeltoshow = ''; if (!empty($val['help'])) { - $rightpart .= $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + $labeltoshow .= $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); } else { - $rightpart .= $langs->trans($val['label']); + if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 1) { + $labeltoshow .= showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($val['label'])); + } else { + $labeltoshow .= $langs->trans($val['label']); + } + } + if (empty($val['alwayseditable'])) { + $rightpart .= $labeltoshow; + } else { + $rightpart .= $form->editfieldkey($labeltoshow, $key, $value, $object, 1, $val['type']); } $rightpart .= ''; $rightpart .= ''; $rightpart .= ''; } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 3db65e198c5..6ef9463971b 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -101,7 +101,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l if ($action == 'edit_extras') { $value = (GETPOSTISSET("options_".$tmpkeyextra) ? GETPOST("options_".$tmpkeyextra) : $object->array_options["options_".$tmpkeyextra]); } else { - $value = (!empty($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : ''); + $value = (isset($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : ''); //var_dump($tmpkeyextra.' - '.$value); } @@ -237,7 +237,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l if ($object->table_element == 'societe') { $fieldid = 'socid'; } - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index b07bb66b46c..b7e6fd15dcb 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -33,10 +33,8 @@ if (empty($conf) || !is_object($conf)) { // DDOS protection $size = (empty($_SERVER['CONTENT_LENGTH']) ? 0 : (int) $_SERVER['CONTENT_LENGTH']); if ($size > 10000) { - http_response_code(413); $langs->loadLangs(array("errors", "install")); - accessforbidden('
'.$langs->trans("ErrorRequestTooLarge").'.
'.$langs->trans("ClickHereToGoToApp").'
', 0, 0, 1); - exit; + httponly_accessforbidden('
'.$langs->trans("ErrorRequestTooLarge").'.
'.$langs->trans("ClickHereToGoToApp").'
', 413, 1); } require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -139,9 +137,11 @@ $(document).ready(function () { \n"; print '';*/ - if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) { + if (!$conf->expedition_bon->enabled && isModEnabled('stock')) { // Entrepot $entrepot = new Entrepot($db); $entrepot->fetch($object->entrepot_id); @@ -545,7 +547,7 @@ if ($action == 'create') { // Create. Seems to no be used $product->fetch($object->lines[$i]->fk_product); // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 55f6293a9d2..ad1a3b9934a 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -973,7 +973,7 @@ class Delivery extends CommonObject $sqlSourceLine .= ", p.ref, p.label"; $sqlSourceLine .= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0]['type']."det as st"; $sqlSourceLine .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid"; - $sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".((int) $this->linked_object[0]['linkid']); + $sqlSourceLine .= " WHERE fk_".$this->linked_objects[0]['type']." = ".((int) $this->linked_objects[0]['linkid']); $resultSourceLine = $this->db->query($sqlSourceLine); if ($resultSourceLine) { @@ -986,12 +986,12 @@ class Delivery extends CommonObject // Get lines of sources alread delivered $sql = "SELECT ld.fk_origin_line, sum(ld.qty) as qty"; $sql .= " FROM ".MAIN_DB_PREFIX."deliverydet as ld, ".MAIN_DB_PREFIX."delivery as l,"; - $sql .= " ".MAIN_DB_PREFIX.$this->linked_object[0]['type']." as c"; - $sql .= ", ".MAIN_DB_PREFIX.$this->linked_object[0]['type']."det as cd"; + $sql .= " ".MAIN_DB_PREFIX.$this->linked_objects[0]['type']." as c"; + $sql .= ", ".MAIN_DB_PREFIX.$this->linked_objects[0]['type']."det as cd"; $sql .= " WHERE ld.fk_delivery = l.rowid"; $sql .= " AND ld.fk_origin_line = cd.rowid"; - $sql .= " AND cd.fk_".$this->linked_object[0]['type']." = c.rowid"; - $sql .= " AND cd.fk_".$this->linked_object[0]['type']." = ".((int) $this->linked_object[0]['linkid']); + $sql .= " AND cd.fk_".$this->linked_objects[0]['type']." = c.rowid"; + $sql .= " AND cd.fk_".$this->linked_objects[0]['type']." = ".((int) $this->linked_objects[0]['linkid']); $sql .= " AND ld.fk_origin_line = ".((int) $objSourceLine->rowid); $sql .= " GROUP BY ld.fk_origin_line"; diff --git a/htdocs/document.php b/htdocs/document.php index 65e5cce7e5f..4f6652fafda 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -104,10 +104,10 @@ $entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; // Security check if (empty($modulepart) && empty($hashp)) { - accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1); + httponly_accessforbidden('Bad link. Bad value for parameter modulepart', 400); } if (empty($original_file) && empty($hashp)) { - accessforbidden('Bad link. Missing identification to find file (original_file or hashp)', 0, 0, 1); + httponly_accessforbidden('Bad link. Missing identification to find file (original_file or hashp)', 400); } if ($modulepart == 'fckeditor') { $modulepart = 'medias'; // For backward compatibility @@ -158,7 +158,7 @@ if (!empty($hashp)) { $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir //var_dump($original_file); exit; } else { - accessforbidden('Bad link. File is from another module part.', 0, 0, 1); + httponly_accessforbidden('Bad link. File is from another module part.', 403); } } else { $modulepart = $moduleparttocheck; @@ -171,7 +171,7 @@ if (!empty($hashp)) { } } else { $langs->load("errors"); - accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"), 0, 0, 1); + httponly_accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"), 403, 1); } } diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index 9a360f69882..a78935c74fd 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; } @@ -169,7 +169,7 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $dir = "../../core/modules/dons/"; $form = new Form($db); -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { $formaccounting = new FormAccounting($db); } @@ -335,7 +335,7 @@ print ''; print ''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { if (empty($conf->productbatch->enabled)) { print ''; } else { @@ -1111,12 +1120,15 @@ if ($action == 'create') { $type = 1; } - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; // Product label if ($line->fk_product > 0) { // If predefined product - $product->fetch($line->fk_product); + $res = $product->fetch($line->fk_product); + if ($res < 0) { + dol_print_error($db, $product->error, $product->errors); + } $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch //var_dump($product->stock_warehouse[1]); @@ -1200,7 +1212,7 @@ if ($action == 'create') { } $warehouseObject = null; - if (count($warehousePicking) == 1 || !($line->fk_product > 0) || empty($conf->stock->enabled)) { // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection + if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !isModEnabled('stock')) { // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection print ''; //ship from preselected location $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0); // Convert to number @@ -1228,7 +1240,7 @@ if ($action == 'create') { print ''; // Stock - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; // Stock - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; } @@ -2078,7 +2090,7 @@ if ($action == 'create') { $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -2157,7 +2169,7 @@ if ($action == 'create') { // Predefined product or service if ($lines[$i]->fk_product > 0) { // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod = new Product($db); $prod->fetch($lines[$i]->fk_product); $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; @@ -2243,7 +2255,7 @@ if ($action == 'create') { print $shipment_static->getNomUrl(1); print ' - '.$shipmentline_var['qty_shipped']; $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (!empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) { + if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { $warehousestatic->fetch($shipmentline_var['warehouse']); $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); } @@ -2280,7 +2292,7 @@ if ($action == 'create') { // Batch number managment print ''; print ''; - } elseif (!empty($conf->stock->enabled)) { + } elseif (isModEnabled('stock')) { if ($lines[$i]->fk_product > 0) { if ($lines[$i]->entrepot_id > 0) { print ''; @@ -2319,7 +2331,7 @@ if ($action == 'create') { print ''; print ''; } - } elseif (empty($conf->stock->enabled) && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. + } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. print ''; print ''; // Qty to ship or shipped @@ -2337,7 +2349,7 @@ if ($action == 'create') { print ''; // Warehouse source - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print '\n"; } // Tracking number @@ -958,7 +967,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { // Get code using getLabelFromKey $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - print ''; } diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index f3e2c2bdb07..d23bb0298ea 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -24,6 +24,7 @@ * \brief Note card expedition */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 4d5b27e9c7a..7619ef140f8 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -26,6 +26,7 @@ * \brief Tab shipments/delivery receipts on the order */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; @@ -37,7 +38,7 @@ if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -if (!empty($conf->stock->enabled)) { +if (isModEnabled('stock')) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; } if (isModEnabled("propal")) { @@ -430,7 +431,7 @@ if ($id > 0 || !empty($ref)) { print ''; // Warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (isModEnabled('stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); print ''; print ''; print ''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; } else { print ''; @@ -678,7 +679,7 @@ if ($id > 0 || !empty($ref)) { // Product label if ($objp->fk_product > 0) { // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); $prod = new Product($db); @@ -793,7 +794,7 @@ if ($id > 0 || !empty($ref)) { $product->load_stock('warehouseopen'); } - if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && !empty($conf->stock->enabled)) { + if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && isModEnabled('stock')) { print ''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { //print ''; diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index b97af33cb6e..3e8cba9def2 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -23,6 +23,7 @@ * \brief Page with shipment statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php'; diff --git a/htdocs/expedition/stats/month.php b/htdocs/expedition/stats/month.php index 254fd9aad90..34842efaaf3 100644 --- a/htdocs/expedition/stats/month.php +++ b/htdocs/expedition/stats/month.php @@ -22,6 +22,7 @@ * \brief Page des stats expeditions par mois */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php'; diff --git a/htdocs/expensereport/ajax/ajaxik.php b/htdocs/expensereport/ajax/ajaxik.php index 9abd767e1f9..209eb3cdde7 100644 --- a/htdocs/expensereport/ajax/ajaxik.php +++ b/htdocs/expensereport/ajax/ajaxik.php @@ -37,9 +37,6 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} $res = 0; require '../../main.inc.php'; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 680f1861fe3..c325aae4854 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -26,6 +26,7 @@ * \brief Page for trip and expense report card */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -44,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } @@ -383,10 +384,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -493,10 +494,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -603,10 +604,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -717,10 +718,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -831,10 +832,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -943,10 +944,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -982,10 +983,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1011,10 +1012,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1185,7 +1186,7 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = GETPOST('lang_id', 'alpha'); - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1229,10 +1230,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1321,10 +1322,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1989,7 +1990,7 @@ if ($action == 'create') { $bankaccountstatic->label = $objp->baref; $bankaccountstatic->number = $objp->banumber; - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { $bankaccountstatic->account_number = $objp->account_number; $accountingjournal = new AccountingJournal($db); @@ -2121,7 +2122,7 @@ if ($action == 'create') { } $titlealt = ''; - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; $accountingaccount = new AccountingAccount($db); $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index ca8f1698767..e0799a46f73 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2069,6 +2069,7 @@ class ExpenseReport extends CommonObject if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED) { $this->db->begin(); + $error = 0; $type = 0; // TODO What if type is service ? // We don't know seller and buyer for expense reports @@ -2152,10 +2153,13 @@ class ExpenseReport extends CommonObject $this->applyOffset(); $this->checkRules(); - $error = 0; - $result = $this->line->update($user); - if ($result > 0 && !$notrigger) { + $result = $this->line->update($user); + if ($result < 0) { + $error++; + } + + if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger('EXPENSE_REPORT_DET_MODIFY', $user); if ($result < 0) { @@ -2164,7 +2168,7 @@ class ExpenseReport extends CommonObject // End call triggers } - if ($result > 0 && $error == 0) { + if (!$error) { $this->db->commit(); return 1; } else { diff --git a/htdocs/expensereport/class/expensereport_ik.class.php b/htdocs/expensereport/class/expensereport_ik.class.php index 0d374f1c722..503fa92b108 100644 --- a/htdocs/expensereport/class/expensereport_ik.class.php +++ b/htdocs/expensereport/class/expensereport_ik.class.php @@ -120,13 +120,12 @@ class ExpenseReportIk 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; } + /** * Update object into database * diff --git a/htdocs/expensereport/class/expensereport_rule.class.php b/htdocs/expensereport/class/expensereport_rule.class.php index 02bf8b8ce5c..d695359229d 100644 --- a/htdocs/expensereport/class/expensereport_rule.class.php +++ b/htdocs/expensereport/class/expensereport_rule.class.php @@ -171,6 +171,19 @@ class ExpenseReportRule extends CommonObject } + /** + * 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; + } + /** * Update object into database * diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index 8c3b5f56549..a4572c9a169 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -28,6 +28,7 @@ * \brief Page of linked files onto trip and expens reports */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 504101a1720..fced8a58e14 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -28,6 +28,7 @@ * \brief Page list of expenses */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index 605197d14ac..c2216185b5c 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -23,6 +23,7 @@ * \brief Page to show a trip information */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 38f85c6c006..896bb29cf43 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -29,6 +29,7 @@ * \brief list of expense reports */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php index 5649f2144e4..18c99dfd229 100644 --- a/htdocs/expensereport/note.php +++ b/htdocs/expensereport/note.php @@ -24,6 +24,7 @@ * \brief Tab for notes on expense reports */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index c24689a9d69..316dccd91d8 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -21,6 +21,7 @@ * \brief Tab payment of an expense report */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php index a654c77b6cd..b5d87b81a51 100644 --- a/htdocs/expensereport/payment/info.php +++ b/htdocs/expensereport/payment/info.php @@ -24,6 +24,7 @@ * \brief Tab payment info */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index 5a08c30f636..cb93aae4ff0 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -33,6 +33,7 @@ * \brief Payment list for expense reports */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 74e0c63151b..6456bf80d7f 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -23,6 +23,7 @@ * \brief Page to add payment of an expense report */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index ded5a7a3805..b4d11320411 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -24,6 +24,7 @@ * \brief Page for statistics of module trips and expenses */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereportstats.class.php'; diff --git a/htdocs/externalsite/admin/index.php b/htdocs/externalsite/admin/index.php index 0b55a297be9..deb05ade024 100644 --- a/htdocs/externalsite/admin/index.php +++ b/htdocs/externalsite/admin/index.php @@ -30,6 +30,7 @@ if (!defined('NOSCANPOSTFORINJECTION')) { define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/externalsite/frames.php b/htdocs/externalsite/frames.php index 6deb6e9cf72..6b958a15a67 100644 --- a/htdocs/externalsite/frames.php +++ b/htdocs/externalsite/frames.php @@ -26,6 +26,7 @@ * /externalsite/frames.php?keyforcontent=EXTERNAL_SITE_URL_abc to show URL defined into $conf->global->EXTERNAL_SITE_URL_abc */ +// Load Dolibarr environment require '../main.inc.php'; // Load translation files required by the page diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index 31459b22b5d..2a6a8d603d1 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -26,6 +26,7 @@ */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,13 +81,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php index 5fb1567efe4..ddc34952dc0 100644 --- a/htdocs/fichinter/admin/fichinterdet_extrafields.php +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -26,6 +26,7 @@ */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -81,13 +82,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 04e9c293cc1..6c07ec6837d 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -30,6 +30,7 @@ * \brief Page to show predefined fichinter */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinterrec.class.php'; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 7cde90e3d7e..8b3868bf195 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -30,6 +30,7 @@ * \ingroup ficheinter */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; @@ -173,10 +174,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -198,10 +199,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -310,7 +311,7 @@ if (empty($reshook)) { $prod->id = $lines[$i]->fk_product; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod->getMultiLangs(); // We show if duration is present on service (so we get it) $prod->fetch($lines[$i]->fk_product); @@ -516,10 +517,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -612,10 +613,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -645,10 +646,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -665,10 +666,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -687,10 +688,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 04bd092cdfa..7a5f3bc73ad 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1217,7 +1217,7 @@ class Fichinter extends CommonObject if (!$error) { // Add lines because it is not included into create function foreach ($this->lines as $line) { - $this->addline($user, $this->id, $line->desc, $line->datei, $line->duration); + $this->addline($user, $this->id, $line->desc, $line->datei, $line->duration, $line->array_options); } // Hook of thirdparty module diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index bcf89704e55..96ef9e97314 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -19,7 +19,7 @@ * 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 . + * along with this program. If not, see . */ /** diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 8528281c607..02099d959c7 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -23,6 +23,7 @@ * \brief Onglet de gestion des contacts de fiche d'intervention */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index a2511cfee8f..1b388763c02 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -28,6 +28,7 @@ * \brief Page des documents joints sur les contrats */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 7e0bf6f7f44..c7b150b7d2d 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -25,6 +25,7 @@ * \brief Home page of interventional module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; @@ -169,7 +170,7 @@ if ($resql) { /* * Draft orders */ -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -292,7 +293,7 @@ if ($resql) { * interventions to process */ -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { $sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index a5c0abfeb3d..c556ba022e0 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -24,6 +24,7 @@ * \brief Page d'affichage des infos d'une fiche d'intervention */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 554f0053a92..731442695d2 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -29,6 +29,7 @@ * \ingroup ficheinter */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; @@ -801,7 +802,7 @@ while ($i < $imaxinloop) { // Note public if (!empty($arrayfields['f.note_public']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -810,7 +811,7 @@ while ($i < $imaxinloop) { // Note private if (!empty($arrayfields['f.note_private']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 3fb2e349c04..5b246e55eb7 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -24,6 +24,7 @@ * \brief Fiche d'information sur une fiche d'intervention */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 9e49d9bc4b5..f1ab4b08fec 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -21,6 +21,7 @@ * \brief Page with interventions statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinterstats.class.php'; diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 6ebac09d8fb..29cf421059e 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -35,6 +35,7 @@ if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; @@ -92,7 +93,7 @@ if ($idprod > 0) { } // After best supplier prices and before costprice - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { // Add price for pmp $price = $producttmp->pmp; if (empty($price) && !empty($conf->global->PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY)) { diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 9a7a3d7dcc0..00a3ba55caa 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -29,6 +29,7 @@ * \brief Page for supplier third party card (view, edit) */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b19609dc7bb..38a9f051288 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -236,8 +236,8 @@ class CommandeFournisseur extends CommonOrder 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>3, 'position'=>140, 'isameasure'=>1), 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>1, 'position'=>145, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>150, 'isameasure'=>1), - 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>155), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>160, 'searchall'=>1), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>155, 'searchall'=>1), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>160, 'searchall'=>1), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>165), 'fk_input_method' =>array('type'=>'integer', 'label'=>'OrderMode', 'enabled'=>1, 'visible'=>3, 'position'=>170), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>3, 'position'=>175), @@ -751,7 +751,7 @@ class CommandeFournisseur extends CommonOrder // phpcs:enable global $conf, $langs, $hookmanager; - if (empty($this->statuts) || empty($this->statutshort)) { + if (empty($this->statuts) || empty($this->statuts_short)) { $langs->load('orders'); $this->statuts[0] = 'StatusSupplierOrderDraft'; @@ -769,15 +769,15 @@ class CommandeFournisseur extends CommonOrder $this->statuts[9] = 'StatusSupplierOrderRefused'; // List of language codes for status - $this->statutshort[0] = 'StatusSupplierOrderDraftShort'; - $this->statutshort[1] = 'StatusSupplierOrderValidatedShort'; - $this->statutshort[2] = 'StatusSupplierOrderApprovedShort'; - $this->statutshort[3] = 'StatusSupplierOrderOnProcessShort'; - $this->statutshort[4] = 'StatusSupplierOrderReceivedPartiallyShort'; - $this->statutshort[5] = 'StatusSupplierOrderReceivedAllShort'; - $this->statutshort[6] = 'StatusSupplierOrderCanceledShort'; - $this->statutshort[7] = 'StatusSupplierOrderCanceledShort'; - $this->statutshort[9] = 'StatusSupplierOrderRefusedShort'; + $this->statuts_short[0] = 'StatusSupplierOrderDraftShort'; + $this->statuts_short[1] = 'StatusSupplierOrderValidatedShort'; + $this->statuts_short[2] = 'StatusSupplierOrderApprovedShort'; + $this->statuts_short[3] = 'StatusSupplierOrderOnProcessShort'; + $this->statuts_short[4] = 'StatusSupplierOrderReceivedPartiallyShort'; + $this->statuts_short[5] = 'StatusSupplierOrderReceivedAllShort'; + $this->statuts_short[6] = 'StatusSupplierOrderCanceledShort'; + $this->statuts_short[7] = 'StatusSupplierOrderCanceledShort'; + $this->statuts_short[9] = 'StatusSupplierOrderRefusedShort'; } $statustrans = array( @@ -806,7 +806,7 @@ class CommandeFournisseur extends CommonOrder } $statusLong = $langs->transnoentitiesnoconv($this->statuts[$status]).$billedtext; - $statusShort = $langs->transnoentitiesnoconv($this->statutshort[$status]); + $statusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); $parameters = array('status' => $status, 'mode' => $mode, 'billed' => $billed); $reshook = $hookmanager->executeHooks('LibStatut', $parameters, $this); // Note that $action and $object may have been modified by hook @@ -1097,7 +1097,7 @@ class CommandeFournisseur extends CommonOrder } // If stock is incremented on validate order, we must increment it - if (!$error && $movetoapprovestatus && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { + if (!$error && $movetoapprovestatus && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -2056,6 +2056,8 @@ class CommandeFournisseur extends CommonOrder $now = dol_now(); + $inventorycode = dol_print_date(dol_now(), 'dayhourlog'); + if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) { $this->db->begin(); @@ -2083,18 +2085,20 @@ class CommandeFournisseur extends CommonOrder } // If module stock is enabled and the stock increase is done on purchase order dispatching - if (!$error && $entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + if (!$error && $entrepot > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $mouv = new MouvementStock($this->db); if ($product > 0) { // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) $mouv->origin = &$this; $mouv->setOrigin($this->element, $this->id); + // Method change if qty < 0 if (!empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN) && $qty < 0) { - $result = $mouv->livraison($user, $product, $entrepot, $qty*(-1), $price, $comment, $now, $eatby, $sellby, $batch); + $result = $mouv->livraison($user, $product, $entrepot, $qty*(-1), $price, $comment, $now, $eatby, $sellby, $batch, 0, $inventorycode); } else { - $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); + $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch, '', 0, $inventorycode); } + if ($result < 0) { $this->error = $mouv->error; $this->errors = $mouv->errors; @@ -2378,7 +2382,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::Livraison"); $usercanreceive = 0; - if (empty($conf->reception->enabled)) { + if (!isModEnabled('reception')) { $usercanreceive = $user->rights->fournisseur->commande->receptionner; } else { $usercanreceive = $user->rights->reception->creer; diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index dfb1e371636..7c8e4acb25f 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -131,9 +131,9 @@ class CommandeFournisseurDispatch extends CommonObjectLine $this->statuts[0] = 'Received'; $this->statuts[1] = 'Verified'; $this->statuts[2] = 'Denied'; - $this->statutshort[0] = 'Received'; - $this->statutshort[1] = 'Verified'; - $this->statutshort[2] = 'Denied'; + $this->statuts_short[0] = 'Received'; + $this->statuts_short[1] = 'Verified'; + $this->statuts_short[2] = 'Denied'; } @@ -580,7 +580,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine if ($mode == 0) { return $langs->trans($this->statuts[$status]); } elseif ($mode == 1) { - return $langs->trans($this->statutshort[$status]); + return $langs->trans($this->statuts_short[$status]); } elseif ($mode == 2) { return $langs->trans($this->statuts[$status]); } elseif ($mode == 3) { @@ -601,11 +601,11 @@ class CommandeFournisseurDispatch extends CommonObjectLine } } elseif ($mode == 5) { if ($status == 0) { - return ''.$langs->trans($this->statutshort[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut0'); + return ''.$langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut0'); } elseif ($status == 1) { - return ''.$langs->trans($this->statutshort[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut4'); + return ''.$langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut4'); } elseif ($status == 2) { - return ''.$langs->trans($this->statutshort[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut8'); + return ''.$langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut8'); } } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c4e034dd7a1..3f7013fec34 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -40,10 +40,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; } -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; } @@ -302,8 +302,8 @@ class FactureFournisseur extends CommonInvoice 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>155), 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>160), 'date_lim_reglement' =>array('type'=>'date', 'label'=>'DateLimReglement', 'enabled'=>1, 'visible'=>-1, 'position'=>165), - 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>170), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>175), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>170), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>175), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPdf', 'enabled'=>1, 'visible'=>0, 'position'=>180), 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>190), 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>1, 'visible'=>-1, 'position'=>195), @@ -504,10 +504,10 @@ class FactureFournisseur extends CommonInvoice $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && isset($this->thirdparty->default_lang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->thirdparty->default_lang)) { $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && isset($this->default_lang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->default_lang)) { $newlang = $this->default_lang; // for thirdparty } if (!empty($newlang)) { @@ -762,7 +762,7 @@ class FactureFournisseur extends CommonInvoice // else we get the best supplier price if ($conf->global->MARGIN_TYPE == 'costprice' && !empty($producttmp->cost_price)) { $buyprice = $producttmp->cost_price; - } elseif (!empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) { + } elseif (isModEnabled('stock') && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) { $buyprice = $producttmp->pmp; } else { if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) { @@ -1812,7 +1812,7 @@ class FactureFournisseur extends CommonInvoice $resql = $this->db->query($sql); if ($resql) { // Si on incrƩmente le produit principal et ses composants Ơ la validation de facture fournisseur - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -1943,7 +1943,7 @@ class FactureFournisseur extends CommonInvoice } // Si on incremente le produit principal et ses composants a la validation de facture fournisseur, on decremente - if ($result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { + if ($result >= 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 276c5b20ed9..16bc43474d8 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -578,7 +578,7 @@ class ProductFournisseur extends Product $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; + $sql .= " p.ref as product_ref, p.tosell as status, p.tobuy as status_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE pfp.rowid = ".(int) $rowid; $sql .= " AND pfp.fk_product = p.rowid"; @@ -594,7 +594,8 @@ class ProductFournisseur extends Product $this->fk_product = $obj->fk_product; $this->product_id = $obj->fk_product; $this->product_ref = $obj->product_ref; - + $this->status = $obj->status; + $this->status_buy = $obj->status_buy; $this->fourn_id = $obj->fk_soc; $this->fourn_ref = $obj->ref_fourn; // deprecated $this->ref_supplier = $obj->ref_fourn; @@ -670,7 +671,7 @@ class ProductFournisseur extends Product // phpcs:enable global $conf; - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; + $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref, p.tosell as status, p.tobuy as status_buy, "; $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; @@ -699,6 +700,8 @@ class ProductFournisseur extends Product $prodfourn->product_ref = $record["product_ref"]; $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; + $prodfourn->status = $record["status"]; + $prodfourn->status_buy = $record["status_buy"]; $prodfourn->product_fourn_id = $record["product_fourn_id"]; $prodfourn->product_fourn_entity = $record["entity"]; $prodfourn->ref_supplier = $record["ref_fourn"]; @@ -735,7 +738,7 @@ class ProductFournisseur extends Product $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; } - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { + if (isModEnabled('dynamicprices') && !empty($prodfourn->fk_supplier_price_expression)) { $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProductSupplier($prodfourn); if ($price_result >= 0) { @@ -841,7 +844,7 @@ class ProductFournisseur extends Product $fourn_unitprice = $record["unitprice"]; $fourn_unitprice_with_discount = $record["unitprice"] * (1 - $record["remise_percent"] / 100); - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { + if (isModEnabled('dynamicprices') && !empty($record["fk_supplier_price_expression"])) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; $prod_supplier->id = $prodid; @@ -1212,13 +1215,13 @@ class ProductFournisseur extends Product } } - if (!empty($conf->accounting->enabled) && $this->status) { + if (isModEnabled('accounting') && $this->status) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); } - if (!empty($conf->accounting->enabled) && $this->status_buy) { + if (isModEnabled('accounting') && $this->status_buy) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index e0b3fcac0c6..bdf4f8aa457 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -349,7 +349,7 @@ class PaiementFourn extends Paiement if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $newlang = ''; $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $invoice->thirdparty->default_lang; } if (!empty($newlang)) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 86113b13592..5e3eb8d7890 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -28,21 +28,24 @@ */ /** - * \file htdocs/fourn/commande/card.php - * \ingroup supplier, order - * \brief Card supplier order + * \file htdocs/fourn/commande/card.php + * \ingroup supplier, order + * \brief Card supplier order */ + +// Load Dolibarr environment require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + if (isModEnabled('supplier_proposal')) { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; } @@ -55,33 +58,37 @@ if (isModEnabled('project')) { } require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP -if (!empty($conf->variants->enabled)) { +if (isModEnabled('variants')) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } + +// Load translation files required by the page $langs->loadLangs(array('admin', 'orders', 'sendings', 'companies', 'bills', 'propal', 'receptions', 'supplier_proposal', 'deliveries', 'products', 'stocks', 'productbatch')); if (!empty($conf->incoterm->enabled)) { $langs->load('incoterm'); } + +// Get Parameters $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'purchaseordercard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$socid = GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); -$cancel = GETPOST('cancel', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$origin = GETPOST('origin', 'alpha'); -$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility -$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; +$cancel = GETPOST('cancel', 'alpha'); +$lineid = GETPOST('lineid', 'int'); +$origin = GETPOST('origin', 'alpha'); +$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; -//PDF +// PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -478,7 +485,7 @@ if (empty($reshook)) { $error++; } - if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') { + if (!$error && isModEnabled('variants') && $prod_entry_mode != 'free') { if ($combinations = GETPOST('combinations', 'array')) { //Check if there is a product with the given combination $prodcomb = new ProductCombination($db); @@ -527,7 +534,7 @@ if (empty($reshook)) { $label = $productsupplier->label; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -678,7 +685,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; if (GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); @@ -854,10 +861,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -892,10 +899,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -934,10 +941,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -983,7 +990,7 @@ if (empty($reshook)) { } // Check parameters - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) { // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER + if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) { // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); @@ -997,10 +1004,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1058,10 +1065,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1691,7 +1698,7 @@ if ($action == 'create') { print $societe->getNomUrl(1, 'supplier'); print ''; } else { - print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print ''; - - // Part to show record if ($object->id > 0) { $res = $object->fetch_optionals(); @@ -447,7 +442,7 @@ if ($object->id > 0) { } // Confirmation to delete line if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid.'&page='.$page.$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation @@ -553,8 +548,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); - - print ''; + print ''; print ''; print ''; print ''; @@ -950,18 +944,22 @@ if ($object->id > 0) { print ''; } print ''; - print ''; if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { print ''; print ''; print ''; print ''; + print ''; + } else { + print ''; } // Actions print ''; @@ -1160,9 +1163,9 @@ if ($object->id > 0) { } if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; } @@ -1189,6 +1192,48 @@ if ($object->id > 0) { } print ''; + print ''; + if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { ?> diff --git a/htdocs/product/inventory/lib/inventory.lib.php b/htdocs/product/inventory/lib/inventory.lib.php index bda792abec4..95bcfcd1fe5 100644 --- a/htdocs/product/inventory/lib/inventory.lib.php +++ b/htdocs/product/inventory/lib/inventory.lib.php @@ -52,6 +52,8 @@ function inventoryAdminPrepareHead() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'inventory'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'inventory', 'remove'); + return $head; } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d24b4e0d12b..3561388709d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -95,7 +95,7 @@ $optioncss = GETPOST('optioncss', 'alpha'); $type = GETPOST("type", "int"); //Show/hide child products -if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { +if (isModEnabled('variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $show_childproducts = GETPOST('search_show_childproducts'); } else { $show_childproducts = ''; @@ -165,7 +165,7 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) - || !empty($conf->mrp->enabled)) { + || isModEnabled('mrp')) { $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } @@ -179,7 +179,7 @@ $fieldstosearchall = array( ); // multilang -if (!empty($conf->global->MAIN_MULTILANGS)) { +if (getDolGlobalInt('MAIN_MULTILANGS')) { $fieldstosearchall['pl.label'] = 'ProductLabelTranslated'; $fieldstosearchall['pl.description'] = 'ProductDescriptionTranslated'; $fieldstosearchall['pl.note'] = 'ProductNoteTranslated'; @@ -234,10 +234,10 @@ $arrayfields = array( 'p.numbuyprice'=>array('label'=>"BuyingPriceNumShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>43), 'p.pmp'=>array('label'=>"PMPValueShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>44), 'p.cost_price'=>array('label'=>"CostPrice", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>45), - 'p.seuil_stock_alerte'=>array('label'=>"StockLimit", 'checked'=>0, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>50), - 'p.desiredstock'=>array('label'=>"DesiredStock", 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>51), - 'p.stock'=>array('label'=>"PhysicalStock", 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>52), - 'stock_virtual'=>array('label'=>"VirtualStock", 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $virtualdiffersfromphysical), 'position'=>53), + 'p.seuil_stock_alerte'=>array('label'=>"StockLimit", 'checked'=>0, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>50), + 'p.desiredstock'=>array('label'=>"DesiredStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>51), + 'p.stock'=>array('label'=>"PhysicalStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>52), + 'stock_virtual'=>array('label'=>"VirtualStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $virtualdiffersfromphysical), 'position'=>53), 'p.tobatch'=>array('label'=>"ManageLotSerial", 'checked'=>0, 'enabled'=>(isModEnabled('productbatch')), 'position'=>60), 'p.fk_country'=>array('label'=>"Country", 'checked'=>0, 'position'=>100), 'p.fk_state'=>array('label'=>"State", 'checked'=>0, 'position'=>101), @@ -371,7 +371,9 @@ if (empty($reshook)) { foreach ($toselect as $toselectid) { $result = $product->fetch($toselectid); if ($result > 0 && $product->id > 0) { - $product->setStatut($product->status ? 0 : 1, null, 'product', 'PRODUCT_MODIFY', 'tosell'); + if ($product->setStatut($product->status ? 0 : 1, null, 'product', 'PRODUCT_MODIFY', 'tosell') < 0) { + setEventMessages($product->error, $product->errors, 'errors'); + } } } } @@ -380,7 +382,9 @@ if (empty($reshook)) { foreach ($toselect as $toselectid) { $result = $product->fetch($toselectid); if ($result > 0 && $product->id > 0) { - $product->setStatut($product->status_buy ? 0 : 1, null, 'product', 'PRODUCT_MODIFY', 'tobuy'); + if ($product->setStatut($product->status_buy ? 0 : 1, null, 'product', 'PRODUCT_MODIFY', 'tobuy') < 0) { + setEventMessages($product->error, $product->errors, 'errors'); + } } } } @@ -415,7 +419,7 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' p.fk_unit, cu.label as cu_label,'; } $sql .= ' MIN(pfp.unitprice) as minsellprice'; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid prod_comb_id'; } // Add fields from extrafields @@ -440,11 +444,11 @@ if (!empty($searchCategoryProductList) || !empty($catid)) { } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; // multilang -if (!empty($conf->global->MAIN_MULTILANGS)) { +if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang())."'"; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } if (!empty($conf->global->PRODUCT_USE_UNITS)) { @@ -465,7 +469,7 @@ if (dol_strlen($search_type) && $search_type != '-1') { } } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " AND pac.rowid IS NULL"; } @@ -576,7 +580,7 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ', p.fk_unit, cu.label'; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid'; } // Add fields from extrafields @@ -740,6 +744,8 @@ if ($resql) { if ($user->rights->{$rightskey}->creer) { $arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus"); $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus"); + } + if (isModEnabled('category') && $user->rights->{$rightskey}->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields'))) { @@ -831,7 +837,7 @@ if ($resql) { } //Show/hide child products. Hidden by default - if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { + if (isModEnabled('variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $moreforfilter .= '
'; $moreforfilter .= ''; $moreforfilter .= ' '; @@ -1303,7 +1309,7 @@ if ($resql) { $obj = $db->fetch_object($resql); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // If multilang is enabled + if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product = ".((int) $obj->rowid); @@ -1354,7 +1360,7 @@ if ($resql) { } // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. - if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock + if ((isModEnabled('stock') && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service $option = 'nobatch'; if (empty($arrayfields['stock_virtual']['checked'])) { diff --git a/htdocs/product/note.php b/htdocs/product/note.php index 93d40e296e9..0d7ad91af5f 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -26,6 +26,7 @@ * \ingroup societe */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -109,7 +110,7 @@ if ($id > 0 || !empty($ref)) { /* * Affichage onglets */ - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 17716a4b3ed..4bde44f1892 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -26,6 +26,7 @@ * \brief List of products or services by popularity */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -213,7 +214,7 @@ print "\n"; if ($mode && $mode != '-1') { foreach ($infoprod as $prodid => $vals) { // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active + if (getDolGlobalInt('MAIN_MULTILANGS')) { // si l'option est active $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product = ".((int) $prodid); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 19d2f388ce6..1dda1f4c89a 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -34,6 +34,7 @@ * \brief Page to show product prices */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1187,21 +1188,29 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print ''; // Price - print '
'; // Price minimum - print ''; // Price by quantity diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 0b1bd5d8d6a..0da084d1f39 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -26,6 +26,7 @@ * \brief Page to list stocks */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index b31fb885c53..f3ad55d526d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -27,6 +27,7 @@ * \brief Page to list stocks */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; @@ -607,7 +608,7 @@ while ($i < $imaxinloop) { $objp = $db->fetch_object($resql); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active + if (getDolGlobalInt('MAIN_MULTILANGS')) { // si l'option est active // TODO Use a cache $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index a8e76a178bf..707549655e0 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -24,6 +24,7 @@ * \brief Page of MO referring product */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index b77997fcfc7..d2f3e2358d9 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -26,6 +26,7 @@ * \brief Page of product statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 9f38f68ee33..f856b8a310f 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -24,6 +24,7 @@ * \brief Page des stats des commandes clients pour un produit */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 03bb1828f66..196831a5466 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -23,6 +23,7 @@ * \brief Page des stats des contrats pour un produit */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index c62c421d6e4..4ee1e4f95b2 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -25,6 +25,7 @@ * \brief Page of invoice statistics for a product */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 59ca77d5937..6e5ed524ad9 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -25,6 +25,7 @@ * \brief Page of supplier invoice statistics for a product */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php index b71c24d75cb..9415f2d6546 100644 --- a/htdocs/product/stats/facturerec.php +++ b/htdocs/product/stats/facturerec.php @@ -26,6 +26,7 @@ * \brief Page of template invoice statistics for a product */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 38bebc562ed..a4947db1085 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -23,6 +23,7 @@ * \brief Page of MO referring product */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 2f6faca07a7..42467368b91 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -24,6 +24,7 @@ * \brief Page des stats des propals pour un produit */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 2136b9b26cf..ff14c764af6 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -24,6 +24,7 @@ * \brief Page des stats des propals pour un produit */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 43fb04b1ad3..095eaee313f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -28,6 +28,7 @@ * \brief Page fiche entrepot */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -691,7 +692,7 @@ if ($action == 'create') { $objp = $db->fetch_object($resql); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active + if (getDolGlobalInt('MAIN_MULTILANGS')) { // si l'option est active $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product = ".((int) $objp->rowid); diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 95da65cd540..a0310a16359 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -114,23 +114,17 @@ class ProductStockEntrepot extends CommonObject // Insert request $sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'('; - $sql .= 'fk_product,'; $sql .= 'fk_entrepot,'; $sql .= 'seuil_stock_alerte,'; $sql .= 'desiredstock,'; $sql .= 'import_key'; - - $sql .= ') VALUES ('; - $sql .= ' '.(!isset($this->fk_product) ? 'NULL' : $this->fk_product).','; $sql .= ' '.(!isset($this->fk_entrepot) ? 'NULL' : $this->fk_entrepot).','; $sql .= ' '.(!isset($this->seuil_stock_alerte) ? '0' : $this->seuil_stock_alerte).','; $sql .= ' '.(!isset($this->desiredstock) ? '0' : $this->desiredstock).','; $sql .= ' '.(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'"); - - $sql .= ')'; $this->db->begin(); diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index a2a15a34e53..b4277e559b1 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -22,6 +22,7 @@ * \brief Page fiche de valorisation du stock dans l'entrepot */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index 0f9deb92772..dcf53a760b1 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -25,6 +25,7 @@ * \brief Home page of stock area */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 29e337c3728..b47706df401 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -21,6 +21,7 @@ * \brief Page des informations d'un entrepot */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index f182cf1847b..496a2720e97 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -25,6 +25,7 @@ * \brief Page with warehouse and stock value */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -382,7 +383,7 @@ $arrayofmassactions = array( if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { $arrayofmassactions = array(); } -if ($user->rights->stock->creer) { +if (isModEnabled('category') && $user->rights->stock->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'label', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 4da9156e955..0c41cbed44a 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -23,6 +23,7 @@ * outgoing warehouse and create all stock movements for this. */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index c31bbbc3101..e28dcc5ca51 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -26,6 +26,7 @@ * \brief Page to list stock movements */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index b0f83cae0ec..7e34931f9a8 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -26,6 +26,7 @@ * \brief Page to list stock movements */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -136,7 +137,7 @@ $arrayfields = array( 'origin'=>array('label'=>"Origin", 'checked'=>1, 'position'=>155), 'm.fk_projet'=>array('label'=>'Project', 'checked'=>0, 'position'=>180), 'm.value'=>array('label'=>"Qty", 'checked'=>1, 'position'=>200), - 'm.price'=>array('label'=>"UnitPurchaseValue", 'checked'=>0, 'position'=>210, 'enabled'=>empty($conf->global->STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE)) + 'm.price'=>array('label'=>"UnitPurchaseValue", 'checked'=>0, 'position'=>210, 'enabled'=>(!getDolGlobalInt('STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE'))) //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) ); @@ -268,10 +269,10 @@ if (empty($reshook)) { // Define output language (Here it is not used because we do only merging existing PDF) $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - //elseif (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && is_object($objecttmp->thirdparty)) { // On massaction, we can have several values for $objecttmp->thirdparty + //elseif (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && is_object($objecttmp->thirdparty)) { // On massaction, we can have several values for $objecttmp->thirdparty // $newlang = $objecttmp->thirdparty->default_lang; //} if (!empty($newlang)) { @@ -1318,7 +1319,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $userstatic->statut = $obj->user_status; // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // If multilang is enabled + if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled // TODO Use a cache $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index ca3624fe147..bd679a3f2d8 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -31,6 +31,7 @@ * \brief Page to list detailed stock of a product */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -47,7 +48,7 @@ if (!empty($conf->project->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } -if (!empty($conf->variants->enabled)) { +if (isModEnabled('variants')) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php'; require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 6e6f8991e83..5219897ed61 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -24,6 +24,7 @@ * Initialy built by build_class_from_table on 2016-05-17 12:22 */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 842aa83bd07..be6c7f640a4 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -29,6 +29,7 @@ * \brief Page of attached documents for porudct lots */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index ed0c62564c6..c15479b1f4f 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -24,6 +24,7 @@ * Initialy built by build_class_from_table on 2016-05-17 12:22 */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 1eb8a444d8a..291fb2b7333 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -28,6 +28,7 @@ * \brief Page to list stocks to replenish */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -179,7 +180,7 @@ if ($action == 'order' && GETPOST('valid')) { //$product = new Product($db); //$product->fetch($obj->fk_product); - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $productsupplier->getMultiLangs(); } @@ -190,7 +191,7 @@ if ($action == 'order' && GETPOST('valid')) { $desc = $productsupplier->description; } $line->desc = $desc; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { // TODO Get desc in language of thirdparty } @@ -802,7 +803,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $prod->load_stock('warehouseopen, warehouseinternal'.(!$usevirtualstock?', novirtual':''), $draftchecked); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql = 'SELECT label,description'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; $sql .= ' WHERE fk_product = '.((int) $objp->rowid); diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index b66eff03a71..d077c1d0ba8 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -25,6 +25,7 @@ * \brief Page to list replenishment orders */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 6297dbcb15b..d88355c6912 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -26,6 +26,7 @@ * \brief Page to list stocks at a given date */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -487,7 +488,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $prod->fetch($objp->rowid); // Multilangs - /*if (!empty($conf->global->MAIN_MULTILANGS)) + /*if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql = 'SELECT label,description'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index d0f27eb46f4..a71098fc2bf 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -57,6 +57,19 @@ class StockTransfer extends CommonObject */ public $isextrafieldmanaged = 1; + /** + * @var string Customer ref + * @deprecated + * @see $ref_customer + */ + public $ref_client; + + /** + * @var string Customer ref + */ + public $ref_customer; + + /** * @var string String with name of icon for stocktransfer. Must be the part after the 'object_' into object_stocktransfer.png */ @@ -140,6 +153,7 @@ class StockTransfer extends CommonObject public $note_private; public $date_creation; public $tms; + public $lead_time_for_warning; public $fk_user_creat; public $fk_user_modif; public $import_key; diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index a5d49dcc3a7..14febad09d4 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -232,7 +232,6 @@ class StockTransferLine extends CommonObjectLine // Reset some properties unset($object->id); - unset($object->fk_user_creat); unset($object->import_key); diff --git a/htdocs/product/stock/stocktransfer/lib/stocktransfer.lib.php b/htdocs/product/stock/stocktransfer/lib/stocktransfer.lib.php index 8460a6405bc..90fd3f25ba9 100644 --- a/htdocs/product/stock/stocktransfer/lib/stocktransfer.lib.php +++ b/htdocs/product/stock/stocktransfer/lib/stocktransfer.lib.php @@ -63,5 +63,7 @@ function stocktransferAdminPrepareHead() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'stocktransfer'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'stocktransfer', 'remove'); + return $head; } diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php index 6d09dd03b44..b62dfa5b00d 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php @@ -22,6 +22,7 @@ * \brief Page of StockTransfer events */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -115,7 +116,7 @@ if ($object->id > 0) { $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (isModEnabled('notification')) $langs->load("mails"); $head = stocktransferPrepareHead($object); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 921ee89758a..8250006178a 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -22,6 +22,7 @@ * \brief Page to create/edit/view stocktransfer */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -993,7 +994,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Delete (need delete permission, or if draft, just need create/modify permission) if ($object->status < $object::STATUS_TRANSFERED && $permissiontodelete) { - print ''.$langs->trans('Delete').''."\n"; + print ''.$langs->trans('Delete').''."\n"; } /*else { diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php index 393a9b6517c..6c0ef97fe28 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php @@ -25,6 +25,7 @@ * \brief Tab to manage contacts/adresses of proposal */ +// Load Dolibarr environment require '../../../main.inc.php'; // Load translation files required by the page $langs->loadLangs(array('facture', 'orders', 'sendings', 'companies', 'stocks')); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_document.php b/htdocs/product/stock/stocktransfer/stocktransfer_document.php index 68233cd358f..7220581bc52 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_document.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_document.php @@ -22,6 +22,7 @@ * \brief Tab for documents linked to StockTransfer */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_list.php b/htdocs/product/stock/stocktransfer/stocktransfer_list.php index 6b9d98a63b9..72c538a58c6 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_list.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_list.php @@ -23,6 +23,7 @@ * \brief List page for stocktransfer */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_note.php b/htdocs/product/stock/stocktransfer/stocktransfer_note.php index 5df73f02e73..2176af2803a 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_note.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_note.php @@ -22,6 +22,7 @@ * \brief Car with notes on StockTransfer */ +// Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php'; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 926b0c01634..6bf59ebeb0e 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -23,6 +23,7 @@ * \brief Page with stock values */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 7f91e9c73a8..3f536b6761a 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -25,6 +25,7 @@ * \brief Page de traduction des produits */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index ead8d24550f..380b4891376 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -15,7 +15,7 @@ * 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 . + * along with this program. If not, see . */ /** diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 36ef3a501ff..37eb33d9206 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -27,6 +27,7 @@ * \brief Page to setup project module */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/admin/project_extrafields.php b/htdocs/projet/admin/project_extrafields.php index bb586b6a100..f2a17d3f150 100644 --- a/htdocs/projet/admin/project_extrafields.php +++ b/htdocs/projet/admin/project_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of project */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,13 +81,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print "
"; diff --git a/htdocs/projet/admin/project_task_extrafields.php b/htdocs/projet/admin/project_task_extrafields.php index 695ef3f57a6..731ac3629ae 100644 --- a/htdocs/projet/admin/project_task_extrafields.php +++ b/htdocs/projet/admin/project_task_extrafields.php @@ -26,6 +26,7 @@ * \brief Page to setup extra fields of project */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,13 +81,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print "
"; diff --git a/htdocs/projet/admin/website.php b/htdocs/projet/admin/website.php index eead379c804..3be04a9843c 100644 --- a/htdocs/projet/admin/website.php +++ b/htdocs/projet/admin/website.php @@ -24,6 +24,7 @@ * \brief File of main public page for project module to catch lead */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 69e439fdf1f..03d118dc9b9 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -38,13 +38,11 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; $htmlname = GETPOST('htmlname', 'aZ09'); @@ -64,7 +62,7 @@ dol_syslog("Call ajax projet/ajax/projects.php"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -top_httphead(); +top_httphead('application/json'); if (empty($htmlname) && !GETPOST('mode', 'aZ09')) { return; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 451334c5d77..52092eb8b94 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -23,6 +23,7 @@ * \brief Project card */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; @@ -1275,7 +1276,7 @@ if ($action == 'create' && $user->rights->projet->creer) { if (empty($reshook)) { if ($action != "edit" && $action != 'presend') { // Create event - /*if ($conf->agenda->enabled && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a + /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a // "workflow" action so should appears somewhere else on // page. { @@ -1291,7 +1292,7 @@ if ($action == 'create' && $user->rights->projet->creer) { // Accounting Report /* - $accouting_module_activated = !empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled); + $accouting_module_activated = isModEnabled('comptabilite') || isModEnabled('accounting'); if ($accouting_module_activated && $object->statut != Project::STATUS_DRAFT) { $start = dol_getdate((int) $object->date_start); $end = dol_getdate((int) $object->date_end); @@ -1368,7 +1369,7 @@ if ($action == 'create' && $user->rights->projet->creer) { $langs->load("suppliers"); print dolGetButtonAction('', $langs->trans('AddSupplierInvoice'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid, '', 1, array('isDropDown' => true)); } - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) { + if (isModEnabled('ficheinter') && $user->rights->ficheinter->creer) { $langs->load("interventions"); print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid, '', 1, array('isDropDown' => true)); } @@ -1380,7 +1381,7 @@ if ($action == 'create' && $user->rights->projet->creer) { $langs->load("trips"); print dolGetButtonAction('', $langs->trans('AddTrip'), 'default', DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid, '', 1, array('isDropDown' => true)); } - if (!empty($conf->don->enabled) && $user->rights->don->creer) { + if (isModEnabled('don') && $user->rights->don->creer) { $langs->load("donations"); print dolGetButtonAction('', $langs->trans('AddDonation'), 'default', DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid, '', 1, array('isDropDown' => true)); } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 04e32a80c5d..9987f9bc4f0 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -345,6 +345,7 @@ class Project extends CommonObject $this->fields['accept_booth_suggestions']['enabled'] = 0; $this->fields['price_registration']['enabled'] = 0; $this->fields['price_booth']['enabled'] = 0; + $this->fields['max_attendees']['enabled'] = 0; } } @@ -854,11 +855,24 @@ class Project extends CommonObject $listoftables = array( 'propal'=>'fk_projet', 'commande'=>'fk_projet', 'facture'=>'fk_projet', 'supplier_proposal'=>'fk_projet', 'commande_fournisseur'=>'fk_projet', 'facture_fourn'=>'fk_projet', - 'expensereport_det'=>'fk_projet', 'contrat'=>'fk_projet', 'fichinter'=>'fk_projet', 'don'=>'fk_projet', - 'actioncomm'=>'fk_project', 'mrp_mo'=>'fk_project', 'entrepot'=>'fk_project' + 'expensereport_det'=>'fk_projet', 'contrat'=>'fk_projet', + 'fichinter'=>'fk_projet', + 'don'=>array('field'=>'fk_projet', 'module'=>'don'), + 'actioncomm'=>'fk_project', + 'mrp_mo'=>'fk_project', + 'entrepot'=>'fk_project' ); foreach ($listoftables as $key => $value) { - $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".((int) $this->id); + if (is_array($value)) { + if (!isModEnabled($value['module'])) { + continue; + } + $fieldname = $value['field']; + } else { + $fieldname = $value; + } + $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$fieldname." = NULL where ".$fieldname." = ".((int) $this->id); + $resql = $this->db->query($sql); if (!$resql) { $this->errors[] = $this->db->lasterror(); diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index f1295c10424..322277187f7 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -32,6 +32,11 @@ class ProjectStats extends Stats public $status; public $opp_status; + //SQL stat + public $field; + public $from; + public $where; + /** * Constructor @@ -46,6 +51,18 @@ class ProjectStats extends Stats require_once 'project.class.php'; $this->project = new Project($this->db); + + $this->from = MAIN_DB_PREFIX.$this->project->table_element; + $this->field = 'opp_amount'; + $this->where = " entity = ".$conf->entity; + if ($this->socid > 0) { + $this->where .= " AND fk_soc = ".((int) $this->socid); + } + if (is_array($this->userid) && count($this->userid) > 0) { + $this->where .= ' AND fk_user IN ('.$this->db->sanitize(join(',', $this->userid)).')'; + } elseif ($this->userid > 0) { + $this->where .= " AND fk_user = ".((int) $this->userid); + } } @@ -538,7 +555,6 @@ class ProjectStats extends Stats { $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; $sql .= " FROM ".$this->from; - $sql .= $this->join; $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index 997f45a39d0..5ea5b920f8c 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -23,6 +23,7 @@ * \brief Page of a project task */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index ec1f739f58f..ee37aa68fdd 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -22,6 +22,7 @@ * \brief List of all contacts of a project */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index ad5b8715e95..0a2acc4c3bc 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -23,6 +23,7 @@ * \brief Page to managed related documents linked to a project */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 594362ba05d..032677c27d8 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -29,6 +29,7 @@ * \brief Page of project referrers */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; @@ -36,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (!empty($conf->stock->enabled)) { +if (isModEnabled('stock')) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; } if (isModEnabled("propal")) { @@ -61,7 +62,7 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO if (isModEnabled('contrat')) { require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; } -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; } if (isModEnabled("expedition")) { @@ -76,14 +77,14 @@ if (isModEnabled('expensereport')) { if (isModEnabled('agenda')) { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; } -if (!empty($conf->don->enabled)) { +if (isModEnabled('don')) { require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; } if (!empty($conf->loan->enabled)) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; } -if (!empty($conf->stock->enabled)) { +if (isModEnabled('stock')) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; } if (isModEnabled('tax')) { @@ -113,7 +114,7 @@ if (isModEnabled('commande')) { if (isModEnabled("propal")) { $langs->load("propal"); } -if (!empty($conf->ficheinter->enabled)) { +if (isModEnabled('ficheinter')) { $langs->load("interventions"); } if (isModEnabled('deplacement')) { @@ -122,7 +123,7 @@ if (isModEnabled('deplacement')) { if (isModEnabled('expensereport')) { $langs->load("trips"); } -if (!empty($conf->don->enabled)) { +if (isModEnabled('don')) { $langs->load("donations"); } if (!empty($conf->loan->enabled)) { @@ -715,7 +716,7 @@ if (!$showdatefilter) { $langs->loadLangs(array("suppliers", "bills", "orders", "proposals", "margins")); -if (!empty($conf->stock->enabled)) { +if (isModEnabled('stock')) { $langs->load('stocks'); } diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index b519f298ecc..b0e779a5bec 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -24,6 +24,7 @@ * \brief Main project home page */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 8964cca8c19..bef020d9a38 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -22,6 +22,7 @@ * \brief Page with events on project */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b22a8849820..2193b0e6676 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -29,6 +29,7 @@ * \brief Page to list projects */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -70,8 +71,8 @@ if (!$user->rights->projet->lire) { $diroutputmassaction = $conf->project->dir_output.'/temp/massgeneration/'.$user->id; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", "aZ09comma"); -$sortorder = GETPOST("sortorder", 'aZ09comma'); +$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 @@ -228,7 +229,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -355,13 +357,22 @@ if (empty($reshook)) { * View */ -$companystatic = new Societe($db); $form = new Form($db); + +$companystatic = new Societe($db); $formother = new FormOther($db); $formproject = new FormProjets($db); $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; -$title = $langs->trans("Projects"); +$title = $langs->trans("LeadsOrProjects"); +if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + $title = $langs->trans("Projects"); +} +if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only + $title = $langs->trans("Leads"); +} +$morejs = array(); +$morecss = array(); // Get list of project id allowed to user (in a string list separated by comma) @@ -774,7 +785,7 @@ if ($user->rights->projet->creer) { if ($user->rights->projet->supprimer) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if ($user->rights->projet->creer) { +if (isModEnabled('category') && $user->rights->projet->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { @@ -1189,8 +1200,12 @@ $totalarray = array( 'nbfield' => 0, 'val' => array(), ); -while ($i < min($num, $limit)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } $object->id = $obj->id; $object->user_author_id = $obj->fk_user_creat; @@ -1647,14 +1662,26 @@ while ($i < min($num, $limit)) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '
'; +} + $db->free($resql); -$parameters = array('sql' => $sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$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 "
'.$langs->trans("Position"); @@ -60,11 +71,14 @@ print ''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("ComputedFormula").''.$langs->trans("Unique").''.$langs->trans("Required").''.$langs->trans("AlwaysEditable").''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$langs->trans("Mandatory").''.$form->textwithpicto($langs->trans("AlwaysEditable"), $langs->trans("EditableWhenDraftOnly")).''.$form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).''.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).''.$form->textwithpicto($langs->trans("CssOnEdit"), $langs->trans("HelpCssOnEditDesc")).''.$form->textwithpicto($langs->trans("CssOnView"), $langs->trans("HelpCssOnViewDesc")).''.$form->textwithpicto($langs->trans("CssOnList"), $langs->trans("HelpCssOnListDesc")).''.$langs->trans("Entity").'".dol_escape_htmltag($extrafields->attributes[$elementtype]['pos'][$key])."".dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key])."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key])."'.dol_escape_htmltag($langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]))."".dol_escape_htmltag($key)."'.dol_escape_htmltag($key)."'; + print ''; print dol_escape_htmltag($typetoshow); print "'.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key])."'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key])."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key])."'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key])."'; if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) { @@ -131,6 +152,7 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel } print ''; print ''.img_edit().''; print '  '.img_delete().''; @@ -138,7 +160,7 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel print "
'."\n"; print '
'.$langs->trans("DefaultLang"); if (!empty($array_query['cust_language'])) { print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 826a8e0a12a..24604388af1 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -63,7 +63,7 @@ if ($action == 'presend') { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; if (GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); @@ -156,6 +156,22 @@ if ($action == 'presend') { $formmail->fromtype = 'special'; } + // Set the default "From" + $defaultfrom = ''; + if (GETPOSTISSET('fromtype')) { + $defaultfrom = GETPOST('fromtype'); + } else { + $parameters = array(); + $reshook = $hookmanager->executeHooks('getDefaultFromEmail', $parameters, $formmail); + if (empty($reshook)) { + $defaultfrom = $formmail->fromtype; + } + if (!empty($hookmanager->resArray['defaultfrom'])) { + $defaultfrom = $hookmanager->resArray['defaultfrom']; + } + } + $formmail->fromtype = $defaultfrom; + $formmail->trackid = empty($trackid) ? '' : $trackid; $formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto; $formmail->withfrom = 1; @@ -212,11 +228,33 @@ if ($action == 'presend') { } // Make substitution in email content - if ($object) { + if (!empty($object)) { // First we set ->substit (useless, it will be erased later) and ->substit_lines $formmail->setSubstitFromObject($object, $langs); } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); + + // Overwrite __SENDEREMAIL_SIGNATURE__ with value select into form + if ($formmail->fromtype) { + $reg = array(); + if (preg_match('/user/', $formmail->fromtype, $reg)) { + $emailsendersignature = $user->signature; + } elseif (preg_match('/company/', $formmail->fromtype, $reg)) { + $emailsendersignature = ''; + } elseif (preg_match('/senderprofile_(\d+)/', $formmail->fromtype, $reg)) { + $sql = "SELECT rowid, label, email, signature FROM ".$db->prefix()."c_email_senderprofile"; + $sql .= " WHERE rowid = ".((int) $reg[1]); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $emailsendersignature = $obj->signature; + } + } + } + } + $substitutionarray['__SENDEREMAIL_SIGNATURE__'] = $emailsendersignature; + $substitutionarray['__CHECK_READ__'] = ""; if (is_object($object) && is_object($object->thirdparty)) { $checkRead= ''; + + $labeltoshow = ''; if (!empty($val['help'])) { - print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + $labeltoshow .= $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); } else { if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 1) { - print showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($val['label'])); + $labeltoshow .= showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($val['label'])); } else { - print $langs->trans($val['label']); + $labeltoshow .= $langs->trans($val['label']); } } + if (empty($val['alwayseditable'])) { + print $labeltoshow; + } else { + print $form->editfieldkey($labeltoshow, $key, $value, $object, 1, $val['type']); + } + print ''; - if (in_array($val['type'], array('text', 'html'))) { - print '
'; - } - if ($key == 'lang') { - $langs->load("languages"); - $labellang = ($value ? $langs->trans('Language_'.$value) : ''); - print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"'); - print $labellang; - } else { - if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 2) { - $out = $object->showOutputField($val, $key, $value, '', '', '', 0); - print showValueWithClipboardCPButton($out, 0, $out); - } else { - print $object->showOutputField($val, $key, $value, '', '', '', 0); + if (empty($val['alwayseditable'])) { + if (in_array($val['type'], array('text', 'html'))) { + print '
'; } - } - //print dol_escape_htmltag($object->$key, 1, 1); - if (in_array($val['type'], array('text', 'html'))) { - print '
'; + if ($key == 'lang') { + $langs->load("languages"); + $labellang = ($value ? $langs->trans('Language_'.$value) : ''); + print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"'); + print $labellang; + } else { + if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 2) { + $out = $object->showOutputField($val, $key, $value, '', '', '', 0); + print showValueWithClipboardCPButton($out, 0, $out); + } else { + print $object->showOutputField($val, $key, $value, '', '', '', 0); + } + } + //print dol_escape_htmltag($object->$key, 1, 1); + if (in_array($val['type'], array('text', 'html'))) { + print '
'; + } + } else { + print $form->editfieldval($labeltoshow, $key, $value, $object, 1, $val['type']); } print '
'; - if (in_array($val['type'], array('text', 'html'))) { - $rightpart .= '
'; - } - $rightpart .= $object->showOutputField($val, $key, $value, '', '', '', 0); - //$rightpart .= dol_escape_htmltag($object->$key, 1, 1); - if (in_array($val['type'], array('text', 'html'))) { - $rightpart .= '
'; + + if (empty($val['alwayseditable'])) { + if (in_array($val['type'], array('text', 'html'))) { + $rightpart .= '
'; + } + if ($key == 'lang') { + $langs->load("languages"); + $labellang = ($value ? $langs->trans('Language_'.$value) : ''); + $rightpart .= picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"'); + $rightpart .= $labellang; + } else { + if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 2) { + $out = $object->showOutputField($val, $key, $value, '', '', '', 0); + $rightpart .= showValueWithClipboardCPButton($out, 0, $out); + } else { + $rightpart.= $object->showOutputField($val, $key, $value, '', '', '', 0); + } + } + if (in_array($val['type'], array('text', 'html'))) { + $rightpart .= '
'; + } + } else { + $rightpart .= $form->editfieldval($labeltoshow, $key, $value, $object, 1, $val['type']); } + $rightpart .= '
'; print $val['picto']; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP')); print ''; print ''.$object->getLibStatut(4)."
'; $label = $langs->trans("AccountAccounting"); print ''; -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1); } else { print ''; diff --git a/htdocs/don/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php index 1fc28065a5c..a0454ea08d7 100644 --- a/htdocs/don/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -22,6 +22,7 @@ * \brief Page to setup extra fields of donations */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -77,13 +78,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - /* ************************************************************************** */ /* */ diff --git a/htdocs/don/card.php b/htdocs/don/card.php index b3b1a517077..ae73fdfd15a 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -27,6 +27,7 @@ * \brief Page of donation card */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; @@ -119,10 +120,10 @@ if (empty($reshook)) { if (method_exists($object, 'generateDocument')) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -181,8 +182,6 @@ if (empty($reshook)) { $object->date = $donation_date; $object->public = $public_donation; $object->fk_project = (int) GETPOST("fk_project", 'int'); - $object->note_private = (string) GETPOST("note_private", 'restricthtml'); - $object->note_public = (string) GETPOST("note_public", 'restricthtml'); $object->modepaymentid = (int) GETPOST('modepayment', 'int'); // Fill array 'array_options' with data from add form @@ -351,8 +350,8 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang=''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang=$object->thirdparty->default_lang; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (!empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 53ca935e5ae..219a5116658 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -29,6 +29,7 @@ * \brief Page of linked files onto donation */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/don/index.php b/htdocs/don/index.php index 85e2eb3e48f..721cfb8d67a 100644 --- a/htdocs/don/index.php +++ b/htdocs/don/index.php @@ -24,6 +24,7 @@ * \brief Home page of donation module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; @@ -90,7 +91,7 @@ print load_fiche_titre($langs->trans("DonationsArea"), '', 'object_donation'); print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // TODO Add a search into global search combo so we can remove this - if (!empty($conf->don->enabled) && $user->rights->don->lire) { + if (isModEnabled('don') && $user->rights->don->lire) { $listofsearchfields['search_donation'] = array('text'=>'Donation'); } diff --git a/htdocs/don/info.php b/htdocs/don/info.php index b19826f9bcd..82dd9842210 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -21,6 +21,7 @@ * \brief Page to show a donation information */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 73314d9727c..1ab7220d894 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -25,6 +25,7 @@ * \brief List of donations */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; if (isModEnabled('project')) { diff --git a/htdocs/don/note.php b/htdocs/don/note.php index 57ca862ad77..4d84c4b1417 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -25,6 +25,7 @@ * \brief Page to show a donation notes */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 1b4ebaaf88e..f5507e5e6c7 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -22,6 +22,7 @@ * \brief Tab payment of a donation */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index 092f5114141..6a2cc78f128 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -22,6 +22,7 @@ * \brief Page to add payment of a donation */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index f56bdcd15ac..4109c30d335 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -24,6 +24,7 @@ * \brief Page with donations statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/donstats.class.php'; diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index 2ce35973483..475e22754b0 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -33,6 +33,7 @@ if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index 6f80a68dc35..01a1cfb63a9 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -25,6 +25,7 @@ if (! defined('DISABLE_JS_GRAHP')) define('DISABLE_JS_GRAPH', 1); +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php'; diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 930575d1778..c36cebfc80c 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -22,6 +22,7 @@ * \brief Card of a directory for ECM module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index 0a1114fb40c..1b572e44eb8 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -21,6 +21,7 @@ * \brief Card of a file for ECM module */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; @@ -341,7 +342,7 @@ $rellink .= '&file='.urlencode($filepath); $fulllink = $urlwithroot.$rellink; print img_picto('', 'globe').' '; if ($action != 'edit') { - print ''; + print ''; } else { print $fulllink; } diff --git a/htdocs/ecm/file_note.php b/htdocs/ecm/file_note.php index 53b120d3191..07534dc5ae8 100644 --- a/htdocs/ecm/file_note.php +++ b/htdocs/ecm/file_note.php @@ -25,6 +25,7 @@ * \brief Tab for notes on an ECM file */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index ceaf74f533d..79c4d7dcc24 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -24,6 +24,7 @@ * \brief Main page for ECM section area */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 8014a4522bb..9d9ff5a463f 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -23,6 +23,7 @@ * \brief Main page for ECM section area */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; @@ -317,20 +318,20 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { $rowspan++; $sectionauto[] = array('position'=>20, 'level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } if (isModEnabled("propal")) { - $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); + $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (isModEnabled('contrat')) { - $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); + $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (isModEnabled('commande')) { - $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); + $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } if (isModEnabled('facture')) { - $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); + $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (isModEnabled('supplier_proposal')) { $langs->load("supplier_proposal"); - $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); + $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")) { $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); @@ -340,41 +341,41 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { } if (isModEnabled('tax')) { $langs->load("compta"); - $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); - $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT"))); + $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT"))); } if (!empty($conf->salaries->enabled)) { $langs->load("compta"); - $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>$conf->salaries->enabled, 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries"))); + $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>isModEnabled('salaries'), 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries"))); } if (isModEnabled('project')) { $rowspan++; $sectionauto[] = array('position'=>130, 'level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); $rowspan++; $sectionauto[] = array('position'=>140, 'level'=>1, 'module'=>'project_task', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks"))); } - if (!empty($conf->ficheinter->enabled)) { + if (isModEnabled('ficheinter')) { $langs->load("interventions"); - $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); + $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (isModEnabled('expensereport')) { $langs->load("trips"); - $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); + $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (isModEnabled('holiday')) { $langs->load("holiday"); - $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); + $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } if (isModEnabled("banque")) { $langs->load("banks"); - $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); - $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); + $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); + $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); } - if (!empty($conf->mrp->enabled)) { + if (isModEnabled('mrp')) { $langs->load("mrp"); - $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); + $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (isModEnabled('recruitment')) { $langs->load("recruitment"); - $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); + $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } $rowspan++; $sectionauto[] = array('position'=>220, 'level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 5f86c0e8c57..e92a888f21b 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -22,6 +22,7 @@ * \brief Page to make advanced search into ECM */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; @@ -120,19 +121,19 @@ if (isModEnabled("societe")) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } if (isModEnabled("propal")) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (isModEnabled('contrat')) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (isModEnabled('commande')) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } if (isModEnabled('facture')) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (isModEnabled('supplier_proposal')) { - $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); + $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); @@ -141,28 +142,28 @@ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMO $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (isModEnabled('tax')) { - $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); } if (isModEnabled('project')) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); } -if (!empty($conf->ficheinter->enabled)) { - $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); +if (isModEnabled('ficheinter')) { + $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (isModEnabled('expensereport')) { - $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); + $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (isModEnabled('holiday')) { - $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); + $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } if (isModEnabled("banque")) { - $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); + $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); } if (!empty($conf->mrp->enabled)) { - $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); + $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (isModEnabled('recruitment')) { - $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); + $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 006376cfd55..f5da262e0c1 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -16,37 +16,38 @@ */ /** - * \file emailcollector/class/emailcollector.class.php - * \ingroup emailcollector - * \brief This file is a CRUD class file for EmailCollector (Create/Read/Update/Delete) + * \file htdocs/emailcollector/class/emailcollector.class.php + * \ingroup emailcollector + * \brief This file is a CRUD class file for EmailCollector (Create/Read/Update/Delete) */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; -require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; +include_once DOL_DOCUMENT_ROOT .'/emailcollector/lib/emailcollector.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; // customer proposal -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; // customer order -require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; // Shipment -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // supplier invoice -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; // supplier order -require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; // supplier proposal -require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; // reception -include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; -//require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Holidays (leave request) -//require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // expernse repor +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + +require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; // Customer Proposal +require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php'; // Customer Order +require_once DOL_DOCUMENT_ROOT .'/compta/facture/class/facture.class.php'; // Customer Invoice +require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; // Contact / Address +require_once DOL_DOCUMENT_ROOT .'/expedition/class/expedition.class.php'; // Shipping / Delivery +require_once DOL_DOCUMENT_ROOT .'/fourn/class/fournisseur.commande.class.php'; // Supplier Order +require_once DOL_DOCUMENT_ROOT .'/fourn/class/fournisseur.facture.class.php'; // Supplier Invoice +require_once DOL_DOCUMENT_ROOT .'/projet/class/project.class.php'; // Project +require_once DOL_DOCUMENT_ROOT .'/reception/class/reception.class.php'; // Reception +require_once DOL_DOCUMENT_ROOT .'/recruitment/class/recruitmentcandidature.class.php'; // Recruiting +require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; // Third-Party +require_once DOL_DOCUMENT_ROOT .'/supplier_proposal/class/supplier_proposal.class.php'; // Supplier Proposal +require_once DOL_DOCUMENT_ROOT .'/ticket/class/ticket.class.php'; // Ticket +//require_once DOL_DOCUMENT_ROOT .'/expensereport/class/expensereport.class.php'; // Expense Report +//require_once DOL_DOCUMENT_ROOT .'/holiday/class/holiday.class.php'; // Holidays (leave request) // use Webklex\PHPIMAP; -require DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php'; -use Webklex\PHPIMAP\ClientManager; +require DOL_DOCUMENT_ROOT .'/includes/webklex/php-imap/vendor/autoload.php'; +use Webklex\PHPIMAP\ClientManager; use Webklex\PHPIMAP\Exceptions\ConnectionFailedException; use Webklex\PHPIMAP\Exceptions\InvalidWhereQueryCriteriaException; use Webklex\PHPIMAP\Exceptions\GetMessagesFailedException; @@ -64,14 +65,17 @@ class EmailCollector extends CommonObject * @var string ID to identify managed object */ public $element = 'emailcollector'; + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'emailcollector_emailcollector'; + /** * @var int Does emailcollector support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 1; + /** * @var int Does emailcollector support extrafields ? 0=No, 1=Yes */ @@ -91,6 +95,7 @@ class EmailCollector extends CommonObject * @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. */ @@ -126,8 +131,8 @@ class EmailCollector extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax150'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector', 'csslist'=>'tdoverflowmax150'), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'csslist'=>'small'), - 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflow125'), - 'port' => array('type'=>'varchar(10)', 'label'=>'EMailHostPort', 'visible'=>1, 'enabled'=>1, 'position'=>91, 'notnull'=>1, 'searchall'=>0, 'comment'=>"IMAP server port", 'help'=>'Example: 993', 'csslist'=>'tdoverflow125', 'default'=>'993'), + 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflowmax125'), + 'port' => array('type'=>'varchar(10)', 'label'=>'EMailHostPort', 'visible'=>1, 'enabled'=>1, 'position'=>91, 'notnull'=>1, 'searchall'=>0, 'comment'=>"IMAP server port", 'help'=>'Example: 993', 'csslist'=>'tdoverflowmax50', 'default'=>'993'), 'hostcharset' => array('type'=>'varchar(16)', 'label'=>'HostCharset', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>0, 'searchall'=>0, 'comment'=>"IMAP server charset", 'help'=>'Example: "UTF-8" (May be "US-ASCII" with some Office365)', 'default'=>'UTF-8'), 'acces_type' => array('type'=>'integer', 'label'=>'accessType', 'visible'=>-1, 'enabled'=>"getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>101, 'notnull'=>1, 'index'=>1, 'comment'=>"IMAP login type", 'arrayofkeyval'=>array('0'=>'loginPassword', '1'=>'oauthToken'), 'default'=>'0', 'help'=>''), 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), @@ -206,7 +211,6 @@ class EmailCollector extends CommonObject */ public $import_key; - public $host; public $port; public $hostcharset; @@ -851,7 +855,7 @@ class EmailCollector extends CommonObject // Loop on each collector foreach ($arrayofcollectors as $emailcollector) { - $result = $emailcollector->doCollectOneCollector(); + $result = $emailcollector->doCollectOneCollector(0); dol_syslog("doCollect result = ".$result." for emailcollector->id = ".$emailcollector->id); $this->error .= 'EmailCollector ID '.$emailcollector->id.':'.$emailcollector->error.'
'; @@ -872,9 +876,10 @@ class EmailCollector extends CommonObject * @param string $messagetext Body * @param string $subject Subject * @param string $header Header + * @param string $operationslog String with logs of operations done * @return int 0=OK, Nb of error if error */ - private function overwritePropertiesOfObject(&$object, $actionparam, $messagetext, $subject, $header) + private function overwritePropertiesOfObject(&$object, $actionparam, $messagetext, $subject, $header, &$operationslog) { $errorforthisaction = 0; @@ -909,6 +914,7 @@ class EmailCollector extends CommonObject $sourcefield = $regforregex[1]; $regexstring = $regforregex[2]; } + if (!empty($sourcefield) && !empty($regexstring)) { if (strtolower($sourcefield) == 'body') { $sourcestring = $messagetext; @@ -930,7 +936,6 @@ class EmailCollector extends CommonObject //var_dump($tmpproperty.' - '.$regexstring.' - '.$regexoptions.' - '.$sourcestring); if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval)) { - //var_dump($regforval[count($regforval)-1]);exit; // Overwrite param $tmpproperty $valueextracted = isset($regforval[count($regforval) - 1]) ?trim($regforval[count($regforval) - 1]) : null; if (strtolower($sourcefield) == 'header') { @@ -946,9 +951,16 @@ class EmailCollector extends CommonObject $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); } } + if (preg_match('/^options_/', $tmpproperty)) { + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->array_options[preg_replace('/^options_/', '', $tmpproperty)], 128)); + } else { + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> found '.dol_escape_htmltag(dol_trunc($object->$tmpproperty, 128)); + } } else { // Regex not found $object->$tmpproperty = null; + + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/'.dol_escape_htmltag($regexoptions).' into '.strtolower($sourcefield).' -> not found, so property '.dol_escape_htmltag($tmpproperty).' is set to null.'; } } else { // Nothing can be done for this param @@ -986,6 +998,8 @@ class EmailCollector extends CommonObject } else { $object->$tmpproperty = $valuetouse; } + + $operationslog .= '
Set value '.dol_escape_htmltag($valuetouse).' into variable '.dol_escape_htmltag($tmpproperty); } } else { $errorforthisaction++; @@ -1001,9 +1015,10 @@ class EmailCollector extends CommonObject /** * Execute collect for current collector loaded previously with fetch. * - * @return int <0 if KO, >0 if OK + * @param int $mode 0=Mode production, 1=Mode test (read IMAP and try SQL update then rollback), 2=Mode test with no SQL updates + * @return int <0 if KO, >0 if OK */ - public function doCollectOneCollector() + public function doCollectOneCollector($mode = 0) { global $db, $conf, $langs, $user; global $hookmanager; @@ -1019,6 +1034,15 @@ class EmailCollector extends CommonObject $error = 0; $this->output = ''; $this->error = ''; + $this->debuginfo = ''; + + $search = ''; + $searchhead = ''; + $searchfilterdoltrackid = 0; + $searchfilternodoltrackid = 0; + $searchfilterisanswer = 0; + $searchfilterisnotanswer = 0; + $operationslog = ''; $now = dol_now(); @@ -1166,12 +1190,6 @@ class EmailCollector extends CommonObject if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { $criteria = array(array('UNDELETED')); // Seems not supported by some servers - $search = ''; - $searchhead = ''; - $searchfilterdoltrackid = 0; - $searchfilternodoltrackid = 0; - $searchfilterisanswer = 0; - $searchfilterisnotanswer = 0; foreach ($this->filters as $rule) { if (empty($rule['status'])) { continue; @@ -1269,11 +1287,6 @@ class EmailCollector extends CommonObject $search = var_export($criteria, true); } else { $search = 'UNDELETED'; // Seems not supported by some servers - $searchhead = ''; - $searchfilterdoltrackid = 0; - $searchfilternodoltrackid = 0; - $searchfilterisanswer = 0; - $searchfilterisnotanswer = 0; foreach ($this->filters as $rule) { if (empty($rule['status'])) { continue; @@ -1478,22 +1491,38 @@ class EmailCollector extends CommonObject $headers['Subject'] = $this->decodeSMTPSubject($headers['Subject']); + $emailto = $this->decodeSMTPSubject($overview[0]->to); + $operationslog .= '
Process email '.dol_escape_htmltag($iforemailloop)." - References: ".dol_escape_htmltag($headers['References'])." - Subject: ".dol_escape_htmltag($headers['Subject']); dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']." Subject: ".$headers['Subject']); + $trackidfoundintorecipienttype = ''; + $trackidfoundintorecipientid = 0; + $reg = array(); + // See also later list of all supported tags... + if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|job|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { + $trackidfoundintorecipienttype = $reg[1]; + $trackidfoundintorecipientid = $reg[2]; + } elseif (preg_match('/\+emailing-(\w+)@/', $emailto, $reg)) { // Can be 'emailing-test' or 'emailing-IdMailing-IdRecipient' + $trackidfoundintorecipienttype = 'emailing'; + $trackidfoundintorecipientid = $reg[1]; + } + // If there is a filter on trackid if ($searchfilterdoltrackid > 0) { - if (empty($headers['References']) || !preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { - $nbemailprocessed++; - dol_syslog(" Discarded - No header References found"); - continue; // Exclude email + if (empty($trackidfoundintorecipienttype)) { + if (empty($headers['References']) || !preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { + $nbemailprocessed++; + dol_syslog(" Discarded - No suffix in email recipient and no Header References found matching signature of application so with a trackid"); + continue; // Exclude email + } } } if ($searchfilternodoltrackid > 0) { - if (!empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { + if (!empty($trackidfoundintorecipienttype) || (!empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References']))) { $nbemailprocessed++; - dol_syslog(" Discarded - Header References found and matching signature of application"); + dol_syslog(" Discarded - Suffix found into email or Header References found and matching signature of application so with a trackid"); continue; // Exclude email } } @@ -1705,72 +1734,78 @@ class EmailCollector extends CommonObject foreach ($arrayofreferences as $reference) { //print "Process mail ".$iforemailloop." email_msgid ".$msgid.", date ".dol_print_date($date, 'dayhour').", subject ".$subject.", reference ".dol_escape_htmltag($reference)."
\n"; - $resultsearchtrackid = preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote($host, '/').'/', $reference, $reg); - if (empty($resultsearchtrackid) && getDolGlobalString('EMAIL_ALTERNATIVE_HOST_SIGNATURE')) { - $resultsearchtrackid = preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote(getDolGlobalString('EMAIL_ALTERNATIVE_HOST_SIGNATURE'), '/').'/', $reference, $reg); + if (!empty($trackidfoundintorecipienttype)) { + $resultsearchtrackid = -1; + $reg[1] = $trackidfoundintorecipienttype; + $reg[2] = $trackidfoundintorecipientid; + } else { + $resultsearchtrackid = preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote($host, '/').'/', $reference, $reg); + if (empty($resultsearchtrackid) && getDolGlobalString('EMAIL_ALTERNATIVE_HOST_SIGNATURE')) { + $resultsearchtrackid = preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote(getDolGlobalString('EMAIL_ALTERNATIVE_HOST_SIGNATURE'), '/').'/', $reference, $reg); + } } - if ($resultsearchtrackid) { - // This is a Dolibarr reference of the server + if (!empty($resultsearchtrackid)) { + // We found a tracker (in recipient email or into a Reference matching the Dolibarr server) $trackid = $reg[1].$reg[2]; $objectid = $reg[2]; // See also list into interface_50_modAgenda_ActionsAuto - if ($reg[1] == 'thi') { + if ($reg[1] == 'thi') { // Third-party $objectemail = new Societe($this->db); } - if ($reg[1] == 'ctc') { + if ($reg[1] == 'ctc') { // Contact $objectemail = new Contact($this->db); } - if ($reg[1] == 'inv') { // customer invoices + if ($reg[1] == 'inv') { // Customer Invoice $objectemail = new Facture($this->db); } - if ($reg[1] == 'sinv') { // supplier invoices + if ($reg[1] == 'sinv') { // Supplier Invoice $objectemail = new FactureFournisseur($this->db); } - if ($reg[1] == 'pro') { // customer proposals + if ($reg[1] == 'pro') { // Customer Proposal $objectemail = new Propal($this->db); } - if ($reg[1] == 'ord') { // customer orders + if ($reg[1] == 'ord') { // Customer Order $objectemail = new Commande($this->db); } - if ($reg[1] == 'shi') { // shipments + if ($reg[1] == 'shi') { // Shipment $objectemail = new Expedition($this->db); } - if ($reg[1] == 'spro') { // supplier proposal + if ($reg[1] == 'spro') { // Supplier Proposal $objectemail = new SupplierProposal($this->db); } - if ($reg[1] == 'sord') { // supplier order + if ($reg[1] == 'sord') { // Supplier Order $objectemail = new CommandeFournisseur($this->db); } - if ($reg[1] == 'rec') { // Reception + if ($reg[1] == 'rec') { // Reception $objectemail = new Reception($this->db); } - if ($reg[1] == 'proj') { + if ($reg[1] == 'proj') { // Project $objectemail = new Project($this->db); } - if ($reg[1] == 'tas') { + if ($reg[1] == 'tas') { // Task $objectemail = new Task($this->db); } - if ($reg[1] == 'con') { + if ($reg[1] == 'con') { // Contact $objectemail = new Contact($this->db); } - if ($reg[1] == 'use') { + if ($reg[1] == 'use') { // User $objectemail = new User($this->db); } - if ($reg[1] == 'tic') { + if ($reg[1] == 'tic') { // Ticket $objectemail = new Ticket($this->db); } - if ($reg[1] == 'recruitmentcandidature') { + if ($reg[1] == 'recruitmentcandidature') { // Recruiting Candidate $objectemail = new RecruitmentCandidature($this->db); } - if ($reg[1] == 'mem') { + if ($reg[1] == 'mem') { // Member $objectemail = new Adherent($this->db); } - /*if ($reg[1] == 'leav') { + /*if ($reg[1] == 'leav') { // Leave / Holiday $objectemail = new Holiday($db); } - if ($reg[1] == 'exp') { + if ($reg[1] == 'exp') { // ExpenseReport $objectemail = new ExpenseReport($db); }*/ } elseif (preg_match('/<(.*@.*)>/', $reference, $reg)) { @@ -1928,305 +1963,324 @@ class EmailCollector extends CommonObject } // Do operations - foreach ($this->actions as $operation) { - $errorforthisaction = 0; + if ($mode < 2) { + foreach ($this->actions as $operation) { + $errorforthisaction = 0; - if ($errorforactions) { - break; - } - if (empty($operation['status'])) { - continue; - } - - // Make Operation - dol_syslog("Execute action ".$operation['type']." actionparam=".$operation['actionparam'].' thirdpartystatic->id='.$thirdpartystatic->id.' contactstatic->id='.$contactstatic->id.' projectstatic->id='.$projectstatic->id); - dol_syslog("Execute action fk_element_id=".$fk_element_id." fk_element_type=".$fk_element_type); // If a Dolibarr tracker id is found, we should now the id of object - - $actioncode = 'EMAIL_IN'; - // If we scan the Sent box, we use the code for out email - if ($this->source_directory == 'Sent') { - $actioncode = 'EMAIL_OUT'; - } - - $description = $descriptiontitle = $descriptionmeta = $descriptionfull = ''; - - $descriptiontitle = $langs->trans("RecordCreatedByEmailCollector", $this->ref, $msgid); - - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTopic").' : '.dol_escape_htmltag($subject)); - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)' : '').' : '.dol_escape_htmltag($fromstring)); - if ($sender) { - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)' : '').' : '.dol_escape_htmltag($sender)); - } - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)' : '').' : '.dol_escape_htmltag($to)); - if ($sendtocc) { - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)' : '').' : '.dol_escape_htmltag($sendtocc)); - } - - // Search and create thirdparty - if ($operation['type'] == 'loadthirdparty' || $operation['type'] == 'loadandcreatethirdparty') { - if (empty($operation['actionparam'])) { - $errorforactions++; - $this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be a rule like 'name=HEADER:^From:(.*);' or 'name=SET:xxx' or 'name=EXTRACT:(body|subject):regex where 'name' can be replaced with 'id' or 'email' to define how to set or extract data. More properties can also be set, for example client=SET:2;"; - $this->errors[] = $this->error; - } else { - $actionparam = $operation['actionparam']; - $idtouseforthirdparty = ''; - $nametouseforthirdparty = ''; - $emailtouseforthirdparty = ''; - - // $actionparam = 'param=SET:aaa' or 'param=EXTRACT:BODY:....' - $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); - foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { - $sourcestring = ''; - $sourcefield = ''; - $regexstring = ''; - $regforregex = array(); - - if (preg_match('/^EXTRACT:([a-zA-Z0-9_]+):(.*)$/', $valueforproperty, $regforregex)) { - $sourcefield = $regforregex[1]; - $regexstring = $regforregex[2]; - } - - if (!empty($sourcefield) && !empty($regexstring)) { - if (strtolower($sourcefield) == 'body') { - $sourcestring = $messagetext; - } elseif (strtolower($sourcefield) == 'subject') { - $sourcestring = $subject; - } elseif (strtolower($sourcefield) == 'header') { - $sourcestring = $header; - } - - if ($sourcestring) { - $regforval = array(); - //var_dump($regexstring);var_dump($sourcestring); - if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval)) { - //var_dump($regforval[count($regforval)-1]);exit; - // Overwrite param $tmpproperty - if ($propertytooverwrite == 'id') { - $idtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; - } elseif ($propertytooverwrite == 'email') { - $emailtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; - } else { - $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; - } - } else { - // Regex not found - $idtouseforthirdparty = null; - $nametouseforthirdparty = null; - $emailtouseforthirdparty = null; - } - //var_dump($object->$tmpproperty);exit; - } else { - // Nothing can be done for this param - $errorforactions++; - $this->error = 'The extract rule to use to load thirdparty has on an unknown source (must be HEADER, SUBJECT or BODY)'; - $this->errors[] = $this->error; - } - } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $reg)) { - //if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $reg[1]; - //else $object->$tmpproperty = $reg[1]; - if ($propertytooverwrite == 'id') { - $idtouseforthirdparty = $reg[2]; - } elseif ($propertytooverwrite == 'email') { - $emailtouseforthirdparty = $reg[2]; - } else { - $nametouseforthirdparty = $reg[2]; - } - } else { - $errorforactions++; - $this->error = 'Bad syntax for description of action parameters: '.$actionparam; - $this->errors[] = $this->error; - break; - } - } - - if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty)) { - $result = $thirdpartystatic->fetch($idtouseforthirdparty, $nametouseforthirdparty, '', '', '', '', '', '', '', '', $emailtouseforthirdparty); - if ($result < 0) { - $errorforactions++; - $this->error = 'Error when getting thirdparty with name '.$nametouseforthirdparty.' (may be 2 record exists with same name ?)'; - $this->errors[] = $this->error; - break; - } elseif ($result == 0) { - if ($operation['type'] == 'loadthirdparty') { - dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found"); - - $errorforactions++; - $langs->load("errors"); - $this->error = $langs->trans('ErrorFailedToLoadThirdParty', $idtouseforthirdparty, $emailtouseforthirdparty, $nametouseforthirdparty); - $this->errors[] = $this->error; - } elseif ($operation['type'] == 'loadandcreatethirdparty') { - dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found. We try to create it."); - - // Create thirdparty - $thirdpartystatic->name = $nametouseforthirdparty; - if ($fromtext != $nametouseforthirdparty) { - $thirdpartystatic->name_alias = $fromtext; - } - $thirdpartystatic->email = ($emailtouseforthirdparty ? $emailtouseforthirdparty : $from); - - // Overwrite values with values extracted from source email - $errorforthisaction = $this->overwritePropertiesOfObject($thirdpartystatic, $operation['actionparam'], $messagetext, $subject, $header); - - if ($thirdpartystatic->client && empty($thirdpartystatic->code_client)) { - $thirdpartystatic->code_client = 'auto'; - } - if ($thirdpartystatic->fournisseur && empty($thirdpartystatic->code_fournisseur)) { - $thirdpartystatic->code_fournisseur = 'auto'; - } - - if ($errorforthisaction) { - $errorforactions++; - } else { - $result = $thirdpartystatic->create($user); - if ($result <= 0) { - $errorforactions++; - $this->error = $thirdpartystatic->error; - $this->errors = $thirdpartystatic->errors; - } - } - } - } - } + if ($errorforactions) { + break; + } + if (empty($operation['status'])) { + continue; } - } elseif ($operation['type'] == 'recordevent') { - // Create event - $actioncomm = new ActionComm($this->db); - $alreadycreated = $actioncomm->fetch(0, '', '', $msgid); - if ($alreadycreated == 0) { - if ($projectstatic->id > 0) { - if ($projectfoundby) { - $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); - } - } - if ($thirdpartystatic->id > 0) { - if ($thirdpartyfoundby) { - $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); - } - } - if ($contactstatic->id > 0) { - if ($contactfoundby) { - $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); - } - } + // Make Operation + dol_syslog("Execute action ".$operation['type']." actionparam=".$operation['actionparam'].' thirdpartystatic->id='.$thirdpartystatic->id.' contactstatic->id='.$contactstatic->id.' projectstatic->id='.$projectstatic->id); + dol_syslog("Execute action fk_element_id=".$fk_element_id." fk_element_type=".$fk_element_type); // If a Dolibarr tracker id is found, we should now the id of object - $description = $descriptiontitle; - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $descriptionmeta); - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $messagetext); + $actioncode = 'EMAIL_IN'; + // If we scan the Sent box, we use the code for out email + if ($this->source_directory == 'Sent') { + $actioncode = 'EMAIL_OUT'; + } - $descriptionfull = $description; - if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); - } + $description = $descriptiontitle = $descriptionmeta = $descriptionfull = ''; - // Insert record of emails sent - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_'.$actioncode; - $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; - $actioncomm->note_private = $descriptionfull; - $actioncomm->fk_project = $projectstatic->id; - $actioncomm->datep = $date; // date of email - $actioncomm->datef = $date; // date of email - $actioncomm->percentage = -1; // Not applicable - $actioncomm->socid = $thirdpartystatic->id; - $actioncomm->contact_id = $contactstatic->id; - $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action - // Fields when action is an email (content should be added into note) - $actioncomm->email_msgid = $msgid; - $actioncomm->email_from = $fromstring; - $actioncomm->email_sender = $sender; - $actioncomm->email_to = $to; - $actioncomm->email_tocc = $sendtocc; - $actioncomm->email_tobcc = $sendtobcc; - $actioncomm->email_subject = $subject; - $actioncomm->errors_to = ''; + $descriptiontitle = $langs->trans("RecordCreatedByEmailCollector", $this->ref, $msgid); - if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user'))) { - $actioncomm->fk_element = $fk_element_id; - $actioncomm->elementid = $fk_element_id; - $actioncomm->elementtype = $fk_element_type; - if (is_object($objectemail) && $objectemail->module) { - $actioncomm->elementtype .= '@'.$objectemail->module; - } - } + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTopic").' : '.dol_escape_htmltag($subject)); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)' : '').' : '.dol_escape_htmltag($fromstring)); + if ($sender) { + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)' : '').' : '.dol_escape_htmltag($sender)); + } + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)' : '').' : '.dol_escape_htmltag($to)); + if ($sendtocc) { + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)' : '').' : '.dol_escape_htmltag($sendtocc)); + } - //$actioncomm->extraparams = $extraparams; - - // Overwrite values with values extracted from source email - $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); - - //var_dump($fk_element_id); - //var_dump($fk_element_type); - //var_dump($alreadycreated); - //var_dump($operation['type']); - //var_dump($actioncomm); - //exit; - - if ($errorforthisaction) { + // Search and create thirdparty + if ($operation['type'] == 'loadthirdparty' || $operation['type'] == 'loadandcreatethirdparty') { + if (empty($operation['actionparam'])) { $errorforactions++; + $this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be a rule like 'name=HEADER:^From:(.*);' or 'name=SET:xxx' or 'name=EXTRACT:(body|subject):regex where 'name' can be replaced with 'id' or 'email' to define how to set or extract data. More properties can also be set, for example client=SET:2;"; + $this->errors[] = $this->error; } else { - $result = $actioncomm->create($user); - if ($result <= 0) { - $errorforactions++; - $this->errors = $actioncomm->errors; + $actionparam = $operation['actionparam']; + $idtouseforthirdparty = ''; + $nametouseforthirdparty = ''; + $emailtouseforthirdparty = ''; + + // $actionparam = 'param=SET:aaa' or 'param=EXTRACT:BODY:....' + $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); + foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { + $sourcestring = ''; + $sourcefield = ''; + $regexstring = ''; + $regforregex = array(); + + if (preg_match('/^EXTRACT:([a-zA-Z0-9_]+):(.*)$/', $valueforproperty, $regforregex)) { + $sourcefield = $regforregex[1]; + $regexstring = $regforregex[2]; + } + + if (!empty($sourcefield) && !empty($regexstring)) { + if (strtolower($sourcefield) == 'body') { + $sourcestring = $messagetext; + } elseif (strtolower($sourcefield) == 'subject') { + $sourcestring = $subject; + } elseif (strtolower($sourcefield) == 'header') { + $sourcestring = $header; + } + + if ($sourcestring) { + $regforval = array(); + //var_dump($regexstring);var_dump($sourcestring); + if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval)) { + //var_dump($regforval[count($regforval)-1]);exit; + // Overwrite param $tmpproperty + if ($propertytooverwrite == 'id') { + $idtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtolower($sourcefield).' -> Found idtouseforthirdparty='.dol_escape_htmltag($idtouseforthirdparty); + } elseif ($propertytooverwrite == 'email') { + $emailtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtolower($sourcefield).' -> Found propertytooverwrite='.dol_escape_htmltag($propertytooverwrite); + } else { + $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtolower($sourcefield).' -> Found nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); + } + } else { + // Regex not found + $idtouseforthirdparty = null; + $nametouseforthirdparty = null; + $emailtouseforthirdparty = null; + + $operationslog .= '
Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtolower($sourcefield).' -> Not found'; + } + //var_dump($object->$tmpproperty);exit; + } else { + // Nothing can be done for this param + $errorforactions++; + $this->error = 'The extract rule to use to load thirdparty has an unknown source (must be HEADER, SUBJECT or BODY)'; + $this->errors[] = $this->error; + } + } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $reg)) { + //if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $reg[1]; + //else $object->$tmpproperty = $reg[1]; + if ($propertytooverwrite == 'id') { + $idtouseforthirdparty = $reg[2]; + + $operationslog .= '
We set property idtouseforthrdparty='.dol_escape_htmltag($idtouseforthirdparty); + } elseif ($propertytooverwrite == 'email') { + $emailtouseforthirdparty = $reg[2]; + + $operationslog .= '
We set property emailtouseforthrdparty='.dol_escape_htmltag($emailtouseforthirdparty); + } else { + $nametouseforthirdparty = $reg[2]; + + $operationslog .= '
We set property nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); + } + } else { + $errorforactions++; + $this->error = 'Bad syntax for description of action parameters: '.$actionparam; + $this->errors[] = $this->error; + break; + } + } + + if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty)) { + $result = $thirdpartystatic->fetch($idtouseforthirdparty, $nametouseforthirdparty, '', '', '', '', '', '', '', '', $emailtouseforthirdparty); + if ($result < 0) { + $errorforactions++; + $this->error = 'Error when getting thirdparty with name '.$nametouseforthirdparty.' (may be 2 record exists with same name ?)'; + $this->errors[] = $this->error; + break; + } elseif ($result == 0) { + if ($operation['type'] == 'loadthirdparty') { + dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found"); + + $errorforactions++; + $langs->load("errors"); + $this->error = $langs->trans('ErrorFailedToLoadThirdParty', $idtouseforthirdparty, $emailtouseforthirdparty, $nametouseforthirdparty); + $this->errors[] = $this->error; + } elseif ($operation['type'] == 'loadandcreatethirdparty') { + dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found. We try to create it."); + + // Create thirdparty + $thirdpartystatic->name = $nametouseforthirdparty; + if ($fromtext != $nametouseforthirdparty) { + $thirdpartystatic->name_alias = $fromtext; + } + $thirdpartystatic->email = ($emailtouseforthirdparty ? $emailtouseforthirdparty : $from); + + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($thirdpartystatic, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + + if ($thirdpartystatic->client && empty($thirdpartystatic->code_client)) { + $thirdpartystatic->code_client = 'auto'; + } + if ($thirdpartystatic->fournisseur && empty($thirdpartystatic->code_fournisseur)) { + $thirdpartystatic->code_fournisseur = 'auto'; + } + + if ($errorforthisaction) { + $errorforactions++; + } else { + $result = $thirdpartystatic->create($user); + if ($result <= 0) { + $errorforactions++; + $this->error = $thirdpartystatic->error; + $this->errors = $thirdpartystatic->errors; + } else { + $operationslog .= '
Thirdparty created -> id = '.dol_escape_htmltag($thirdpartystatic->id); + } + } + } + } } } - } - } elseif ($operation['type'] == 'recordjoinpiece') { - $pj = getAttachments($imapemail, $connection); - foreach ($pj as $key => $val) { - $data[$val['filename']] = getFileData($imapemail, $val['pos'], $val['type'], $connection); - } - if (count($pj) > 0) { - $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."user WHERE email LIKE '%".$this->db->escape($from)."%'"; - $resql = $this->db->query($sql); - if ($this->db->num_rows($resql) == 0) { - $this->errors[] = 'User Not allowed to add documents'; + } elseif ($operation['type'] == 'recordevent') { + // Create event + $actioncomm = new ActionComm($this->db); + + $alreadycreated = $actioncomm->fetch(0, '', '', $msgid); + if ($alreadycreated == 0) { + if ($projectstatic->id > 0) { + if ($projectfoundby) { + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); + } + } + if ($thirdpartystatic->id > 0) { + if ($thirdpartyfoundby) { + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + } + } + if ($contactstatic->id > 0) { + if ($contactfoundby) { + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + } + } + + $description = $descriptiontitle; + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $descriptionmeta); + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $messagetext); + + $descriptionfull = $description; + if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); + } + + // Insert record of emails sent + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->code = 'AC_'.$actioncode; + $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; + $actioncomm->note_private = $descriptionfull; + $actioncomm->fk_project = $projectstatic->id; + $actioncomm->datep = $date; // date of email + $actioncomm->datef = $date; // date of email + $actioncomm->percentage = -1; // Not applicable + $actioncomm->socid = $thirdpartystatic->id; + $actioncomm->contact_id = $contactstatic->id; + $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action + // Fields when action is an email (content should be added into note) + $actioncomm->email_msgid = $msgid; + $actioncomm->email_from = $fromstring; + $actioncomm->email_sender = $sender; + $actioncomm->email_to = $to; + $actioncomm->email_tocc = $sendtocc; + $actioncomm->email_tobcc = $sendtobcc; + $actioncomm->email_subject = $subject; + $actioncomm->errors_to = ''; + + if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user'))) { + $actioncomm->fk_element = $fk_element_id; + $actioncomm->elementid = $fk_element_id; + $actioncomm->elementtype = $fk_element_type; + if (is_object($objectemail) && $objectemail->module) { + $actioncomm->elementtype .= '@'.$objectemail->module; + } + } + + //$actioncomm->extraparams = $extraparams; + + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + + //var_dump($fk_element_id); + //var_dump($fk_element_type); + //var_dump($alreadycreated); + //var_dump($operation['type']); + //var_dump($actioncomm); + //exit; + + if ($errorforthisaction) { + $errorforactions++; + } else { + $result = $actioncomm->create($user); + if ($result <= 0) { + $errorforactions++; + $this->errors = $actioncomm->errors; + } else { + $operationslog .= '
Event created -> id='.dol_escape_htmltag($actioncomm->id); + } + } } - $arrayobject = array( + } elseif ($operation['type'] == 'recordjoinpiece') { + $pj = getAttachments($imapemail, $connection); + foreach ($pj as $key => $val) { + $data[$val['filename']] = getFileData($imapemail, $val['pos'], $val['type'], $connection); + } + if (count($pj) > 0) { + $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."user WHERE email LIKE '%".$this->db->escape($from)."%'"; + $resql = $this->db->query($sql); + if ($this->db->num_rows($resql) == 0) { + $this->errors[] = 'User Not allowed to add documents'; + } + $arrayobject = array( 'propale' => array('table' => 'propal', - 'fields' => array('ref'), - 'class' => 'comm/propal/class/propal.class.php', - 'object' => 'Propal'), + 'fields' => array('ref'), + 'class' => 'comm/propal/class/propal.class.php', + 'object' => 'Propal'), 'holiday' => array('table' => 'holiday', - 'fields' => array('ref'), - 'class' => 'holiday/class/holiday.class.php', - 'object' => 'Holiday'), + 'fields' => array('ref'), + 'class' => 'holiday/class/holiday.class.php', + 'object' => 'Holiday'), 'expensereport' => array('table' => 'expensereport', - 'fields' => array('ref'), - 'class' => 'expensereport/class/expensereport.class.php', - 'object' => 'ExpenseReport'), + 'fields' => array('ref'), + 'class' => 'expensereport/class/expensereport.class.php', + 'object' => 'ExpenseReport'), 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentjobposition.class.php', - 'object' => 'RecruitmentJobPosition'), + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentjobposition.class.php', + 'object' => 'RecruitmentJobPosition'), 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentcandidature', - 'fields' => array('ref'), - 'class' => 'recruitment/class/recruitmentcandidature.class.php', - 'object' => ' RecruitmentCandidature'), + 'fields' => array('ref'), + 'class' => 'recruitment/class/recruitmentcandidature.class.php', + 'object' => ' RecruitmentCandidature'), 'societe' => array('table' => 'societe', 'fields' => array('code_client', 'code_fournisseur'), 'class' => 'societe/class/societe.class.php', 'object' => 'Societe'), - 'commande' => array('table' => 'commande', + 'commande' => array('table' => 'commande', 'fields' => array('ref'), 'class' => 'commande/class/commande.class.php', 'object' => 'Commande'), - 'expedition' => array('table' => 'expedition', + 'expedition' => array('table' => 'expedition', 'fields' => array('ref'), 'class' => 'expedition/class/expedition.class.php', 'object' => 'Expedition'), - 'contract' => array('table' => 'contrat', + 'contract' => array('table' => 'contrat', 'fields' => array('ref'), 'class' => 'contrat/class/contrat.class.php', 'object' => 'Contrat'), - 'fichinter' => array('table' => 'fichinter', + 'fichinter' => array('table' => 'fichinter', 'fields' => array('ref'), 'class' => 'fichinter/class/fichinter.class.php', 'object' => 'Fichinter'), @@ -2234,395 +2288,407 @@ class EmailCollector extends CommonObject 'fields' => array('ref'), 'class' => 'ticket/class/ticket.class.php', 'object' => ' Ticket'), - 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', + 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord', 'fields' => array('ref'), 'class' => 'knowledgemanagement/class/knowledgemanagement.class.php', 'object' => 'KnowledgeRecord'), - 'supplier_proposal' => array('table' => 'supplier_proposal', + 'supplier_proposal' => array('table' => 'supplier_proposal', 'fields' => array('ref'), 'class' => 'supplier_proposal/class/supplier_proposal.class.php', 'object' => 'SupplierProposal'), - 'fournisseur/commande' => array('table' => 'commande_fournisseur', + 'fournisseur/commande' => array('table' => 'commande_fournisseur', 'fields' => array('ref', 'ref_supplier'), 'class' => 'fourn/class/fournisseur.commande.class.php', 'object' => 'SupplierProposal'), - 'facture' => array('table' => 'facture', + 'facture' => array('table' => 'facture', 'fields' => array('ref'), 'class' => 'compta/facture/class/facture.class.php', 'object' => 'Facture'), - 'fournisseur/facture' => array('table' => 'facture_fourn', + 'fournisseur/facture' => array('table' => 'facture_fourn', 'fields' => array('ref', ref_client), 'class' => 'fourn/class/fournisseur.facture.class.php', 'object' => 'FactureFournisseur'), - 'produit' => array('table' => 'product', + 'produit' => array('table' => 'product', 'fields' => array('ref'), 'class' => 'product/class/product.class.php', 'object' => 'Product'), - 'productlot' => array('table' => 'product_lot', + 'productlot' => array('table' => 'product_lot', 'fields' => array('batch'), 'class' => 'product/stock/class/productlot.class.php', 'object' => 'Productlot'), - 'projet' => array('table' => 'projet', + 'projet' => array('table' => 'projet', 'fields' => array('ref'), 'class' => 'projet/class/projet.class.php', 'object' => 'Project'), - 'projet_task' => array('table' => 'projet_task', + 'projet_task' => array('table' => 'projet_task', 'fields' => array('ref'), 'class' => 'projet/class/task.class.php', 'object' => 'Task'), - 'ressource' => array('table' => 'resource', + 'ressource' => array('table' => 'resource', 'fields' => array('ref'), 'class' => 'ressource/class/dolressource.class.php', 'object' => 'Dolresource'), - 'bom' => array('table' => 'bom_bom', + 'bom' => array('table' => 'bom_bom', 'fields' => array('ref'), 'class' => 'bom/class/bom.class.php', 'object' => 'BOM'), - 'mrp' => array('table' => 'mrp_mo', + 'mrp' => array('table' => 'mrp_mo', 'fields' => array('ref'), 'class' => 'mrp/class/mo.class.php', 'object' => 'Mo'), - ); + ); - if (!is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($this->db); - } - $hookmanager->initHooks(array('emailcolector')); - $parameters = array('arrayobject' => $arrayobject); - $reshook = $hookmanager->executeHooks('addmoduletoeamailcollectorjoinpiece', $parameters); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) { - $arrayobject = $hookmanager->resArray; - } - - $resultobj = array(); - - foreach ($arrayobject as $key => $objectdesc) { - $sql = 'SELECT DISTINCT t.rowid '; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $objectdesc['table'] . ' AS t'; - $sql .= ' WHERE '; - foreach ($objectdesc['fields'] as $field) { - $sql .= "'" .$this->db->escape($subject) . "' LIKE CONCAT('%', t." . $field . ", '%') OR "; + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('emailcolector')); + $parameters = array('arrayobject' => $arrayobject); + $reshook = $hookmanager->executeHooks('addmoduletoeamailcollectorjoinpiece', $parameters); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $arrayobject = $hookmanager->resArray; } - $sql = substr($sql, 0, -4); - $ressqlobj = $this->db->query($sql); - if ($ressqlobj) { - while ($obj = $this->db->fetch_object($ressqlobj)) { - $resultobj[$key][] = $obj->rowid; + $resultobj = array(); + + foreach ($arrayobject as $key => $objectdesc) { + $sql = 'SELECT DISTINCT t.rowid '; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $objectdesc['table'] . ' AS t'; + $sql .= ' WHERE '; + foreach ($objectdesc['fields'] as $field) { + $sql .= "'" .$this->db->escape($subject) . "' LIKE CONCAT('%', t." . $field . ", '%') OR "; + } + $sql = substr($sql, 0, -4); + + $ressqlobj = $this->db->query($sql); + if ($ressqlobj) { + while ($obj = $this->db->fetch_object($ressqlobj)) { + $resultobj[$key][] = $obj->rowid; + } } } + $dirs = array(); + foreach ($resultobj as $mod => $ids) { + $moddesc = $arrayobject[$mod]; + $elementpath = $mod; + dol_include_once($moddesc['class']); + $objectmanaged = new $moddesc['object']($this->db); + foreach ($ids as $val) { + $res = $objectmanaged->fetch($val); + if ($res) { + $path = ($objectmanaged->entity > 1 ? "/" . $objectmanaged->entity : ''); + $dirs[] = DOL_DATA_ROOT . $path . "/" . $elementpath . '/' . dol_sanitizeFileName($objectmanaged->ref) . '/'; + } else { + $this->errors[] = 'object not found'; + } + } + } + foreach ($dirs as $target) { + foreach ($data as $filename => $content) { + $prefix = $this->actions[$this->id]['actionparam']; + + $resr = saveAttachment($target, $prefix . '_' . $filename, $content); + if ($resr == -1) { + $this->errors[] = 'Doc not saved'; + } + } + } + + $operationslog .= '
Save attachment files on disk'; + } else { + $this->errors[] = 'no joined piece'; + + $operationslog .= '
No joinded files'; } - $dirs = array(); - foreach ($resultobj as $mod => $ids) { - $moddesc = $arrayobject[$mod]; - $elementpath = $mod; - dol_include_once($moddesc['class']); - $objectmanaged = new $moddesc['object']($this->db); - foreach ($ids as $val) { - $res = $objectmanaged->fetch($val); - if ($res) { - $path = ($objectmanaged->entity > 1 ? "/" . $objectmanaged->entity : ''); - $dirs[] = DOL_DATA_ROOT . $path . "/" . $elementpath . '/' . dol_sanitizeFileName($objectmanaged->ref) . '/'; + } elseif ($operation['type'] == 'project') { + // Create project / lead + $projecttocreate = new Project($this->db); + $alreadycreated = $projecttocreate->fetch(0, '', '', $msgid); + if ($alreadycreated == 0) { + if ($thirdpartystatic->id > 0) { + $projecttocreate->socid = $thirdpartystatic->id; + if ($thirdpartyfoundby) { + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + } + } + if ($contactstatic->id > 0) { + $projecttocreate->contact_id = $contactstatic->id; + if ($contactfoundby) { + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + } + } + + $description = $descriptiontitle; + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $descriptionmeta); + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $messagetext); + + $descriptionfull = $description; + if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); + } + + $id_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'rowid'); + $percent_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'percent'); + + $projecttocreate->title = $subject; + $projecttocreate->date_start = $date; // date of email + $projecttocreate->date_end = ''; + $projecttocreate->opp_status = $id_opp_status; + $projecttocreate->opp_percent = $percent_opp_status; + $projecttocreate->description = dol_concatdesc(dolGetFirstLineOfText(dol_string_nohtmltag($description, 2), 10), '...'.$langs->transnoentities("SeePrivateNote").'...'); + $projecttocreate->note_private = $descriptionfull; + $projecttocreate->entity = $conf->entity; + $projecttocreate->email_msgid = $msgid; + + $savesocid = $projecttocreate->socid; + + // Overwrite values with values extracted from source email. + // This may overwrite any $projecttocreate->xxx properties. + $errorforthisaction = $this->overwritePropertiesOfObject($projecttocreate, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + + // Set project ref if not yet defined + if (empty($projecttocreate->ref)) { + // Get next Ref + $defaultref = ''; + $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; + + // Search template files + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); + if (file_exists($file)) { + $filefound = 1; + $classname = $modele; + break; + } + } + + if ($filefound) { + if ($savesocid > 0) { + if ($savesocid != $projecttocreate->socid) { + $errorforactions++; + setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$projecttocreate->socid.') by setting socid in operation with a different value', null, 'errors'); + } + } else { + if ($projecttocreate->socid > 0) { + $thirdpartystatic->fetch($projecttocreate->socid); + } + } + + $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); + $modModuleToUseForNextValue = new $classname; + $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate); + } + $projecttocreate->ref = $defaultref; + } + + + if ($errorforthisaction) { + $errorforactions++; + } else { + if (empty($projecttocreate->ref) || (is_numeric($projecttocreate->ref) && $projecttocreate->ref <= 0)) { + $errorforactions++; + $this->error = 'Failed to create project: Can\'t get a valid value for the field ref with numbering template = '.$modele.', thirdparty id = '.$thirdpartystatic->id; } else { - $this->errors[] = 'object not found'; + // Create project + $result = $projecttocreate->create($user); + if ($result <= 0) { + $errorforactions++; + $this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error); + $this->errors = $projecttocreate->errors; + } else { + if ($attachments) { + $destdir = $conf->project->dir_output.'/'.$projecttocreate->ref; + if (!dol_is_dir($destdir)) { + dol_mkdir($destdir); + } + if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { + foreach ($attachments as $attachment) { + $attachment->save($destdir.'/'); + } + } else { + $this->getmsg($connection, $imapemail, $destdir); + } + + $operationslog .= '
Project created with attachments -> id='.dol_escape_htmltag($projecttocreate->id); + } else { + $operationslog .= '
Project created without attachments -> id='.dol_escape_htmltag($projecttocreate->id); + } + } } } } - foreach ($dirs as $target) { - foreach ($data as $filename => $content) { - $prefix = $this->actions[$this->id]['actionparam']; + } elseif ($operation['type'] == 'ticket') { + // Create ticket + $tickettocreate = new Ticket($this->db); - $resr = saveAttachment($target, $prefix . '_' . $filename, $content); - if ($resr == -1) { - $this->errors[] = 'Doc not saved'; + $alreadycreated = $tickettocreate->fetch(0, '', '', $msgid); + if ($alreadycreated == 0) { + if ($thirdpartystatic->id > 0) { + $tickettocreate->socid = $thirdpartystatic->id; + $tickettocreate->fk_soc = $thirdpartystatic->id; + if ($thirdpartyfoundby) { + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + } + } + if ($contactstatic->id > 0) { + $tickettocreate->contact_id = $contactstatic->id; + if ($contactfoundby) { + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + } + } + + $description = $descriptiontitle; + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $descriptionmeta); + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $messagetext); + + $descriptionfull = $description; + if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); + } + + $tickettocreate->subject = $subject; + $tickettocreate->message = $description; + $tickettocreate->type_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_type', 'use_default', 'code', 1)); + $tickettocreate->category_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_category', 'use_default', 'code', 1)); + $tickettocreate->severity_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_severity', 'use_default', 'code', 1)); + $tickettocreate->origin_email = $from; + $tickettocreate->fk_user_create = $user->id; + $tickettocreate->datec = dol_now(); + $tickettocreate->fk_project = $projectstatic->id; + $tickettocreate->notify_tiers_at_create = 0; + $tickettocreate->note_private = $descriptionfull; + $tickettocreate->entity = $conf->entity; + $tickettocreate->email_msgid = $msgid; + $tickettocreate->email_date = $date; + //$tickettocreate->fk_contact = $contactstatic->id; + + $savesocid = $tickettocreate->socid; + + // Overwrite values with values extracted from source email. + // This may overwrite any $projecttocreate->xxx properties. + $errorforthisaction = $this->overwritePropertiesOfObject($tickettocreate, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + + // Set ticket ref if not yet defined + if (empty($tickettocreate->ref)) { + // Get next Ref + $defaultref = ''; + $modele = empty($conf->global->TICKET_ADDON) ? 'mod_ticket_simple' : $conf->global->TICKET_ADDON; + + // Search template files + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); + if (file_exists($file)) { + $filefound = 1; + $classname = $modele; + break; + } + } + + if ($filefound) { + if ($savesocid > 0) { + if ($savesocid != $tickettocreate->socid) { + $errorforactions++; + setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$tickettocreate->socid.') by setting socid in operation with a different value', null, 'errors'); + } + } else { + if ($tickettocreate->socid > 0) { + $thirdpartystatic->fetch($tickettocreate->socid); + } + } + + $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); + $modModuleToUseForNextValue = new $classname; + $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); + } + $tickettocreate->ref = $defaultref; + } + + if ($errorforthisaction) { + $errorforactions++; + } else { + if (is_numeric($tickettocreate->ref) && $tickettocreate->ref <= 0) { + $errorforactions++; + $this->error = 'Failed to create ticket: Can\'t get a valid value for the field ref with numbering template = '.$modele.', thirdparty id = '.$thirdpartystatic->id; + } else { + // Create project + $result = $tickettocreate->create($user); + if ($result <= 0) { + $errorforactions++; + $this->error = 'Failed to create ticket: '.$langs->trans($tickettocreate->error); + $this->errors = $tickettocreate->errors; + } else { + if ($attachments) { + $destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref; + if (!dol_is_dir($destdir)) { + dol_mkdir($destdir); + } + if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { + foreach ($attachments as $attachment) { + $attachment->save($destdir.'/'); + } + } else { + $this->getmsg($connection, $imapemail, $destdir); + } + + $operationslog .= '
Ticket created with attachments -> id='.dol_escape_htmltag($tickettocreate->id); + } else { + $operationslog .= '
Ticket created without attachments -> id='.dol_escape_htmltag($tickettocreate->id); + } + } } } } - } else { - $this->errors[] = 'no joined piece'; - } - } elseif ($operation['type'] == 'project') { - // Create project / lead - $projecttocreate = new Project($this->db); - $alreadycreated = $projecttocreate->fetch(0, '', '', $msgid); - if ($alreadycreated == 0) { - if ($thirdpartystatic->id > 0) { - $projecttocreate->socid = $thirdpartystatic->id; - if ($thirdpartyfoundby) { - $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); - } - } - if ($contactstatic->id > 0) { - $projecttocreate->contact_id = $contactstatic->id; - if ($contactfoundby) { - $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); - } - } + } elseif ($operation['type'] == 'candidature') { + // Create candidature + $candidaturetocreate = new RecruitmentCandidature($this->db); - $description = $descriptiontitle; - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $descriptionmeta); - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $messagetext); + $alreadycreated = $candidaturetocreate->fetch(0, '', $msgid); + if ($alreadycreated == 0) { + $description = $descriptiontitle; + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $descriptionmeta); + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $messagetext); - $descriptionfull = $description; - if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { + $descriptionfull = $description; $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); $descriptionfull = dol_concatdesc($descriptionfull, $header); - } - $id_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'rowid'); - $percent_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'percent'); + $candidaturetocreate->subject = $subject; + $candidaturetocreate->message = $description; + $candidaturetocreate->type_code = 0; + $candidaturetocreate->category_code = null; + $candidaturetocreate->severity_code = null; + $candidaturetocreate->email = $from; + //$candidaturetocreate->lastname = $langs->trans("Anonymous").' - '.$from; + $candidaturetocreate->fk_user_creat = $user->id; + $candidaturetocreate->date_creation = dol_now(); + $candidaturetocreate->fk_project = $projectstatic->id; + $candidaturetocreate->description = $description; + $candidaturetocreate->note_private = $descriptionfull; + $candidaturetocreate->entity = $conf->entity; + $candidaturetocreate->email_msgid = $msgid; + $candidaturetocreate->email_date = $date; // date of email + $candidaturetocreate->status = $candidaturetocreate::STATUS_DRAFT; + //$candidaturetocreate->fk_contact = $contactstatic->id; - $projecttocreate->title = $subject; - $projecttocreate->date_start = $date; // date of email - $projecttocreate->date_end = ''; - $projecttocreate->opp_status = $id_opp_status; - $projecttocreate->opp_percent = $percent_opp_status; - $projecttocreate->description = dol_concatdesc(dolGetFirstLineOfText(dol_string_nohtmltag($description, 2), 10), '...'.$langs->transnoentities("SeePrivateNote").'...'); - $projecttocreate->note_private = $descriptionfull; - $projecttocreate->entity = $conf->entity; - $projecttocreate->email_msgid = $msgid; + // Overwrite values with values extracted from source email. + // This may overwrite any $projecttocreate->xxx properties. + $errorforthisaction = $this->overwritePropertiesOfObject($candidaturetocreate, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); - $savesocid = $projecttocreate->socid; - - // Overwrite values with values extracted from source email. - // This may overwrite any $projecttocreate->xxx properties. - $errorforthisaction = $this->overwritePropertiesOfObject($projecttocreate, $operation['actionparam'], $messagetext, $subject, $header); - - // Set project ref if not yet defined - if (empty($projecttocreate->ref)) { - // Get next Ref - $defaultref = ''; - $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; - - // Search template files - $file = ''; $classname = ''; $filefound = 0; $reldir = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); - if (file_exists($file)) { - $filefound = 1; - $classname = $modele; - break; - } - } - - if ($filefound) { - if ($savesocid > 0) { - if ($savesocid != $projecttocreate->socid) { - $errorforactions++; - setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$projecttocreate->socid.') by setting socid in operation with a different value', null, 'errors'); - } - } else { - if ($projecttocreate->socid > 0) { - $thirdpartystatic->fetch($projecttocreate->socid); - } - } - - $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); - $modModuleToUseForNextValue = new $classname; - $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate); - } - $projecttocreate->ref = $defaultref; - } - - - if ($errorforthisaction) { - $errorforactions++; - } else { - if (empty($projecttocreate->ref) || (is_numeric($projecttocreate->ref) && $projecttocreate->ref <= 0)) { - $errorforactions++; - $this->error = 'Failed to create project: Can\'t get a valid value for the field ref with numbering template = '.$modele.', thirdparty id = '.$thirdpartystatic->id; - } else { - // Create project - $result = $projecttocreate->create($user); - if ($result <= 0) { - $errorforactions++; - $this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error); - $this->errors = $projecttocreate->errors; - } else { - if ($attachments) { - $destdir = $conf->project->dir_output.'/'.$projecttocreate->ref; - if (!dol_is_dir($destdir)) { - dol_mkdir($destdir); - } - if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { - foreach ($attachments as $attachment) { - $attachment->save($destdir.'/'); - } - } else { - $this->getmsg($connection, $imapemail, $destdir); - } - } - } - } - } - } - } elseif ($operation['type'] == 'ticket') { - // Create ticket - $tickettocreate = new Ticket($this->db); - - $alreadycreated = $tickettocreate->fetch(0, '', '', $msgid); - if ($alreadycreated == 0) { - if ($thirdpartystatic->id > 0) { - $tickettocreate->socid = $thirdpartystatic->id; - $tickettocreate->fk_soc = $thirdpartystatic->id; - if ($thirdpartyfoundby) { - $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); - } - } - if ($contactstatic->id > 0) { - $tickettocreate->contact_id = $contactstatic->id; - if ($contactfoundby) { - $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); - } - } - - $description = $descriptiontitle; - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $descriptionmeta); - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $messagetext); - - $descriptionfull = $description; - if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); - } - - $tickettocreate->subject = $subject; - $tickettocreate->message = $description; - $tickettocreate->type_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_type', 'use_default', 'code', 1)); - $tickettocreate->category_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_category', 'use_default', 'code', 1)); - $tickettocreate->severity_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_severity', 'use_default', 'code', 1)); - $tickettocreate->origin_email = $from; - $tickettocreate->fk_user_create = $user->id; - $tickettocreate->datec = dol_now(); - $tickettocreate->fk_project = $projectstatic->id; - $tickettocreate->notify_tiers_at_create = 0; - $tickettocreate->note_private = $descriptionfull; - $tickettocreate->entity = $conf->entity; - $tickettocreate->email_msgid = $msgid; - $tickettocreate->email_date = $date; - //$tickettocreate->fk_contact = $contactstatic->id; - - $savesocid = $tickettocreate->socid; - - // Overwrite values with values extracted from source email. - // This may overwrite any $projecttocreate->xxx properties. - $errorforthisaction = $this->overwritePropertiesOfObject($tickettocreate, $operation['actionparam'], $messagetext, $subject, $header); - - // Set ticket ref if not yet defined - if (empty($tickettocreate->ref)) { - // Get next Ref - $defaultref = ''; - $modele = empty($conf->global->TICKET_ADDON) ? 'mod_ticket_simple' : $conf->global->TICKET_ADDON; - - // Search template files - $file = ''; $classname = ''; $filefound = 0; $reldir = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); - if (file_exists($file)) { - $filefound = 1; - $classname = $modele; - break; - } - } - - if ($filefound) { - if ($savesocid > 0) { - if ($savesocid != $tickettocreate->socid) { - $errorforactions++; - setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$tickettocreate->socid.') by setting socid in operation with a different value', null, 'errors'); - } - } else { - if ($tickettocreate->socid > 0) { - $thirdpartystatic->fetch($tickettocreate->socid); - } - } - - $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); - $modModuleToUseForNextValue = new $classname; - $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); - } - $tickettocreate->ref = $defaultref; - } - - if ($errorforthisaction) { - $errorforactions++; - } else { - if (is_numeric($tickettocreate->ref) && $tickettocreate->ref <= 0) { - $errorforactions++; - $this->error = 'Failed to create ticket: Can\'t get a valid value for the field ref with numbering template = '.$modele.', thirdparty id = '.$thirdpartystatic->id; - } else { - // Create project - $result = $tickettocreate->create($user); - if ($result <= 0) { - $errorforactions++; - $this->error = 'Failed to create ticket: '.$langs->trans($tickettocreate->error); - $this->errors = $tickettocreate->errors; - } else { - if ($attachments) { - $destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref; - if (!dol_is_dir($destdir)) { - dol_mkdir($destdir); - } - if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { - foreach ($attachments as $attachment) { - $attachment->save($destdir.'/'); - } - } else { - $this->getmsg($connection, $imapemail, $destdir); - } - } - } - } - } - } - } elseif ($operation['type'] == 'candidature') { - // Create candidature - $candidaturetocreate = new RecruitmentCandidature($this->db); - - $alreadycreated = $candidaturetocreate->fetch(0, '', $msgid); - if ($alreadycreated == 0) { - $description = $descriptiontitle; - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $descriptionmeta); - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $messagetext); - - $descriptionfull = $description; - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); - - $candidaturetocreate->subject = $subject; - $candidaturetocreate->message = $description; - $candidaturetocreate->type_code = 0; - $candidaturetocreate->category_code = null; - $candidaturetocreate->severity_code = null; - $candidaturetocreate->email = $from; - //$candidaturetocreate->lastname = $langs->trans("Anonymous").' - '.$from; - $candidaturetocreate->fk_user_creat = $user->id; - $candidaturetocreate->date_creation = dol_now(); - $candidaturetocreate->fk_project = $projectstatic->id; - $candidaturetocreate->description = $description; - $candidaturetocreate->note_private = $descriptionfull; - $candidaturetocreate->entity = $conf->entity; - $candidaturetocreate->email_msgid = $msgid; - $candidaturetocreate->email_date = $date; // date of email - $candidaturetocreate->status = $candidaturetocreate::STATUS_DRAFT; - //$candidaturetocreate->fk_contact = $contactstatic->id; - - // Overwrite values with values extracted from source email. - // This may overwrite any $projecttocreate->xxx properties. - $errorforthisaction = $this->overwritePropertiesOfObject($candidaturetocreate, $operation['actionparam'], $messagetext, $subject, $header); - - // Set candidature ref if not yet defined - /*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status - { + // Set candidature ref if not yet defined + /*if (empty($candidaturetocreate->ref)) We do not need this because we create object in draft status + { // Get next Ref $defaultref = ''; $modele = empty($conf->global->CANDIDATURE_ADDON) ? 'mod_candidature_simple' : $conf->global->CANDIDATURE_ADDON; @@ -2658,68 +2724,73 @@ class EmailCollector extends CommonObject $defaultref = $modModuleToUseForNextValue->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); } $candidaturetocreate->ref = $defaultref; - }*/ + }*/ - if ($errorforthisaction) { - $errorforactions++; - } else { - // Create project - $result = $candidaturetocreate->create($user); - if ($result <= 0) { + if ($errorforthisaction) { $errorforactions++; - $this->error = 'Failed to create ticket: '.join(', ', $candidaturetocreate->errors); - $this->errors = $candidaturetocreate->errors; + } else { + // Create project + $result = $candidaturetocreate->create($user); + if ($result <= 0) { + $errorforactions++; + $this->error = 'Failed to create ticket: '.join(', ', $candidaturetocreate->errors); + $this->errors = $candidaturetocreate->errors; + } + + $operationslog .= '
Candidature created without attachments -> id='.dol_escape_htmltag($candidaturetocreate->id); } } - } - } elseif (substr($operation['type'], 0, 4) == 'hook') { - // Create event specific on hook - // this code action is hook..... for support this call - if (!is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($this->db); + } elseif (substr($operation['type'], 0, 4) == 'hook') { + // Create event specific on hook + // this code action is hook..... for support this call + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + + $parameters = array( + 'connection'=> $connection, + 'imapemail'=>$imapemail, + 'overview'=>$overview, + + 'from' => $from, + 'fromtext' => $fromtext, + + 'actionparam'=> $operation['actionparam'], + + 'thirdpartyid' => $thirdpartyid, + 'objectid'=> $objectid, + 'objectemail'=> $objectemail, + + 'messagetext'=>$messagetext, + 'subject'=>$subject, + 'header'=>$header, + 'attachments'=>$attachments, + ); + $reshook = $hookmanager->executeHooks('doCollectImapOneCollector', $parameters, $this, $operation['type']); + + if ($reshook < 0) { + $errorforthisaction++; + $this->error = $hookmanager->resPrint; + } + if ($errorforthisaction) { + $errorforactions++; + $operationslog .= '
Hook doCollectImapOneCollector executed with error'; + } else { + $operationslog .= '
Hook doCollectImapOneCollector executed without error'; + } } - $parameters = array( - 'connection'=> $connection, - 'imapemail'=>$imapemail, - 'overview'=>$overview, - - 'from' => $from, - 'fromtext' => $fromtext, - - 'actionparam'=> $operation['actionparam'], - - 'thirdpartyid' => $thirdpartyid, - 'objectid'=> $objectid, - 'objectemail'=> $objectemail, - - 'messagetext'=>$messagetext, - 'subject'=>$subject, - 'header'=>$header, - 'attachments'=>$attachments, - ); - $reshook = $hookmanager->executeHooks('doColleimapctOneCollector', $parameters, $this, $operation['type']); - - if ($reshook < 0) { - $errorforthisaction++; - $this->error = $hookmanager->resPrint; + if (!$errorforactions) { + $nbactiondoneforemail++; } - if ($errorforthisaction) { - $errorforactions++; - } - } - - - if (!$errorforactions) { - $nbactiondoneforemail++; } } // Error for email or not ? if (!$errorforactions) { - if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { - if ($targetdir) { + if ($targetdir && empty($mode)) { + if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG); $res = imap_mail_move($connection, $imapemail, $targetdir, 0); if ($res == false) { @@ -2729,9 +2800,10 @@ class EmailCollector extends CommonObject dol_syslog(imap_last_error()); } } else { - dol_syslog("EmailCollector::doCollectOneCollector message ".$imapemail." to ".$connectstringtarget." was set to read", LOG_DEBUG); - // TODO Make the move + // TODO Move mail using PHP-IMAP } + } else { + dol_syslog("EmailCollector::doCollectOneCollector message ".$imapemail." to ".$connectstringtarget." was set to read", LOG_DEBUG); } } else { $errorforemail++; @@ -2749,7 +2821,11 @@ class EmailCollector extends CommonObject $nbactiondone += $nbactiondoneforemail; $nbemailok++; - $this->db->commit(); + if (empty($mode)) { + $this->db->commit(); + } else { + $this->db->rollback(); + } // Stop the loop to process email if we reach maximum collected per collect if ($this->maxemailpercollect > 0 && $nbemailok >= $this->maxemailpercollect) { @@ -2773,19 +2849,23 @@ class EmailCollector extends CommonObject if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { $client->disconnect(); } else { - imap_expunge($connection); // To validate any move - + if (empty($mode)) { + imap_expunge($connection); // To validate any move + } imap_close($connection); } $this->datelastresult = $now; $this->lastresult = $output; - $this->debuginfo = 'IMAP search string used : '.$search; + $this->debuginfo .= 'IMAP search string used : '.$search; if ($searchhead) { - $this->debuginfo .= '
Then search string into email header : '.$searchhead; + $this->debuginfo .= '
Then search string into email header : '.dol_escape_htmltag($searchhead); + } + if ($operationslog) { + $this->debuginfo .= $operationslog; } - if (!$error) { + if (empty($error) && empty($mode)) { $this->datelastok = $now; } @@ -2793,11 +2873,14 @@ class EmailCollector extends CommonObject $this->lastresult .= "
".join("
", $this->errors); } $this->codelastresult = ($error ? 'KO' : 'OK'); - $this->update($user); + + if (empty($mode)) { + $this->update($user); + } dol_syslog("EmailCollector::doCollectOneCollector end", LOG_DEBUG); - return $error ?-1 : 1; + return $error ? -1 : 1; } @@ -2853,6 +2936,7 @@ class EmailCollector extends CommonObject 2.2.1 text/plain 2.2.2 text/html */ + /** * Sub function for getpart(). Only called by createPartArray() and itself. * @@ -2971,10 +3055,10 @@ class EmailCollector extends CommonObject /** * Converts a string from one encoding to another. * - * @param string $string String to convert - * @param string $fromEncoding String encoding - * @param string $toEncoding String return encoding - * @return string Converted string if conversion was successful, or the original string if not + * @param string $string String to convert + * @param string $fromEncoding String encoding + * @param string $toEncoding String return encoding + * @return string Converted string if conversion was successful, or the original string if not * @throws Exception */ protected function convertStringEncoding($string, $fromEncoding, $toEncoding = 'UTF-8') diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index c19610f14ad..cff80aa4153 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -158,6 +158,7 @@ class EmailCollectorFilter extends CommonObject public function create(User $user, $notrigger = false) { global $langs; + if (empty($this->type)) { $langs->load("errors"); $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); @@ -169,6 +170,12 @@ class EmailCollectorFilter extends CommonObject return -2; } + if (in_array($this->type, array('to')) && strpos($this->rulevalue, '+') != false) { + $langs->load("errors"); + $this->errors[] = $langs->trans("ErrorCharPlusNotSupportedByImapForSearch"); + return -3; + } + return $this->createCommon($user, $notrigger); } diff --git a/htdocs/eventorganization/conferenceorboothattendee_note.php b/htdocs/eventorganization/conferenceorboothattendee_note.php index b6e343e4496..ea186041602 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_note.php +++ b/htdocs/eventorganization/conferenceorboothattendee_note.php @@ -28,7 +28,6 @@ //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu @@ -38,7 +37,6 @@ //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 24489288554..6d31298e3c2 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2016 Yasser Carreón - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2020 Lenin Rivas * Copyright (C) 2022 Josep Lluís Amador * @@ -35,6 +35,7 @@ * \brief Card of a shipment */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; @@ -213,13 +214,13 @@ if (empty($reshook)) { $db->begin(); $object->note = GETPOST('note', 'alpha'); - $object->origin = $origin; + $object->origin = $origin; $object->origin_id = $origin_id; $object->fk_project = GETPOST('projectid', 'int'); - $object->weight = GETPOST('weight', 'int') == '' ? "NULL" : GETPOST('weight', 'int'); - $object->sizeH = GETPOST('sizeH', 'int') == '' ? "NULL" : GETPOST('sizeH', 'int'); - $object->sizeW = GETPOST('sizeW', 'int') == '' ? "NULL" : GETPOST('sizeW', 'int'); - $object->sizeS = GETPOST('sizeS', 'int') == '' ? "NULL" : GETPOST('sizeS', 'int'); + $object->weight = GETPOST('weight', 'int') == '' ? "NULL" : GETPOST('weight', 'int'); + $object->sizeH = GETPOST('sizeH', 'int') == '' ? "NULL" : GETPOST('sizeH', 'int'); + $object->sizeW = GETPOST('sizeW', 'int') == '' ? "NULL" : GETPOST('sizeW', 'int'); + $object->sizeS = GETPOST('sizeS', 'int') == '' ? "NULL" : GETPOST('sizeS', 'int'); $object->size_units = GETPOST('size_units', 'int'); $object->weight_units = GETPOST('weight_units', 'int'); @@ -232,8 +233,8 @@ if (empty($reshook)) { $object->ref_customer = GETPOST('ref_customer', 'alpha'); $object->model_pdf = GETPOST('model'); $object->date_delivery = $date_delivery; // Date delivery planed - $object->fk_delivery_address = $objectsrc->fk_delivery_address; - $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); + $object->fk_delivery_address = $objectsrc->fk_delivery_address; + $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->tracking_number = GETPOST('tracking_number', 'alpha'); $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -264,7 +265,7 @@ if (empty($reshook)) { $qty .= '_'.$j; while (GETPOSTISSET($batch)) { // save line of detail into sub_qty - $sub_qty[$j]['q'] = GETPOST($qty, 'int'); // the qty we want to move for this stock record + $sub_qty[$j]['q'] = price2num(GETPOST($qty, 'alpha'), 'MS'); // the qty we want to move for this stock record $sub_qty[$j]['id_batch'] = GETPOST($batch, 'int'); // the id into llx_product_batch of stock record to move $subtotalqty += $sub_qty[$j]['q']; @@ -284,12 +285,13 @@ if (empty($reshook)) { $totalqty += $subtotalqty; } else { - // No detail were provided for lots, so if a qty was provided, we can show an error. + // No detail were provided for lots, so if a qty was provided, we can throw an error. if (GETPOST($qty)) { // We try to set an amount // Case we dont use the list of available qty for each warehouse/lot // GUI does not allow this yet - setEventMessages($langs->trans("StockIsRequiredToChooseWhichLotToUse"), null, 'errors'); + setEventMessages($langs->trans("StockIsRequiredToChooseWhichLotToUse").' ('.$langs->trans("Line").' '.GETPOST($idl, 'int').')', null, 'errors'); + $error++; } } } elseif (GETPOSTISSET($stockLocation)) { @@ -327,7 +329,7 @@ if (empty($reshook)) { //var_dump($batch_line[2]); - if ($totalqty > 0) { // There is at least one thing to ship + if ($totalqty > 0 && !$error) { // There is at least one thing to ship and no error for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; if (!isset($batch_line[$i])) { @@ -387,9 +389,9 @@ if (empty($reshook)) { $error++; } } - } else { + } elseif (!$error) { $labelfieldmissing = $langs->transnoentitiesnoconv("QtyToShip"); - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { $labelfieldmissing .= '/'.$langs->transnoentitiesnoconv("Warehouse"); } setEventMessages($langs->trans("ErrorFieldRequired", $labelfieldmissing), null, 'errors'); @@ -407,11 +409,17 @@ if (empty($reshook)) { } } elseif ($action == 'create_delivery' && $conf->delivery_note->enabled && $user->rights->expedition->delivery->creer) { // Build a receiving receipt + $db->begin(); + $result = $object->create_delivery($user); if ($result > 0) { + $db->commit(); + header("Location: ".DOL_URL_ROOT.'/delivery/card.php?action=create_delivery&id='.$result); exit; } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && @@ -429,10 +437,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -474,7 +482,7 @@ if (empty($reshook)) { // setEventMessages($object->error, $object->errors, 'errors'); // } //} - } elseif ($action == 'setdate_livraison' && $user->rights->expedition->creer) { + } elseif ($action == 'setdate_livraison' && !empty($user->rights->expedition->creer)) { $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); @@ -548,6 +556,7 @@ if (empty($reshook)) { $object->fetch($id); $lines = $object->lines; $line = new ExpeditionLigne($db); + $line->fk_expedition = $object->id; $num_prod = count($lines); for ($i = 0; $i < $num_prod; $i++) { @@ -589,6 +598,7 @@ if (empty($reshook)) { for ($i = 0; $i < $num_prod; $i++) { if ($lines[$i]->id == $line_id) { // we have found line to update $line = new ExpeditionLigne($db); + $line->fk_expedition = $object->id; // Extrafields Lines $line->array_options = $extrafields->getOptionalsFromPost($object->table_element_line); @@ -729,7 +739,7 @@ if (empty($reshook)) { unset($_POST[$qty]); } } - } elseif (empty($conf->stock->enabled) && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. + } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. $qty = "qtyl".$line_id; $line->id = $line_id; $line->qty = GETPOST($qty, 'int'); @@ -763,10 +773,10 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -855,7 +865,7 @@ if ($action == 'create') { $author = new User($db); $author->fetch($object->user_author_id); - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { $entrepot = new Entrepot($db); } @@ -864,7 +874,6 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; if (GETPOST('entrepot_id', 'int')) { print ''; } @@ -1068,7 +1077,7 @@ if ($action == 'create') { } print ''.img_picto($langs->trans("Reset"), 'eraser').''; print '
'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')
'; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Type of product need stock change ? // Show warehouse combo list @@ -1399,7 +1411,7 @@ if ($action == 'create') { $deliverableQty = GETPOST($inputName, 'int'); } - print ''; + print ''; print ''; } else { if (!empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) { @@ -1411,7 +1423,7 @@ if ($action == 'create') { print ''; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print $tmpwarehouseObject->getNomUrl(0).' '; @@ -1681,7 +1693,7 @@ if ($action == 'create') { $text = $langs->trans("ConfirmValidateSending", $numref); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; @@ -1728,7 +1740,7 @@ if ($action == 'create') { $morehtmlref = '
'; // Ref customer shipment $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project @@ -2033,7 +2045,7 @@ if ($action == 'create') { } if ($action == 'editline') { $editColspan = 3; - if (empty($conf->stock->enabled)) { + if (!isModEnabled('stock')) { $editColspan--; } if (empty($conf->productbatch->enabled)) { @@ -2045,7 +2057,7 @@ if ($action == 'create') { } else { print $langs->trans("QtyShipped").' - '; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print $langs->trans("WarehouseSource").' - '; } if (isModEnabled('productbatch')) { @@ -2058,7 +2070,7 @@ if ($action == 'create') { } else { print '
'.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).'
'.$lines[$i]->qty_shipped.' '.$unit_order.''; if ($lines[$i]->entrepot_id > 0) { $entrepot = new Entrepot($db); @@ -2440,7 +2452,7 @@ if ($action == 'create') { if (isModEnabled('productbatch')) { $colspan++; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { $colspan++; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b1a767e197d..0790b54daa3 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -98,12 +98,6 @@ class Expedition extends CommonObject */ public $ref_customer; - /** - * @var string internal ref - * @deprecated - */ - public $ref_int; - public $brouillon; /** @@ -217,11 +211,11 @@ class Expedition extends CommonObject $this->statuts[2] = 'StatusSendingProcessed'; // List of short language codes for status - $this->statutshorts = array(); - $this->statutshorts[-1] = 'StatusSendingCanceledShort'; - $this->statutshorts[0] = 'StatusSendingDraftShort'; - $this->statutshorts[1] = 'StatusSendingValidatedShort'; - $this->statutshorts[2] = 'StatusSendingProcessedShort'; + $this->statuts_short = array(); + $this->statuts_short[-1] = 'StatusSendingCanceledShort'; + $this->statuts_short[0] = 'StatusSendingDraftShort'; + $this->statuts_short[1] = 'StatusSendingValidatedShort'; + $this->statuts_short[2] = 'StatusSendingProcessedShort'; } /** @@ -304,7 +298,6 @@ class Expedition extends CommonObject $sql .= "ref"; $sql .= ", entity"; $sql .= ", ref_customer"; - $sql .= ", ref_int"; $sql .= ", ref_ext"; $sql .= ", date_creation"; $sql .= ", fk_user_author"; @@ -329,7 +322,6 @@ class Expedition extends CommonObject $sql .= "'(PROV)'"; $sql .= ", ".((int) $conf->entity); $sql .= ", ".($this->ref_customer ? "'".$this->db->escape($this->ref_customer)."'" : "null"); - $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", ".((int) $user->id); @@ -527,7 +519,7 @@ class Expedition extends CommonObject return -1; } - $sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed"; + $sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed"; $sql .= ", e.date_valid"; $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; @@ -551,9 +543,6 @@ class Expedition extends CommonObject if ($ref_ext) { $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; } - if ($notused) { - $sql .= " AND e.ref_int='".$this->db->escape($notused)."'"; - } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -567,7 +556,6 @@ class Expedition extends CommonObject $this->socid = $obj->socid; $this->ref_customer = $obj->ref_customer; $this->ref_ext = $obj->ref_ext; - $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); @@ -719,7 +707,7 @@ class Expedition extends CommonObject } // If stock increment is done on sending (recommanded choice) - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -771,7 +759,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. - // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) + // Note: ->fk_origin_stock = id into table llx_product_batch (may be renamed into llx_product_stock_batch in another version) $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock, '', 1); if ($result < 0) { $error++; @@ -925,7 +913,7 @@ class Expedition extends CommonObject $line->rang = $orderline->rang; $line->product_type = $orderline->product_type; - if (!empty($conf->stock->enabled) && !empty($orderline->fk_product)) { + if (isModEnabled('stock') && !empty($orderline->fk_product)) { $fk_product = $orderline->fk_product; if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) { @@ -965,8 +953,9 @@ class Expedition extends CommonObject } // If product need a batch number, we should not have called this function but addline_batch instead. + // If this happen, we may have a bug in card.php page if (isModEnabled('productbatch') && !empty($orderline->fk_product) && !empty($orderline->product_tobatch)) { - $this->error = 'ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH'; + $this->error = 'ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH '.$orderline->id.' '.$orderline->fk_product; // return -4; } @@ -1221,7 +1210,7 @@ class Expedition extends CommonObject } // Stock control - if (!$error && $conf->stock->enabled && + if (!$error && isModEnabled('stock') && (($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) || ($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; @@ -1412,7 +1401,7 @@ class Expedition extends CommonObject } // Stock control - if (!$error && $conf->stock->enabled && + if (!$error && isModEnabled('stock') && (($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) || ($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; @@ -1883,7 +1872,7 @@ class Expedition extends CommonObject global $langs; $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); - $labelStatusShort = $langs->transnoentitiesnoconv($this->statutshorts[$status]); + $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) { @@ -2161,7 +2150,7 @@ class Expedition extends CommonObject $this->status = self::STATUS_CLOSED; // Will be revert to STATUS_VALIDATED at end if there is a rollback // If stock increment is done on closing - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -2338,7 +2327,7 @@ class Expedition extends CommonObject $this->billed = 0; // If stock increment is done on closing - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -2498,12 +2487,28 @@ class ExpeditionLigne extends CommonObjectLine */ public $table_element = 'expeditiondet'; + + /** + * Id of the line. Duplicate of $id. + * + * @var int + * @deprecated + */ + public $line_id; // deprecated + /** * @deprecated * @see $fk_origin_line */ public $origin_line_id; + /** + * Code of object line that is origin of the shipment line. + * + * @var string + */ + public $fk_origin; // Example: 'orderline' + /** * @var int ID */ @@ -2533,8 +2538,16 @@ class ExpeditionLigne extends CommonObjectLine * @var int Id of product */ public $fk_product; + + // detail of lot and qty = array(id in llx_expeditiondet_batch, fk_expeditiondet, batch, qty, fk_origin_stock) + // We can use this to know warehouse planned to be used for each lot. public $detail_batch; + // detail of warehouses and qty + // We can use this to know warehouse when there is no lot. + public $details_entrepot; + + /** * @var int Id of warehouse */ diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index b2562734447..5d99d1c7a74 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -44,7 +44,7 @@ class ExpeditionLineBatch extends CommonObject public $qty; public $dluo_qty; // deprecated, use qty public $entrepot_id; - public $fk_origin_stock; + public $fk_origin_stock; // rowid in llx_product_batch table public $fk_expeditiondet; diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index da2fe595aec..4c540adcd9e 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -23,6 +23,7 @@ * \brief Onglet de gestion des contacts de expedition */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index 08f30446f72..71e325677e6 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -26,6 +26,7 @@ * \brief Management page of documents attached to an expedition */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 8a992e0c7ec..a644aeedbad 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -25,6 +25,7 @@ * \brief Home page of shipping area. */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index b693800e253..e697c0be6c3 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -26,6 +26,7 @@ * \brief Page to list all shipments */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -261,7 +262,10 @@ if ($sall || $search_product_category > 0 || $search_user > 0) { $sql = 'SELECT DISTINCT'; } $sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.billed, e.tracking_number, e.fk_shipping_method,"; -$sql .= " l.date_delivery as date_reception,"; +if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { + // Link for delivery fields ref and date. Does not duplicate the line because we should always have ony 1 link or 0 per shipment + $sql .= " l.date_delivery as date_reception,"; +} $sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, "; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; @@ -298,8 +302,11 @@ if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target"; +if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { + // Link for delivery fields ref and date. Does not duplicate the line because we should always have ony 1 link or 0 per shipment + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target"; +} $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON e.fk_user_author = u.rowid'; if ($search_user > 0) { // Get link to order to get the order id in eesource.fk_source $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as eesource ON eesource.fk_target = e.rowid AND eesource.targettype = 'shipping' AND eesource.sourcetype = 'commande'"; @@ -369,26 +376,28 @@ if ($search_user > 0) { // The contact on a shipment is also the contact of the order. $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = eesource.fk_source AND ec.fk_socpeople = ".((int) $search_user); } -if ($search_ref_exp) { - $sql .= natural_search('e.ref', $search_ref_exp); -} -if ($search_ref_liv) { - $sql .= natural_search('l.ref', $search_ref_liv); -} if ($search_company) { $sql .= natural_search('s.nom', $search_company); } +if ($search_ref_exp) { + $sql .= natural_search('e.ref', $search_ref_exp); +} if ($search_datedelivery_start) { $sql .= " AND e.date_delivery >= '".$db->idate($search_datedelivery_start)."'"; } if ($search_datedelivery_end) { $sql .= " AND e.date_delivery <= '".$db->idate($search_datedelivery_end)."'"; } -if ($search_datereceipt_start) { - $sql .= " AND l.date_delivery >= '".$db->idate($search_datereceipt_start)."'"; -} -if ($search_datereceipt_end) { - $sql .= " AND l.date_delivery <= '".$db->idate($search_datereceipt_end)."'"; +if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { + if ($search_ref_liv) { + $sql .= natural_search('l.ref', $search_ref_liv); + } + if ($search_datereceipt_start) { + $sql .= " AND l.date_delivery >= '".$db->idate($search_datereceipt_start)."'"; + } + if ($search_datereceipt_end) { + $sql .= " AND l.date_delivery <= '".$db->idate($search_datereceipt_end)."'"; + } } if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); @@ -693,7 +702,7 @@ if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { // Delivery method print ''; $shipment->fetch_delivery_methods(); - print $form->selectarray("search_shipping_method_id", $shipment->meths, $search_shipping_method_id, 1, 0, 0, "", 1); + print $form->selectarray("search_shipping_method_id", $shipment->meths, $search_shipping_method_id, 1, 0, 0, "", 1, 0, 0, '', 'maxwidth150'); print "'; + print ''; if ($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); print '
'; @@ -641,7 +642,7 @@ if ($id > 0 || !empty($ref)) { print ''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("KeepToShip").''.$langs->trans("RealStock").' '; print $product->stock_reel; if ($product->stock_reel < $toBeShipped[$objp->fk_product]) { @@ -857,7 +858,7 @@ if ($id > 0 || !empty($ref)) { print '
'; // Bouton expedier sans gestion des stocks - if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { + if (!isModEnabled('stock') && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { print ''.$langs->trans("CreateShipment").''; if ($toBeShippedTotal <= 0) { @@ -873,11 +874,11 @@ if ($id > 0 || !empty($ref)) { // Bouton expedier avec gestion des stocks - if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) { + if (isModEnabled('stock') && $object->statut == Commande::STATUS_DRAFT) { print $langs->trans("ValidateOrderFirstBeforeShipment"); } - if (!empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { + if (isModEnabled('stock') && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { //print load_fiche_titre($langs->trans("CreateShipment")); print '
'; @@ -895,7 +896,7 @@ if ($id > 0 || !empty($ref)) { //print '
'; print $langs->trans("WarehouseSource"); //print ''; - print dol_escape_htmltag($obj->note_public); + print dol_string_nohtmltag($obj->note_public); print ''; - print dol_escape_htmltag($obj->note_private); + print dol_string_nohtmltag($obj->note_private); print ''; - print ''; - print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; + print ''; + print ''; @@ -975,6 +973,7 @@ if ($object->id > 0) { $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); + $sql .= $db->plimit($limit, $offset); $cacheOfProducts = array(); $cacheOfWarehouses = array(); @@ -984,6 +983,10 @@ if ($object->id > 0) { if ($resql) { $num = $db->num_rows($resql); + if (!empty($limit != 0) || $num > $limit || $page) { + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '', $limit); + } + $i = 0; $hasinput = false; $totalarray = array(); @@ -1104,7 +1107,7 @@ if ($object->id > 0) { // Picto delete line print ''; - print ''.img_delete().''; + print ''.img_delete().''; $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; print ''; print '
'.$langs->trans("Total").''.$langs->trans("Total").''.price($totalExpectedValuation).''.price($totalRealValuation).''.price($totalRealValuation).'
'.$langs->trans("SellingPrice").''; + print '
'.$langs->trans("SellingPrice").''; if ($object->price_base_type == 'TTC') { print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { print price($object->price).' '.$langs->trans($object->price_base_type); + if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_ttc)) { + print ' - ' . price($object->price_ttc).' '.$langs->trans('TTC') . ''; + } } + print '
'.$langs->trans("MinPrice").''; + print '
'.$langs->trans("MinPrice").''; if ($object->price_base_type == 'TTC') { print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); } else { print price($object->price_min).' '.$langs->trans($object->price_base_type); + if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_min_ttc)) { + print ' - ' . price($object->price_min_ttc).' '.$langs->trans('TTC') . ''; + } } + print '
'.$langs->trans("NoRecordFound").'
\n"; print ''; + print "\n"; // End of page diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 3eed5e14c60..ce099c04745 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -22,6 +22,7 @@ * \brief Fiche d'information sur un projet */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index 5926451e321..ba293dea744 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -22,6 +22,7 @@ * \brief Page for project statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index bc313dcebfa..3e569cd557f 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -24,6 +24,7 @@ * \brief Page de gestion des documents attachees a une tache d'un projet */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index f958a3b217c..2c84872bb38 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -1102,7 +1102,7 @@ while ($i < $imaxinloop) { // Description if (!empty($arrayfields['t.description']['checked'])) { print '
'; - print dol_escape_htmltag($object->description); + print dolGetFirstLineOfText($object->description, 5); print ''.$langs->trans("Amount").''.$langs->trans("MembersNature").''.$langs->trans("VoteAllowed").''.$langs->trans("Members").''.$langs->trans("NewSubscription").'
'.yn($objp->vote).''.$membercount.'
'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')'; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Type of product need stock change ? // Show warehouse combo list @@ -1322,7 +1323,7 @@ if ($action == 'create') { $text = $langs->trans("ConfirmValidateReception", $numref); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; @@ -1685,7 +1686,7 @@ if ($action == 'create') { } if ($action == 'editline') { $editColspan = 3; - if (empty($conf->stock->enabled)) { + if (!isModEnabled('stock')) { $editColspan--; } if (empty($conf->productbatch->enabled)) { @@ -1697,7 +1698,7 @@ if ($action == 'create') { } else { print $langs->trans("QtyReceived").' - '; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print $langs->trans("WarehouseSource").' - '; } if (isModEnabled('productbatch')) { @@ -1717,7 +1718,7 @@ if ($action == 'create') { } else { print '
'.$langs->trans("QtyReceived").''.$langs->trans("WarehouseSource").''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { if ($lines[$i]->fk_product > 0) { print ''; print ''; @@ -1943,7 +1944,7 @@ if ($action == 'create') { print ''; // Warehouse source - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { if ($lines[$i]->fk_entrepot > 0) { $entrepot = new Entrepot($db); $entrepot->fetch($lines[$i]->fk_entrepot); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 85071a49b94..47b4bcdeb0d 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -71,12 +71,6 @@ class Reception extends CommonObject public $socid; public $ref_supplier; - /** - * @var int Ref int - * @deprecated - */ - public $ref_int; - public $brouillon; public $entrepot_id; public $tracking_number; @@ -149,11 +143,11 @@ class Reception extends CommonObject $this->statuts[2] = 'StatusReceptionProcessed'; // List of short language codes for status - $this->statutshorts = array(); - $this->statutshorts[-1] = 'StatusReceptionCanceledShort'; - $this->statutshorts[0] = 'StatusReceptionDraftShort'; - $this->statutshorts[1] = 'StatusReceptionValidatedShort'; - $this->statutshorts[2] = 'StatusReceptionProcessedShort'; + $this->statuts_short = array(); + $this->statuts_short[-1] = 'StatusReceptionCanceledShort'; + $this->statuts_short[0] = 'StatusReceptionDraftShort'; + $this->statuts_short[1] = 'StatusReceptionValidatedShort'; + $this->statuts_short[2] = 'StatusReceptionProcessedShort'; } /** @@ -365,13 +359,10 @@ class Reception extends CommonObject * @param int $id Id of object to load * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param string $notused Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ - public function fetch($id, $ref = '', $ref_ext = '', $notused = '') + public function fetch($id, $ref = '', $ref_ext = '') { - global $conf; - // Check parameters if (empty($id) && empty($ref) && empty($ref_ext)) { return -1; @@ -398,9 +389,6 @@ class Reception extends CommonObject if ($ref_ext) { $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; } - if ($notused) { - $sql .= " AND e.ref_int='".$this->db->escape($notused)."'"; - } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -456,8 +444,8 @@ class Reception extends CommonObject $this->brouillon = 1; } - $file = $conf->reception->dir_output."/".get_exdir($this->id, 2, 0, 0, $this, 'reception')."/".$this->id.".pdf"; - $this->pdf_filename = $file; + //$file = $conf->reception->dir_output."/".get_exdir(0, 0, 0, 1, $this, 'reception')."/".$this->id.".pdf"; + //$this->pdf_filename = $file; // Tracking url $this->getUrlTrackingStatus($obj->tracking_number); @@ -558,7 +546,7 @@ class Reception extends CommonObject } // If stock increment is done on reception (recommanded choice) - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -836,7 +824,7 @@ class Reception extends CommonObject } $fk_product = 0; - if (!empty($conf->stock->enabled) && !empty($supplierorderline->fk_product)) { + if (isModEnabled('stock') && !empty($supplierorderline->fk_product)) { $fk_product = $supplierorderline->fk_product; if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS)) { @@ -1177,9 +1165,11 @@ class Reception extends CommonObject $line = new CommandeFournisseurDispatch($this->db); $line->fetch($obj->rowid); + + // TODO Remove or keep this ? $line->fetch_product(); - $sql_commfourndet = 'SELECT qty, ref, label, description, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent'; + $sql_commfourndet = 'SELECT qty, ref, label, description, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent, total_ht, total_ttc, total_tva'; $sql_commfourndet .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet'; $sql_commfourndet .= ' WHERE rowid = '.((int) $line->fk_commandefourndet); $sql_commfourndet .= ' ORDER BY rang'; @@ -1197,6 +1187,9 @@ class Reception extends CommonObject $line->remise_percent = $obj->remise_percent; $line->label = !empty($obj->label) ? $obj->label : $line->product->label; $line->ref_supplier = $obj->ref; + $line->total_ht = $obj->total_ht; + $line->total_ttc = $obj->total_ttc; + $line->total_tva = $obj->total_tva; } else { $line->qty_asked = 0; $line->description = ''; @@ -1304,7 +1297,7 @@ class Reception extends CommonObject global $langs; $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); - $labelStatusShort = $langs->transnoentitiesnoconv($this->statutshorts[$status]); + $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) { @@ -1561,7 +1554,7 @@ class Reception extends CommonObject // If stock increment is done on closing - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -1726,7 +1719,7 @@ class Reception extends CommonObject $this->billed = 0; // If stock increment is done on closing - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $numref = $this->ref; $langs->load("agenda"); @@ -1858,7 +1851,7 @@ class Reception extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); if ($this->db->query($sql)) { // If stock increment is done on closing - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 5b10ac8bcb1..442657ecf43 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -23,6 +23,7 @@ * \brief Onglet de gestion des contacts de reception */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; diff --git a/htdocs/reception/document.php b/htdocs/reception/document.php index c349a25fd8b..10227373015 100644 --- a/htdocs/reception/document.php +++ b/htdocs/reception/document.php @@ -26,6 +26,7 @@ * \brief Management page of documents attached to an reception */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index ed5f3a715d2..62eb42924c1 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -25,6 +25,7 @@ * \brief Home page of reception area. */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 88c86168678..155e5185f57 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -24,6 +24,7 @@ * \brief Page to list all receptions */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; @@ -715,7 +716,7 @@ if ($massaction == 'createbills') { print $langs->trans('ValidateInvoices'); print ''; print ''; // Type print ''; // Bank account diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index 8c885385a7f..30279ee3538 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -23,6 +23,7 @@ * \brief Page to add payment of a salary */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; diff --git a/htdocs/salaries/payment_salary/card.php b/htdocs/salaries/payment_salary/card.php index 3e41e4269f6..2d295a23131 100644 --- a/htdocs/salaries/payment_salary/card.php +++ b/htdocs/salaries/payment_salary/card.php @@ -26,6 +26,7 @@ * \remarks Fichier presque identique a fournisseur/paiement/card.php */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 6893d701d96..8fcc7183dae 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -24,6 +24,7 @@ * \brief List of salaries payments */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; @@ -443,7 +444,7 @@ print ''; -$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); +print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, '', 1); print ''; // Chq number print ''; diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index b3a8fdaa30e..4dfd0c84e0c 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -23,6 +23,7 @@ * \brief Page for statistics of module salaries */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salariesstats.class.php'; diff --git a/htdocs/societe/admin/contact_extrafields.php b/htdocs/societe/admin/contact_extrafields.php index 6b9a872be6c..6f9a24e27fc 100644 --- a/htdocs/societe/admin/contact_extrafields.php +++ b/htdocs/societe/admin/contact_extrafields.php @@ -24,6 +24,7 @@ * \brief Page to setup extra fields of contact */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,13 +81,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index f9f5f800a04..76fd9297e2b 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -25,6 +25,7 @@ * \brief Third party module setup page */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -713,7 +714,7 @@ foreach ($profid as $key => $val) { $i++; } -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { print ''; print '\n"; print ''; diff --git a/htdocs/societe/admin/societe_extrafields.php b/htdocs/societe/admin/societe_extrafields.php index 1d77831c661..861f4888be0 100644 --- a/htdocs/societe/admin/societe_extrafields.php +++ b/htdocs/societe/admin/societe_extrafields.php @@ -24,6 +24,7 @@ * \brief Page to setup extra fields of third party */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,13 +81,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index c0525767527..550d8ca772d 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('bills', 'companies', 'orders', 'propal')); +$langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal')); if (GETPOST('actioncode', 'array')) { @@ -121,7 +121,7 @@ if ($socid > 0) { } llxHeader('', $title); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = societe_prepare_head($object); diff --git a/htdocs/societe/ajax/ajaxcompanies.php b/htdocs/societe/ajax/ajaxcompanies.php index d9c9885ecc5..08d914d562a 100644 --- a/htdocs/societe/ajax/ajaxcompanies.php +++ b/htdocs/societe/ajax/ajaxcompanies.php @@ -38,10 +38,8 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index f845c161ab2..7bdfe6e0e34 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -37,10 +37,8 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index e71ee255981..fc8794aa1a8 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -246,7 +246,7 @@ abstract class ActionsCardCommon } // Language - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1); } @@ -306,7 +306,7 @@ abstract class ActionsCardCommon $arr = $formcompany->typent_array(1); $this->tpl['typent'] = $arr[$this->object->typent_code]; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; //$s=picto_from_langcode($this->default_lang); //print ($s?$s.' ':''); diff --git a/htdocs/societe/canvas/company/tpl/card_create.tpl.php b/htdocs/societe/canvas/company/tpl/card_create.tpl.php index 58752a1bc7b..d70277dc58d 100644 --- a/htdocs/societe/canvas/company/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_create.tpl.php @@ -189,7 +189,7 @@ for ($i = 1; $i <= 4; $i++) { -global->MAIN_MULTILANGS)) { ?> + diff --git a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php index eb300cfdd4e..c432f5a6d95 100644 --- a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php @@ -211,7 +211,7 @@ for ($i = 1; $i <= 4; $i++) { -global->MAIN_MULTILANGS)) { ?> + diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index d1ba18f82fd..22c46cb93b5 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -190,7 +190,7 @@ for ($i = 1; $i <= 4; $i++) { -global->MAIN_MULTILANGS)) { ?> + @@ -263,7 +263,7 @@ for ($i = 1; $i <= 4; $i++) { ">trans("Modify"); ?> -rights->societe->supprimer) { ?> +hasRight('societe', 'supprimer')) { ?> use_javascript_ajax) { ?> trans('Delete'); ?> @@ -283,7 +283,7 @@ for ($i = 1; $i <= 4; $i++) { */ $filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; -$genallowed = $user->rights->societe->lire; +$genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); diff --git a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php index 1c8b51dac7c..1a574019948 100644 --- a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php @@ -156,7 +156,7 @@ if (isModEnabled('barcode')) { ?> -global->MAIN_MULTILANGS)) { ?> + diff --git a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php index 56192bbe4e7..adfd1d8363a 100644 --- a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php @@ -160,7 +160,7 @@ if ($this->control->tpl['fournisseur']) { -global->MAIN_MULTILANGS)) { ?> + diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 98979c917d4..11716519f16 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -131,7 +131,7 @@ if ($this->control->tpl['action_delete']) { -global->MAIN_MULTILANGS)) { ?> + @@ -190,7 +190,7 @@ if ($this->control->tpl['action_delete']) { ">trans("Modify"); ?> -rights->societe->supprimer) { ?> +hasRight('societe', 'supprimer')) { ?> use_javascript_ajax) { ?> trans('Delete'); ?> @@ -209,7 +209,7 @@ if ($this->control->tpl['action_delete']) { */ $filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; -$genallowed = $user->rights->societe->lire; +$genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 4a145a15f87..ee058f8685f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -12,7 +12,7 @@ * Copyright (C) 2015 Raphaƫl Doursenaud * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018-2021 FrƩdƩric France + * 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 @@ -50,13 +50,13 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (isModEnabled('adherent')) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; } -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; } -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; } -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; } if (isModEnabled('eventorganization')) { @@ -77,10 +77,10 @@ if (isModEnabled('categorie')) { if (!empty($conf->incoterm->enabled)) { $langs->load("incoterm"); } -if (!empty($conf->notification->enabled)) { +if (isModEnabled('notification')) { $langs->load("mails"); } -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { $langs->load("products"); } @@ -137,9 +137,9 @@ if (!empty($canvas)) { } // Permissions -$permissiontoread = $user->rights->societe->lire; +$permissiontoread = $user->hasRight('societe', 'lire'); $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); +$permissiontodelete = $user->hasRight('societe', 'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0); $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -342,6 +342,7 @@ if (empty($reshook)) { if (!$error) { //We finally remove the old thirdparty if ($soc_origin->delete($soc_origin->id, $user) < 1) { + setEventMessages($soc_origin->error, $soc_origin->errors, 'errors'); $error++; } } @@ -425,12 +426,12 @@ if (empty($reshook)) { $error++; } - if (!empty($conf->mailing->enabled) && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { + if (isModEnabled('mailing') && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors'); } - if (!empty($conf->mailing->enabled) && GETPOST("private", 'int') == 1 && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { + if (isModEnabled('mailing') && GETPOST("private", 'int') == 1 && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors'); } @@ -914,7 +915,7 @@ if (empty($reshook)) { } // Delete third party - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'supprimer')) { $object->fetch($socid); $object->oldcopy = clone $object; $result = $object->delete($socid, $user); @@ -990,7 +991,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { $formaccounting = new FormAccounting($db); } @@ -1616,13 +1617,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Email / Web print ''; - print 'browser->layout == 'phone') || empty($conf->mailing->enabled) ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' '; - if (!empty($conf->mailing->enabled) && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) { + print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' '; + if (isModEnabled('mailing') && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) { if ($conf->browser->layout == 'phone') { print ''; } print ''; - print ''; + print ''; } print ''; print ''; @@ -1803,7 +1804,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { print ''.$langs->trans("Currency".$conf->currency).''; } - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { print ''; @@ -1892,7 +1893,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { print '
'.$lines[$i]->qty.''; - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { print $form->selectyesno('validate_invoices', 0, 1, 1); print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; } else { diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index cb2c84ebd76..617d260e643 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -24,6 +24,7 @@ * \brief Note card reception */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php'; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 638b7b0dbfc..b1f5dbdc7f9 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -24,6 +24,7 @@ * \brief Page with reception statistics */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/receptionstats.class.php'; diff --git a/htdocs/reception/stats/month.php b/htdocs/reception/stats/month.php index 806006394df..019cafce8c6 100644 --- a/htdocs/reception/stats/month.php +++ b/htdocs/reception/stats/month.php @@ -22,6 +22,7 @@ * \brief Page des stats receptions par mois */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/receptionstats.class.php'; diff --git a/htdocs/recruitment/admin/candidature_extrafields.php b/htdocs/recruitment/admin/candidature_extrafields.php index 73a8398fd80..24cc74b6892 100644 --- a/htdocs/recruitment/admin/candidature_extrafields.php +++ b/htdocs/recruitment/admin/candidature_extrafields.php @@ -21,6 +21,7 @@ * \brief Page to setup extra fields of Candidature */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -78,14 +79,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/recruitment/admin/jobposition_extrafields.php b/htdocs/recruitment/admin/jobposition_extrafields.php index 95918bdd1c1..02e4eb2566d 100644 --- a/htdocs/recruitment/admin/jobposition_extrafields.php +++ b/htdocs/recruitment/admin/jobposition_extrafields.php @@ -21,6 +21,7 @@ * \brief Page to setup extra fields of Candidature */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -78,14 +79,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - /* * Creation of an optional field */ diff --git a/htdocs/recruitment/admin/public_interface.php b/htdocs/recruitment/admin/public_interface.php index f145b0b39a9..a9cbf698a10 100644 --- a/htdocs/recruitment/admin/public_interface.php +++ b/htdocs/recruitment/admin/public_interface.php @@ -24,6 +24,7 @@ * \brief File of main public page for open job position */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment.lib.php'; diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 4632d90fee6..794eed1716d 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -825,6 +825,9 @@ class RecruitmentCandidature extends CommonObject $statusType = 'status'.$status; //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; if ($status == self::STATUS_CANCELED) { + $statusType = 'status9'; + } + if ($status == self::STATUS_CONTRACT_SIGNED) { $statusType = 'status6'; } if ($status == self::STATUS_REFUSED) { diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index f95eb6682e3..d5c109a5516 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -107,7 +107,7 @@ class RecruitmentJobPosition extends CommonObject 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500', 'picto'=>'project'), 'fk_user_recruiter' => array('type'=>'integer:User:user/class/user.class.php:status=1', 'label'=>'ResponsibleOfRecruitement', 'enabled'=>'1', 'position'=>54, 'notnull'=>1, 'visible'=>1, 'foreignkey'=>'user.rowid', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150', 'picto'=>'user'), 'email_recruiter' => array('type'=>'varchar(255)', 'label'=>'EmailRecruiter', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>-1, 'help'=>'ToUseAGenericEmail', 'picto'=>'email'), - 'fk_user_supervisor' => array('type'=>'integer:User:user/class/user.class.php::t.statut = 1', 'label'=>'FutureManager', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'foreignkey'=>'user.rowid', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150', 'picto'=>'user'), + 'fk_user_supervisor' => array('type'=>'integer:User:user/class/user.class.php:t.statut = 1', 'label'=>'FutureManager', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'foreignkey'=>'user.rowid', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150', 'picto'=>'user'), 'fk_establishment' => array('type'=>'integer:Establishment:hrm/class/establishment.class.php', 'label'=>'Establishment', 'enabled'=>'$conf->hrm->enabled', 'position'=>56, 'notnull'=>0, 'visible'=>-1, 'foreignkey'=>'establishment.rowid',), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'WorkPlace', 'enabled'=>'$conf->societe->enabled', 'position'=>57, 'notnull'=>-1, 'visible'=>-1, 'css'=>'maxwidth500', 'index'=>1, 'help'=>"IfJobIsLocatedAtAPartner", 'picto'=>'company'), 'date_planned' => array('type'=>'date', 'label'=>'DateExpected', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), @@ -115,7 +115,7 @@ class RecruitmentJobPosition extends CommonObject 'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>3,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>101, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>102, 'notnull'=>0, 'visible'=>0,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-4,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), @@ -694,7 +694,7 @@ class RecruitmentJobPosition extends CommonObject if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 2e85bfab121..bf267a475c6 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -121,10 +121,10 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; $this->format = array($this->page_largeur, $this->page_hauteur); - $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; - $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; - $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; - $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; + $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 diff --git a/htdocs/recruitment/index.php b/htdocs/recruitment/index.php index 80ef1c9fbd9..03b2a9e6431 100644 --- a/htdocs/recruitment/index.php +++ b/htdocs/recruitment/index.php @@ -24,6 +24,7 @@ * \brief Home page of recruitment top menu */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; @@ -34,17 +35,22 @@ $langs->loadLangs(array("recruitment", "boxes")); $action = GETPOST('action', 'aZ09'); +$max = 5; +$now = dol_now(); -// Security check -//if (! $user->rights->recruitment->myobject->read) accessforbidden(); $socid = GETPOST('socid', 'int'); if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } -$max = 5; -$now = dol_now(); +// Security check (enable the most restrictive one) +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +// if (! $user->hasRight('mymodule', 'myobject', 'read')) { +// accessforbidden(); +// } +restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid'); /* diff --git a/htdocs/recruitment/lib/recruitment.lib.php b/htdocs/recruitment/lib/recruitment.lib.php index cb1f0b7e2bc..acc7160f282 100644 --- a/htdocs/recruitment/lib/recruitment.lib.php +++ b/htdocs/recruitment/lib/recruitment.lib.php @@ -70,5 +70,7 @@ function recruitmentAdminPrepareHead() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'recruitment'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'recruitment', 'remove'); + return $head; } diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 50a79a35872..9988140393d 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -27,8 +27,8 @@ require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); -dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentcandidature.lib.php'; // Load translation files required by the page @@ -36,9 +36,9 @@ $langs->loadLangs(array("recruitment", "other")); // Get parameters $id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { @@ -129,7 +129,7 @@ if ($object->id > 0) { $help_url = 'Module_Agenda_En'; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = recruitmentCandidaturePrepareHead($object); diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index f3d41f9de97..7f1bbab2566 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -36,14 +36,14 @@ $langs->loadLangs(array("recruitment", "other", "users")); // Get parameters $id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturecard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +//$lineid = GETPOST('lineid', 'int'); // Initialize technical objects $object = new RecruitmentCandidature($db); @@ -559,7 +559,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Contract refused / accepted if ($object->status == $object::STATUS_CONTRACT_PROPOSED) { if ($permissiontoadd) { - print ''.$langs->trans("Accept").' / '.$langs->trans("Decline").''; + print ''.$langs->trans("Accept").' / '.$langs->trans("Decline").''; } } @@ -586,7 +586,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Cancel if ($permissiontoadd) { if ($object->status == $object::STATUS_VALIDATED) { - print ''.$langs->trans("Cancel").''."\n"; + print ''.$langs->trans("Cancel").''."\n"; } elseif ($object->status == $object::STATUS_REFUSED || $object->status == $object::STATUS_CANCELED || $object->status == $object::STATUS_CONTRACT_REFUSED) { print ''.$langs->trans("Re-Open").''."\n"; } diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index f72271a3105..3f08c770111 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -28,8 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); -dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentcandidature.lib.php'; // Load translation files required by the page $langs->loadLangs(array("recruitment", "companies", "other", "mails")); @@ -118,7 +118,6 @@ if ($object->id) { } // Object card - // ------------------------------------------------------------ $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 2b1126e838f..34b852574f6 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -31,25 +31,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; -// for other modules -//dol_include_once('/othermodule/class/otherobject.class.php'); - // Load translation files required by the page $langs->loadLangs(array("recruitment", "other")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : ((empty($id) && empty($ref)) ? 'recruitmentcandidaturelist' : 'recruitmentjobposition_candidature'); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index ccb6b2a60cc..543d7a66c10 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -24,17 +24,17 @@ // Load Dolibarr environment require_once '../main.inc.php'; -dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); -dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentcandidature.lib.php'; // Load translation files required by the page $langs->loadLangs(array("recruitment", "companies")); // Get parameters $id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects @@ -139,7 +139,6 @@ if ($id > 0 || !empty($ref)) { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; print '
'; diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index 11e54486bfe..f2f4d37484b 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -27,8 +27,8 @@ require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); -dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php'; // Load translation files required by the page @@ -36,9 +36,9 @@ $langs->loadLangs(array("recruitment", "other")); // Get parameters $id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { @@ -129,7 +129,7 @@ if ($object->id > 0) { $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = recruitmentjobpositionPrepareHead($object); diff --git a/htdocs/recruitment/recruitmentjobposition_applications.php b/htdocs/recruitment/recruitmentjobposition_applications.php index 6a7d471046e..3cdca44c93e 100644 --- a/htdocs/recruitment/recruitmentjobposition_applications.php +++ b/htdocs/recruitment/recruitmentjobposition_applications.php @@ -22,52 +22,23 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); -dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php'; // Load translation files required by the page $langs->loadLangs(array("recruitment", "other")); // Get parameters $id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index cf41a06f954..a23888fd8a9 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -37,12 +37,12 @@ $langs->loadLangs(array("recruitment", "other")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +//$lineid = GETPOST('lineid', 'int'); // Initialize technical objects $object = new RecruitmentJobPosition($db); @@ -285,7 +285,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); - /*if (!empty($conf->notification->enabled)) + /*if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); @@ -426,7 +426,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close as recruited/canceled if ($object->status == $object::STATUS_VALIDATED) { if ($usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; print '>'.$langs->trans('Close').''; } else { print ''.$langs->trans('Close').''; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 5435a5a2ac2..5b1bee43e56 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -29,9 +29,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; -// for other modules -//dol_include_once('/othermodule/class/otherobject.class.php'); - // Load translation files required by the page $langs->loadLangs(array("recruitment", "other")); diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php index bbcced5326a..dcda5b53109 100644 --- a/htdocs/recruitment/recruitmentjobposition_note.php +++ b/htdocs/recruitment/recruitmentjobposition_note.php @@ -24,17 +24,17 @@ // Load Dolibarr environment require_once '../main.inc.php'; -dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); -dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php'; // Load translation files required by the page $langs->loadLangs(array("recruitment", "companies")); // Get parameters $id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects @@ -97,7 +97,6 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_head($head, 'note', $langs->trans("RecruitmentJobPosition"), -1, $object->picto); // Object card - // ------------------------------------------------------------ $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index a5af098f10b..8fddadcce11 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -28,6 +28,7 @@ * \brief Page of resource events */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 4ffbe1eb0a7..cf4b4b8e110 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -22,6 +22,7 @@ */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php index cf291cce28c..45e4ce4b329 100644 --- a/htdocs/resource/contact.php +++ b/htdocs/resource/contact.php @@ -1,5 +1,4 @@ * Copyright (C) 2007-2009 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent @@ -28,6 +27,7 @@ * \brief Contacts management tab for resources */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php index 001598d2023..6c5b4496d23 100644 --- a/htdocs/resource/document.php +++ b/htdocs/resource/document.php @@ -28,6 +28,7 @@ * \brief Page des documents joints sur les resources */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 80e25fa9c25..a5ca456310e 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -25,6 +25,7 @@ */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index d67f55f51f2..6b649b396db 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -23,6 +23,7 @@ * \brief Page to manage resource objects */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; diff --git a/htdocs/resource/note.php b/htdocs/resource/note.php index 98efb72d55b..d2c02df0481 100644 --- a/htdocs/resource/note.php +++ b/htdocs/resource/note.php @@ -25,6 +25,7 @@ * \brief Fiche d'information sur une resource */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; diff --git a/htdocs/salaries/admin/salaries.php b/htdocs/salaries/admin/salaries.php index 5343d4831ba..c30b6ff3565 100644 --- a/htdocs/salaries/admin/salaries.php +++ b/htdocs/salaries/admin/salaries.php @@ -22,6 +22,7 @@ * \brief Setup page to configure salaries module */ +// Load Dolibarr environment require '../../main.inc.php'; // Class diff --git a/htdocs/salaries/admin/salaries_extrafields.php b/htdocs/salaries/admin/salaries_extrafields.php index 86fc5991757..85b389d0697 100644 --- a/htdocs/salaries/admin/salaries_extrafields.php +++ b/htdocs/salaries/admin/salaries_extrafields.php @@ -23,6 +23,7 @@ * \brief Page to setup extra fields of salaries */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -80,13 +81,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '

'; diff --git a/htdocs/salaries/ajax/ajaxsalaries.php b/htdocs/salaries/ajax/ajaxsalaries.php index 0e0428b9074..1cbecf840d2 100644 --- a/htdocs/salaries/ajax/ajaxsalaries.php +++ b/htdocs/salaries/ajax/ajaxsalaries.php @@ -38,10 +38,8 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index d5ccbdec38f..ab4ba4cd4b8 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -26,6 +26,7 @@ * \brief Page of salaries payments */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index eb4c63390a8..163042dbeb8 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -30,6 +30,7 @@ * \brief Page of linked files onto salaries */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index 7c8962499ce..e16493ddc91 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -24,6 +24,7 @@ * \brief Page with info about salaries contribution */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index dd44155ea5a..639879f8e17 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -24,6 +24,7 @@ * \brief List of salaries payments */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -434,7 +435,7 @@ print '
'; -$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); +print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, '', 1); print '
'.$langs->trans('CustomerAccountancyCodeShort')."control->tpl['select_workforce']; echo $this->control->tpl['info_admin']; ?>
trans("DefaultLang"); ?> control->tpl['select_lang']; ?>control->tpl['select_workforce']; echo $this->control->tpl['info_admin']; ?>
trans("DefaultLang"); ?> control->tpl['select_lang']; ?>control->tpl['effectif']; ?>
trans("DefaultLang"); ?> control->tpl['default_lang']; ?>
trans("DefaultLang"); ?> control->tpl['select_lang']; ?>
trans("DefaultLang"); ?> control->tpl['select_lang']; ?>control->tpl['typent']; ?>
trans("DefaultLang"); ?> control->tpl['default_lang']; ?>
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).'
'.$form->editfieldkey($langs->trans('No_Email') .' ('.$langs->trans('Contact').')', 'contact_no_email', '', $object, 0).'browser->layout == 'phone') || empty($conf->mailing->enabled) ? ' colspan="3"' : '').'>'.$form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ? GETPOST("contact_no_email", 'alpha') : (empty($object->no_email) ? 0 : 1)), 1, false, 1).'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.$form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ? GETPOST("contact_no_email", 'alpha') : (empty($object->no_email) ? 0 : 1)), 1, false, 1).'
'.$form->editfieldkey('Web', 'url', '', $object, 0).'
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print '
'; - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { // Accountancy_code_sell print ''; print ''; @@ -2669,7 +2670,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'; print '
'.$langs->trans("ProductAccountancySellCode").''; @@ -2553,7 +2554,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Default language - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { print '
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; print img_picto('', 'language').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); print '
'; - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { // Accountancy_code_sell print ''; print ''; // Warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) { + if (isModEnabled('stock') && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -3070,7 +3071,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Default language - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''."\n"; } else { - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { $statstring = ""; $statstring .= ''; $statstring .= ""; } - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { $statstring .= ""; $statstring .= ''; $statstring .= ""; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ff6de888284..6c45982a929 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -383,8 +383,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Societe'; $objectlabel = 'ThirdParty'; - $permissiontoread = $user->rights->societe->lire; - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoread = $user->hasRight('societe', 'lire'); + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -883,7 +883,7 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->creer) { +if (isModEnabled('category') && $user->rights->societe->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if ($user->rights->societe->creer) { @@ -898,7 +898,7 @@ if ($user->rights->societe->creer) { if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); } -if ($user->rights->societe->supprimer) { +if ($user->hasRight('societe', 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -1455,24 +1455,19 @@ while ($i < min($num, $limit)) { } } if (!empty($arrayfields['s.nom']['checked'])) { - $savalias = $obj->name_alias; - if (!empty($arrayfields['s.name_alias']['checked'])) { - $companystatic->name_alias = ''; - } print 'global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').' data-key="ref">'; if ($contextpage == 'poslist') { - print $obj->name; + print dol_escape_htmltag($obj->name); } else { - print $companystatic->getNomUrl(1, '', 100, 0, 1); + print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); } print "\n"; - $companystatic->name_alias = $savalias; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['s.name_alias']['checked'])) { - print '\n"; if (!$i) { @@ -1481,7 +1476,7 @@ while ($i < min($num, $limit)) { } // Barcode if (!empty($arrayfields['s.barcode']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index dabc5d7e39e..a15f96fa1f6 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -91,7 +91,7 @@ if ($object->id > 0) { /* * Affichage onglets */ - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index a9c0bdf04d0..ba1ead0e068 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -24,6 +24,7 @@ * \brief Tab for notifications of third party */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 4e0552d3c15..b7bcd153092 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -164,7 +164,7 @@ if ($id > 0) { $object = new Societe($db); $result = $object->fetch($id); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = societe_prepare_head($object); diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index e7899db813e..6110fc7a5e5 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -79,7 +79,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $hookmanager->initHooks(array('thirdpartybancard', 'globalcard')); // Permissions -$permissiontoread = $user->rights->societe->lire; +$permissiontoread = $user->hasRight('societe', 'lire'); $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_builddoc.inc.php $permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write))); @@ -138,6 +138,7 @@ if (empty($reshook)) { $action = 'edit'; $error++; } + $companybankaccount->fetch($id); if ($companybankaccount->needIBAN() == 1) { if (!GETPOST('iban')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); @@ -151,7 +152,6 @@ if (empty($reshook)) { } } - $companybankaccount->fetch($id); if (!$error) { $companybankaccount->socid = $object->id; @@ -175,6 +175,12 @@ if (empty($reshook)) { $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); } + if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) { + // If we set a stripe value that is different than previous one, we also set the stripe account + $companypaymentmode->stripe_account = $stripecu.'@'.$site_account; + } + $companybankaccount->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); + $result = $companybankaccount->update($user); if (!$result) { setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); @@ -416,6 +422,7 @@ if (empty($reshook)) { if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes') { $companypaymentmode = new CompanyPaymentMode($db); if ($companypaymentmode->fetch($ribid ? $ribid : $id)) { + // TODO This is currently done at bottom of page instead of asking confirm /*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref)) { $payment_method = \Stripe\PaymentMethod::retrieve($companypaymentmode->stripe_card_ref); @@ -428,6 +435,7 @@ if (empty($reshook)) { $result = $companypaymentmode->delete($user); if ($result > 0) { $url = $_SERVER['PHP_SELF']."?socid=".$object->id; + header('Location: '.$url); exit; } else { @@ -440,9 +448,21 @@ if (empty($reshook)) { if ($action == 'confirm_delete' && GETPOST('confirm', 'alpha') == 'yes') { $companybankaccount = new CompanyBankAccount($db); if ($companybankaccount->fetch($ribid ? $ribid : $id)) { + // TODO This is currently done at bottom of page instead of asking confirm + /*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref)) + { + $payment_method = \Stripe\PaymentMethod::retrieve($companypaymentmode->stripe_card_ref); + if ($payment_method) + { + $payment_method->detach(); + } + }*/ + $result = $companybankaccount->delete($user); + if ($result > 0) { $url = $_SERVER['PHP_SELF']."?socid=".$object->id; + header('Location: '.$url); exit; } else { @@ -505,7 +525,7 @@ if (empty($reshook)) { } if (!$error) { - // Creation of Stripe card + update of societe_account + // Creation of Stripe card + update of llx_societe_rib // Note that with the new Stripe API, option to create a card is no more available, instead an error message will be returned to // ask to create the crdit card from Stripe backoffice. $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); @@ -517,35 +537,30 @@ if (empty($reshook)) { } } if ($action == 'syncsepatostripe') { - $companybankaccount->fetch(GETPOST('bankid', 'int')); - // print "stripe account = " . json_encode($stripe->getStripeAccount($service)); - // print json_encode($companybankaccount); - // print "fetch id = " . json_encode($socid); - - $companypaymentmode = new CompanyPaymentMode($db); - $companypaymentmode->fetch(null, null, $socid); - // print json_encode($companypaymentmode); + $companypaymentmode = new CompanyPaymentMode($db); // Get record in llx_societe_rib + $companypaymentmode->fetch($id); if ($companypaymentmode->type != 'ban') { $error++; - setEventMessages('ThisPaymentModeIsNotSepa', null, 'errors'); + $langs->load("errors"); + setEventMessages('ThisPaymentModeIsNotABan', null, 'errors'); } else { // Get the Stripe customer $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); // print json_encode($cu); - if (!$cu) { + if (empty($cu)) { $error++; - setEventMessages($stripe->error, $stripe->errors, 'errors'); + $langs->load("errors"); + setEventMessages($langs->trans("ErrorStripeCustomerNotFoundCreateFirst"), null, 'errors'); } - if (!$error) { - // Creation of Stripe SEPA + update of societe_account + // Creation of Stripe SEPA + update of llx_societe_rib $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); if (!$card) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); } else { - setEventMessages("", array("SEPA on Stripe", "SEPA IBAN is now linked to the Stripe customer account !")); + setEventMessages("", array("Bank Account on Stripe", "BAN is now linked to the Stripe customer account !")); } } } @@ -711,6 +726,37 @@ if (empty($reshook)) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } + } elseif ($action == 'delete' && $source) { + try { + if (preg_match('/pm_/', $source)) { + $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); + if ($payment_method) { + $payment_method->detach(); + } + } else { + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); + $card = $cu->sources->retrieve("$source"); + if ($card) { + // $card->detach(); Does not work with card_, only with src_ + if (method_exists($card, 'detach')) { + $card->detach(); + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib as sr "; + $sql .= " SET stripe_card_ref = null"; + $sql .= " WHERE sr.stripe_card_ref = '".$db->escape($source)."'"; + $resql = $db->query($sql); + } else { + $card->delete(); + } + } + } + + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + header('Location: '.$url); + exit; + } catch (Exception $e) { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); + } } } } @@ -938,70 +984,75 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
'; - // List of Stripe payment modes - if (!(empty($conf->stripe->enabled)) && $object->client) { + $showcardpaymentmode = 0; + if (isModEnabled('stripe')) { + $showcardpaymentmode++; + } + + // Get list of remote payment modes + $listofsources = array(); + + if (is_object($stripe)) { + try { + $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); + if (!empty($customerstripe->id)) { + // When using the Charge API architecture + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + $listofsources = $customerstripe->sources->data; + } else { + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { + $service = 'StripeLive'; + $servicestatus = 1; + } + + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); + + try { + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card")); + $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit")); + } else { + $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card"), array("stripe_account" => $stripeacc)); + $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit"), array("stripe_account" => $stripeacc)); + } + + if ($paymentmethodobjsA->data != null && $paymentmethodobjsB->data != null) { + $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data); + } elseif ($paymentmethodobjsB->data != null) { + $listofsources = $paymentmethodobjsB->data; + } else { + $listofsources = $paymentmethodobjsA->data; + } + } catch (Exception $e) { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); + } + } + } + } catch (Exception $e) { + dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); + } + } + + + // List of Card payment modes + if ($showcardpaymentmode && $object->client) { $morehtmlright = ''; if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); } - print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); + print load_fiche_titre($langs->trans('CreditCard').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'fa-credit-card'); - $listofsources = array(); - if (is_object($stripe)) { - try { - $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); - if (!empty($customerstripe->id)) { - // When using the Charge API architecture - if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - $listofsources = $customerstripe->sources->data; - } else { - $service = 'StripeTest'; - $servicestatus = 0; - if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { - $service = 'StripeLive'; - $servicestatus = 1; - } - - // Force to use the correct API key - global $stripearrayofkeysbyenv; - \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); - - try { - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card")); - $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit")); - } else { - $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card"), array("stripe_account" => $stripeacc)); - $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit"), array("stripe_account" => $stripeacc)); - } - - if ($paymentmethodobjsA->data != null && $paymentmethodobjsB->data != null) { - $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data); - } elseif ($paymentmethodobjsB->data != null) { - $listofsources = $paymentmethodobjsB->data; - } else { - $listofsources = $paymentmethodobjsA->data; - } - } catch (Exception $e) { - $error++; - setEventMessages($e->getMessage(), null, 'errors'); - } - } - } - } catch (Exception $e) { - dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); - } - } - - print ''."\n"; + print ''."\n"; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.$langs->trans("ProductAccountancySellCode").''; @@ -2966,7 +2967,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'.$langs->trans("DefaultLang").''; //$s=picto_from_langcode($object->default_lang); @@ -3113,7 +3114,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'; print $langs->trans("ProductAccountancySellCode"); print ''; - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { if (!empty($object->accountancy_code_sell)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code_sell, 1); @@ -3129,7 +3130,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'; print $langs->trans("ProductAccountancyBuyCode"); print ''; - if (!empty($conf->accounting->enabled)) { + if (isModEnabled('accounting')) { if (!empty($object->accountancy_code_buy)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $object->accountancy_code_buy, 1); @@ -3247,7 +3248,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete); - if ($user->rights->societe->supprimer) { + if ($user->hasRight('societe', 'supprimer')) { $deleteUrl = $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(); $buttonId = 'action-delete-no-ajax'; if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile @@ -3277,7 +3278,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { */ $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed = $user->rights->societe->lire; + $genallowed = $user->hasRight('societe', 'lire'); $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index f197a1b7024..c0401ce958f 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -132,7 +132,7 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -527,7 +527,7 @@ class Thirdparties extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->societe->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'supprimer')) { throw new RestException(401); } $result = $this->company->fetch($id); @@ -848,7 +848,7 @@ class Thirdparties extends DolibarrApi */ public function getOutStandingProposals($id, $mode = 'customer') { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -890,7 +890,7 @@ class Thirdparties extends DolibarrApi */ public function getOutStandingOrder($id, $mode = 'customer') { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -931,7 +931,7 @@ class Thirdparties extends DolibarrApi */ public function getOutStandingInvoices($id, $mode = 'customer') { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -972,7 +972,7 @@ class Thirdparties extends DolibarrApi */ public function getSalesRepresentatives($id, $mode = 0) { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -1015,7 +1015,7 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -1366,8 +1366,8 @@ class Thirdparties extends DolibarrApi $outputlangs = $langs; $newlang = ''; - //if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { if (isset($this->company->thirdparty->default_lang)) { $newlang = $this->company->thirdparty->default_lang; // for proposal, order, invoice, ... } elseif (isset($this->company->default_lang)) { @@ -1439,7 +1439,7 @@ class Thirdparties extends DolibarrApi */ public function getSocieteAccounts($id, $site = null) { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } @@ -1870,7 +1870,7 @@ class Thirdparties extends DolibarrApi { global $conf; - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login.'. No read permission on thirdparties.'); } diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 4ddbd1c613f..c3ecbe31ccd 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -47,6 +47,9 @@ class CompanyBankAccount extends Account public $rum; public $date_rum; + public $stripe_card_ref; // ID of BAN into an external payment system + public $stripe_account; // Account of the external payment system + /** * Date creation record (datec) * @@ -187,6 +190,8 @@ class CompanyBankAccount extends Account } else { $sql .= ",label = NULL"; } + $sql .= ",stripe_card_ref = '".$this->db->escape($this->stripe_card_ref)."'"; + $sql .= ",stripe_account = '".$this->db->escape($this->stripe_account)."'"; $sql .= " WHERE rowid = ".((int) $this->id); $result = $this->db->query($sql); @@ -232,7 +237,8 @@ class CompanyBankAccount extends Account } $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum,"; + $sql .= " stripe_card_ref, stripe_account"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) { $sql .= " WHERE rowid = ".((int) $id); @@ -274,6 +280,8 @@ class CompanyBankAccount extends Account $this->rum = $obj->rum; $this->frstrecur = $obj->frstrecur; $this->date_rum = $this->db->jdate($obj->date_rum); + $this->stripe_card_ref = $obj->stripe_card_ref; + $this->stripe_account = $obj->stripe_account; } $this->db->free($resql); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5d7b9dfee90..007c98f1840 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -700,12 +700,6 @@ class Societe extends CommonObject */ public $ref; - /** - * @var string Internal ref - * @deprecated - */ - public $ref_int; - /** * External user reference. * This is to allow external systems to store their id and make self-developed synchronizing functions easier to build. @@ -1097,7 +1091,7 @@ class Societe extends CommonObject } } - if (empty($error) && !empty($conf->mailing->enabled) && !empty($contact->email) && isset($no_email)) { + if (empty($error) && isModEnabled('mailing') && !empty($contact->email) && isset($no_email)) { $result = $contact->setNoEmail($no_email); if ($result < 0) { $this->error = $contact->error; @@ -1844,7 +1838,7 @@ class Societe extends CommonObject $this->stcomm_picto = $obj->stcomm_picto; // picto statut commercial $this->email = $obj->email; - $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); + $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : array()); $this->url = $obj->url; $this->phone = $obj->phone; @@ -2658,11 +2652,16 @@ class Societe extends CommonObject if (isset($this->status)) { $label .= ' '.$this->getLibStatut(5); } + if (isset($this->client) && isset($this->fournisseur)) { + $label .= '   '; + $label .= $this->getTypeUrl(1); + } $label .= '
'.$langs->trans('Name').': '.dol_escape_htmltag($this->name); if (!empty($this->name_alias)) { $label .= ' ('.dol_escape_htmltag($this->name_alias).')'; } + if ($this->email) { $label .= '
'.img_picto('', 'email', 'class="pictofixedwidth"').$this->email; } @@ -2711,10 +2710,10 @@ class Societe extends CommonObject if (!empty($this->code_fournisseur) && $this->fournisseur) { $label2 .= '
'.$langs->trans('SupplierCode').': '.$this->code_fournisseur; } - if (!empty($conf->accounting->enabled) && ($this->client == 1 || $this->client == 3)) { + if (isModEnabled('accounting') && ($this->client == 1 || $this->client == 3)) { $label2 .= '
'.$langs->trans('CustomerAccountancyCode').': '.($this->code_compta ? $this->code_compta : $this->code_compta_client); } - if (!empty($conf->accounting->enabled) && $this->fournisseur) { + if (isModEnabled('accounting') && $this->fournisseur) { $label2 .= '
'.$langs->trans('SupplierAccountancyCode').': '.$this->code_compta_fournisseur; } $label .= ($label2 ? '
'.$label2 : '').''; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 0c1370f7440..83961ac74cf 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -181,7 +181,7 @@ if ($object->client) { } } -if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) { +if (isModEnabled('ficheinter') && !empty($user->rights->ficheinter->lire)) { $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions'); } @@ -535,7 +535,7 @@ if ($sql_select) { // Product if ($objp->fk_product > 0) { // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod = new Product($db); $prod->fetch($objp->fk_product); diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 313947cbb0e..90267403a16 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -56,7 +56,7 @@ if (isModEnabled('categorie')) { if (!empty($conf->incoterm->enabled)) { $langs->load("incoterm"); } -if (!empty($conf->notification->enabled)) { +if (isModEnabled('notification')) { $langs->load("mails"); } diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 92c7efb63d9..ccb668f9055 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -92,7 +92,9 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'societe', $object->id, '&societe'); -$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles +if (empty($object->id)) { + accessforbidden(); +} /* @@ -115,88 +117,80 @@ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($object->id) { - /* - * Show tabs - */ - if (!empty($conf->notification->enabled)) { - $langs->load("mails"); - } - $head = societe_prepare_head($object); - - $form = new Form($db); - - print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company'); - - - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; - } - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - - print '
'; - - print '
'; - print ''; - - // Type Prospect/Customer/Supplier - print ''; - - // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field - print ''; - } - - if ($object->client) { - print ''; - } - - if ($object->fournisseur) { - print ''; - } - - // Number of files - print ''; - - // Total size - print ''; - - print '
'.$langs->trans('NatureOfThirdParty').''; - print $object->getTypeUrl(1); - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; - print $langs->trans('CustomerCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } - print '
'; - print $langs->trans('SupplierCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; - - print '
'; - - print dol_get_fiche_end(); - - $modulepart = 'societe'; - $permissiontoadd = $user->rights->societe->creer; - $permtoedit = $user->rights->societe->creer; - $param = '&id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { - accessforbidden('', 0, 0); +// Show tabs +if (isModEnabled('notification')) { + $langs->load("mails"); } +$head = societe_prepare_head($object); + +print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company'); + + +// Build file list +$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); +$totalsize = 0; +foreach ($filearray as $key => $file) { + $totalsize += $file['size']; +} + +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + +print '
'; + +print '
'; +print ''; + +// Type Prospect/Customer/Supplier +print ''; + +// Prefix +if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field + print ''; +} + +if ($object->client) { + print ''; +} + +if ($object->fournisseur) { + print ''; +} + +// Number of files +print ''; + +// Total size +print ''; + +print '
'.$langs->trans('NatureOfThirdParty').''; +print $object->getTypeUrl(1); +print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); + $tmpcheck = $object->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongCustomerCode").')'; + } + print '
'; + print $langs->trans('SupplierCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); + $tmpcheck = $object->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongSupplierCode").')'; + } + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + +print '
'; + +print dol_get_fiche_end(); + +$modulepart = 'societe'; +$permissiontoadd = $user->rights->societe->creer; +$permtoedit = $user->rights->societe->creer; +$param = '&id='.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; // End of page llxFooter(); diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 1d0bdfe39a1..e161cd8668c 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -124,10 +124,10 @@ $result = $db->query($sql); if ($result) { while ($objp = $db->fetch_object($result)) { $found = 0; - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; } - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; } if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { @@ -150,10 +150,10 @@ $thirdpartygraph .= '
'.$langs->trans("St if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) { $thirdpartygraph .= '
'; $dataseries = array(); - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { $dataseries[] = array($langs->trans("Prospects"), round($third['prospect'])); } - if (isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { $dataseries[] = array($langs->trans("Customers"), round($third['customer'])); } if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { @@ -173,12 +173,12 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + $thirdpartygraph .= $dolgraph->show(); $thirdpartygraph .= '
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'; + print ''; print dol_escape_htmltag($companystatic->name_alias); print "'.dol_escape_htmltag($obj->barcode).''.dol_escape_htmltag($obj->barcode).'
'."\n"; print ''; - if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { - print ''; - } print ''; - print ''; + print ''; // external system ID print ''; print ''; print ''; @@ -1018,7 +1069,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $nbremote = 0; $nblocal = 0; - $arrayofstripecard = array(); + $arrayofremotecard = array(); // Show local sources if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { @@ -1042,18 +1093,16 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if ($obj) { $companypaymentmodetemp->fetch($obj->rowid); - $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref; + $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref; - print ''; - print ''; + print ''; + // Label print ''; - print ''; + // Type print ''; + // Information (Owner, ...) print ''; - // Local ID - if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { - print ''; + $imgline = ''; + if ($src->object == 'card') { + $imgline = img_credit_card($src->brand); + } elseif ($src->object == 'source' && $src->type == 'card') { + $imgline = img_credit_card($src->card->brand); + } elseif ($src->object == 'payment_method' && $src->type == 'card') { + $imgline = img_credit_card($src->card->brand); + } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { + continue; + } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { + continue; } + + print ''; print ''; // Src ID - print ''; - // Img of credit card + // Img print ''; // Information print ''; + print ''; + // Fields from hook $parameters = array('arrayfields'=>array(), 'stripesource'=>$src, 'linetype'=>'stripecardremoteonly'); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Action column print '
'.$langs->trans('LocalID').''.$langs->trans('Label').''.$langs->trans('StripeID').''.$langs->trans('StripeID').''.$langs->trans('Type').''.$langs->trans('Informations').'
'; - print $companypaymentmodetemp->id; - print '
'; print dol_escape_htmltag($companypaymentmodetemp->label); print ''; - print $companypaymentmodetemp->stripe_card_ref; - if ($companypaymentmodetemp->stripe_card_ref) { + // External card ID + print ''; + if (!empty($companypaymentmodetemp->stripe_card_ref)) { $connect = ''; if (!empty($stripeacc)) { $connect = $stripeacc.'/'; @@ -1062,12 +1111,15 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if ($servicestatus) { $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; } - print ' '.img_picto($langs->trans('ShowInStripe').' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account, 'globe').''; + print ''.img_picto($langs->trans('ShowInStripe').' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account, 'globe').' '; } + print $companypaymentmodetemp->stripe_card_ref; print ''; print img_credit_card($companypaymentmodetemp->type); print ''; if ($companypaymentmodetemp->proprio) { print ''.$companypaymentmodetemp->proprio.'
'; @@ -1121,7 +1173,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; - print ' '; print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& print img_picto($langs->trans("Delete"), 'delete'); print ''; @@ -1140,24 +1191,31 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Show remote sources (not already shown as local source) if (is_array($listofsources) && count($listofsources)) { foreach ($listofsources as $src) { - if (!empty($arrayofstripecard[$src->id])) { + if (!empty($arrayofremotecard[$src->id])) { continue; // Already in previous list } $nbremote++; - print '
'; - print '
'; print ''; + print ''; $connect = ''; - print $src->id; if (!empty($stripeacc)) { $connect = $stripeacc.'/'; } @@ -1167,21 +1225,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; } - print " ".img_picto($langs->trans('ShowInStripe'), 'globe').""; + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." "; + print $src->id; print ''; - if ($src->object == 'card') { - print img_credit_card($src->brand); - } elseif ($src->object == 'source' && $src->type == 'card') { - print img_credit_card($src->card->brand); - } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { - print ''; - } elseif ($src->object == 'payment_method' && $src->type == 'card') { - print img_credit_card($src->card->brand); - } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { - print ''; - } + print $imgline; print''; @@ -1256,18 +1305,20 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $langs->trans("Remote"); //if ($src->cvc_check == 'fail') print ' - CVC check fail'; print ''; //var_dump($src); - print ''; print ''; if ($permissiontoaddupdatepaymentinformation) { - print ''; + print ''; print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1286,7 +1337,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
'; } - // List of Stripe payment modes + // List of Stripe connect accounts if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) { print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); @@ -1337,16 +1388,20 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '&action=create'); } - print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank'); + $nblocal = 0; $nbremote = 0; + $arrayofremoteban = array(); + $rib_list = $object->get_all_rib(); + if (is_array($rib_list)) { print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print ''; print ''; - print_liste_field_titre("LabelRIB"); + print_liste_field_titre("Label"); + print_liste_field_titre("StripeID"); // external system ID print_liste_field_titre("Bank"); print_liste_field_titre("RIB"); print_liste_field_titre("IBAN"); @@ -1356,17 +1411,43 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print_liste_field_titre("DateRUM"); print_liste_field_titre("WithdrawMode"); } - print_liste_field_titre("DefaultRIB", '', '', '', '', '', '', '', 'center '); + print_liste_field_titre("Default", '', '', '', '', '', '', '', 'center '); print_liste_field_titre('', '', '', '', '', '', '', '', 'center '); + // Fields from hook + $parameters = array('arrayfields'=>array(), 'linetype'=>'stripebantitle'); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); print "\n"; + // List of local BAN foreach ($rib_list as $rib) { + $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref; + + $nblocal++; + print ''; // Label - print ''; + print ''; + // Stripe ID + print ''; // Bank name - print ''; + print ''; // Account number print ''; // IBAN - print ''; - print ''; + print ''; print ''; @@ -1467,7 +1548,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $allowgenifempty = 0; // Language code (if multilang) - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); $defaultlang = $langs->getDefaultLang(); @@ -1500,12 +1581,20 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $out; print ''; + // Fields from hook + $parameters = array('arrayfields'=>array(), 'stripe_card_ref'=>$rib->stripe_card_ref, 'stripe_account'=>$rib->stripe_account, 'linetype'=>'stripeban'); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Edit/Delete print ''; } - if (count($rib_list) == 0) { - $colspan = 9; + + // List of remote BAN (if not already added as local) + foreach ($listofsources as $src) { + if (!empty($arrayofremoteban[$src->id])) { + continue; // Already in previous list + } + + $imgline = ''; + if ($src->object == 'source' && $src->type == 'sepa_debit') { + $imgline = ''; + } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { + $imgline = ''; + } else { + continue; + } + + $nbremote++; + + print ''; + print ''; + // Src ID + print ''; + // Bank + print ''; + // Account number + print ''; + // IBAN + print ''; + // BIC + print ''; + if (!empty($conf->prelevement->enabled)) { - $colspan += 2; + // RUM + print ''; + // Date + print ''; + // Mode mandate + print ''; + } + + // Default + print ''; + /* + print ''; + */ + + print ''; + + // Fields from hook + $parameters = array('arrayfields'=>array(), 'stripe_card_ref'=>$rib->stripe_card_ref, 'stripe_account'=>$rib->stripe_account, 'linetype'=>'stripebanremoteonly'); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action column + print ''; + + print ''; + } + + if ($nbremote == 0 && $nblocal == 0) { + $colspan = 10; + if (isModEnabled('prelevement')) { + $colspan += 3; } print ''; } @@ -1603,10 +1796,12 @@ if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) { print '
'; + print '
'; + print '
'; print '
'.$rib->label.''.dol_escape_htmltag($rib->label).''; + if ($rib->stripe_card_ref) { + $connect = ''; + if (!empty($stripeacc)) { + $connect = $stripeacc.'/'; + } + //$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$rib->stripe_card_ref; + if ($servicestatus) { + //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$rib->stripe_card_ref; + } + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." "; + } + print $rib->stripe_card_ref; + print ''.$rib->bank.''.dol_escape_htmltag($rib->bank).''; $string = ''; @@ -1398,7 +1479,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $string; print ''.$rib->iban; + print ''.dol_escape_htmltag($rib->iban); if (!empty($rib->iban)) { if (!checkIbanForAccount($rib)) { print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); @@ -1417,7 +1498,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (!empty($conf->prelevement->enabled)) { // RUM //print ''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''.$rib->rum.''.dol_escape_htmltag($rib->rum).''.dol_print_date($rib->date_rum, 'day').''; if ($permissiontoaddupdatepaymentinformation) { - print ''; - print img_picto($langs->trans("CreateBAN"), 'stripe'); - print ''; + if (empty($rib->stripe_card_ref)) { + // Add link to create BAN on Stripe + print ''; + print img_picto($langs->trans("CreateBANOnStripe"), 'stripe'); + print ''; + } print ''; print img_picto($langs->trans("Modify"), 'edit'); @@ -1520,10 +1609,114 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
'; + print ''; + $connect = ''; + if (!empty($stripeacc)) { + $connect = $stripeacc.'/'; + } + //$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id; + if ($servicestatus) { + //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; + } + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." "; + print $src->id; + print ''; + print''; + print ''; + //var_dump($src); + print ''; + //var_dump($src); + print ''; + //var_dump($src); + print ''; + //var_dump($src); + print ''; + //var_dump($src); + print ''; + if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) || + (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) { + print ''; + print img_picto($langs->trans("Default"), 'off'); + print ''; + } else { + print img_picto($langs->trans("Default"), 'on'); + } + print ''; + print $langs->trans("Remote"); + //if ($src->cvc_check == 'fail') print ' - CVC check fail'; + print ''; + print ''; + if ($permissiontoaddupdatepaymentinformation) { + print ''; + print img_picto($langs->trans("Delete"), 'delete'); + print ''; + } + print '
'.$langs->trans("NoBANRecord").'
'; - print ''; + print ''; print ''; print ''; @@ -1702,6 +1897,9 @@ if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) { print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ?GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0); print ''; + print '"; + print ''; + print '
'.$langs->trans("LabelRIB").'
'.$langs->trans("Label").'
'.$langs->trans("BankName").'
'.$langs->trans("StripeID")." ('src_....')
'; print '
'; } @@ -1720,9 +1918,12 @@ if ($socid && $action == 'editcard' && $permissiontoaddupdatepaymentinformation) dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - print '
'; + print '
'; print '
'; + + print '
'; + print ''; print ''; @@ -1766,9 +1967,12 @@ if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) { print '
'; print '
'; + + print '
'; + print '
'.$langs->trans("Label").'
'; - print ''; + print ''; print ''; print ''; @@ -1858,6 +2062,9 @@ if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) { print $form->selectarray("frstrecur", $tblArraychoice, (GETPOSTISSET('frstrecur') ? GETPOST('frstrecur') : 'FRST'), 0); print ''; + print '"; + print ''; + print '
'.$langs->trans("LabelRIB").'
'.$langs->trans("Label").'
'.$langs->trans("Bank").'
'.$langs->trans("StripeID")." ('src_....')
'; } @@ -1881,6 +2088,9 @@ if ($socid && $action == 'createcard' && $permissiontoaddupdatepaymentinformatio print '
'; print '
'; + + print '
'; + print ''; print ''; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 12d7a7d62fb..a75a194a0e8 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -199,7 +199,7 @@ $object = new Societe($db); $result = $object->fetch($socid); llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer')); -if (!empty($conf->notification->enabled)) { +if (isModEnabled('notification')) { $langs->load("mails"); } $head = societe_prepare_head($object); diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index f704273db60..5a8ba6a46b2 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -84,7 +84,7 @@ if ($socid) { } llxHeader('', $title); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = societe_prepare_head($object); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 8de63dfeffc..9ca58ab0bf4 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -161,8 +161,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'WebsiteAccount'; $objectlabel = 'WebsiteAccount'; - $permissiontoread = $user->rights->societe->lire; - $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoread = $user->hasRight('societe', 'lire'); + $permissiontodelete = $user->hasRight('societe', 'supprimer'); $uploaddir = $conf->societe->multidir_output[$object->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -250,7 +250,7 @@ print dol_get_fiche_end(); $newcardbutton = ''; if (isModEnabled('website')) { - if (!empty($user->rights->societe->lire)) { + if ($user->hasRight('societe', 'lire')) { $newcardbutton .= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id)); } else { $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0); diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index eb947d1dc28..33536271115 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -25,6 +25,7 @@ * \brief Page to setup stripe module */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/stripe/ajax/ajax.php b/htdocs/stripe/ajax/ajax.php index fa5392349eb..5fa4da88ae7 100644 --- a/htdocs/stripe/ajax/ajax.php +++ b/htdocs/stripe/ajax/ajax.php @@ -20,9 +20,6 @@ * \brief Ajax action for Stipe ie: Terminal */ -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -39,6 +36,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index eb30537438c..522445334eb 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -18,6 +18,7 @@ // Put here all includes required by your class file +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -26,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 6410050c642..cc8178d2a01 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -434,8 +434,10 @@ class Stripe extends CommonObject // list of payment method types $paymentmethodtypes = array("card"); + $descriptor = dol_trunc($tag, 10, 'right', 'UTF-8', 1); if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) { $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) + //$descriptor = preg_replace('/ref=[^:=]+/', '', $descriptor); // Clean ref } if (!empty($conf->global->STRIPE_KLARNA)) { $paymentmethodtypes[] = "klarna"; @@ -463,7 +465,8 @@ class Stripe extends CommonObject "currency" => $currency_code, "payment_method_types" => $paymentmethodtypes, "description" => $description, - "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => $descriptor, // For card payment, 22 chars that appears on bank receipt (prefix into stripe setup + this suffix) + "statement_descriptor" => $descriptor, // For SEPA, it will take only statement_descriptor, not statement_descriptor_suffix //"save_payment_method" => true, "setup_future_usage" => "on_session", "metadata" => $metadata @@ -589,131 +592,6 @@ class Stripe extends CommonObject } } - /** - * Get the Stripe SEPA of a company payment mode - * - * @param \Stripe\StripeCustomer $cu Object stripe customer. - * @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity) - * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) - * @param int $createifnotlinkedtostripe 1=Create the stripe sepa and the link if the sepa is not yet linked to a stripe sepa. Deprecated with new Stripe API and SCA. - * @return \Stripe\PaymentMethod|null Stripe SEPA or null if not found - */ - public function sepaStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) - { - global $conf, $user, $langs; - $sepa = null; - - $sql = "SELECT sa.stripe_card_ref, sa.proprio, sa.iban_prefix"; // stripe_card_ref is src_ for sepa - $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as sa"; - $sql .= " WHERE sa.rowid = '".$this->db->escape($object->id)."'"; // We get record from ID, no need for filter on entity - $sql .= " AND sa.type = 'ban'"; //type ban to get normal bank account of customer (prelevement) - - $soc = new Societe($this->db); - $soc->fetch($object->fk_soc); - - dol_syslog(get_class($this)."::fetch search stripe sepa(card) id for paymentmode id=".$object->id.", stripeacc=".$stripeacc.", status=".$status.", createifnotlinkedtostripe=".$createifnotlinkedtostripe, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) { - $obj = $this->db->fetch_object($resql); - $cardref = $obj->stripe_card_ref; - dol_syslog(get_class($this)."::cardStripe cardref=".$cardref); - if ($cardref) { - try { - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) { - $sepa = $cu->sources->retrieve($cardref); - } else { - $sepa = \Stripe\PaymentMethod::retrieve($cardref); - } - } else { - if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) { - //$sepa = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided - $sepa = $cu->sources->retrieve($cardref); - } else { - //$sepa = \Stripe\PaymentMethod::retrieve($cardref, array("stripe_account" => $stripeacc)); // Don't know if this works - $sepa = \Stripe\PaymentMethod::retrieve($cardref); - } - } - } catch (Exception $e) { - $this->error = $e->getMessage(); - dol_syslog($this->error, LOG_WARNING); - } - } elseif ($createifnotlinkedtostripe) { - $iban = $obj->iban_prefix; //prefix ? - $ipaddress = getUserRemoteIP(); - - $dataforcard = array( - 'type'=>'sepa_debit', - "sepa_debit" => array('iban' => $iban), - 'currency' => 'eur', - 'usage' => 'reusable', - 'owner' => array( - 'name' => $soc->name, - ), - "metadata" => array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress) - ); - - //$a = \Stripe\Stripe::getApiKey(); - //var_dump($a);var_dump($stripeacc);exit; - try { - dol_syslog("Try to create sepa_debit 0"); - - $service = 'StripeTest'; - $servicestatus = 0; - if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { - $service = 'StripeLive'; - $servicestatus = 1; - } - // Force to use the correct API key - global $stripearrayofkeysbyenv; - $stripeacc = $stripearrayofkeysbyenv[$servicestatus]['secret_key']; - - dol_syslog("Try to create sepa_debit with data = ".json_encode($dataforcard)); - $s = new \Stripe\StripeClient($stripeacc); - $sepa = $s->sources->create($dataforcard); - if (!$sepa) { - $this->error = 'Creation of sepa_debit on Stripe has failed'; - } else { - //association du client avec cette source de paimeent - $cs = $cu->createSource( - $cu->id, - [ - 'source' => $sepa->id, - ] - ); - if (!$cs) { - $this->error = 'Link SEPA <-> Customer failed'; - } else { - dol_syslog("Try to create sepa_debit 3"); - // print json_encode($sepa); - - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib"; - $sql .= " SET stripe_card_ref = '".$this->db->escape($sepa->id)."', card_type = 'sepa_debit',"; - $sql .= " stripe_account= '" . $this->db->escape($cu->id . "@" . $stripeacc) . "'"; - $sql .= " WHERE rowid = '".$this->db->escape($object->id)."'"; - $sql .= " AND type = 'ban'"; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - } - } - } - } catch (Exception $e) { - $this->error = $e->getMessage(); - dol_syslog($this->error, LOG_WARNING); - } - } - } - } else { - dol_print_error($this->db); - } - - return $sepa; - } - /** * Get the Stripe payment intent. Create it with confirmnow=false * Warning. If a payment was tried and failed, a payment intent was created. @@ -896,7 +774,7 @@ class Stripe extends CommonObject $sql .= " WHERE sa.rowid = ".((int) $object->id); // We get record from ID, no need for filter on entity $sql .= " AND sa.type = 'card'"; - dol_syslog(get_class($this)."::fetch search stripe card id for paymentmode id=".$object->id.", stripeacc=".$stripeacc.", status=".$status.", createifnotlinkedtostripe=".$createifnotlinkedtostripe, LOG_DEBUG); + dol_syslog(get_class($this)."::cardStripe search stripe card id for paymentmode id=".$object->id.", stripeacc=".$stripeacc.", status=".$status.", createifnotlinkedtostripe=".$createifnotlinkedtostripe, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -1012,6 +890,127 @@ class Stripe extends CommonObject return $card; } + + /** + * Get the Stripe SEPA of a company payment mode + * + * @param \Stripe\StripeCustomer $cu Object stripe customer. + * @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity) + * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int $status Status (0=test, 1=live) + * @param int $createifnotlinkedtostripe 1=Create the stripe sepa and the link if the sepa is not yet linked to a stripe sepa. Deprecated with new Stripe API and SCA. + * @return \Stripe\PaymentMethod|null Stripe SEPA or null if not found + */ + public function sepaStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) + { + global $conf, $user, $langs; + $sepa = null; + + $sql = "SELECT sa.stripe_card_ref, sa.proprio, sa.iban_prefix"; // stripe_card_ref is src_ for sepa + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as sa"; + $sql .= " WHERE sa.rowid = '".$this->db->escape($object->id)."'"; // We get record from ID, no need for filter on entity + $sql .= " AND sa.type = 'ban'"; //type ban to get normal bank account of customer (prelevement) + + $soc = new Societe($this->db); + $soc->fetch($object->fk_soc); + + dol_syslog(get_class($this)."::sepaStripe search stripe ban id for paymentmode id=".$object->id.", stripeacc=".$stripeacc.", status=".$status.", createifnotlinkedtostripe=".$createifnotlinkedtostripe, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) { + $obj = $this->db->fetch_object($resql); + $cardref = $obj->stripe_card_ref; + dol_syslog(get_class($this)."::sepaStripe cardref=".$cardref); + if ($cardref) { + try { + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) { + $sepa = $cu->sources->retrieve($cardref); + } else { + $sepa = \Stripe\PaymentMethod::retrieve($cardref); + } + } else { + if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) { + //$sepa = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided + $sepa = $cu->sources->retrieve($cardref); + } else { + //$sepa = \Stripe\PaymentMethod::retrieve($cardref, array("stripe_account" => $stripeacc)); // Don't know if this works + $sepa = \Stripe\PaymentMethod::retrieve($cardref); + } + } + } catch (Exception $e) { + $this->error = $e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + } + } elseif ($createifnotlinkedtostripe) { + $iban = $obj->iban_prefix; //prefix ? + $ipaddress = getUserRemoteIP(); + + $dataforcard = array( + 'type'=>'sepa_debit', + "sepa_debit" => array('iban' => $iban), + 'currency' => 'eur', + 'usage' => 'reusable', + 'owner' => array( + 'name' => $soc->name, + ), + "metadata" => array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress) + ); + + //$a = \Stripe\Stripe::getApiKey(); + //var_dump($a);var_dump($stripeacc);exit; + try { + dol_syslog("Try to create sepa_debit 0"); + + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { + $service = 'StripeLive'; + $servicestatus = 1; + } + // Force to use the correct API key + global $stripearrayofkeysbyenv; + $stripeacc = $stripearrayofkeysbyenv[$servicestatus]['secret_key']; + + dol_syslog("Try to create sepa_debit with data = ".json_encode($dataforcard)); + $s = new \Stripe\StripeClient($stripeacc); + $sepa = $s->sources->create($dataforcard); + if (!$sepa) { + $this->error = 'Creation of sepa_debit on Stripe has failed'; + } else { + // association du client avec cette source de paimeent + $cs = $cu->createSource($cu->id, array('source' => $sepa->id)); + if (!$cs) { + $this->error = 'Link SEPA <-> Customer failed'; + } else { + dol_syslog("Try to create sepa_debit 3"); + // print json_encode($sepa); + + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib"; + $sql .= " SET stripe_card_ref = '".$this->db->escape($sepa->id)."', card_type = 'sepa_debit',"; + $sql .= " stripe_account= '" . $this->db->escape($cu->id . "@" . $stripeacc) . "'"; + $sql .= " WHERE rowid = ".((int) $object->id); + $sql .= " AND type = 'ban'"; + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + } + } + } + } catch (Exception $e) { + $this->error = $e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + } + } + } + } else { + dol_print_error($this->db); + } + + return $sepa; + } + /** * Create charge. * This is called by page htdocs/stripe/payment.php and may be deprecated. diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index a33c183a1e7..81baa5db4ac 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -18,6 +18,7 @@ // Put here all includes required by your class file +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -26,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } @@ -51,6 +52,10 @@ if (empty($page) || $page == -1) { $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$optioncss = GETPOST('optioncss', 'alpha'); +$param = ""; +$num = 0; +$totalnboflines = 0; $result = restrictedArea($user, 'banque'); @@ -95,12 +100,12 @@ if (!$rowid) { print ''; $title = $langs->trans("StripePayoutList"); - $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); + $title .= ($stripeacc ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
'; - print '
'.$langs->trans("Label").'
'."\n"; + print '
'."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index f04833ff107..c36c061b91e 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -18,6 +18,7 @@ // Put here all includes required by your class file +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -26,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (!empty($conf->accounting->enabled)) { +if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } @@ -52,7 +53,9 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; $optioncss = GETPOST('optioncss', 'alpha'); - +$param = ""; +$num = 0; +$totalnboflines = 0; $result = restrictedArea($user, 'banque'); @@ -95,12 +98,12 @@ if (!$rowid) { print ''; $title = $langs->trans("StripeTransactionList"); - $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); + $title .= (!empty($stripeacc) ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
'; - print '
'."\n"; + print '
'."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); @@ -113,6 +116,7 @@ if (!$rowid) { print_liste_field_titre("Fee", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right '); print "\n"; + $connect = ""; try { if ($stripeacc) { @@ -146,7 +150,7 @@ if (!$rowid) { else { $memberstatic->id = 0; - }*/ + } $societestatic->fetch($charge->metadata->idcustomer); $societestatic->id = $charge->metadata->idcustomer; @@ -155,7 +159,7 @@ if (!$rowid) { $societestatic->admin = $obj->admin; $societestatic->login = $obj->login; $societestatic->email = $obj->email; - $societestatic->societe_id = $obj->fk_soc; + $societestatic->societe_id = $obj->fk_soc;*/ print ''; diff --git a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php index e77a72ea6c4..4d69ad5d8ae 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -75,13 +76,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print "
"; diff --git a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php index 304cbbd1e3a..be89df64755 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php @@ -21,6 +21,7 @@ * along with this program. If not, see . */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -81,13 +82,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; print dol_get_fiche_end(); -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - // Creation of an optional field if ($action == 'create') { print '
'; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 26679d58908..49f0fc408ce 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -34,6 +34,7 @@ * \brief Card supplier proposal */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -201,7 +202,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -221,10 +222,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -448,10 +449,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -526,7 +527,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -658,7 +659,7 @@ if (empty($reshook)) { $label = $productsupplier->label; // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { @@ -695,6 +696,7 @@ if (empty($reshook)) { $ref_supplier = $productsupplier->ref_supplier; // Get vat rate + $tva_npr = 0; if (!GETPOSTISSET('tva_tx')) { // If vat rate not provided from the form (the form has the priority) $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); @@ -850,10 +852,10 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1038,7 +1040,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -1276,7 +1278,7 @@ if ($action == 'create') { // Terms of payment print '
'; // Mode of payment @@ -1294,7 +1296,7 @@ if ($action == 'create') { // Shipping Method if (isModEnabled("expedition")) { print ''; } @@ -1302,7 +1304,7 @@ if ($action == 'create') { print ''; print ''; print '"; @@ -1528,7 +1530,7 @@ if ($action == 'create') { } $text = $langs->trans('ConfirmValidateAsk', $numref); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 98da7f03365..7ecd6e0b3a5 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1721,7 +1721,7 @@ class SupplierProposal extends CommonObject if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -2950,7 +2950,7 @@ class SupplierProposalLine extends CommonObjectLine $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; - $this->ref_fourn = $objp->ref_produit_forun; + $this->ref_fourn = $objp->ref_produit_fourn; // Multicurrency $this->fk_multicurrency = $objp->fk_multicurrency; diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index 51137133aca..fde016c78c4 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -24,6 +24,7 @@ * \brief Tab to manage contact of a supplier proposal */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 74dd7c6160e..7aacfb8f8b2 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -26,6 +26,7 @@ * \brief Management page of documents attached to a business proposal */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 6fd6480105b..a77c4eac47d 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -24,6 +24,7 @@ * \brief Home page of vendor proposal area */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index b95c06581ce..d1f0daad639 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -24,6 +24,7 @@ * \brief Page d'affichage des infos d'une proposition commerciale */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 3b04695da20..a0299ef3fec 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -33,6 +33,7 @@ * \brief Page of supplier proposals card and list */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 48ce778c0cf..118855cecf3 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -26,6 +26,7 @@ * \brief Fiche d'information sur une proposition commerciale */ +// Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 9198b03bb63..250606703af 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -14,7 +14,7 @@ * 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 . + * along with this program. If not, see . */ /** @@ -23,6 +23,7 @@ * \brief Setup page for TakePos module */ +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; diff --git a/htdocs/takepos/admin/bar.php b/htdocs/takepos/admin/bar.php index 2f37de1a1b0..77a7a68b1c3 100644 --- a/htdocs/takepos/admin/bar.php +++ b/htdocs/takepos/admin/bar.php @@ -23,6 +23,7 @@ * \brief Setup page for TakePos module - Bar Restaurant features */ +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; diff --git a/htdocs/takepos/admin/orderprinters.php b/htdocs/takepos/admin/orderprinters.php index cddf839375a..d2fadf94c81 100644 --- a/htdocs/takepos/admin/orderprinters.php +++ b/htdocs/takepos/admin/orderprinters.php @@ -26,6 +26,7 @@ * \brief Home page of category area */ +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; @@ -174,6 +175,7 @@ print '< print ''; $nbofentries = (count($data) - 1); print ''; +print ''; if ($nbofentries > 0) { print '< print ''; $nbofentries = (count($data) - 1); print ''; +print ''; if ($nbofentries > 0) { print '< print ''; $nbofentries = (count($data) - 1); print ''; +print ''; if ($nbofentries > 0) { print '\n"; -if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { +if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "browser" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; @@ -189,7 +190,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; print '
\n"; print ''; // Customer information @@ -253,7 +254,7 @@ if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_v print "\n"; } -if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) { +if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) { print '\n"; -if (!empty($conf->global->TAKEPOS_PRINT_WITHOUT_DETAILS)) { +if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { print '
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); + print $form->getSelectConditionsPaiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); print '
'.$langs->trans('SendingMethod').''; - print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1); + print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : "", 'shipping_method_id', '', 1); print '
'.$langs->trans("DeliveryDate").''; $datedelivery = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { + if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); $smonth = date("m", $tmpdte); @@ -1319,7 +1321,7 @@ if ($action == 'create') { print ''.$langs->trans("DefaultModel").''; $list = ModelePDFSupplierProposal::liste_modeles($db); - $preselected = ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF); + $preselected = (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT) ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF); print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1); print "
'.$langs->trans("Printer").' 1
'; print ''; @@ -183,7 +185,7 @@ if ($nbofentries > 0) { } else { $checked = ''; } - if ($row["fk_menu"] == 0) { + if ($row["fk_menu"] >= 0) { print ''.$row["label"].'
'; } } @@ -207,6 +209,7 @@ print '
'.$langs->trans("Printer").' 2
'; print ''; @@ -216,7 +219,7 @@ if ($nbofentries > 0) { } else { $checked = ''; } - if ($row["fk_menu"] == 0) { + if ($row["fk_menu"] >= 0) { print ''.$row["label"].'
'; } } @@ -240,6 +243,7 @@ print '
'.$langs->trans("Printer").' 3
'; print ''; @@ -249,7 +253,7 @@ if ($nbofentries > 0) { } else { $checked = ''; } - if ($row["fk_menu"] == 0) { + if ($row["fk_menu"] >= 0) { print ''.$row["label"].'
'; } } diff --git a/htdocs/takepos/admin/other.php b/htdocs/takepos/admin/other.php index 6200fce8768..7f07b214085 100644 --- a/htdocs/takepos/admin/other.php +++ b/htdocs/takepos/admin/other.php @@ -82,7 +82,6 @@ print ''; print ''; print ''; - print '
'; // Marketplace diff --git a/htdocs/takepos/admin/printqr.php b/htdocs/takepos/admin/printqr.php index 87f742fe544..b5fe118e847 100644 --- a/htdocs/takepos/admin/printqr.php +++ b/htdocs/takepos/admin/printqr.php @@ -21,6 +21,7 @@ * \brief Print QR Menu */ +// Load Dolibarr environment require '../../main.inc.php'; // Security check diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 7cc5da97f64..bcf0a853705 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . */ /** @@ -25,6 +25,7 @@ * \brief Setup page for TakePos module */ +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; @@ -38,6 +39,7 @@ if (!$user->admin) { $langs->loadLangs(array("admin", "cashdesk", "commercial")); + /* * Actions */ @@ -67,7 +69,7 @@ if (GETPOST('action', 'alpha') == 'set') { } elseif (GETPOST('action', 'alpha') == 'setmethod') { dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity); // TakePOS connector require ReceiptPrinter module - if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && !isModEnabled('receiptprinter')) { + if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && !isModEnabled('receiptprinter')) { activateModule("modReceiptPrinter"); } } @@ -105,7 +107,7 @@ print $langs->trans('Browser'); print '
'; print $langs->trans('BrowserMethodDescription'); print ''; -if ($conf->global->TAKEPOS_PRINT_METHOD == "browser") { +if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "browser") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; @@ -143,14 +145,14 @@ print "TakePOS Connector"; print ''; print $langs->trans('TakeposConnectorMethodDescription'); -if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { +if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { print '
'; print $langs->trans("URL")." / ".$langs->trans("IPAddress").' ('.$langs->trans("TakeposConnectorNecesary").')'; print ' '; } print '
'; -if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { +if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; @@ -173,10 +175,9 @@ print '
'; print $langs->trans('TicketVatGrouped'); print ''; print ajax_constantonoff("TAKEPOS_TICKET_VAT_GROUPPED", array(), $conf->entity, 0, 0, 1, 0); -//print $form->selectyesno("TAKEPOS_TICKET_VAT_GROUPPED", $conf->global->TAKEPOS_TICKET_VAT_GROUPPED, 1); print "
'; $variablename = 'TAKEPOS_HEADER'; - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { + if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -202,7 +203,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; print '
'; $variablename = 'TAKEPOS_FOOTER'; - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { + if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -212,7 +213,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P print "
'; - print ''; + print ''; print '
'; print $langs->trans('CustomerDisplay'); print ''; @@ -267,7 +268,7 @@ print $langs->trans('PrintWithoutDetailsButton'); print ''; print ajax_constantonoff('TAKEPOS_PRINT_WITHOUT_DETAILS', array(), $conf->entity, 0, 0, 1, 0); print "
'; print $langs->trans('PrintWithoutDetailsLabelDefault'); print ''; diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 543b5ba160f..38cd6d1275d 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -24,6 +24,7 @@ * \brief Setup page for TakePos module */ +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index dcf9ef08cee..eb43455216c 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -24,6 +24,7 @@ * \brief Setup page for TakePos module */ +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index a2698e05cd5..1ee27c51f8b 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -21,9 +21,6 @@ * \brief Ajax search component for TakePos. It search products of a category. */ -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -40,6 +37,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index acb195af15c..1ffe5c63db3 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -31,9 +31,6 @@ if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', 1); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', 1); } diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 868719112b5..85aab47528f 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -25,12 +25,6 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); -} if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } @@ -41,6 +35,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -184,7 +179,7 @@ function LoadPlace(place){ $( document ).ready(function() { - $.getJSON('./floors.php?action=getTables&floor=', function(data) { + $.getJSON('./floors.php?action=getTables&token=&floor=', function(data) { $.each(data, function(key, val) { $('body').append('
'+val.label+'
'); diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index 9da6ed3b8ef..e1b24ec286d 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -26,9 +26,6 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -42,6 +39,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -111,7 +109,7 @@ top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); */ function Save() { console.log("We click so we call page invoice.php with place= tva_tx="+vatRate); - parent.$("#poslines").load("invoice.php?action=freezone&place=&number="+$('#number').val()+"&tva_tx="+vatRate, {desc:$('#desc').val()}); + parent.$("#poslines").load("invoice.php?action=freezone&token=&place=&number="+$('#number').val()+"&tva_tx="+vatRate, {desc:$('#desc').val()}); parent.$.colorbox.close(); } diff --git a/htdocs/takepos/genimg/index.php b/htdocs/takepos/genimg/index.php index dcb8c1fe487..84ce27868ae 100644 --- a/htdocs/takepos/genimg/index.php +++ b/htdocs/takepos/genimg/index.php @@ -23,9 +23,6 @@ if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } diff --git a/htdocs/takepos/genimg/qr.php b/htdocs/takepos/genimg/qr.php index c1dae9e8b20..b289814f9e1 100644 --- a/htdocs/takepos/genimg/qr.php +++ b/htdocs/takepos/genimg/qr.php @@ -26,9 +26,6 @@ if (!defined('NOIPCHECK')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -42,6 +39,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; // Load $user and permissions require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php'; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 410de2c330c..2e4edc99da2 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -18,21 +18,16 @@ */ /** - * \file htdocs/takepos/index.php - * \ingroup takepos - * \brief Main TakePOS screen + * \file htdocs/takepos/index.php + * \ingroup takepos + * \brief Main TakePOS screen */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); -} +// if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +// if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } @@ -43,14 +38,16 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is id of table for Bar or Restaurant or multiple sales $action = GETPOST('action', 'aZ09'); @@ -325,7 +322,7 @@ function LoadProducts(position, issubcat) { }); idata=0; //product data counter - $.getJSON('/takepos/ajax/ajax.php?action=getProducts&category='+currentcat, function(data) { + $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&category='+currentcat, function(data) { console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs"); console.log(data); while (ishow < maxproduct) { @@ -415,7 +412,7 @@ function MoreProducts(moreorless) { if (pageproducts==0) return; //Return if no less pages pageproducts=pageproducts-1; } - $.getJSON('/takepos/ajax/ajax.php?action=getProducts&category='+currentcat, function(data) { + $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&category='+currentcat, function(data) { console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat); if (typeof (data[(maxproduct * pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages @@ -490,7 +487,7 @@ function ClickProduct(position, qty = 1) { function ChangeThirdparty(idcustomer) { console.log("ChangeThirdparty"); // Call page list.php to change customer - $("#poslines").load("../societe/list.php?action=change&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() { + $("#poslines").load("../societe/list.php?action=change&token=&type=t&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() { }); ClearSearch(); @@ -540,7 +537,7 @@ function Floors() { function FreeZone() { console.log("Open box to enter a free product"); - $.colorbox({href:"freezone.php?action=freezone&place="+place, width:"80%", height:"200px", transition:"none", iframe:"true", title:"trans("FreeZone"); ?>"}); + $.colorbox({href:"freezone.php?action=freezone&token=&place="+place, width:"80%", height:"200px", transition:"none", iframe:"true", title:"trans("FreeZone"); ?>"}); } function TakeposOrderNotes() { @@ -562,7 +559,7 @@ function New() { console.log("New with place = , js place="+place+", invoiceid="+invoiceid); - $.getJSON('/takepos/ajax/ajax.php?action=getInvoice&id='+invoiceid, function(data) { + $.getJSON('/takepos/ajax/ajax.php?action=getInvoice&token=&id='+invoiceid, function(data) { var r; if (parseInt(data['paye']) === 1) { @@ -628,7 +625,7 @@ function Search2(keyCodeForEnter, moreorless) { pageproducts = 0; jQuery(".wrapper2 .catwatermark").hide(); var nbsearchresults = 0; - $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { + $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { for (i = 0; i < ; i++) { if (typeof (data[i]) == "undefined") { $("#prowatermark" + i).html(""); @@ -687,8 +684,8 @@ function Search2(keyCodeForEnter, moreorless) { console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']); ChangeThirdparty(data[0]['rowid']); } - else if ('product' == data[0]['object']) { - console.log("There is only 1 answer matching the search, so we add the product in basket, qty="+data[0]['qty']); + else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) { + console.log("There is only 1 answer and we found search on a barcode, so we add the product in basket, qty="+data[0]['qty']); ClickProduct(0, data[0]['qty']); } } @@ -746,7 +743,7 @@ function Edit(number) { return; } else if (number=='qty') { if (editaction=='qty' && editnumber != '') { - $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { + $("#poslines").load("invoice.php?action=updateqty&token=&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#qty").html("trans("Qty"); ?>").removeClass('clicked'); @@ -760,7 +757,7 @@ function Edit(number) { } } else if (number=='p') { if (editaction=='p' && editnumber!="") { - $("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { + $("#poslines").load("invoice.php?action=updateprice&token=&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#price").html("trans("Price"); ?>").removeClass('clicked'); @@ -774,7 +771,7 @@ function Edit(number) { } } else if (number=='r') { if (editaction=='r' && editnumber!="") { - $("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { + $("#poslines").load("invoice.php?action=updatereduction&token=&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#reduction").html("trans("ReductionShort"); ?>").removeClass('clicked'); @@ -814,14 +811,14 @@ function Edit(number) { function TakeposPrintingOrder(){ console.log("TakeposPrintingOrder"); - $("#poslines").load("invoice.php?action=order&place="+place, function() { + $("#poslines").load("invoice.php?action=order&token=&place="+place, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } function TakeposPrintingTemp(){ console.log("TakeposPrintingTemp"); - $("#poslines").load("invoice.php?action=temp&place="+place, function() { + $("#poslines").load("invoice.php?action=temp&token=&place="+place, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } @@ -843,11 +840,11 @@ function OpenDrawer(){ } function DolibarrOpenDrawer() { - console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&term="); + console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=&term="); $.ajax({ type: "GET", data: { token: '' }, - url: "", + url: "", }); } @@ -892,7 +889,7 @@ function ModalBox(ModalID) function DirectPayment(){ console.log("DirectPayment"); - $("#poslines").load("invoice.php?place="+place+"&action=valid&pay=LIQ", function() { + $("#poslines").load("invoice.php?place="+place+"&action=valid&token=&pay=LIQ", function() { }); } @@ -908,7 +905,7 @@ function WeighingScale(){ url: '/scale/index.php', }) .done(function( editnumber ) { - $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { + $("#poslines").load("invoice.php?&token=&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; }); }); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 8659cc6ea52..e22f6e6d226 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -18,18 +18,16 @@ */ /** - * \file htdocs/takepos/invoice.php - * \ingroup takepos - * \brief Page to generate section with list of lines + * \file htdocs/takepos/invoice.php + * \ingroup takepos + * \brief Page to generate section with list of lines */ -// if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language -// if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language -// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} +// if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +// if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language +// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); + if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -43,16 +41,16 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { require '../main.inc.php'; } -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager->initHooks(array('takeposinvoice')); +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -global $mysoc; +$hookmanager->initHooks(array('takeposinvoice')); $langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks", "banks")); @@ -1082,7 +1080,7 @@ function SendTicket(id) function PrintBox(id, action) { console.log("Open box before printing"); - $.colorbox({href:"printbox.php?facid="+id+"&action="+action, width:"80%", height:"200px", transition:"none", iframe:"true", title:"trans("PrintWithoutDetails"); ?>"}); + $.colorbox({href:"printbox.php?facid="+id+"&action="+action+"&token=", width:"80%", height:"200px", transition:"none", iframe:"true", title:"trans("PrintWithoutDetails"); ?>"}); } function Print(id, gift){ @@ -1105,7 +1103,7 @@ function TakeposPrinting(id){ function TakeposConnector(id){ console.log("TakeposConnector" + id); - $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { + $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&token=&term=&id="+id+"&token=", function(data, status) { $.ajax({ type: "POST", url: '/printer/index.php', @@ -1119,7 +1117,7 @@ function DolibarrTakeposPrinting(id) { $.ajax({ type: "GET", data: { token: '' }, - url: "" + id, + url: "" + id, }); } diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 7b5d4aea6b5..1222ccd1786 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -22,13 +22,11 @@ * \brief Page with the content of the popup to enter payments */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} +// if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +// if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language +// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); + if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -39,11 +37,13 @@ if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + +// Load translation files required by the page $langs->loadLangs(array("main", "bills", "cashdesk", "banks")); $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant @@ -110,9 +110,13 @@ function unexpectedDisconnect() { } function fetchConnectionToken() { global->STRIPE_LOCATION)) $urlconnexiontoken .= '&location='.$conf->global->STRIPE_LOCATION; - if (!empty($stripeacc)) $urlconnexiontoken .= '&stripeacc='.$stripeacc; + $urlconnexiontoken = DOL_URL_ROOT.'/stripe/ajax/ajax.php?action=getConnexionToken&token='.newToken().'&servicestatus='.urlencode($servicestatus); + if (!empty($conf->global->STRIPE_LOCATION)) { + $urlconnexiontoken .= '&location='.urlencode($conf->global->STRIPE_LOCATION); + } + if (!empty($stripeacc)) { + $urlconnexiontoken .= '&stripeacc='.urlencode($stripeacc); + } ?> // Do not cache or hardcode the ConnectionToken. The SDK manages the ConnectionToken's lifecycle. return fetch('', { method: "POST" }) @@ -318,7 +322,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { amountpayed = total_ttc; ?>; } console.log("We click on the payment mode to pay amount = "+amountpayed); - parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { + parent.$("#poslines").load("invoice.php?place=&action=valid&token=&pay="+payment+"&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { if (amountpayed > || amountpayed == || amountpayed==0 ) { console.log("Close popup"); parent.$.colorbox.close(); @@ -355,8 +359,10 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { function capturePaymentIntent(paymentIntentId) { const bodyContent = JSON.stringify({"id": paymentIntentId}) return fetch('', { method: "POST", @@ -416,7 +422,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { } else { document.getElementById("card-present-alert").innerHTML = '
trans('PaymentValidated'); ?>
'; console.log("Capture paymentIntent successfull "+paymentIntentId); - parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { + parent.$("#poslines").load("invoice.php?place=&action=valid&token=&pay=CB&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { if (amountpayed > || amountpayed == || amountpayed==0 ) { console.log("Close popup"); parent.$.colorbox.close(); @@ -455,7 +461,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { url: '/takepos/smpcb.php?status' }).done(function (data) { console.log(data); if (data === "SUCCESS") { - parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () { + parent.$("#poslines").load("invoice.php?place=&action=valid&token=&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () { //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); parent.$.colorbox.close(); //parent.setFocusOnSearchField(); // This does not have effect diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php index fa12487763e..f1e633d994d 100644 --- a/htdocs/takepos/phone.php +++ b/htdocs/takepos/phone.php @@ -25,9 +25,6 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -228,7 +225,7 @@ function AddProduct(placeid, productid){ // If is a public terminal first show product information if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { print 'place=placeid; - $("#phonediv1").load("auto_order.php?action=productinfo&place="+place+"&idproduct="+productid, function() { + $("#phonediv1").load("auto_order.php?action=productinfo&token='.newToken().'&place="+place+"&idproduct="+productid, function() { });'; } else { print 'AddProductConfirm(placeid, productid);'; @@ -237,7 +234,7 @@ function AddProduct(placeid, productid){ } function PublicPreOrder(){ - $("#phonediv1").load("auto_order.php?action=publicpreorder&place="+place, function() { + $("#phonediv1").load("auto_order.php?action=publicpreorder&token=&place="+place, function() { }); } @@ -263,7 +260,7 @@ function SetQty(place, selectedline, qty){ }); } else{ - $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() { + $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&token=&place="+place+"&idline="+selectedline+"&number="+qty, function() { }); } &place="+place+"&idline="+selectedline+"&number="+qty, function() { }); } trans('Note'); ?>", ""); - $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() { + $("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&token=&place="+place+"&idline="+selectedline+"&number="+qty, function() { }); LoadCats(); } @@ -324,12 +321,12 @@ function TakeposPrintingOrder(){ console.log("TakeposPrintingOrder"); @@ -341,12 +338,12 @@ function Exit(){ function CheckPlease(payment){ if (payment==undefined){ - $("#phonediv1").load("auto_order.php?action=checkplease&place="+place, function() { + $("#phonediv1").load("auto_order.php?action=checkplease&token=&place="+place, function() { }); } else{ console.log("Request the check to the waiter"); - $("#phonediv1").load("auto_order.php?action=checkplease&place=&payment="+payment, function() { + $("#phonediv1").load("auto_order.php?action=checkplease&token=&place=&payment="+payment, function() { }); } } diff --git a/htdocs/takepos/printbox.php b/htdocs/takepos/printbox.php index 7a79bdbcf88..53c07bcf1d7 100644 --- a/htdocs/takepos/printbox.php +++ b/htdocs/takepos/printbox.php @@ -26,9 +26,6 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -42,6 +39,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -77,7 +75,7 @@ top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); function Save() { console.log("We click so we call page receipt.php with facid="); parent.$.colorbox.close(); - $.colorbox({href:"receipt.php?facid=&action=&label="+$('#label').val()+"&qty="+$('#qty').val(), width:"40%", height:"90%", transition:"none", iframe:"true", title:'trans("PrintTicket")); ?>'}); + $.colorbox({ href:"receipt.php?facid=&action=&token=&label="+$('#label').val()+"&qty="+$('#qty').val(), width:"40%", height:"90%", transition:"none", iframe:"true", title:'trans("PrintTicket")); ?>'}); } jQuery(document).ready(function(){ diff --git a/htdocs/takepos/public/auto_order.php b/htdocs/takepos/public/auto_order.php index 308cd75b12e..d123ac84f53 100644 --- a/htdocs/takepos/public/auto_order.php +++ b/htdocs/takepos/public/auto_order.php @@ -31,6 +31,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; if (!$conf->global->TAKEPOS_AUTO_ORDER) { diff --git a/htdocs/takepos/public/menu.php b/htdocs/takepos/public/menu.php index 5d9d318db07..e7ab4d9fe1d 100644 --- a/htdocs/takepos/public/menu.php +++ b/htdocs/takepos/public/menu.php @@ -31,6 +31,7 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; diff --git a/htdocs/takepos/reduction.php b/htdocs/takepos/reduction.php index bcb133d7ff1..5d80acb0f81 100644 --- a/htdocs/takepos/reduction.php +++ b/htdocs/takepos/reduction.php @@ -25,9 +25,6 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -41,6 +38,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -187,13 +185,13 @@ if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->glob if (reductionType === 'percent') { var invoiceid = 0 ? $invoiceid : 0); ?>; - parent.$("#poslines").load("invoice.php?action=update_reduction_global&place=&number="+reductionNumber+"&invoiceid="+invoiceid, function() { + parent.$("#poslines").load("invoice.php?action=update_reduction_global&token=&place=&number="+reductionNumber+"&invoiceid="+invoiceid, function() { Reset(); parent.$.colorbox.close(); }); } else if (reductionType === 'amount') { var desc = "transnoentities('Reduction')); ?>"; - parent.$("#poslines").load("invoice.php?action=freezone&place=&number=-"+reductionNumber+"&desc="+desc, function() { + parent.$("#poslines").load("invoice.php?action=freezone&token=&place=&number=-"+reductionNumber+"&desc="+desc, function() { Reset(); parent.$.colorbox.close(); }); diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 890bc1d55dd..ffa7e0c5c35 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -13,7 +13,7 @@ * 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 . + * along with this program. If not, see . */ /** @@ -26,9 +26,6 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -42,6 +39,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -84,7 +82,7 @@ if ($action == "send") { $sendto = $email; $from = $mysoc->email; $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1); - if ($mail->error || $mail->errors) { + if ($mail->error || !empty($mail->errors)) { setEventMessages($mail->error, $mail->errors, 'errors'); } else { $result = $mail->sendfile(); @@ -109,7 +107,7 @@ function SendMail() { $.ajax({ type: "GET", data: { token: '' }, - url: "" + $("#email"). val(), + url: "" + $("#email"). val(), }); parent.$.colorbox.close(); } diff --git a/htdocs/takepos/smpcb.php b/htdocs/takepos/smpcb.php index 66dfdd32a2f..505ec27c1b0 100644 --- a/htdocs/takepos/smpcb.php +++ b/htdocs/takepos/smpcb.php @@ -12,7 +12,7 @@ * 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 . + * along with this program. If not, see . */ /** @@ -21,9 +21,6 @@ * \brief Page with the content for smpcb payment */ -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -37,6 +34,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; if (empty($user->rights->takepos->run)) { diff --git a/htdocs/takepos/split.php b/htdocs/takepos/split.php index 2c9c68902b5..0391e911ba5 100644 --- a/htdocs/takepos/split.php +++ b/htdocs/takepos/split.php @@ -25,9 +25,6 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -41,6 +38,7 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } +// Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -166,7 +164,7 @@ $arrayOfValidBankAccount = array();