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/COPYRIGHT b/COPYRIGHT index 8c8a1f56355..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,11 +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 7a87f3fbc2d..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,14 +55,11 @@ 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 border 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. @@ -70,12 +69,10 @@ 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: 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 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 @@ -94,25 +91,26 @@ 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: 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 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: 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: 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: Knowledge Management - Add status "Obsolete" to KM articles +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: 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: 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 @@ -122,6 +120,10 @@ 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 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/makepack-howto.txt b/build/makepack-howto.txt index be88302cd1d..dd99621f479 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,13 @@ 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/) +Install Dolibarr verions: git clone https://github.com/dolibarr/dolibarr ***** Actions to do a BETA ***** 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/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index a76fa1945c2..c374f5ba9fe 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -480,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'; @@ -653,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; @@ -701,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; @@ -861,8 +867,8 @@ if ($optioncss != '') { print ''; } print ''; -print ''; -print ''; +print ''; +print ''; print ''; if (count($filter)) { @@ -883,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')); @@ -983,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 @@ -1008,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 ''; } @@ -1116,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 ba94415782f..e417f21832c 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -395,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/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/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0b2a060d7a2..ebd7df6bbc8 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); 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 d34d1f5c3dc..675c900680d 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -311,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; @@ -601,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; @@ -791,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/adherents/admin/member_extrafields.php b/htdocs/adherents/admin/member_extrafields.php index ef12b5cf68e..5776828c078 100644 --- a/htdocs/adherents/admin/member_extrafields.php +++ b/htdocs/adherents/admin/member_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 if ($action == 'create') { print '

'; diff --git a/htdocs/adherents/admin/member_type_extrafields.php b/htdocs/adherents/admin/member_type_extrafields.php index 2fc8864b323..ac796a4d3ab 100644 --- a/htdocs/adherents/admin/member_type_extrafields.php +++ b/htdocs/adherents/admin/member_type_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 if ($action == 'create') { print "
"; diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 8831f06fd06..26c39df5b63 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -59,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'); @@ -66,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); @@ -237,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/card.php b/htdocs/adherents/card.php index b9e04015d7d..e0f6b693eb7 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -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); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 73c527cb2eb..0aa1af68afc 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -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/list.php b/htdocs/adherents/list.php index b0e63098322..4c80627d70e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -623,7 +623,7 @@ if ($user->hasRight('adherent', 'creer')) { 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->hasRight('adherent', 'creer') && $user->rights->user->user->creer) { diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 6c477d46239..215635757c2 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -268,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)) { @@ -351,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/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index cc91646b456..cade3a90e71 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -87,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/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index b872a22108c..3626eec4455 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -83,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 966281cb0d1..96dd7affdba 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -32,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_extrafields.php b/htdocs/admin/bom_extrafields.php index 2facfc570b8..7b77702eea4 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_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/commande_fournisseur_dispatch_extrafields.php b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php index 4f89dd8fff6..277d61e1b2f 100644 --- a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php +++ b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php @@ -92,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/confexped.php b/htdocs/admin/confexped.php deleted file mode 100644 index 870b793fce8..00000000000 --- a/htdocs/admin/confexped.php +++ /dev/null @@ -1,147 +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 - */ - -// Load Dolibarr environment -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/dav.php b/htdocs/admin/dav.php index d70356650d9..d0fd21c80a0 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -77,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) { @@ -97,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 ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; @@ -120,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/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 32c8f34e570..214f209b2be 100644 --- a/htdocs/admin/delivery_extrafields.php +++ b/htdocs/admin/delivery_extrafields.php @@ -89,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 5030379320f..9c054f5bcfd 100644 --- a/htdocs/admin/deliverydet_extrafields.php +++ b/htdocs/admin/deliverydet_extrafields.php @@ -90,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 f55190f7bf8..43472c9724c 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -843,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]; diff --git a/htdocs/admin/ecm_directories_extrafields.php b/htdocs/admin/ecm_directories_extrafields.php index 4191e40a369..f820f376995 100644 --- a/htdocs/admin/ecm_directories_extrafields.php +++ b/htdocs/admin/ecm_directories_extrafields.php @@ -89,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 1887103bcc9..563f9f58275 100644 --- a/htdocs/admin/ecm_files_extrafields.php +++ b/htdocs/admin/ecm_files_extrafields.php @@ -89,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 19486510f58..8dfafb19b63 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -146,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) { @@ -235,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'); @@ -784,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/eventorganization_confbooth_extrafields.php b/htdocs/admin/eventorganization_confbooth_extrafields.php index 97bc4ad37bd..a4b14206c65 100644 --- a/htdocs/admin/eventorganization_confbooth_extrafields.php +++ b/htdocs/admin/eventorganization_confbooth_extrafields.php @@ -79,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/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index ed4e062970d..303b0f88167 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -89,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 e0ce6a82b8f..56a023e1c83 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -90,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_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 3406b9092e7..69f6bf14d61 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -83,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/fckeditor.php b/htdocs/admin/fckeditor.php index f997c44ef6e..dd4748a99f1 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -68,7 +68,7 @@ $conditions = array( 'USERSIGN' => 1, '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/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index c51b2846cf9..21fce3d62d6 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -83,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/index.php b/htdocs/admin/index.php index 3218f673fd5..87b49c95468 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -28,6 +28,8 @@ require '../main.inc.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'companies')); +$action = ''; + if (!$user->admin) { accessforbidden(); } @@ -120,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_contacts.php b/htdocs/admin/ldap_contacts.php index 424c426f023..0f8fec1cecc 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -143,7 +143,7 @@ if (!function_exists("ldap_connect")) { print dol_get_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -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 2422282655e..23a4103bc75 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -117,7 +117,7 @@ if (!function_exists("ldap_connect")) { print dol_get_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -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 010b5c08e33..b7783c99ca0 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -191,7 +191,7 @@ print ''; print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -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 0a71033d465..abb017ea037 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -109,7 +109,7 @@ if (!function_exists("ldap_connect")) { print dol_get_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -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 a333536a440..2ec3ef169d8 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -180,7 +180,7 @@ print ''; print dol_get_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1); -print $langs->trans("LDAPDescUsers").'
'; +print ''.$langs->trans("LDAPDescUsers").'
'; print '
'; @@ -501,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(); @@ -526,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/mails_templates.php b/htdocs/admin/mails_templates.php index b02d05ca478..02eef8a00d3 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -186,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')) { @@ -207,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')) { @@ -222,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)) { @@ -583,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) { @@ -706,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"); @@ -1332,7 +1332,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; } elseif ($value == 'lang') { 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/modulehelp.php b/htdocs/admin/modulehelp.php index 13332b5c277..e18e65e47a0 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -384,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"); } @@ -415,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/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index 5553604eeff..cd18b47eec7 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_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/oauth.php b/htdocs/admin/oauth.php index 1f2966b05b1..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,7 @@ * \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'; @@ -37,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) { @@ -85,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++; } } @@ -111,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 ''; @@ -141,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) { @@ -172,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 62162616a1a..fa1fd18f049 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -172,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/order_extrafields.php b/htdocs/admin/order_extrafields.php index 0339f3a2b45..8ebbce2cc4d 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -86,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 889a042389a..e9c0947d6a2 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -87,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/pdf.php b/htdocs/admin/pdf.php index b5a823edfb4..d59e2279435 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -291,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 '
'; @@ -472,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 645fff6adf1..f2f9f83f67c 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -104,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 ''; @@ -127,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 '
'; @@ -170,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/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index 31b4d836db8..bf87698e5d8 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -92,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/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index b7770797f21..62c1c4cfed2 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -85,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 14975f8c68a..02cddbd5d70 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -216,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) { @@ -226,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"); @@ -246,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'); @@ -267,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 '
'; @@ -346,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(){'; @@ -470,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 b20287ce19b..ff0d5780ad4 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -113,7 +113,7 @@ print '
'; // Upload options print '
'; -print ''; +print '
'; print ''; print ''; print ''; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 760a89c4a0d..d0da90dcad4 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -87,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 55664d46966..8fa0f5130c9 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -89,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 63c679e3ef9..17a2eccbc58 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -87,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 7f38fe77cc8..6e5b8aa0175 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -88,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/system/database.php b/htdocs/admin/system/database.php index 9a0a1e4d850..8cd1ad3d597 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -65,7 +65,7 @@ print '
'; print '
'; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; 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/perf.php b/htdocs/admin/system/perf.php index dcd853a5356..6d7ef8f1863 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -28,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/security.php b/htdocs/admin/system/security.php index 4ba5bec5b11..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 @@ -297,7 +297,7 @@ if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) { -// Menu security +// Menu Home - Setup - Security print '
'; print '
'; @@ -312,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").''; @@ -325,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; @@ -489,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\")
"; @@ -507,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/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index fc792030ade..ccd0c75bd76 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -78,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/workflow.php b/htdocs/admin/workflow.php index 824643093ad..10f32eed97d 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -75,7 +75,7 @@ $workflowcodes = array( 'WORKFLOW_TICKET_CREATE_INTERVENTION' => array ( 'family'=>'create', 'position'=>25, - 'enabled'=>(!empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)), + 'enabled'=>(isModEnabled('ticket') && isModEnabled('ficheinter')), 'picto'=>'ticket' ), @@ -133,7 +133,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION'=>array( 'family'=>'classify_supplier_order', 'position'=>63, - 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled))), + 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -141,7 +141,7 @@ $workflowcodes = array( 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED'=>array( 'family'=>'classify_supplier_order', 'position'=>64, - 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled))), + 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !isModEnabled('supplier_order'))), 'picto'=>'supplier_order', 'warning'=>'' ), @@ -174,13 +174,13 @@ $workflowcodes = array( 'WORKFLOW_TICKET_LINK_CONTRACT' => array( 'family' => 'link_ticket', 'position' => 75, - 'enabled' => !empty($conf->ticket->enabled) && !empty($conf->contract->enabled), + 'enabled' => isModEnabled('ticket') && !empty($conf->contract->enabled), 'picto' => 'ticket' ), 'WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS' => array( 'family' => 'link_ticket', 'position' => 76, - 'enabled' => !empty($conf->ticket->enabled) && !empty($conf->contract->enabled), + 'enabled' => isModEnabled('ticket') && !empty($conf->contract->enabled), 'picto' => 'ticket' ), ); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 0ef143d36ad..fa5e2ff1de8 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -127,7 +127,6 @@ class DolibarrApi unset($object->ref_previous); unset($object->ref_next); - unset($object->ref_int); unset($object->imgWidth); unset($object->imgHeight); unset($object->barcode_type_code); @@ -163,6 +162,7 @@ class DolibarrApi unset($object->statuts_short); unset($object->statuts_logo); unset($object->statuts_long); + //unset($object->labelStatus); //unset($object->labelStatusShort); @@ -184,6 +184,7 @@ class DolibarrApi unset($object->picto); unset($object->fieldsforcombobox); + unset($object->regeximgext); unset($object->skip_update_total); unset($object->context); @@ -259,6 +260,11 @@ class DolibarrApi if (!empty($object->thirdparty) && is_object($object->thirdparty)) { $this->_cleanObjectDatas($object->thirdparty); } + + if (!empty($object->product) && is_object($object->product)) { + $this->_cleanObjectDatas($object->product); + } + return $object; } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index d4d652f3e74..2c7653c3bb3 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -272,7 +272,7 @@ class Documents extends DolibarrApi if ($modulepart == 'societe' || $modulepart == 'thirdparty') { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(401); } diff --git a/htdocs/asset/admin/asset_extrafields.php b/htdocs/asset/admin/asset_extrafields.php index b7a67151407..b5671e27071 100644 --- a/htdocs/asset/admin/asset_extrafields.php +++ b/htdocs/asset/admin/asset_extrafields.php @@ -86,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 */ diff --git a/htdocs/asset/admin/assetmodel_extrafields.php b/htdocs/asset/admin/assetmodel_extrafields.php index 44f2b1d7ca4..cddd3831e8e 100644 --- a/htdocs/asset/admin/assetmodel_extrafields.php +++ b/htdocs/asset/admin/assetmodel_extrafields.php @@ -86,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 */ diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index 4d1e6d4be56..b40ed122ec6 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -128,7 +128,7 @@ if ($object->id > 0) { $help_url = 'EN:Module_Agenda_En'; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = assetPrepareHead($object); diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 55d2bc07593..5c50b972c93 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -1171,10 +1171,10 @@ class Asset extends CommonObject global $hidedetails, $hidedesc, $hideref; $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 = $this->thirdparty->default_lang; } if (!empty($newlang)) { @@ -1234,10 +1234,10 @@ class Asset extends CommonObject global $hidedetails, $hidedesc, $hideref; $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 = $this->thirdparty->default_lang; } if (!empty($newlang)) { diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index e0a463ec112..17fb19fe565 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -130,7 +130,7 @@ if ($object->id > 0) { $help_url = 'EN:Module_Agenda_En'; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) { + if (isModEnabled('notification')) { $langs->load("mails"); } $head = assetModelPrepareHead($object); diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 7313fdfd2d5..2f5096f6436 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -34,9 +34,6 @@ if (!defined('NOREQUIRESOC')) { if (!defined('NOREQUIRETRAN')) { define('NOREQUIRETRAN', '1'); } -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } @@ -75,7 +72,6 @@ function llxFooter() print "\n".''."\n"; } - require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 96caac1dbb4..373effecbe8 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -397,7 +397,7 @@ if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire) print '
'; } -if (!empty($user->rights->societe->lire)) { +if ($user->hasRight('societe', 'lire')) { print ''; print '
'; print '
'; 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 46d4f0b8ff9..09d2b2bcb9d 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -19,7 +19,7 @@ /** * \file htdocs/bom/bom_card.php * \ingroup bom - * \brief Page to create/edit/view BillOfMaterial + * \brief Page to create/edit/view Bill Of Material */ // Load Dolibarr environment @@ -161,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++; @@ -194,19 +194,22 @@ if (empty($reshook)) { } 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(); } } @@ -220,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'); @@ -230,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) @@ -490,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(); @@ -498,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'); + } } } @@ -581,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/class/bom.class.php b/htdocs/bom/class/bom.class.php index 7ff9627f25b..af14185b3d0 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 ($conf->workstation->enabled && !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) { @@ -1478,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..41aeec4b96f 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 ($conf->workstation->enabled) 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 ($conf->workstation->enabled) 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..a3b9df0bdf0 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 ''; + + //Poste de travail + if ($conf->workstation->enabled) { + $workstation = new Workstation($object->db); + $res = $workstation->fetch($tmpproduct->fk_default_workstation); + + print ''; + } } - -print ''; -print ''; - -print ''; - $total_cost = 0; 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..f93fb59fe0d 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/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 2abd90cf538..2fd18aa0893 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -42,8 +42,12 @@ 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))); } } } @@ -61,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); diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index aea67145258..7f2fabe4a3a 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -80,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/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 76381c0d53d..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); 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/comm/action/list.php b/htdocs/comm/action/list.php index 25e389f2e85..a5aca966530 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -395,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/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index d0aa0db96b0..fa0c9117430 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -80,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 4d68948e34c..0f904b31407 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -83,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 67df6af0298..f6ae06b1f7f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -60,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'; } @@ -82,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"); } @@ -131,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(); } } @@ -545,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); @@ -1231,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"; @@ -1564,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/index.php b/htdocs/comm/index.php index ed6184e0cd4..27f9b91a9d7 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -40,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'; } @@ -104,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); } @@ -519,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"; @@ -594,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"; @@ -700,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/card.php b/htdocs/comm/mailing/card.php index 81e36c006ca..e59389a87b7 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -477,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/propal/card.php b/htdocs/comm/propal/card.php index 0a1d1bdbc06..5b2d7197eb7 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -55,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'; } @@ -256,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); @@ -281,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)) { @@ -326,8 +326,8 @@ if (empty($reshook)) { } elseif (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); @@ -347,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); @@ -647,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)) { @@ -746,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'); @@ -877,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); @@ -976,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); @@ -1133,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')) { @@ -1167,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')) { @@ -1268,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); @@ -1442,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); @@ -1696,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; } @@ -1742,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 ' @@ -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 '
'.$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 888cb1d7026..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'); diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 19411968df4..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); } diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index f179ea9ed36..b7e6fd15dcb 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -137,9 +137,11 @@ $(document).ready(function () {