diff --git a/.gitignore b/.gitignore index 30151359365..344822f0e9e 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,8 @@ htdocs/includes/jakub-onderka/ htdocs/includes/phpdocumentor/ htdocs/includes/phpspec/ htdocs/includes/phpunit/ +htdocs/includes/php-parallel-lint/ htdocs/includes/sebastian/ htdocs/includes/squizlabs/ -htdocs/includes/symfony/ htdocs/includes/webmozart/ htdocs/.well-known/apple-developer-merchantid-domain-association diff --git a/.travis.yml b/.travis.yml index ca9641ce63e..c47e1b19598 100644 --- a/.travis.yml +++ b/.travis.yml @@ -119,24 +119,18 @@ install: echo - | - echo "Installing Composer dependencies (PHP Unit, Parallel Lint & PHP CodeSniffer" - if [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then - composer -n require phpunit/phpunit ^4 \ - jakub-onderka/php-parallel-lint ^0 \ - jakub-onderka/php-console-highlighter ^0 \ - squizlabs/php_codesniffer ^3 - fi + echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$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' ]; then composer -n require phpunit/phpunit ^5 \ - jakub-onderka/php-parallel-lint ^0 \ - jakub-onderka/php-console-highlighter ^0 \ + php-parallel-lint/php-parallel-lint ^0 \ + php-parallel-lint/php-console-highlighter ^0 \ squizlabs/php_codesniffer ^3 fi if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ - jakub-onderka/php-parallel-lint ^0 \ - jakub-onderka/php-console-highlighter ^0 \ + php-parallel-lint/php-parallel-lint ^1 \ + php-parallel-lint/php-console-highlighter ^0 \ squizlabs/php_codesniffer ^3 fi echo @@ -283,7 +277,11 @@ script: # Ensure we catch errors set -e #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . + parallel-lint --exclude dev/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/phpexcel --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 \ + --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ + --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame . set +e echo diff --git a/COPYRIGHT b/COPYRIGHT index 251ad7f2fe4..d8cefedcd65 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -21,7 +21,7 @@ Mobiledetect 2.8.34 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 -PHPDebugBar 1.15.0 MIT License Yes Used only by the module "debugbar" for developers +PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP diff --git a/ChangeLog b/ChangeLog index d3a5558db6b..9653e4577cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,7 +13,10 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * Properties ->contactid has been renamed into ->contact_id * Rename property $paiementid in API api_supplier_invoices into $payment_mode_id - +* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in + your email templates. +* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom + days of holiday. ***** ChangeLog for 12.0.2 compared to 12.0.1 ***** FIX: computation of the bottom margin of returns NaN because body is not loaded yet @@ -341,14 +344,14 @@ Following changes may create regressions for some external modules, but were nec WARNING FOR DOLIWAMP USERS ONLY: -Only people that installed Dolibarr using the all-in-one autoinstaller for Windows called "DoliWAMP" are concerned by the following warnings: +Only people that installed Dolibarr using the all-in-one auto-installer for Windows called "DoliWAMP" are concerned by the following warnings: -* DoliWAMP autoinstaller for Windows is not more available on 32bits systems. Use standard package if you need to use such architecture. -* It is not possible to migrate from an installation done with the old DoliWAMP autoinstaller for Windows by using this new one. You must make a backup - of your database, make a fresh installation using the new installer and reload your backup. Don't forget that DoliWAMP is a good solution to make a - quick test of Dolibarr on your local computer but was never recommanded as a production solution on a local desktop since a desktop computer has not - a backup and security policy as good as on a server (when there is one). - DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard package for production. +* DoliWAMP auto-installer for Windows is no more available on 32 bits systems. Use standard package if you need to use such architecture. +* It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one. + You must make a backup of your database, make a fresh installation using the new installer and reload your backup. + Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production + solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one). + DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard packages for production. ***** ChangeLog for 11.0.5 compared to 11.0.4 ***** diff --git a/SECURITY.md b/SECURITY.md index ac9ccbc677f..d0ab526b012 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -64,9 +64,10 @@ No vulnerability disclosure, including partial is allowed for the moment. ONLY vulnerabilities discovered, when the following setup on tested platform is used, are accepted: -* $dolibarr_main_prod must be 1 into conf.php -* $dolibarr_nocsrfcheck must not be set to 0 (should be 1 by default) into conf.php -* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be hard switched soon to 1 by default) +* $dolibarr_main_prod must be set to 1 into conf.php +* $dolibarr_nocsrfcheck must be kept to the default value 1 into conf.php +* The module DebugBar must NOT be enabled (by default, this module is not enabled) +* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be switched soon to 1 by default) * ONLY security reports on "stable" modules are allowed (troubles into "experimental" and "developement" modules are not accepted). Scope is the web application (back office) and the APIs. diff --git a/composer.json b/composer.json index d26bbb05ad9..9fede994525 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "vendor-dir" : "htdocs/includes" }, "require" : { - "php" : ">=5.5.0", + "php" : ">=5.6.0", "ext-curl" : "*", "ckeditor/ckeditor" : "4.12.1", "mike42/escpos-php" : "2.2", @@ -33,11 +33,13 @@ "restler/framework" : "3.0.0-RC6", "tecnickcom/tcpdf" : "6.3.2", "nnnick/chartjs" : "^2.9", - "stripe/stripe-php" : "6.43.1" + "stripe/stripe-php" : "6.43.1", + "maximebf/debugbar" : "1.15.1", + "symfony/var-dumper": "3" }, "require-dev" : { - "jakub-onderka/php-parallel-lint" : "^0", - "jakub-onderka/php-console-highlighter" : "^0", + "php-parallel-lint/php-parallel-lint" : "^0", + "php-parallel-lint/php-console-highlighter" : "^0", "phpunit/phpunit" : "^4", "squizlabs/php_codesniffer" : "^2", "phpunit/phpunit-selenium" : "^2" diff --git a/composer.lock b/composer.lock index 09c71674512..5afe0ca34f2 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "17e906996157e8a94564f686a6096dc5", + "content-hash": "1dbd2d05cc0836acfca5988f29005cf2", "packages": [ { "name": "ckeditor/ckeditor", @@ -47,6 +47,67 @@ ], "time": "2019-06-28T10:41:23+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.15.1", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6c4277f6117e4864966c9cb58fb835cee8c74a1e", + "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "psr/log": "^1.0", + "symfony/var-dumper": "^2.6|^3|^4" + }, + "require-dev": { + "phpunit/phpunit": "^5" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "time": "2019-09-24T14:55:42+00:00" + }, { "name": "mike42/escpos-php", "version": "v2.2", @@ -253,6 +314,53 @@ "abandoned": "phpoffice/phpspreadsheet", "time": "2015-05-01T07:00:55+00:00" }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2020-03-23T09:12:05+00:00" + }, { "name": "restler/framework", "version": "3.0.0-RC6", @@ -260,12 +368,12 @@ "source": { "type": "git", "url": "https://github.com/Luracast/Restler-Framework.git", - "reference": "0f6b0f26152f83e43a2a86820206c455095fb2b0" + "reference": "d52e61600d153bca60a287c35141c5c01863127b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/0f6b0f26152f83e43a2a86820206c455095fb2b0", - "reference": "0f6b0f26152f83e43a2a86820206c455095fb2b0", + "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/d52e61600d153bca60a287c35141c5c01863127b", + "reference": "d52e61600d153bca60a287c35141c5c01863127b", "shasum": "" }, "require": { @@ -312,7 +420,7 @@ "rest", "server" ], - "time": "2019-05-12T15:15:11+00:00" + "time": "2020-02-13T16:05:12+00:00" }, { "name": "stripe/stripe-php", @@ -370,6 +478,146 @@ ], "time": "2019-08-29T16:56:12+00:00" }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.18.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "737e07704cca83f9dd0af926d45ce27eedc25657" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/737e07704cca83f9dd0af926d45ce27eedc25657", + "reference": "737e07704cca83f9dd0af926d45ce27eedc25657", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "twig/twig": "~1.20|~2.0" + }, + "suggest": { + "ext-symfony_debug": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony mechanism for exploring and dumping PHP variables", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "time": "2015-11-18T13:48:51+00:00" + }, { "name": "tecnickcom/tcpdf", "version": "6.3.2", @@ -489,16 +737,16 @@ "time": "2015-06-14T21:17:01+00:00" }, { - "name": "jakub-onderka/php-console-color", + "name": "php-parallel-lint/php-console-color", "version": "v0.2", "source": { "type": "git", - "url": "https://github.com/JakubOnderka/PHP-Console-Color.git", + "url": "https://github.com/php-parallel-lint/PHP-Console-Color.git", "reference": "d5deaecff52a0d61ccb613bb3804088da0307191" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/d5deaecff52a0d61ccb613bb3804088da0307191", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Color/zipball/d5deaecff52a0d61ccb613bb3804088da0307191", "reference": "d5deaecff52a0d61ccb613bb3804088da0307191", "shasum": "" }, @@ -531,28 +779,31 @@ "time": "2018-09-29T17:23:10+00:00" }, { - "name": "jakub-onderka/php-console-highlighter", - "version": "v0.4", + "name": "php-parallel-lint/php-console-highlighter", + "version": "v0.5", "source": { "type": "git", - "url": "https://github.com/JakubOnderka/PHP-Console-Highlighter.git", - "reference": "9f7a229a69d52506914b4bc61bfdb199d90c5547" + "url": "https://github.com/php-parallel-lint/PHP-Console-Highlighter.git", + "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/9f7a229a69d52506914b4bc61bfdb199d90c5547", - "reference": "9f7a229a69d52506914b4bc61bfdb199d90c5547", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Highlighter/zipball/21bf002f077b177f056d8cb455c5ed573adfdbb8", + "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8", "shasum": "" }, "require": { "ext-tokenizer": "*", - "jakub-onderka/php-console-color": "~0.2", - "php": ">=5.4.0" + "php": ">=5.4.0", + "php-parallel-lint/php-console-color": "~0.2" + }, + "replace": { + "jakub-onderka/php-console-highlighter": "*" }, "require-dev": { - "jakub-onderka/php-code-style": "~1.0", - "jakub-onderka/php-parallel-lint": "~1.0", - "jakub-onderka/php-var-dump-check": "~0.1", + "php-parallel-lint/php-code-style": "~1.0", + "php-parallel-lint/php-parallel-lint": "~1.0", + "php-parallel-lint/php-var-dump-check": "~0.1", "phpunit/phpunit": "~4.0", "squizlabs/php_codesniffer": "~1.5" }, @@ -574,19 +825,19 @@ } ], "description": "Highlight PHP code in terminal", - "time": "2018-09-29T18:48:56+00:00" + "time": "2020-05-13T07:37:49+00:00" }, { - "name": "jakub-onderka/php-parallel-lint", + "name": "php-parallel-lint/php-parallel-lint", "version": "v0.9.2", "source": { "type": "git", - "url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", "reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/2ead2e4043ab125bee9554f356e0a86742c2d4fa", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/2ead2e4043ab125bee9554f356e0a86742c2d4fa", "reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa", "shasum": "" }, @@ -1082,6 +1333,7 @@ "keywords": [ "tokenizer" ], + "abandoned": true, "time": "2017-12-04T08:55:13+00:00" }, { @@ -1785,6 +2037,159 @@ ], "time": "2019-08-06T08:03:45+00:00" }, + { + "name": "symfony/polyfill-php72", + "version": "v1.18.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "639447d008615574653fb3bc60d1986d7172eaae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/639447d008615574653fb3bc60d1986d7172eaae", + "reference": "639447d008615574653fb3bc60d1986d7172eaae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.18.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981", + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981", + "shasum": "" + }, + "require": { + "php": ">=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, { "name": "symfony/yaml", "version": "v3.4.32", @@ -1903,8 +2308,9 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.5.0", + "php": ">=5.6.0", "ext-curl": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 3c7ff061e49..5f09d9536be 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -28,19 +28,6 @@ With -DEBUGBAR: ---------- - -Move - this.options = { - bodyMarginBottom: true, - bodyMarginBottomHeight: parseInt($('body').css('margin-bottom')), - }; -few line lower in the - initialize: function() { - - - ESCPOS: ------- Replace diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 26ea76d2277..afc40bfdff9 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta", "bills", "admin", "accountancy")); +$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other")); // Security access if (empty($user->rights->accounting->chartofaccount)) @@ -46,14 +46,15 @@ $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_* and others $list = array( - 'ACCOUNTING_LENGTH_GACCOUNT', - 'ACCOUNTING_LENGTH_AACCOUNT', + 'ACCOUNTING_LENGTH_GACCOUNT', + 'ACCOUNTING_LENGTH_AACCOUNT', // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); $list_binding = array( 'ACCOUNTING_DATE_START_BINDING', + 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER' ); /* @@ -67,17 +68,17 @@ if ($action == 'update') { if (!$error) { - foreach ($list as $constname) - { - $constvalue = GETPOST($constname, 'alpha'); + foreach ($list as $constname) + { + $constvalue = GETPOST($constname, 'alpha'); - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - if ($error) { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + if ($error) { + setEventMessages($langs->trans("Error"), null, 'errors'); + } foreach ($list_binding as $constname) { @@ -96,46 +97,46 @@ if ($action == 'update') { } } - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } } if ($action == 'setlistsorttodo') { - $setlistsorttodo = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; + $setlistsorttodo = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } if ($action == 'setlistsortdone') { - $setlistsortdone = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + $setlistsortdone = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } if ($action == 'setmanagezero') { - $setmanagezero = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + $setmanagezero = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } if ($action == 'setdisabledirectinput') { @@ -163,15 +164,51 @@ if ($action == 'setenabledraftexport') { } if ($action == 'setenablesubsidiarylist') { - $setenablesubsidiarylist = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + $setenablesubsidiarylist = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setdisablebindingonsales') { + $setdisablebindingonsales = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setdisablebindingonpurchases') { + $setdisablebindingonpurchases = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setdisablebindingonexpensereports') { + $setdisablebindingonexpensereports = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } /* @@ -226,82 +263,78 @@ print ''; print ''.$langs->trans('Options').''; print "\n"; -if (!empty($user->admin)) +// TO DO Mutualize code for yes/no constants + +/* Set this option as a hidden option but keep it for some needs. +print ''; +print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; +if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; +*/ + +print ''; +print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; +if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; +if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; +if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +// Param a user $user->rights->accounting->chartofaccount can access +foreach ($list as $key) { - // TO DO Mutualize code for yes/no constants + print ''; - /* Set this option as a hidden option but keep it for some needs. - print ''; - print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; - if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; + + // Param + $label = $langs->trans($key); + print ''.$label.''; + // Value + print ''; + print ''; + + print ''; print ''; - */ - - print ''; - print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; - if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - print ''; - print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - print ''; - print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; - if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - // Param a user $user->rights->accounting->chartofaccount can access - foreach ($list as $key) - { - print ''; - - if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; - - // Param - $label = $langs->trans($key); - print ''.$label.''; - // Value - print ''; - print ''; - - print ''; - - print ''; - } } print ''; print '
'; @@ -312,57 +345,94 @@ print ''; print ''.$langs->trans('BindingOptions').''; print "\n"; -if (!empty($user->admin)) -{ - // TO DO Mutualize code for yes/no constants - print ''; - print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; - if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - print ''; - print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; - if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; +// TO DO Mutualize code for yes/no constants +print ''; +print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; +if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; +if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; // Param a user $user->rights->accounting->chartofaccount can access foreach ($list_binding as $key) { - print ''; + print ''; - // Param - $label = $langs->trans($key); - print ''.$label.''; - // Value - print ''; - if ($key == 'ACCOUNTING_DATE_START_BINDING') { + // Param + $label = $langs->trans($key); + print ''.$label.''; + // Value + print ''; + if ($key == 'ACCOUNTING_DATE_START_BINDING') { print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); - } else { + } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { + $array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); + print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER)?$conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER:0)); + } else { print ''; } - print ''; - - print ''; + print ''; + print ''; } +print ''; +print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").''; +if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").''; +if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").''; +if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 0f5acd96ae2..6b326ec872f 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -93,7 +93,7 @@ $formaccounting = new FormAccounting($db); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $search_societe = ''; - $search_lineid = ''; + $search_lineid = ''; $search_ref = ''; $search_invoice = ''; $search_label = ''; @@ -203,7 +203,7 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_lineid) { - $sql .= natural_search("fd.rowid", $search_lineid, 1); + $sql .= natural_search("fd.rowid", $search_lineid, 1); } if (strlen(trim($search_invoice))) { $sql .= natural_search("f.ref", $search_invoice); @@ -251,13 +251,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -309,9 +309,9 @@ if ($result) { print ''; print ''; print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''; @@ -349,10 +349,10 @@ if ($result) { print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; - $thirdpartystatic = new Societe($db); - $facturestatic = new Facture($db); + $thirdpartystatic = new Societe($db); + $facturestatic = new Facture($db); $productstatic = new Product($db); - $accountingaccountstatic = new AccountingAccount($db); + $accountingaccountstatic = new AccountingAccount($db); $i = 0; while ($i < min($num_lines, $limit)) { @@ -362,16 +362,16 @@ if ($result) { $facturestatic->id = $objp->facid; $facturestatic->type = $objp->ftype; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta_client = $objp->code_compta_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta_client = $objp->code_compta_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->country_code = $objp->country_code; $productstatic->ref = $objp->product_ref; $productstatic->id = $objp->product_id; @@ -412,7 +412,7 @@ if ($result) { print ''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'customer') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'customer').''; // Country print ''; @@ -425,7 +425,7 @@ if ($result) { print ''.$objp->tva_intra.''; print ''; - print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); + print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print ' '; print img_edit(); print ''; @@ -434,14 +434,14 @@ if ($result) { print ''; $i++; } - print ''; - print ""; + print ''; + print ""; - if ($nbtotalofrecords > $limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); - } + if ($nbtotalofrecords > $limit) { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); + } - print ''; + print ''; } else { print $db->lasterror(); } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index b55d587c48b..b7027282281 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -114,7 +114,7 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_societe=''; + $search_societe = ''; $search_lineid = ''; $search_ref = ''; $search_invoice = ''; @@ -386,7 +386,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); //print ''; @@ -582,7 +582,7 @@ if ($result) { print ''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'customer') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'customer').''; // Country print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 4b06c49a0cb..63305791ec7 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -201,16 +201,16 @@ if ($resql) { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else print $row[1]; print ''; - for ($i = 2; $i <= 12; $i++) { - print ''.price($row[$i]).''; - } - print ''.price($row[13]).''; - print ''.price($row[14]).''; - print ''; - } - $db->free($resql); + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''.price($row[14]).''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "\n"; print ''; @@ -275,16 +275,16 @@ if ($resql) { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else print $row[1]; print ''; - for ($i = 2; $i <= 12; $i++) { - print ''.price($row[$i]).''; - } - print ''.price($row[13]).''; - print ''.price($row[14]).''; - print ''; - } - $db->free($resql); + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''.price($row[14]).''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "\n"; print ''; @@ -293,60 +293,60 @@ print ''; if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? { - print '
'; - print '
'; + print '
'; + print '
'; - print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); - //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); + print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); + //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); print '
'; - print ''; - print ''; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - print ''; - } - print ''; + print '
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; + } + print ''; - $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; - } - $sql .= " SUM(erd.total_ht) as total"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; - $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; - $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; + $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + } + $sql .= " SUM(erd.total_ht) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; + $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } - $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; - $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy + $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; + $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy - dol_syslog('htdocs/accountancy/expensereport/index.php'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); + dol_syslog('htdocs/accountancy/expensereport/index.php'); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); - while ($row = $db->fetch_row($resql)) { - print ''; - for ($i = 1; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - } + while ($row = $db->fetch_row($resql)) { + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; + } + print ''; + print ''; + } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
\n"; - print '
'; + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "\n"; + print ''; } // End of page diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 5ff43d200d7..6135a213115 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -86,8 +86,8 @@ $formaccounting = new FormAccounting($db); // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $search_login = ''; - $search_expensereport = ''; + $search_login = ''; + $search_expensereport = ''; $search_label = ''; $search_desc = ''; $search_amount = ''; @@ -178,7 +178,7 @@ $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't sha $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; // Add search filter like if (strlen(trim($search_login))) { - $sql .= natural_search("u.login", $search_login); + $sql .= natural_search("u.login", $search_login); } if (strlen(trim($search_expensereport))) { $sql .= natural_search("er.ref", $search_expensereport); @@ -207,13 +207,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -228,7 +228,7 @@ if ($result) { $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport); if ($search_label) $param .= "&search_label=".urlencode($search_label); if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); @@ -257,12 +257,12 @@ if ($result) { $moreforfilter = ''; - print '
'; + print '
'; print ''."\n"; print ''; - print ''; - print ''; + print ''; + print ''; print ''; if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print ''; @@ -278,14 +278,14 @@ if ($result) { print ''; print ''; print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; print "\n"; print ''; - print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); @@ -296,31 +296,31 @@ if ($result) { print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); - $checkpicto = $form->showCheckAddButtons(); + $checkpicto = $form->showCheckAddButtons(); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; $expensereportstatic = new ExpenseReport($db); $accountingaccountstatic = new AccountingAccount($db); - $userstatic = new User($db); + $userstatic = new User($db); - $i = 0; + $i = 0; while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); $expensereportstatic->ref = $objp->ref; $expensereportstatic->id = $objp->erid; - $userstatic->id = $objp->rowid; - $userstatic->ref = $objp->label; - $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; - $userstatic->email = $objp->email; - $userstatic->gender = $objp->gender; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->employee = $objp->employee; - $userstatic->photo = $objp->photo; + $userstatic->id = $objp->rowid; + $userstatic->ref = $objp->label; + $userstatic->login = $objp->login; + $userstatic->statut = $objp->statut; + $userstatic->email = $objp->email; + $userstatic->gender = $objp->gender; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->employee = $objp->employee; + $userstatic->photo = $objp->photo; $accountingaccountstatic->rowid = $objp->fk_compte; $accountingaccountstatic->label = $objp->label; @@ -329,15 +329,15 @@ if ($result) { print ''; - // Login - print ''; + // Login + print ''; - // Line id + // Line id print ''; - // Ref Expense report + // Ref Expense report print ''; // Date validation @@ -347,10 +347,10 @@ if ($result) { print ''; - // Fees label + // Fees label print ''; - // Fees description -- Can be null + // Fees description -- Can be null print ''; - // Vat rate + // Vat rate print ''; // Accounting account affected print ''; print ''; @@ -379,7 +379,7 @@ if ($result) { print ""; if ($nbtotalofrecords > $limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); } print ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 166a448d5ff..0a5bef0c57e 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -102,16 +102,16 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_login = ''; - $search_expensereport = ''; - $search_label = ''; - $search_desc = ''; - $search_amount = ''; - $search_account = ''; - $search_vat = ''; - $search_day = ''; - $search_month = ''; - $search_year = ''; + $search_login = ''; + $search_expensereport = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; } // Mass actions @@ -124,46 +124,46 @@ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($massaction == 'ventil') { $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; - if (!empty($mesCasesCochees)) { - $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; - $msg .= '
'; - $cpt = 0; - $ok = 0; - $ko = 0; + //print '
' . $langs->trans("Processing") . '...
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; + $cpt = 0; + $ok = 0; + $ko = 0; - foreach ($mesCasesCochees as $maLigneCochee) { - $maLigneCourante = explode("_", $maLigneCochee); - $monId = $maLigneCourante[0]; - $monCompte = GETPOST('codeventil'.$monId); + foreach ($mesCasesCochees as $maLigneCochee) { + $maLigneCourante = explode("_", $maLigneCochee); + $monId = $maLigneCourante[0]; + $monCompte = GETPOST('codeventil'.$monId); - if ($monCompte <= 0) - { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; - $ko++; - } else { - $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sql .= " SET fk_code_ventilation = ".$monCompte; - $sql .= " WHERE rowid = ".$monId; + if ($monCompte <= 0) + { + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $ko++; + } else { + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; - $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, ''); + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); - dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); - if ($db->query($sql)) { - $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; - $ok++; - } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; - $ko++; - } - } + dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); + if ($db->query($sql)) { + $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $ok++; + } else { + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $ko++; + } + } - $cpt++; - } - $msg .= '
'; - $msg .= '
'.$langs->trans("EndProcessing").'
'; - } + $cpt++; + } + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; + } } @@ -181,8 +181,8 @@ if (empty($chartaccountcode)) { print $langs->trans("ErrorChartOfAccountSystemNotSelected"); // End of page - llxFooter(); - $db->close(); + llxFooter(); + $db->close(); exit; } @@ -204,25 +204,25 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { } // Add search filter like if (strlen(trim($search_login))) { - $sql .= natural_search("u.login", $search_login); + $sql .= natural_search("u.login", $search_login); } if (strlen(trim($search_expensereport))) { - $sql .= natural_search("er.ref", $search_expensereport); + $sql .= natural_search("er.ref", $search_expensereport); } if (strlen(trim($search_label))) { - $sql .= natural_search("f.label", $search_label); + $sql .= natural_search("f.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= natural_search("erd.comments", $search_desc); + $sql .= natural_search("erd.comments", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= natural_search("erd.total_ht", $search_amount, 1); + $sql .= natural_search("erd.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("erd.tva_tx", $search_vat, 1); + $sql .= natural_search("erd.tva_tx", $search_vat, 1); } $sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy @@ -233,13 +233,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -255,7 +255,7 @@ if ($result) { $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_month) $param .= '&search_month='.urlencode($search_month); @@ -267,7 +267,7 @@ if ($result) { if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); $arrayofmassactions = array( - 'ventil' => $langs->trans("Ventilate") + 'ventil' => $langs->trans("Ventilate") ); $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); @@ -295,12 +295,12 @@ if ($result) { $moreforfilter = ''; - print '
'; + print '
'; print '
'; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; - print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); - print ''; + print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); + print ''.$objp->rowid.''.$expensereportstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->date), 'day').''.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; @@ -360,13 +360,13 @@ if ($result) { // Amount without taxes print ''.price($objp->total_ht).''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); - print ' '; + print ' '; print img_edit(); print '
'."\n"; // We add search filter print ''; - print ''; + print ''; print ''; print ''; if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -324,7 +324,7 @@ if ($result) { print ''; print ''; - print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -356,23 +356,23 @@ if ($result) { $expensereport_static->ref = $objp->ref; $expensereport_static->id = $objp->erid; - $userstatic->id = $objp->rowid; - $userstatic->ref = $objp->label; - $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; - $userstatic->email = $objp->email; - $userstatic->gender = $objp->gender; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->employee = $objp->employee; - $userstatic->photo = $objp->photo; + $userstatic->id = $objp->rowid; + $userstatic->ref = $objp->label; + $userstatic->login = $objp->login; + $userstatic->statut = $objp->statut; + $userstatic->email = $objp->email; + $userstatic->gender = $objp->gender; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->employee = $objp->employee; + $userstatic->photo = $objp->photo; - print ''; + print ''; - // Login - print ''; + // Login + print ''; // Line id print ''; @@ -400,7 +400,7 @@ if ($result) { print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments); print ''; - // Amount without taxes + // Amount without taxes print ''; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 29f1cb76d0b..12fe8792401 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -90,17 +90,16 @@ if ($user->socid > 0 && empty($id_journal)) $error = 0; -$year_current = strftime("%Y", dol_now()); -$pastmonth = strftime("%m", dol_now()) - 1; -$pastmonthyear = $year_current; -if ($pastmonth == 0) { - $pastmonth = 12; - $pastmonthyear--; -} - $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); +// Period by default on transfer +$dates = getDefaultDatesForTransfer(); +$date_start = $dates['date_start']; +$date_end = $dates['date_end']; +$pastmonthyear = $dates['pastmonthyear']; +$pastmonth = $dates['pastmonth']; + if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 4a1d2935f0f..b24f8550e50 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -70,17 +70,16 @@ $accountingjournalstatic->fetch($id_journal); $journal = $accountingjournalstatic->code; $journal_label = $accountingjournalstatic->label; -$year_current = strftime("%Y", dol_now()); -$pastmonth = strftime("%m", dol_now()) - 1; -$pastmonthyear = $year_current; -if ($pastmonth == 0) { - $pastmonth = 12; - $pastmonthyear--; -} - $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); +// Period by default on transfer +$dates = getDefaultDatesForTransfer(); +$date_start = $dates['date_start']; +$date_end = $dates['date_end']; +$pastmonthyear = $dates['pastmonthyear']; +$pastmonth = $dates['pastmonth']; + if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 4c9e25725f2..779c04f68fa 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -75,17 +75,16 @@ $accountingjournalstatic->fetch($id_journal); $journal = $accountingjournalstatic->code; $journal_label = $accountingjournalstatic->label; -$year_current = strftime("%Y", dol_now()); -$pastmonth = strftime("%m", dol_now()) - 1; -$pastmonthyear = $year_current; -if ($pastmonth == 0) { - $pastmonth = 12; - $pastmonthyear--; -} - $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); +// Period by default on transfer +$dates = getDefaultDatesForTransfer(); +$date_start = $dates['date_start']; +$date_end = $dates['date_end']; +$pastmonthyear = $dates['pastmonthyear']; +$pastmonth = $dates['pastmonth']; + if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 4b66feb9e3d..998f34745ac 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -78,17 +78,16 @@ $accountingjournalstatic->fetch($id_journal); $journal = $accountingjournalstatic->code; $journal_label = $accountingjournalstatic->label; -$year_current = strftime("%Y", dol_now()); -$pastmonth = strftime("%m", dol_now()) - 1; -$pastmonthyear = $year_current; -if ($pastmonth == 0) { - $pastmonth = 12; - $pastmonthyear--; -} - $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); +// Period by default on transfer +$dates = getDefaultDatesForTransfer(); +$date_start = $dates['date_start']; +$date_end = $dates['date_end']; +$pastmonthyear = $dates['pastmonthyear']; +$pastmonth = $dates['pastmonth']; + if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3deb3cc9d1c..f1807c1c2cc 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -331,9 +331,9 @@ $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - while ($row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for ($i = 2; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - print ''; - } - $db->free($resql); + for ($i = 2; $i <= 12; $i++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "
'; - print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); - print ''; + print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); + print ''.$objp->rowid.''; print price($objp->price); print '
'; if ($row[0] == 'tobind') { @@ -346,16 +346,16 @@ if ($resql) { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else print $row[1]; print ''.price($row[$i]).''.price($row[13]).''.price($row[14]).'
'.price($row[$i]).''.price($row[13]).''.price($row[14]).'
\n"; print '
'; @@ -364,60 +364,60 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? { - print '
'; - print '
'; + print '
'; + print '
'; - print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); - //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); + print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); + //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); print '
'; - print ''; - print ''; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - print ''; - } - print ''; + print '
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; + } + print ''; - $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; - } - $sql .= " SUM(ffd.total_ht) as total"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; - $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; - $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; + $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + } + $sql .= " SUM(ffd.total_ht) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } - $sql .= " AND ff.fk_statut > 0"; + $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; - $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy + $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy - dol_syslog('htdocs/accountancy/supplier/index.php'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); + dol_syslog('htdocs/accountancy/supplier/index.php'); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); - while ($row = $db->fetch_row($resql)) { - print ''; - for ($i = 1; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
\n"; - print '
'; + while ($row = $db->fetch_row($resql)) { + print ''.$row[0].''; + for ($i = 1; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "\n"; + print ''; } // End of page diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 9437b0e8c32..6a5e234532c 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -94,7 +94,7 @@ $formaccounting = new FormAccounting($db); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { $search_societe = ''; - $search_lineid = ''; + $search_lineid = ''; $search_ref = ''; $search_invoice = ''; $search_label = ''; @@ -196,7 +196,7 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_lineid) { - $sql .= natural_search("l.rowid", $search_lineid, 1); + $sql .= natural_search("l.rowid", $search_lineid, 1); } if (strlen(trim($search_invoice))) { $sql .= natural_search("f.ref", $search_invoice); @@ -250,13 +250,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -318,7 +318,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); // print ''; @@ -348,29 +348,29 @@ if ($result) { print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; - $thirdpartystatic = new Societe($db); + $thirdpartystatic = new Societe($db); $facturefournisseur_static = new FactureFournisseur($db); $productstatic = new ProductFournisseur($db); - $accountingaccountstatic = new AccountingAccount($db); + $accountingaccountstatic = new AccountingAccount($db); - $i = 0; + $i = 0; while ($i < min($num_lines, $limit)) - { + { $objp = $db->fetch_object($result); $facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->id = $objp->facid; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta_client = $objp->code_compta_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta_client = $objp->code_compta_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->country_code = $objp->country_code; $productstatic->ref = $objp->product_ref; $productstatic->id = $objp->product_id; @@ -415,7 +415,7 @@ if ($result) { print ''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'supplier') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'supplier').''; // Country print ''; @@ -428,7 +428,7 @@ if ($result) { print ''.$objp->tva_intra.''; print ''; - print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); + print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print ' '; print img_edit(); print ''; @@ -437,14 +437,14 @@ if ($result) { print ''; $i++; } - print ''; - print ""; + print ''; + print ""; - if ($nbtotalofrecords > $limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); - } + if ($nbtotalofrecords > $limit) { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); + } - print ''; + print ''; } else { print $db->lasterror(); } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 073b8791f2b..53c987e0189 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -118,7 +118,7 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_societe=''; + $search_societe = ''; $search_lineid = ''; $search_ref = ''; $search_invoice = ''; @@ -385,7 +385,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); //print ''; @@ -419,7 +419,7 @@ if ($result) { print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; - $thirdpartystatic=new Societe($db); + $thirdpartystatic = new Societe($db); $facturefourn_static = new FactureFournisseur($db); $product_static = new Product($db); @@ -569,7 +569,7 @@ if ($result) { print ''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'supplier') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'supplier').''; // Country print ''; diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index 97411a27abf..1b26a029a01 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -47,15 +47,15 @@ $error = 0; // Editing global variables not related to a specific theme $constantes = array( - 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), - 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', - 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ - 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ - 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ - 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ - 'ADHERENT_MAIL_FROM'=>'string', - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string', - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html', + 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), + 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', + 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ + 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ + 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ + 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ + 'ADHERENT_MAIL_FROM'=>'string', + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string', + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html', ); @@ -66,16 +66,16 @@ $constantes = array( // if ($action == 'updateall') { - $db->begin(); - $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; - $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); - if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { - setEventMessages('ErrorFailedToSaveDate', null, 'errors'); - $db->rollback(); - } else { - setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); - $db->commit(); - } + $db->begin(); + $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; + $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { + setEventMessages('ErrorFailedToSaveDate', null, 'errors'); + $db->rollback(); + } else { + setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); + $db->commit(); + } } // Action to update or add a constant diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 2a177ebade4..439854229e0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -335,8 +335,8 @@ if (empty($reshook)) { if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { - // Create thumbs - $object->addThumbs($newfile); + // Create thumbs + $object->addThumbs($newfile); } } } else { @@ -354,8 +354,8 @@ if (empty($reshook)) { } } - $rowid = $object->id; - $id = $object->id; + $rowid = $object->id; + $id = $object->id; $action = ''; if (!empty($backtopage)) { @@ -402,7 +402,7 @@ if (empty($reshook)) { // $skype=GETPOST("member_skype", 'alpha'); // $twitter=GETPOST("member_twitter", 'alpha'); // $facebook=GETPOST("member_facebook", 'alpha'); - // $linkedin=GETPOST("member_linkedin", 'alpha'); + // $linkedin=GETPOST("member_linkedin", 'alpha'); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $login = GETPOST("member_login", 'alpha'); $pass = GETPOST("password", 'alpha'); @@ -755,7 +755,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->display_canvas($action); // Show template } else { // ----------------------------------------- // When used in standard mode @@ -778,16 +778,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->country = $tmparray['label']; } - if (!empty($socid)) { - $object = new Societe($db); - if ($socid > 0) $object->fetch($socid); + if (!empty($socid)) { + $object = new Societe($db); + if ($socid > 0) $object->fetch($socid); - if (!($object->id > 0)) { - $langs->load("errors"); - print($langs->trans('ErrorRecordNotFound')); - exit; - } - } + if (!($object->id > 0)) { + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; + } + } $adht = new AdherentType($db); @@ -829,7 +829,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; if ($backtopage) print ''; - dol_fiche_head(''); + dol_fiche_head(''); print ''; print ''; @@ -934,14 +934,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - if (!empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; + if (!$value['active']) break; print ''; } } - // Birth Date + // Birth Date print "\n"; @@ -1167,14 +1167,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - if (!empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; + if (!$value['active']) break; print ''; } } - // Birth Date + // Birth Date print "\n"; @@ -1447,10 +1447,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { dol_banner_tab($object, 'rowid', $linkback); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; + print '
'; print '
'.$langs->trans("PhoneMobile").''.img_picto('', 'object_phoning_mobile').'
'.$langs->trans($value['label']).'
".$langs->trans("DateToBirth")."\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print "
'.$langs->trans("PhoneMobile").''.img_picto('', 'object_phoning_mobile').' phone_mobile).'">
'.$langs->trans($value['label']).'
".$langs->trans("DateToBirth")."\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print "
'; // Login @@ -1483,13 +1483,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } @@ -1503,8 +1503,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } else { if ($object->need_subscription == 0) { - print $langs->trans("SubscriptionNotNeeded"); - } elseif (!$adht->subscription) { + print $langs->trans("SubscriptionNotNeeded"); + } elseif (!$adht->subscription) { print $langs->trans("SubscriptionNotRecorded"); if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated } else { @@ -1560,14 +1560,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } print ''; - print '
'.$langs->trans("Password").''.preg_replace('/./i', '*', $object->pass); if ($object->pass) print preg_replace('/./i', '*', $object->pass); else { - if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - else print $langs->trans("Hidden"); + if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; + else print $langs->trans("Hidden"); } if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { - $langs->load("errors"); - $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); - print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); + $langs->load("errors"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); + print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); } print '
'; + print ''; - print ''; + print ''; - print '
'; - print '
'; + print '
'; + print '
'; - print ''; + print '
'; // Birth Date print ''; @@ -1585,12 +1585,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { //VCard print ''; + print ''; // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -1598,9 +1598,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "
'.$langs->trans("DateToBirth").''.dol_print_date($object->birth, 'day').'
'; - print $langs->trans("VCard").''; + print $langs->trans("VCard").''; print ''; print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); print $langs->trans("Download"); print ''; - print '
\n"; print "
\n"; - print '
'; + print '
'; - dol_fiche_end(); + dol_fiche_end(); /* @@ -1769,7 +1769,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3f8a5ce1b25..94bf34208ff 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -62,26 +62,26 @@ class AdherentType extends CommonObject public $libelle; /** - * @var string Adherent type label - */ - public $label; + * @var string Adherent type label + */ + public $label; - /** - * @var string Adherent type nature - */ - public $morphy; + /** + * @var string Adherent type nature + */ + public $morphy; - public $duration; + public $duration; - /* + /* * type expiration */ - public $duration_value; + public $duration_value; - /** - * Expiration unit - */ - public $duration_unit; + /** + * Expiration unit + */ + public $duration_unit; /** * @var int Subsription required (0 or 1) @@ -101,7 +101,7 @@ class AdherentType extends CommonObject /** @var array Array of members */ public $members = array(); - public $multilangs = array(); + public $multilangs = array(); /** @@ -115,157 +115,157 @@ class AdherentType extends CommonObject $this->status = 1; } - /** - * Load array this->multilangs - * - * @return int <0 if KO, >0 if OK - */ - public function getMultiLangs() - { - global $langs; + /** + * Load array this->multilangs + * + * @return int <0 if KO, >0 if OK + */ + public function getMultiLangs() + { + global $langs; - $current_lang = $langs->getDefaultLang(); + $current_lang = $langs->getDefaultLang(); - $sql = "SELECT lang, label, description, email"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id; + $sql = "SELECT lang, label, description, email"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; - $result = $this->db->query($sql); - if ($result) { - while ($obj = $this->db->fetch_object($result)) { - //print 'lang='.$obj->lang.' current='.$current_lang.'
'; - if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. + $result = $this->db->query($sql); + if ($result) { + while ($obj = $this->db->fetch_object($result)) { + //print 'lang='.$obj->lang.' current='.$current_lang.'
'; + if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. $this->label = $obj->label; - $this->description = $obj->description; - $this->email = $obj->email; - } - $this->multilangs["$obj->lang"]["label"] = $obj->label; - $this->multilangs["$obj->lang"]["description"] = $obj->description; - $this->multilangs["$obj->lang"]["email"] = $obj->email; - } - return 1; - } else { - $this->error = "Error: ".$this->db->lasterror()." - ".$sql; - return -1; - } - } + $this->description = $obj->description; + $this->email = $obj->email; + } + $this->multilangs["$obj->lang"]["label"] = $obj->label; + $this->multilangs["$obj->lang"]["description"] = $obj->description; + $this->multilangs["$obj->lang"]["email"] = $obj->email; + } + return 1; + } else { + $this->error = "Error: ".$this->db->lasterror()." - ".$sql; + return -1; + } + } - /** - * Update or add a translation for a product - * - * @param User $user Object user making update - * @return int <0 if KO, >0 if OK - */ - public function setMultiLangs($user) - { - global $conf, $langs; + /** + * Update or add a translation for a product + * + * @param User $user Object user making update + * @return int <0 if KO, >0 if OK + */ + public function setMultiLangs($user) + { + global $conf, $langs; - $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); - $current_lang = $langs->getDefaultLang(); + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); + $current_lang = $langs->getDefaultLang(); - foreach ($langs_available as $key => $value) { - if ($key == $current_lang) { - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id; - $sql .= " AND lang='".$key."'"; + foreach ($langs_available as $key => $value) { + if ($key == $current_lang) { + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($this->db->num_rows($result)) { // if there is already a description line for this language + if ($this->db->num_rows($result)) { // if there is already a description line for this language $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2 .= " SET "; - $sql2 .= " label='".$this->db->escape($this->label)."',"; - $sql2 .= " description='".$this->db->escape($this->description)."'"; - $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - $sql2 .= ")"; - $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; - $sql2 .= " '".$this->db->escape($this->description)."'"; - $sql2 .= ")"; - } - dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); - if (!$this->db->query($sql2)) { - $this->error = $this->db->lasterror(); - return -1; - } - } elseif (isset($this->multilangs[$key])) { - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id; - $sql .= " AND lang='".$key."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; + $sql2 .= " '".$this->db->escape($this->description)."'"; + $sql2 .= ")"; + } + dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); + return -1; + } + } elseif (isset($this->multilangs[$key])) { + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($this->db->num_rows($result)) { // if there is already a description line for this language + if ($this->db->num_rows($result)) { // if there is already a description line for this language $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2 .= " SET "; - $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - $sql2 .= ")"; - $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; - $sql2 .= ")"; - } + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; + $sql2 .= ")"; + } - // We do not save if main fields are empty - if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { - if (!$this->db->query($sql2)) { - $this->error = $this->db->lasterror(); - return -1; - } - } - } else { - // language is not current language and we didn't provide a multilang description for this language - } - } + // We do not save if main fields are empty + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); + return -1; + } + } + } else { + // language is not current language and we didn't provide a multilang description for this language + } + } - // Call trigger - $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user); - if ($result < 0) { - $this->error = $this->db->lasterror(); - return -1; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user); + if ($result < 0) { + $this->error = $this->db->lasterror(); + return -1; + } + // End call triggers - return 1; - } + return 1; + } - /** - * Delete a language for this product - * - * @param string $langtodelete Language code to delete - * @param User $user Object user making delete - * - * @return int <0 if KO, >0 if OK - */ - public function delMultiLangs($langtodelete, $user) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; + /** + * Delete a language for this product + * + * @param string $langtodelete Language code to delete + * @param User $user Object user making delete + * + * @return int <0 if KO, >0 if OK + */ + public function delMultiLangs($langtodelete, $user) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; - dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - // Call trigger - $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user); - if ($result < 0) { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); - return -1; - } - // End call triggers - return 1; - } else { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); - return -1; - } - } + dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + // Call trigger + $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user); + if ($result < 0) { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); + return -1; + } + // End call triggers + return 1; + } else { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); + return -1; + } + } /** * Fonction qui permet de creer le status de l'adherent @@ -337,7 +337,7 @@ class AdherentType extends CommonObject */ public function update($user, $notrigger = 0) { - global $langs, $conf, $hookmanager; + global $langs, $conf, $hookmanager; $error = 0; @@ -359,15 +359,15 @@ class AdherentType extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->description = $this->db->escape($this->note); + $this->description = $this->db->escape($this->note); - // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { - if ($this->setMultiLangs($user) < 0) { - $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; - return -2; - } - } + // Multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { + if ($this->setMultiLangs($user) < 0) { + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; + return -2; + } + } $action = 'update'; @@ -439,7 +439,7 @@ class AdherentType extends CommonObject */ public function fetch($rowid) { - global $langs, $conf; + global $langs, $conf; $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; @@ -465,10 +465,10 @@ class AdherentType extends CommonObject $this->note = $obj->note; $this->vote = $obj->vote; - // multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { - $this->getMultiLangs(); - } + // multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { + $this->getMultiLangs(); + } } return 1; @@ -478,7 +478,7 @@ class AdherentType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of members' type * @@ -487,7 +487,7 @@ class AdherentType extends CommonObject */ public function liste_array($status = -1) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $adherenttypes = array(); @@ -578,31 +578,31 @@ class AdherentType extends CommonObject //return $morphy; } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen length max label - * @param int $notooltip 1=Disable tooltip - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) - { - global $langs; + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int $notooltip 1=Disable tooltip + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + { + global $langs; - $result = ''; - $label = $langs->trans("ShowTypeCard", $this->label); + $result = ''; + $label = $langs->trans("ShowTypeCard", $this->label); - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); + $result .= $linkend; - return $result; - } + return $result; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -611,7 +611,7 @@ class AdherentType extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } @@ -623,9 +623,9 @@ class AdherentType extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Status label */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('companies'); @@ -640,10 +640,10 @@ class AdherentType extends CommonObject } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -655,7 +655,7 @@ class AdherentType extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN; @@ -665,8 +665,8 @@ class AdherentType extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * @@ -674,7 +674,7 @@ class AdherentType extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $info = array(); @@ -766,15 +766,15 @@ class AdherentType extends CommonObject * * @return string Return mail model content of type or empty */ - public function getMailOnResiliate() - { - global $conf; + public function getMailOnResiliate() + { + global $conf; - // NOTE mail_resiliate not defined so never used - if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined + // NOTE mail_resiliate not defined so never used + if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined return $this->mail_resiliate; - } + } - return ''; - } + return ''; + } } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 7d744b599de..39ee57a6744 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -81,10 +81,10 @@ $extrafields->fetch_name_optionals_label($object->table_element); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_lastname = ""; - $search_login = ""; - $search_email = ""; - $type = ""; - $sall = ""; + $search_login = ""; + $search_email = ""; + $type = ""; + $sall = ""; } @@ -226,8 +226,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $newcardbutton = ''; if ($user->rights->adherent->configurer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); - } + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); + } print '
'; if ($optioncss != '') print ''; @@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''.$langs->trans("Ref").''; print ''.$langs->trans("Label").''; - print ''.$langs->trans("MemberNature").''; + print ''.$langs->trans("MemberNature").''; print ''.$langs->trans("SubscriptionRequired").''; print ''.$langs->trans("VoteAllowed").''; print ''.$langs->trans("Status").''; @@ -270,9 +270,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') { //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' print ''; print ''.dol_escape_htmltag($objp->label).''; - print ''; + print ''; if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy"); - print ''; + print ''; print ''.yn($objp->subscription).''; print ''.yn($objp->vote).''; print ''.$membertype->getLibStatut(5).''; @@ -308,7 +308,7 @@ if ($action == 'create') { print ''; print ''; - dol_fiche_head(''); + dol_fiche_head(''); print ''; print ''; @@ -319,10 +319,10 @@ if ($action == 'create') { print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); print ''; - // Morphy + // Morphy $morphys = array(); - $morphys[""] = $langs->trans("MorPhy"); - $morphys["phy"] = $langs->trans("Physical"); + $morphys[""] = $langs->trans("MorPhy"); + $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print ''; print '
'; - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - $moreforfilter = ''; + $moreforfilter = ''; - print '
'; - print '
'.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); @@ -447,11 +447,11 @@ if ($rowid > 0) { } // Add - if ($user->rights->adherent->configurer && !empty($object->status)) { - print ''; - } else { - print ''; - } + if ($user->rights->adherent->configurer && !empty($object->status)) { + print ''; + } else { + print ''; + } // Delete if ($user->rights->adherent->configurer) { @@ -479,7 +479,7 @@ if ($rowid > 0) { $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } if ($status != '') { - $sql .= natural_search('d.statut', $status, 2); + $sql .= natural_search('d.statut', $status, 2); } if ($action == 'search') { if (GETPOST('search', 'alpha')) { @@ -495,12 +495,12 @@ if ($rowid > 0) { if (!empty($search_email)) { $sql .= natural_search("d.email", $search_email); } - if ($filter == 'uptodate') { - $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; - } - if ($filter == 'outofdate') { - $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; - } + if ($filter == 'uptodate') { + $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; + } + if ($filter == 'outofdate') { + $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; + } $sql .= " ".$db->order($sortfield, $sortorder); @@ -508,71 +508,71 @@ if ($rowid > 0) { $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($result); - else dol_print_error($db); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if ($resql) $nbtotalofrecords = $db->num_rows($result); + else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; - $offset = 0; - } + $offset = 0; + } } $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $titre = $langs->trans("MembersList"); - if ($status != '') { - if ($status == '-1,1') { - $titre = $langs->trans("MembersListQualified"); - } elseif ($status == '-1') { - $titre = $langs->trans("MembersListToValid"); - } elseif ($status == '1' && !$filter) { - $titre = $langs->trans("MembersListValid"); - } elseif ($status == '1' && $filter == 'uptodate') { - $titre = $langs->trans("MembersListUpToDate"); - } elseif ($status == '1' && $filter == 'outofdate') { - $titre = $langs->trans("MembersListNotUpToDate"); - } elseif ($status == '0') { - $titre = $langs->trans("MembersListResiliated"); - } - } elseif ($action == 'search') { - $titre = $langs->trans("MembersListQualified"); - } + $titre = $langs->trans("MembersList"); + if ($status != '') { + if ($status == '-1,1') { + $titre = $langs->trans("MembersListQualified"); + } elseif ($status == '-1') { + $titre = $langs->trans("MembersListToValid"); + } elseif ($status == '1' && !$filter) { + $titre = $langs->trans("MembersListValid"); + } elseif ($status == '1' && $filter == 'uptodate') { + $titre = $langs->trans("MembersListUpToDate"); + } elseif ($status == '1' && $filter == 'outofdate') { + $titre = $langs->trans("MembersListNotUpToDate"); + } elseif ($status == '0') { + $titre = $langs->trans("MembersListResiliated"); + } + } elseif ($action == 'search') { + $titre = $langs->trans("MembersListQualified"); + } - if ($type > 0) { + if ($type > 0) { $membertype = new AdherentType($db); - $result = $membertype->fetch($type); + $result = $membertype->fetch($type); $titre .= " (".$membertype->label.")"; - } + } - $param = "&rowid=".$object->id; - if (!empty($status)) $param .= "&status=".$status; - if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; - if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; - if (!empty($search_login)) $param .= "&search_login=".$search_login; - if (!empty($search_email)) $param .= "&search_email=".$search_email; - if (!empty($filter)) $param .= "&filter=".$filter; + $param = "&rowid=".$object->id; + if (!empty($status)) $param .= "&status=".$status; + if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; + if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; + if (!empty($search_login)) $param .= "&search_login=".$search_login; + if (!empty($search_email)) $param .= "&search_email=".$search_email; + if (!empty($filter)) $param .= "&filter=".$filter; - if ($sall) { - print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; - } + if ($sall) { + print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; + } print ''; - print ''; + print ''; print '
'."\n"; + print '
'; + print '
'."\n"; - // Fields title search + // Fields title search print ''; print ''; print "\n"; print ''; - print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); - print "\n"; + print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); + print "\n"; - while ($i < $num && $i < $conf->liste_limit) { - $objp = $db->fetch_object($resql); + while ($i < $num && $i < $conf->liste_limit) { + $objp = $db->fetch_object($resql); - $datefin = $db->jdate($objp->datefin); + $datefin = $db->jdate($objp->datefin); - $adh = new Adherent($db); - $adh->lastname = $objp->lastname; - $adh->firstname = $objp->firstname; + $adh = new Adherent($db); + $adh->lastname = $objp->lastname; + $adh->firstname = $objp->firstname; - // Lastname - print ''; - if ($objp->company != '') { - print ''."\n"; - } else { - print ''."\n"; - } + // Lastname + print ''; + if ($objp->company != '') { + print ''."\n"; + } else { + print ''."\n"; + } - // Login - print "\n"; + // Login + print "\n"; - // Type - /*print ''; */ - // Moral/Physique - print "\n"; + // Moral/Physique + print "\n"; - // EMail - print "\n"; + // EMail + print "\n"; - // Statut - print '"; + // Statut + print '"; - // Date end subscription - if ($datefin) { - print ''; - } else { - print ''; - } + // Date end subscription + if ($datefin) { + print ''; + } else { + print ''; + } - // Actions - print '"; - print "\n"; - $i++; - } + print "\n"; + $i++; + } - print "
'; @@ -590,105 +590,105 @@ if ($rowid > 0) { print ''; print ''; - print '  '; - print ''; + print '  '; + print ''; print '
'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).''.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'
'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).''.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'".$objp->login."".$objp->login."'; + // Type + /*print ''; $membertypestatic->id=$objp->type_id; $membertypestatic->label=$objp->type; print $membertypestatic->getNomUrl(1,12); print '".$adh->getmorphylib($objp->morphy)."".$adh->getmorphylib($objp->morphy)."".dol_print_email($objp->email, 0, 0, 1)."".dol_print_email($objp->email, 0, 0, 1)."'; - print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); - print "'; + print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); + print "'; - if ($datefin < dol_now() && $objp->status > 0) { - print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate")); - } else { - print dol_print_date($datefin, 'day'); - } - print ''; - if ($objp->subscription == 'yes') { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->status > 0) print " ".img_warning(); - } else { - print ' '; - } - print ''; + if ($datefin < dol_now() && $objp->status > 0) { + print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate")); + } else { + print dol_print_date($datefin, 'day'); + } + print ''; + if ($objp->subscription == 'yes') { + print $langs->trans("SubscriptionNotReceived"); + if ($objp->status > 0) print " ".img_warning(); + } else { + print ' '; + } + print ''; + // Actions + print ''; if ($user->rights->adherent->creer) { print ''.img_edit().''; } print ' '; if ($user->rights->adherent->supprimer) { print ''.img_picto($langs->trans("Resiliate"), 'disable.png').''; - } + } print "
\n"; - print '
'; - print ''; + print "\n"; + print ''; + print ''; if ($num > $conf->liste_limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); } } else { - dol_print_error($db); + dol_print_error($db); } } @@ -719,18 +719,18 @@ if ($rowid > 0) { print ''.$langs->trans("Label").''; print ''.$langs->trans("Status").''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); - print ''; + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); + print ''; - // Morphy - $morphys[""] = $langs->trans("MorPhy"); - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); - print ''.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); - print ""; + // Morphy + $morphys[""] = $langs->trans("MorPhy"); + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + print ''.$langs->trans("MemberNature").''; + print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); + print ""; - print ''.$langs->trans("SubscriptionRequired").''; + print ''.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("subscription", $object->subscription, 1); print ''; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 94632dc0184..9b66b8e5c7f 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); if (!$user->admin) - accessforbidden(); + accessforbidden(); $action = GETPOST('action', 'alpha'); $actionsave = GETPOST('save', 'alpha'); @@ -240,31 +240,31 @@ $i = 0; $nbofbank = count($bankorder); while ($i < $nbofbank) { - print ''; - print ''.$bankorder[$i][0]."\n"; - print $bankorder[$i][1]; - print ''; - print ''; - $tmparray = explode(' ', $bankorder[$i][2]); - foreach ($tmparray as $key => $val) { - if ($key > 0) - print ', '; - print $langs->trans($val); - } - print "\n"; + print ''; + print ''.$bankorder[$i][0]."\n"; + print $bankorder[$i][1]; + print ''; + print ''; + $tmparray = explode(' ', $bankorder[$i][2]); + foreach ($tmparray as $key => $val) { + if ($key > 0) + print ', '; + print $langs->trans($val); + } + print "\n"; - if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { - print ''; - print img_picto($langs->trans("Activated"), 'on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'off'); - print ''; - } - print ' '; - print ''."\n"; - $i++; + if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { + print ''; + print img_picto($langs->trans("Activated"), 'on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'off'); + print ''; + } + print ' '; + print ''."\n"; + $i++; } print ''."\n"; @@ -287,15 +287,15 @@ $sql .= " WHERE type = '".$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++; - } + $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); + dol_print_error($db); } print "\n"; @@ -311,100 +311,100 @@ print "\n"; clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) { - $dir = dol_buildpath($reldir."core/modules/bank".$valdir); + foreach (array('', '/doc') as $valdir) { + $dir = dol_buildpath($reldir."core/modules/bank".$valdir); - if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; + if ($modulequalified) { + print ''; - // Active - if (in_array($name, $def)) { - print ''; - } else { - print '"; - } + // Active + if (in_array($name, $def)) { + print ''; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') { - $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 .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); - //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); - // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') { + $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 .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); + //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); - print ''; + print ''; - // Preview - print ''; + // Preview + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print '
'; - print(empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) - print $module->info($langs); - else print $module->description; - print '
'; + 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 ''; - 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 "'."\n"; + print ''; + 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->BANKADDON_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 ''; + if ($conf->global->BANKADDON_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 ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + if ($module->type == 'pdf') { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; //} @@ -423,38 +423,38 @@ print $langs->trans('BankColorizeMovementDesc'); print ""; // Active if ($conf->global->BANK_COLORIZE_MOVEMENT) { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; } else { - print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; } print "\n"; if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) { - $i = 1; - while ($i <= 2) - { - $key = $i; - $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; + $i = 1; + while ($i <= 2) + { + $key = $i; + $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; - print ''; + print ''; - // Label - print ''.$langs->trans("BankColorizeMovementName".$key).""; - // Color - print ''; - print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); - print ''; - print ""; - $i++; - } + // Label + print ''.$langs->trans("BankColorizeMovementName".$key).""; + // Color + print ''; + print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); + print ''; + print ""; + $i++; + } } print ''; @@ -482,15 +482,15 @@ print $langs->trans('AutoReportLastAccountStatement'); print ''; // Active if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; } else { - print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; } print "\n"; diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 3aebadf25a6..621a994cabe 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -55,11 +55,11 @@ if ($action == 'updateMask') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -72,7 +72,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -110,7 +110,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); + if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); } } @@ -144,11 +144,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_BOM_FREE_TEXT') { $freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string @@ -158,11 +158,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); @@ -229,13 +229,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->BOM_ADDON == $file) @@ -256,16 +256,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $bom->type = 0; $nextval = $module->getNextValue($mysoc, $bom); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -324,108 +324,108 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/bom".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/bom".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->BOM_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 ''; + // Default + print ''; + if ($conf->global->BOM_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -457,11 +457,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans(" $variablename = 'BOM_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index ca3fd795b8b..8f28addc994 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -48,99 +48,99 @@ $boxes = array(); if ($action == 'addconst') { - dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity); } if ($action == 'add') { - $error = 0; - $db->begin(); - if (isset($_POST['boxid']) && is_array($_POST['boxid'])) - { - foreach ($_POST['boxid'] as $boxid) - { - if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=... - { - $pos = $boxid['pos']; + $error = 0; + $db->begin(); + if (isset($_POST['boxid']) && is_array($_POST['boxid'])) + { + foreach ($_POST['boxid'] as $boxid) + { + if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=... + { + $pos = $boxid['pos']; - // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") - $distinctfkuser = array(); - if (!$error) - { - $sql = "SELECT fk_user"; - $sql .= " FROM ".MAIN_DB_PREFIX."user_param"; - $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'"; - $sql .= " AND entity = ".$conf->entity; - dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $distinctfkuser[$obj->fk_user] = $obj->fk_user; - $i++; - } - } else { - setEventMessages($db->lasterror(), null, 'errors'); - $error++; - } - } + // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") + $distinctfkuser = array(); + if (!$error) + { + $sql = "SELECT fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."user_param"; + $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'"; + $sql .= " AND entity = ".$conf->entity; + dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $distinctfkuser[$obj->fk_user] = $obj->fk_user; + $i++; + } + } else { + setEventMessages($db->lasterror(), null, 'errors'); + $error++; + } + } - $distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val + $distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val - foreach ($distinctfkuser as $fk_user) - { - if (!$error && $fk_user != '') - { - $arrayofexistingboxid = array(); - $nbboxonleft = $nbboxonright = 0; - $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; - dol_syslog("boxes.php activate box", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { - $boxorder = $obj->box_order; - if (preg_match('/A/', $boxorder)) $nbboxonleft++; - if (preg_match('/B/', $boxorder)) $nbboxonright++; - $arrayofexistingboxid[$obj->box_id] = 1; - } - } else dol_print_error($db); + foreach ($distinctfkuser as $fk_user) + { + if (!$error && $fk_user != '') + { + $arrayofexistingboxid = array(); + $nbboxonleft = $nbboxonright = 0; + $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes"; + $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; + dol_syslog("boxes.php activate box", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + while ($obj = $db->fetch_object($resql)) + { + $boxorder = $obj->box_order; + if (preg_match('/A/', $boxorder)) $nbboxonleft++; + if (preg_match('/B/', $boxorder)) $nbboxonright++; + $arrayofexistingboxid[$obj->box_id] = 1; + } + } else dol_print_error($db); - if (empty($arrayofexistingboxid[$boxid['value']])) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; - $sql .= "box_id, position, box_order, fk_user, entity"; - $sql .= ") values ("; - $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; - $sql .= ")"; + if (empty($arrayofexistingboxid[$boxid['value']])) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; + $sql .= "box_id, position, box_order, fk_user, entity"; + $sql .= ") values ("; + $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; + $sql .= ")"; - dol_syslog("boxes.php activate box", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql) - { - setEventMessages($db->lasterror(), null, 'errors'); - $error++; - } - } else { - dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG); - } - } - } - } - } - } - if (!$error) - { - $db->commit(); - $action = ''; - } else { - $db->rollback(); - } + dol_syslog("boxes.php activate box", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql) + { + setEventMessages($db->lasterror(), null, 'errors'); + $error++; + } + } else { + dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG); + } + } + } + } + } + } + if (!$error) + { + $db->commit(); + $action = ''; + } else { + $db->rollback(); + } } if ($action == 'delete') @@ -150,23 +150,23 @@ if ($action == 'delete') $resql = $db->query($sql); $obj = $db->fetch_object($resql); - if (!empty($obj->box_id)) - { - $db->begin(); + if (!empty($obj->box_id)) + { + $db->begin(); - // Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes) - // $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; - // $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; - // $resql = $db->query($sql); + // Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes) + // $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; + // $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; + // $resql = $db->query($sql); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE entity = ".$conf->entity; - $sql .= " AND box_id=".$obj->box_id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " AND box_id=".$obj->box_id; - $resql = $db->query($sql); + $resql = $db->query($sql); - $db->commit(); - } + $db->commit(); + } } if ($action == 'switch') @@ -184,14 +184,14 @@ if ($action == 'switch') $resultupdateto = 0; if (is_object($objfrom) && is_object($objto)) { - $newfirst = $objto->box_order; + $newfirst = $objto->box_order; $newsecond = $objfrom->box_order; - if ($newfirst == $newsecond) - { - $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond); - $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond); - $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1); - } + if ($newfirst == $newsecond) + { + $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond); + $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond); + $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1); + } $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid; dol_syslog($sql); $resultupdatefrom = $db->query($sql); @@ -268,7 +268,7 @@ if ($resql) if ($decalage) { - // If we have renumbered, we correct the field box_order + // If we have renumbered, we correct the field box_order // This occurs just after an insert. $sql = "SELECT box_order"; $sql .= " FROM ".MAIN_DB_PREFIX."boxes"; @@ -339,34 +339,34 @@ print "\n"; foreach ($boxtoadd as $box) { - if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) - { - $logo = $box->boximg; - } else { - $logo = preg_replace("/^object_/i", "", $box->boximg); - } + if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) + { + $logo = $box->boximg; + } else { + $logo = preg_replace("/^object_/i", "", $box->boximg); + } - print "\n".''."\n"; - print ''."\n"; - print ''.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); - if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; - print ''."\n"; - print ''; - if ($box->note == '(WarningUsingThisBoxSlowDown)') - { - $langs->load("errors"); - print $langs->trans("WarningUsingThisBoxSlowDown"); - } else print ($box->note ? $box->note : ' '); - print ''."\n"; - print ''.$box->sourcefile.''."\n"; + print "\n".''."\n"; + print ''."\n"; + print ''.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); + if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; + print ''."\n"; + print ''; + if ($box->note == '(WarningUsingThisBoxSlowDown)') + { + $langs->load("errors"); + print $langs->trans("WarningUsingThisBoxSlowDown"); + } else print ($box->note ? $box->note : ' '); + print ''."\n"; + print ''.$box->sourcefile.''."\n"; - // For each possible position, an activation link is displayed if the box is not already active for that position - print ''; - print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n"; - print ''."\n"; - print ''; + // For each possible position, an activation link is displayed if the box is not already active for that position + print ''; + print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n"; + print ''."\n"; + print ''; - print ''."\n"; + print ''."\n"; } if (!count($boxtoadd) && count($boxactivated)) { @@ -408,7 +408,7 @@ foreach ($boxactivated as $key => $box) $logo = preg_replace("/^object_/i", "", $box->boximg); } - print "\n".''."\n"; + print "\n".''."\n"; print ''; print ''.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; @@ -465,10 +465,10 @@ print ''; // Activate FileCache - Developement if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - print ''.$langs->trans("EnableFileCache").''; - print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); - print ''; - print ''; + print ''.$langs->trans("EnableFileCache").''; + print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); + print ''; + print ''; } print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 1e6d21b6f58..febddf901c5 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -64,11 +64,11 @@ if ($action == 'updateMask') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -81,7 +81,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -119,7 +119,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); + if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); } } @@ -153,11 +153,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_ORDER_FREE_TEXT') { $freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string @@ -167,21 +167,21 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == "setshippableiconinlist") { - // Activate Set Shippable Icon In List - $setshippableiconinlist = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); - if (!$res > 0) $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + // Activate Set Shippable Icon In List + $setshippableiconinlist = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); + if (!$res > 0) $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); @@ -203,31 +203,31 @@ elseif ($action == 'setdoc') // Activate ask for payment bank elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } // Activate ask for warehouse elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') { - $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -294,13 +294,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->COMMANDE_ADDON == $file) @@ -321,16 +321,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $commande->type = 0; $nextval = $module->getNextValue($mysoc, $commande); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -389,113 +389,113 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/commande".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/commande".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->COMMANDE_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 ''; + // Default + print ''; + if ($conf->global->COMMANDE_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - //$htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); - //$htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + //$htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + //$htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -636,11 +636,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans $variablename = 'ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f2e69f81707..e5c20f647e5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -109,7 +109,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) foreach ($arrayofimages as $varforimage) { - if ($_FILES[$varforimage]["name"] && ! preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. + if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. $langs->load("errors"); setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); break; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 19ae30d7674..4aeabd4439d 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -41,7 +41,7 @@ $type = 'contract'; if (empty($conf->global->CONTRACT_ADDON)) { - $conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; + $conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; } @@ -53,18 +53,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstcontract', 'alpha'); - $maskvalue = GETPOST('maskcontract', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + $maskconst = GETPOST('maskconstcontract', 'alpha'); + $maskvalue = GETPOST('maskcontract', 'alpha'); + if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') // For contract { $modele = GETPOST('module', 'alpha'); @@ -77,7 +77,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -115,7 +115,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); + if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); } } @@ -149,17 +149,17 @@ elseif ($action == 'setdoc') $draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); - $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); + $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); + $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $contract); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -319,111 +319,111 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/contract".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/contract".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->CONTRACT_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 ''; + // Defaut + print ''; + if ($conf->global->CONTRACT_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -457,11 +457,11 @@ print '
'; $variablename = 'CONTRACT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index f9dae118316..88115195328 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -76,8 +76,6 @@ $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup'); -//print load_fiche_titre($langs->trans("DebugBar")); - if (!function_exists('mb_check_encoding')) { $langs->load("errors"); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 2f33b8445f9..94a3d698c2a 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -165,19 +165,19 @@ if (GETPOST('addoperation', 'alpha')) if ($action == 'updateoperation') { - $emailcollectoroperation = new EmailCollectorAction($db); - $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int')); + $emailcollectoroperation = new EmailCollectorAction($db); + $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int')); - $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none'); + $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none'); - $result = $emailcollectoroperation->update($user); + $result = $emailcollectoroperation->update($user); - if ($result > 0) - { - $object->fetchActions(); - } else { - setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); - } + if ($result > 0) + { + $object->fetchActions(); + } else { + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } } if ($action == 'deleteoperation') { @@ -199,11 +199,11 @@ if ($action == 'confirm_collect') $res = $object->doCollectOneCollector(); if ($res > 0) { - $debuginfo = $object->debuginfo; - setEventMessages($object->lastresult, null, 'mesgs'); + $debuginfo = $object->debuginfo; + setEventMessages($object->lastresult, null, 'mesgs'); } else { - $debuginfo = $object->debuginfo; - setEventMessages($object->error, null, 'errors'); + $debuginfo = $object->debuginfo; + setEventMessages($object->error, null, 'errors'); } $action = ''; @@ -475,27 +475,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; $arrayoftypes = array( - 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), - 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), - 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), - 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), - 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), - 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), - // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 - //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value - //'X1'=>'---', - //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'), - //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'), - 'X2'=>'---', - 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), - 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), - 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), - 'answered'=>array('label'=>'Answered', 'data-noparam'=>1), - 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), - 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), - 'X3'=>'---', - 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), - 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), + 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), + 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), + 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), + 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), + 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), + 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), + // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 + //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value + //'X1'=>'---', + //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'), + //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'), + 'X2'=>'---', + 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), + 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), + 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), + 'answered'=>array('label'=>'Answered', 'data-noparam'=>1), + 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'X3'=>'---', + 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), + 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), 'X4'=>'---', 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) @@ -559,9 +559,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; $arrayoftypes = array( - 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), - 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), - 'recordevent'=>'RecordEvent'); + 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), + 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), + 'recordevent'=>'RecordEvent'); if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature'; @@ -602,7 +602,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $langs->trans($arrayoftypes[$ruleaction['type']]); if (in_array($ruleaction['type'], array('recordevent'))) { - print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); + print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); } elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) { print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); } @@ -610,11 +610,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($action == 'editoperation' && $ruleaction['id'] == $operationid) { - print '
'; - print '
'; - print ' '; + print '
'; + print '
'; + print ' '; } else { - print $ruleaction['actionparam']; + print $ruleaction['actionparam']; } print ''; // Move up/down @@ -641,7 +641,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if (!empty($conf->use_javascript_ajax)) { - $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id; + $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } @@ -668,7 +668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'.$langs->trans("Edit").'
'; // Clone - print '
'.$langs->trans("ToClone").'
'; + print '
'.$langs->trans("ToClone").'
'; // Collect now if (count($object->actions) > 0) { @@ -684,7 +684,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($debuginfo)) { - print info_admin($debuginfo); + print info_admin($debuginfo); } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 32ab8c2e277..1a0be0cb65f 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -48,7 +48,7 @@ $type = 'shipping'; if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { - $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; + $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; } @@ -105,7 +105,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -143,7 +143,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); + if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); } } @@ -231,14 +231,14 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { + // Show example of numbering module + 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 ''."\n"; + else print $tmp; + print ''."\n"; print ''; if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") @@ -258,16 +258,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $expedition); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -328,107 +328,107 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/expedition".$valdir); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/expedition".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->EXPEDITION_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 ''; + // Defaut + print ''; + if ($conf->global->EXPEDITION_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $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 .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $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 .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -461,11 +461,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->tr $variablename = 'SHIPPING_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print "\n"; diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index ebdc1f7ed59..840cf4d2681 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -35,13 +35,11 @@ $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); if (!$user->admin) accessforbidden(); -//Init error -$error = false; -$message = false; +$error = 0; $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); -$offset = GETPOST('offset', 'int'); +$ikoffset = GETPOST('ikoffset', 'int'); $coef = GETPOST('coef', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); @@ -59,10 +57,13 @@ if ($action == 'updateik') $expIk->setValues($_POST); $result = $expIk->create($user); - if ($result > 0) setEventMessages('SetupSaved', null, 'mesgs'); - - header('Location: '.$_SERVER['PHP_SELF']); - exit; + if ($result > 0) { + setEventMessages('SetupSaved', null, 'mesgs'); + header('Location: '.$_SERVER['PHP_SELF']); + exit; + } else { + setEventMessages($expIk->error, $expIk->errors, 'errors'); + } } elseif ($action == 'delete') // TODO add confirm { $expIk = new ExpenseReportIk($db); @@ -81,6 +82,7 @@ if ($action == 'updateik') $rangesbycateg = ExpenseReportIk::getAllRanges(); + /* * View */ @@ -90,12 +92,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup")); $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ExpenseReportsIkSetup"), $linkback, 'title_setup'); +print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip'); -echo $langs->trans('ExpenseReportIkDesc'); +echo ''.$langs->trans('ExpenseReportIkDesc').''; +print '

'; echo '
'; @@ -136,21 +139,23 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; // Label - echo '['.$langs->trans('RangeNum', $tranche++).'] - '.$label.''; + echo '['.$langs->trans('RangeNum', $tranche++).'] - '.$label.''; // Offset - echo ''; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; - else echo $range->ik->offset; + echo ''; + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; + else { + echo $range->ik->ikoffset; + } echo ''; // Coef - echo ''; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; + echo ''; + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); echo ''; // Total for one - echo ''.$langs->trans('expenseReportPrintExample', price($range->ik->offset + 5 * $range->ik->coef)).''; + echo ''.$langs->trans('expenseReportPrintExample', price($range->ik->ikoffset + 5 * $range->ik->coef)).''; // Action echo ''; @@ -161,8 +166,8 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; echo ''; } else { - echo ''.img_edit().''; - if (!empty($range->ik->id)) echo ''.img_delete().''; + echo ''.img_edit().''; + if (!empty($range->ik->id)) echo ''.img_delete().''; // TODO add delete link } } diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 337311b85e7..28d5b3341b1 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -138,6 +138,7 @@ $rules = ExpenseReportRule::getAllRule(); $tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User')); $tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense')); + /* * View */ @@ -147,12 +148,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup")); $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup'); +print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip'); -echo $langs->trans('ExpenseReportRulesDesc'); +echo ''.$langs->trans('ExpenseReportRulesDesc').''; +print '

'; if ($action != 'edit') { @@ -164,7 +166,7 @@ if ($action != 'edit') echo ''; echo ''.$langs->trans('ExpenseReportApplyTo').''; - echo ''.$langs->trans('ExpenseReportDomain').''; + echo ''.$langs->trans('Type').''; echo ''.$langs->trans('ExpenseReportLimitOn').''; echo ''.$langs->trans('ExpenseReportDateStart').''; echo ''.$langs->trans('ExpenseReportDateEnd').''; @@ -184,7 +186,7 @@ if ($action != 'edit') echo ''.$form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0).''; echo ''.$form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0).''; echo ''.$form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0).''; - echo ''.$conf->currency.''; + echo ' '.$conf->currency.''; echo ''.$form->selectyesno('restrictive', 0, 1).''; echo ''; echo ''; @@ -207,7 +209,7 @@ echo ''; echo ''; echo ''; -echo ''; +echo ''; echo ''; echo ''; echo ''; @@ -300,11 +302,11 @@ foreach ($rules as $rule) echo ''; - echo ''; + print ''; - // Show example of numbering module - print ''."\n"; + // Show example of numbering module + print ''."\n"; - print ''; + print ''; - $facture = new Facture($db); - $facture->initAsSpecimen(); + $facture = new Facture($db); + $facture->initAsSpecimen(); - // Example for standard invoice - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $facture->type = 0; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForInvoices").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } - // Example for remplacement - $facture->type = 1; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForReplacements").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Example for standard invoice + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type = 0; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForInvoices").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + // Example for remplacement + $facture->type = 1; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForReplacements").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - // Example for credit invoice - $facture->type = 2; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } - // Example for deposit invoice - $facture->type = 3; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForDeposit").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval; - } else { - $htmltooltip .= $langs->trans($module->error); - } - } + // Example for credit invoice + $facture->type = 2; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + // Example for deposit invoice + $facture->type = 3; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForDeposit").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval; + } else { + $htmltooltip .= $langs->trans($module->error); + } + } - print ''; + print ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print '
'.$langs->trans('ExpenseReportApplyTo').''.$langs->trans('ExpenseReportDomain').''.$langs->trans('Type').''.$langs->trans('ExpenseReportLimitOn').''.$langs->trans('ExpenseReportDateStart').''.$langs->trans('ExpenseReportDateEnd').''; + echo ''; if ($object->id != $rule->id) { - echo ''.img_edit().' '; - echo ''.img_delete().''; + echo ''.img_edit().' '; + echo ''.img_delete().''; } else { echo ' '; echo ''.$langs->trans('Cancel').''; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index ac24f1e0404..221244bfb9d 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -53,66 +53,66 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); + $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); + $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); - $maskinvoice = GETPOST('maskinvoice', 'alpha'); - $maskreplacement = GETPOST('maskreplacement', 'alpha'); - $maskcredit = GETPOST('maskcredit', 'alpha'); + $maskinvoice = GETPOST('maskinvoice', 'alpha'); + $maskreplacement = GETPOST('maskreplacement', 'alpha'); + $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); - if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); - if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); + if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); + if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); + if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $facture = new Facture($db); - $facture->initAsSpecimen(); + $facture = new Facture($db); + $facture->initAsSpecimen(); // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($facture, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($facture, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model elseif ($action == 'set') @@ -123,7 +123,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); + if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); } } // Set default model @@ -144,89 +144,89 @@ elseif ($action == 'setdoc') } } elseif ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); $chq = GETPOST('chq', 'alpha'); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') { $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); - $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_INVOICE_FREE_TEXT') { $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string - $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setforcedate') { $forcedate = GETPOST('forcedate', 'alpha'); - $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setDefaultPDFModulesByType') { - $invoicetypemodels = GETPOST('invoicetypemodels'); + $invoicetypemodels = GETPOST('invoicetypemodels'); - if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) - { - $error = 0; + if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) + { + $error = 0; - foreach ($invoicetypemodels as $type => $value) - { - $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; - } + foreach ($invoicetypemodels as $type => $value) + { + $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } } @@ -267,144 +267,144 @@ clearstatcache(); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/facture/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_facture_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_facture_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($db); - // 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; + // 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; - if ($module->isEnabled()) - { - print '
'; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + print '
'; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + print $module->info(); - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; - //print "> ".$conf->global->FACTURE_ADDON." - ".$file; - if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + //print "> ".$conf->global->FACTURE_ADDON." - ".$file; + if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $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 ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print '
'; @@ -426,16 +426,16 @@ $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++; - } + $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); + dol_print_error($db); } print ''; @@ -454,156 +454,156 @@ $activatedModels = array(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/facture".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/facture".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; + if ($modulequalified) + { + print ''; - // Active - if (in_array($name, $def)) - { - print ''; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print ''; + } else { + print '"; + } - // Defaut - print ''; + // Defaut + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1); - $htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1); + $htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1); - print ''; + print ''; - // Preview - print ''; + // Preview + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print '
'; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print '
'; + 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 ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').''; - print "'."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').''; + print "'; - if ($conf->global->FACTURE_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("SetAsDefault"), 'off').''; - } - print ''; + if ($conf->global->FACTURE_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("SetAsDefault"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf { - /* + /* * Document templates generators */ - print '
'; - print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', ''); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
'; + print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', ''); + print ''; + print ''; + print ''; + print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $listtype = array( - Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), - Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), - Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), - Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), - ); - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); - } + $listtype = array( + Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), + Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), + Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), + Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + ); + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); + } - foreach ($listtype as $type => $trans) - { - $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; - print ''; - print ''; - print ''; - print "\n"; - } + foreach ($listtype as $type => $trans) + { + $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; + $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + print ''; + print ''; + print ''; + print "\n"; + } - print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'.$trans.''.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'
'.$trans.''.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'
'; - print "
"; + print ''; + print ""; } /* @@ -629,37 +629,37 @@ print "".$langs->trans("SuggestPaymentByRIBOnAccount").""; print ""; if (!empty($conf->banque->enabled)) { - $sql = "SELECT rowid, label"; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql .= " WHERE clos = 0"; - $sql .= " AND courant = 1"; - $sql .= " AND entity IN (".getEntity('bank_account').")"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num > 0) - { - print ''; + print ''; + while ($i < $num) + { + $row = $db->fetch_row($resql); - print ''; + print ''; - $i++; - } - print ""; - } else { - print ''.$langs->trans("NoActiveBankAccountDefined").''; - } - } + $i++; + } + print ""; + } else { + print ''.$langs->trans("NoActiveBankAccountDefined").''; + } + } } else { - print $langs->trans("BankModuleNotActive"); + print $langs->trans("BankModuleNotActive"); } print ""; @@ -679,18 +679,18 @@ $sql .= " AND entity IN (".getEntity('bank_account').")"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); - print ''; + print ''; - $i++; - } + $i++; + } } print ""; print ""; @@ -735,11 +735,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra $variablename = 'INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index c8094b99239..3886f85d330 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -43,7 +43,7 @@ $type = 'contract'; if (empty($conf->global->HOLIDAY_ADDON)) { - $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; + $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } @@ -55,18 +55,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstholiday', 'alpha'); - $maskvalue = GETPOST('maskholiday', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + $maskconst = GETPOST('maskconstholiday', 'alpha'); + $maskvalue = GETPOST('maskholiday', 'alpha'); + if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') // For contract { $modele = GETPOST('module', 'alpha'); @@ -79,7 +79,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -117,7 +117,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); + if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); } } @@ -154,11 +154,11 @@ elseif ($action == 'setdoc') if (!$res1 > 0 || !$res2 > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $holiday); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -282,11 +282,11 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - dol_fiche_end(); - // End of page - llxFooter(); - $db->close(); - exit; + dol_fiche_end(); + // End of page + llxFooter(); + $db->close(); + exit; } /* @@ -304,8 +304,8 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); + $i = 0; + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -332,111 +332,111 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/holiday".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/holiday".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->HOLIDAY_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 ''; + // Default + print ''; + if ($conf->global->HOLIDAY_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -473,11 +473,11 @@ print '
'; $variablename = 'HOLIDAY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 3414f00b5d1..ea36b25e3ce 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -113,29 +113,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { - $tmp = FormMail::getAvailableSubstitKey('formemail'); - $tmp['__(AnyTranslationKey)__'] = 'Translation'; - $helpsubstit = $langs->trans("AvailableVariables").':
'; - $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; - foreach ($tmp as $key => $val) - { - $helpsubstit .= $key.' -> '.$val.'
'; - $helpsubstitforlines .= $key.' -> '.$val.'
'; - } + $tmp = FormMail::getAvailableSubstitKey('formemail'); + $tmp['__(AnyTranslationKey)__'] = 'Translation'; + $helpsubstit = $langs->trans("AvailableVariables").':
'; + $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; + foreach ($tmp as $key => $val) + { + $helpsubstit .= $key.' -> '.$val.'
'; + $helpsubstitforlines .= $key.' -> '.$val.'
'; + } } else { - $tmp = FormMail::getAvailableSubstitKey('formemailwithlines'); - $tmp['__(AnyTranslationKey)__'] = 'Translation'; - $helpsubstit = $langs->trans("AvailableVariables").':
'; - $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; - foreach ($tmp as $key => $val) - { - $helpsubstit .= $key.' -> '.$val.'
'; - } - $tmp = FormMail::getAvailableSubstitKey('formemailforlines'); - foreach ($tmp as $key => $val) - { - $helpsubstitforlines .= $key.' -> '.$val.'
'; - } + $tmp = FormMail::getAvailableSubstitKey('formemailwithlines'); + $tmp['__(AnyTranslationKey)__'] = 'Translation'; + $helpsubstit = $langs->trans("AvailableVariables").':
'; + $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; + foreach ($tmp as $key => $val) + { + $helpsubstit .= $key.' -> '.$val.'
'; + } + $tmp = FormMail::getAvailableSubstitKey('formemailforlines'); + foreach ($tmp as $key => $val) + { + $helpsubstitforlines .= $key.' -> '.$val.'
'; + } } @@ -201,206 +201,206 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { - $search_label = ''; - $search_type_template = ''; - $search_lang = ''; - $search_fk_user = ''; - $search_topic = ''; - $toselect = ''; - $search_array_options = array(); - } + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_label = ''; + $search_type_template = ''; + $search_lang = ''; + $search_fk_user = ''; + $search_topic = ''; + $toselect = ''; + $search_array_options = array(); + } - // Actions add or modify an entry into a dictionary - if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) - { - $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert = explode(',', $tabfieldinsert[$id]); - $listfieldmodify = explode(',', $tabfieldinsert[$id]); - $listfieldvalue = explode(',', $tabfieldvalue[$id]); + // Actions add or modify an entry into a dictionary + if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) + { + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); - // Check that all fields are filled - $ok = 1; - foreach ($listfield as $f => $value) - { - // Not mandatory fields - if ($value == 'joinfiles') continue; - if ($value == 'content') continue; - if ($value == 'content_lines') continue; + // Check that all fields are filled + $ok = 1; + foreach ($listfield as $f => $value) + { + // Not mandatory fields + if ($value == 'joinfiles') continue; + if ($value == 'content') continue; + if ($value == 'content_lines') continue; - if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; + if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; - if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') - { - $ok = 0; - $fieldnamekey = $listfield[$f]; - // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Code'; - if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; - if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; - if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate'; - if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner'; - if ($fieldnamekey == 'private') $fieldnamekey = 'Private'; - if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; - if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic'; + if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') + { + $ok = 0; + $fieldnamekey = $listfield[$f]; + // We take translate key of field + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Code'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; + if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate'; + if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner'; + if ($fieldnamekey == 'private') $fieldnamekey = 'Private'; + if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; + if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic'; - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - } - } + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + } + } - // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd')) - { - // Add new entry - $sql = "INSERT INTO ".$tabname[$id]." ("; - // List of fields - $sql .= $tabfieldinsert[$id]; - $sql .= ",active)"; - $sql .= " VALUES("; + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd')) + { + // Add new entry + $sql = "INSERT INTO ".$tabname[$id]." ("; + // List of fields + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; - // List of values - $i = 0; - foreach ($listfieldinsert as $f => $value) - { - $keycode = $listfieldvalue[$i]; - if ($value == 'lang') $keycode = 'langcode'; - if (empty($keycode)) $keycode = $value; + // List of values + $i = 0; + foreach ($listfieldinsert as $f => $value) + { + $keycode = $listfieldvalue[$i]; + if ($value == 'lang') $keycode = 'langcode'; + if (empty($keycode)) $keycode = $value; - if ($value == 'entity') $_POST[$keycode] = $conf->entity; - if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = ''; - if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0'; - if ($value == 'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '1'; - //var_dump($keycode.' '.$value); + if ($value == 'entity') $_POST[$keycode] = $conf->entity; + if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = ''; + if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0'; + if ($value == 'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '1'; + //var_dump($keycode.' '.$value); - if ($i) $sql .= ", "; - if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work - elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'content') { - $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { - $sql .= (int) GETPOST($keycode, 'int'); - } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; - } + if ($i) $sql .= ", "; + if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work + elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'content') { + $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; + } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { + $sql .= (int) GETPOST($keycode, 'int'); + } else { + $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + } - $i++; - } - $sql .= ", 1)"; + $i++; + } + $sql .= ", 1)"; - dol_syslog("actionadd", LOG_DEBUG); - $result = $db->query($sql); - if ($result) // Add is ok - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST = array('id'=>$id); // Clean $_POST array, we keep only id - } else { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } else { - dol_print_error($db); - } - } - } + dol_syslog("actionadd", LOG_DEBUG); + $result = $db->query($sql); + if ($result) // Add is ok + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + $_POST = array('id'=>$id); // Clean $_POST array, we keep only id + } else { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } else { + dol_print_error($db); + } + } + } - // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify')) - { - $rowidcol = "rowid"; + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify')) + { + $rowidcol = "rowid"; - // Modify entry - $sql = "UPDATE ".$tabname[$id]." SET "; - // Modifie valeur des champs - $i = 0; - foreach ($listfieldmodify as $field) - { - $keycode = $listfieldvalue[$i]; - if ($field == 'lang') $keycode = 'langcode'; - if (empty($keycode)) $keycode = $field; + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + $i = 0; + foreach ($listfieldmodify as $field) + { + $keycode = $listfieldvalue[$i]; + if ($field == 'lang') $keycode = 'langcode'; + if (empty($keycode)) $keycode = $field; - if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = ''; - if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; - if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid]; - if ($field == 'content') $_POST['content'] = $_POST['content-'.$rowid]; - if ($field == 'content_lines') $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; - if ($field == 'entity') $_POST[$keycode] = $conf->entity; + if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = ''; + if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; + if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid]; + if ($field == 'content') $_POST['content'] = $_POST['content-'.$rowid]; + if ($field == 'content_lines') $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; + if ($field == 'entity') $_POST[$keycode] = $conf->entity; - if ($i) $sql .= ", "; - $sql .= $field."="; + if ($i) $sql .= ", "; + $sql .= $field."="; - if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work - elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'content') { - $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { - $sql .= (int) GETPOST($keycode, 'int'); - } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; - } + if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work + elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'content') { + $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; + } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { + $sql .= (int) GETPOST($keycode, 'int'); + } else { + $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + } - $i++; - } - $sql .= " WHERE ".$rowidcol." = '".$rowid."'"; - //print $sql;exit; - dol_syslog("actionmodify", LOG_DEBUG); - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - } else { - setEventMessages($db->error(), null, 'errors'); - } - } - } + $i++; + } + $sql .= " WHERE ".$rowidcol." = '".$rowid."'"; + //print $sql;exit; + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + } else { + setEventMessages($db->error(), null, 'errors'); + } + } + } - if ($action == 'confirm_delete' && $confirm == 'yes') // delete - { - $rowidcol = "rowid"; + if ($action == 'confirm_delete' && $confirm == 'yes') // delete + { + $rowidcol = "rowid"; - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; - dol_syslog("delete", LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { - setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } else { - dol_print_error($db); - } - } - } + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } else { + dol_print_error($db); + } + } + } - // activate - if ($action == $acts[0]) - { - $rowidcol = "rowid"; + // activate + if ($action == $acts[0]) + { + $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } + } - // disable - if ($action == $acts[1]) - { - $rowidcol = "rowid"; + // disable + if ($action == $acts[1]) + { + $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } + } } @@ -428,7 +428,7 @@ dol_fiche_head($head, 'templates', '', -1); // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -613,90 +613,90 @@ dol_syslog("htdocs/admin/dict", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $param = '&id='.$id; - if ($search_label) $param .= '&search_label='.urlencode($search_label); - if ($search_lang > 0) $param .= '&search_lang='.urlencode($search_lang); - if ($search_type_template != '-1') $param .= '&search_type_template='.urlencode($search_type_template); - if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); - if ($search_topic) $param .= '&search_topic='.urlencode($search_topic); + $param = '&id='.$id; + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_lang > 0) $param .= '&search_lang='.urlencode($search_lang); + if ($search_type_template != '-1') $param .= '&search_type_template='.urlencode($search_type_template); + if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); + if ($search_topic) $param .= '&search_topic='.urlencode($search_topic); - $paramwithsearch = $param; - if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); - if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); - if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); + $paramwithsearch = $param; + if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); + if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); + if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); - // There is several pages - if ($num > $listlimit) - { - print ''; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print ''; - } + // There is several pages + if ($num > $listlimit) + { + print ''; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print ''; + } - // Title line with search boxes - print ''; + // Title line with search boxes + print ''; - $filterfound = 0; - foreach ($fieldlist as $field => $value) - { - if ($value == 'label') { - print ''; - } elseif ($value == 'lang') { - print ''; - print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100'); - print ''; - } elseif ($value == 'fk_user') { - print ''; - $restrictid = array(); - if (!$user->admin) $restrictid = array($user->id); - //var_dump($restrictid); - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100'); - print ''; - } elseif ($value == 'topic') { - print ''; - } elseif ($value == 'type_template') { - print ''.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').''; - } elseif (!in_array($value, array('content', 'content_lines'))) { - print ''; - } - } + $filterfound = 0; + foreach ($fieldlist as $field => $value) + { + if ($value == 'label') { + print ''; + } elseif ($value == 'lang') { + print ''; + print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100'); + print ''; + } elseif ($value == 'fk_user') { + print ''; + $restrictid = array(); + if (!$user->admin) $restrictid = array($user->id); + //var_dump($restrictid); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100'); + print ''; + } elseif ($value == 'topic') { + print ''; + } elseif ($value == 'type_template') { + print ''.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').''; + } elseif (!in_array($value, array('content', 'content_lines'))) { + print ''; + } + } - if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; + if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; - // Action column - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; - print ''; + // Action column + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; + print ''; - // Title of lines - print ''; - foreach ($fieldlist as $field => $value) - { - $showfield = 1; // By defaut - $align = "left"; - $sortable = 1; - $valuetoshow = ''; - $forcenowrap = 1; - /* + // Title of lines + print ''; + foreach ($fieldlist as $field => $value) + { + $showfield = 1; // By defaut + $align = "left"; + $sortable = 1; + $valuetoshow = ''; + $forcenowrap = 1; + /* $tmparray=getLabelOfField($fieldlist[$field]); $showfield=$tmp['showfield']; $valuetoshow=$tmp['valuetoshow']; $align=$tmp['align']; $sortable=$tmp['sortable']; */ - $valuetoshow = ucfirst($fieldlist[$field]); // By defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } - if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } - if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } + if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } + if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } if ($fieldlist[$field] == 'private') { $align = 'center'; } if ($fieldlist[$field] == 'position') { $align = 'center'; } @@ -704,99 +704,99 @@ if ($resql) if ($fieldlist[$field] == 'content') { $valuetoshow = $langs->trans("Content"); $showfield = 0; } if ($fieldlist[$field] == 'content_lines') { $valuetoshow = $langs->trans("ContentLines"); $showfield = 0; } - // Show fields - if ($showfield) - { - if (!empty($tabhelp[$id][$value])) - { - if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click - else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover - } - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); - } - } + // Show fields + if ($showfield) + { + if (!empty($tabhelp[$id][$value])) + { + if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click + else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover + } + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); + } + } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); - print getTitleFieldOfList(''); - print ''; + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList(''); + print ''; - if ($num) - { - // Lines with values - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + // Lines with values + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) - { - print ''; + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) + { + print ''; - $tmpaction = 'edit'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; - // Show fields - if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit'); + // Show fields + if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit'); - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print ''; + print ''; - $fieldsforcontent = array('topic', 'joinfiles', 'content'); - if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) - { - $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); - } - foreach ($fieldsforcontent as $tmpfieldlist) - { - $showfield = 1; - $align = "left"; - $valuetoshow = $obj->{$tmpfieldlist}; + $fieldsforcontent = array('topic', 'joinfiles', 'content'); + if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) + { + $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); + } + foreach ($fieldsforcontent as $tmpfieldlist) + { + $showfield = 1; + $align = "left"; + $valuetoshow = $obj->{$tmpfieldlist}; - $class = 'tddict'; - // Show value for field - if ($showfield) { + $class = 'tddict'; + // Show value for field + if ($showfield) { // Show line for topic, joinfiles and content - print ''; - print ''; - if ($tmpfieldlist == 'topic') - { - print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; - print ''; - } - if ($tmpfieldlist == 'joinfiles') - { - print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; - print ''; - } - if ($tmpfieldlist == 'content') - { - print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; - $okforextended = true; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); - print $doleditor->Create(1); - } - print ''; - print ''; - print ''; - } - } + print ''; + print ''; + if ($tmpfieldlist == 'topic') + { + print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; + print ''; + } + if ($tmpfieldlist == 'joinfiles') + { + print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; + print ''; + } + if ($tmpfieldlist == 'content') + { + print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; + $okforextended = true; + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); + print $doleditor->Create(1); + } + print ''; + print ''; + print ''; + } + } - print "\n"; - } else { - $keyforobj = 'type_template'; - if (!in_array($obj->$keyforobj, array_keys($elementList))) - { - $i++; - continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) - } + print "\n"; + } else { + $keyforobj = 'type_template'; + if (!in_array($obj->$keyforobj, array_keys($elementList))) + { + $i++; + continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) + } // Test on 'enabled' if (!dol_eval($obj->enabled, 1)) { @@ -804,100 +804,100 @@ if ($resql) continue; // Email template not qualified } - print ''; + print ''; - $tmpaction = 'view'; - $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $tmpaction = 'view'; + $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + $error = $hookmanager->error; $errors = $hookmanager->errors; - if (empty($reshook)) - { - foreach ($fieldlist as $field => $value) - { - if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue; - $showfield = 1; - $align = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; - if ($value == 'label' || $value == 'topic') - { - $valuetoshow = dol_escape_htmltag($valuetoshow); - } - if ($value == 'type_template') - { - $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; - } - if ($value == 'lang' && $valuetoshow) - { - $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); - } - if ($value == 'fk_user') - { - if ($valuetoshow > 0) - { - $fuser = new User($db); - $fuser->fetch($valuetoshow); - $valuetoshow = $fuser->getNomUrl(1); - } - } - if ($value == 'private') - { - $align = "center"; - if ($valuetoshow) $valuetoshow = yn($valuetoshow); - else $valuetoshow = ''; - } - if ($value == 'position') - { - $align = "center"; - } - if ($value == 'joinfiles') - { - $align = "center"; - if ($valuetoshow) $valuetoshow = 1; - else $valuetoshow = ''; - } + if (empty($reshook)) + { + foreach ($fieldlist as $field => $value) + { + if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue; + $showfield = 1; + $align = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; + if ($value == 'label' || $value == 'topic') + { + $valuetoshow = dol_escape_htmltag($valuetoshow); + } + if ($value == 'type_template') + { + $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; + } + if ($value == 'lang' && $valuetoshow) + { + $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); + } + if ($value == 'fk_user') + { + if ($valuetoshow > 0) + { + $fuser = new User($db); + $fuser->fetch($valuetoshow); + $valuetoshow = $fuser->getNomUrl(1); + } + } + if ($value == 'private') + { + $align = "center"; + if ($valuetoshow) $valuetoshow = yn($valuetoshow); + else $valuetoshow = ''; + } + if ($value == 'position') + { + $align = "center"; + } + if ($value == 'joinfiles') + { + $align = "center"; + if ($valuetoshow) $valuetoshow = 1; + else $valuetoshow = ''; + } - $class = 'tddict'; + $class = 'tddict'; // Show value for field if ($showfield) { - print ''; - print ''.$valuetoshow.''; + print ''; + print ''.$valuetoshow.''; } - } - } + } + } - // Can an entry be erased or disabled ? - $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default - if (!$user->admin && $obj->fk_user != $user->id) - { - $iserasable = 0; - $canbedisabled = 0; - $canbemodified = 0; - } + // Can an entry be erased or disabled ? + $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default + if (!$user->admin && $obj->fk_user != $user->id) + { + $iserasable = 0; + $canbedisabled = 0; + $canbemodified = 0; + } - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); - if ($param) $url .= '&'.$param; - $url .= '&'; + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if ($param) $url .= '&'.$param; + $url .= '&'; - // Status / Active - print ''; - if ($canbedisabled) print ''.$actl[$obj->active].''; - else print ''.$actl[$obj->active].''; - print ""; + // Status / Active + print ''; + if ($canbedisabled) print ''.$actl[$obj->active].''; + else print ''.$actl[$obj->active].''; + print ""; - // Modify link / Delete link - print ''; - if ($canbemodified) print ''.img_edit().''; - if ($iserasable) - { - print ''.img_delete().''; - //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin - } - print ''; + // Modify link / Delete link + print ''; + if ($canbemodified) print ''.img_edit().''; + if ($iserasable) + { + print ''.img_delete().''; + //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin + } + print ''; - /* + /* $fieldsforcontent = array('content'); if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { @@ -925,15 +925,15 @@ if ($resql) } }*/ - print "\n"; - } + print "\n"; + } - $i++; - } - } + $i++; + } + } } else { - dol_print_error($db); + dol_print_error($db); } print ''; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index d92a3b30504..b0514dfc975 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -89,7 +89,6 @@ if ($action == 'update') $result = $menu->fetch(GETPOST('menuId', 'int')); if ($result > 0) { - $menu->titre = GETPOST('titre', 'alpha'); // deprecated $menu->title = GETPOST('titre', 'alpha'); $menu->leftmenu = GETPOST('leftmenu', 'aZ09'); $menu->url = GETPOST('url', 'alpha'); @@ -200,7 +199,6 @@ if ($action == 'add') $menu = new Menubase($db); $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); $menu->type = GETPOST('type', 'alpha'); - $menu->titre = GETPOST('titre', 'alpha'); // deprecated $menu->title = GETPOST('titre', 'alpha'); $menu->url = GETPOST('url', 'alpha'); $menu->langs = GETPOST('langs', 'alpha'); @@ -478,7 +476,7 @@ if ($action == 'create') //print ''.$langs->trans('Level').''.$menu->level.''.$langs->trans('DetailLevel').''; // Title - print ''.$langs->trans('Title').''.$langs->trans('DetailTitre').''; + print ''.$langs->trans('Title').''.$langs->trans('DetailTitre').''; // Url print ''.$langs->trans('URL').''.$langs->trans('DetailUrl').''; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index fe4e4a05818..2ea4853e3ca 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -56,11 +56,11 @@ if ($action == 'updateMask') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -73,7 +73,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -111,7 +111,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity); + if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity); } } @@ -145,11 +145,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_MRP_MO_FREE_TEXT') { $freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string @@ -159,11 +159,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -212,7 +212,7 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); @@ -230,13 +230,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->MRP_MO_ADDON == $file) @@ -257,16 +257,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $mrp->type = 0; $nextval = $module->getNextValue($mysoc, $mrp); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -325,108 +325,108 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/mrp".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/mrp".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->MRP_MO_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 ''; + // Default + print ''; + if ($conf->global->MRP_MO_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -458,11 +458,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("A $variablename = 'MRP_MO_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index 89b16023d4c..3d0b591af10 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -45,13 +45,13 @@ $type = 'reception'; if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { - // This option should always be set to on when module is on. - dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity); + // This option should always be set to on when module is on. + dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity); } if (empty($conf->global->RECEPTION_ADDON_NUMBER)) { - $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl'; + $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl'; } @@ -108,7 +108,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -146,7 +146,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity); + if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity); } } @@ -236,14 +236,14 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { + // Show example of numbering module + 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 ''."\n"; + else print $tmp; + print ''."\n"; print ''; if ($conf->global->RECEPTION_ADDON_NUMBER == "$file") @@ -263,16 +263,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $reception); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -333,110 +333,110 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/reception".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/reception".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->RECEPTION_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 ''; + // Defaut + print ''; + if ($conf->global->RECEPTION_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 090a72327d8..4edff5e93b3 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -51,42 +51,42 @@ $reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; + $code = $reg[1]; - // If constant is for a unique choice, delete other choices - if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) { - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity); - } - if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) { - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity); - } + // If constant is for a unique choice, delete other choices + if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) { + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity); + } + if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) { + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity); + } - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if ($action == 'warehouse') @@ -224,14 +224,14 @@ print ''.$langs->trans("DeStockOnBill").''; print ''; if (!empty($conf->facture->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); } print "\n\n"; $found++; @@ -242,14 +242,14 @@ print ''.$langs->trans("DeStockOnValidateOrder").''; print ''; if (!empty($conf->commande->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); } print "\n\n"; $found++; @@ -262,14 +262,14 @@ print ''.$langs->trans("DeStockOnShipment").''; print ''; if (!empty($conf->expedition->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); } print "\n\n"; $found++; @@ -280,14 +280,14 @@ print ''.$langs->trans("DeStockOnShipmentOnClosing").''; print ''; if (!empty($conf->expedition->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); } print "\n\n"; $found++; @@ -312,14 +312,14 @@ print ''.$langs->trans("ReStockOnBill").''; print ''; if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } print "\n\n"; $found++; @@ -331,14 +331,14 @@ print ''.$langs->trans("ReStockOnValidateOrder").''; print ''; if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } print "\n\n"; $found++; @@ -347,43 +347,43 @@ if (!empty($conf->reception->enabled)) { print ''; print ''.$langs->trans("StockOnReception").''; - print ''; + print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); + } print "\n\n"; $found++; - print ''; + print ''; print ''.$langs->trans("StockOnReceptionOnClosing").''; - print ''; + print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); + } print "\n\n"; $found++; } else { print ''; print ''.$langs->trans("ReStockOnDispatchOrder").''; - print ''; + print ''; if (!empty($conf->fournisseur->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); + } } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } @@ -406,10 +406,10 @@ print ''; print ''.$langs->trans("WarehouseAllowNegativeTransfer").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER'); + print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER); } print "\n"; print "\n"; @@ -419,28 +419,28 @@ if ($conf->invoice->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForInvoice").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE); - } - print "\n"; - print "\n"; + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE); + } + print "\n"; + print "\n"; } if ($conf->order->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForOrder").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER); - } + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER); + } print "\n"; print "\n"; } @@ -449,13 +449,13 @@ if ($conf->expedition->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForShipment").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT); - } + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT); + } print "\n"; print "\n"; } @@ -471,26 +471,26 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) || !empty($conf->mrp->enabled)) { - $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } if ($virtualdiffersfromphysical) { - print ''; - print ''; + print '
'; + print ''; print "\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''; print ''; - print '\n"; print "\n"; print '
".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."'.$langs->trans("Status").''.$langs->trans("Status").'
'.$langs->trans("UseVirtualStockByDefault").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK); - } + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK); + } print "
'; @@ -725,10 +725,10 @@ print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans( print ''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_SUPPORTS_SERVICES'); + print ajax_constantonoff('STOCK_SUPPORTS_SERVICES'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES); } print "\n"; print "\n"; @@ -737,10 +737,10 @@ print ''; print ''.$langs->trans("AllowAddLimitStockByWarehouse").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE'); + print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE); } print "\n"; print "\n"; @@ -749,10 +749,10 @@ print ''; print ''.$langs->trans("AlwaysShowFullArbo").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO'); + print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO); } print "\n"; print "\n"; diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index f2d9e5aef60..079fb3a6052 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -158,11 +158,12 @@ if ($action == 'setlevel') } } + /* * View */ -llxHeader(); +llxHeader('', $langs->trans("SyslogSetup")); $form = new Form($db); @@ -170,8 +171,6 @@ $linkback = ''; -$def = array(); - $syslogfacility = $defaultsyslogfacility = dolibarr_get_const($db, "SYSLOG_FACILITY", 0); $syslogfile = $defaultsyslogfile = dolibarr_get_const($db, "SYSLOG_FILE", 0); @@ -188,7 +187,7 @@ if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity) //print "conf->global->MAIN_FEATURES_LEVEL = ".$conf->global->MAIN_FEATURES_LEVEL."

\n"; // Output mode -print load_fiche_titre($langs->trans("SyslogOutput")); +print load_fiche_titre($langs->trans("SyslogOutput"), '', ''); // Mode print '
'; @@ -260,7 +259,7 @@ print "
\n"; print '
'."\n\n"; -print load_fiche_titre($langs->trans("SyslogLevel")); +print load_fiche_titre($langs->trans("SyslogLevel"), '', ''); // Level print '
'; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 36399534eb6..05038c13bbc 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -114,16 +114,29 @@ if (!function_exists("session_id")) } print ''; + print 'UTF-8 support'; if (!function_exists("utf8_encode")) { - print 'Warning '.$langs->trans("ErrorPHPDoesNotSupportUTF8"); + print 'Warning '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8"); } else { - print 'Ok '.$langs->trans("PHPSupportUTF8"); + print 'Ok '.$langs->trans("PHPSupport", "UTF8"); } print ''; + +print 'MBString support'; + +if (!function_exists("mb_check_encoding")) +{ + print 'Warning '.$langs->trans("ErrorPHPDoesNotSupport", "mbstring"); +} else { + print 'Ok '.$langs->trans("PHPSupport", "mbstring"); +} + +print ''; + print ''; print '
'; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 0f28f65912a..079fcb608ab 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -61,7 +61,7 @@ $search_all = GETPOST("search_all", 'alpha'); $search = array(); foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } if (empty($action) && empty($id) && empty($ref)) $action = 'view'; @@ -92,18 +92,18 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - $error = 0; + $error = 0; - $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; + $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); - } - } + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + } - $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record + $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, delete or clone include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -149,39 +149,39 @@ if (empty($reshook)) } if ($object->fk_product == $idprod) { - setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); - $error++; + setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); + $error++; } if (!$error) { $lastposition = 0; - $bomline = new BOMLine($db); - $bomline->fk_bom = $id; - $bomline->fk_product = $idprod; - $bomline->qty = $qty; - $bomline->qty_frozen = (int) $qty_frozen; - $bomline->disable_stock_change = (int) $disable_stock_change; - $bomline->efficiency = $efficiency; + $bomline = new BOMLine($db); + $bomline->fk_bom = $id; + $bomline->fk_product = $idprod; + $bomline->qty = $qty; + $bomline->qty_frozen = (int) $qty_frozen; + $bomline->disable_stock_change = (int) $disable_stock_change; + $bomline->efficiency = $efficiency; - // Rang to use + // Rang to use $rangmax = $object->line_max(0); $ranktouse = $rangmax + 1; $bomline->position = ($ranktouse + 1); - $result = $bomline->create($user); - if ($result <= 0) - { - setEventMessages($bomline->error, $bomline->errors, 'errors'); - $action = ''; - } else { - unset($_POST['idprod']); - unset($_POST['qty']); - unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); - } + $result = $bomline->create($user); + if ($result <= 0) + { + setEventMessages($bomline->error, $bomline->errors, 'errors'); + $action = ''; + } else { + unset($_POST['idprod']); + unset($_POST['qty']); + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } } } @@ -218,9 +218,9 @@ if (empty($reshook)) unset($_POST['idprod']); unset($_POST['qty']); unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); + unset($_POST['disable_stock_change']); - $object->fetchLines(); + $object->fetchLines(); } } } @@ -290,7 +290,7 @@ if (($id || $ref) && $action == 'edit') print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -321,7 +321,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); + $res = $object->fetch_optionals(); $head = bomPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); @@ -331,7 +331,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // 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); + $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') @@ -451,7 +451,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $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); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); } // Call Hook formConfirm @@ -543,129 +543,129 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->table_element_line)) { - print ' + 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 - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } - 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 ''; + } + print ''; - print "
\n"; + print "\n"; } // Buttons for actions if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - { - // Send - //if (empty($user->socid)) { - // print '' . $langs->trans('SendMail') . ''."\n"; - //} + if (empty($reshook)) + { + // Send + //if (empty($user->socid)) { + // print '' . $langs->trans('SendMail') . ''."\n"; + //} - // Back to draft - if ($object->status == $object::STATUS_VALIDATED) - { - if ($permissiontoadd) - { - print ''.$langs->trans("SetToDraft").''; - } - } + // Back to draft + if ($object->status == $object::STATUS_VALIDATED) + { + if ($permissiontoadd) + { + print ''.$langs->trans("SetToDraft").''; + } + } - // Modify - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { - print ''.$langs->trans("Modify").''."\n"; - } else { - print ''.$langs->trans('Modify').''."\n"; - } - } + // Modify + if ($object->status == $object::STATUS_DRAFT) + { + if ($permissiontoadd) + { + print ''.$langs->trans("Modify").''."\n"; + } else { + print ''.$langs->trans('Modify').''."\n"; + } + } - // Validate - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { - if (is_array($object->lines) && count($object->lines) > 0) - { - print ''.$langs->trans("Validate").''; - } else { - $langs->load("errors"); - print ''.$langs->trans("Validate").''; - } - } - } + // Validate + if ($object->status == $object::STATUS_DRAFT) + { + if ($permissiontoadd) + { + if (is_array($object->lines) && count($object->lines) > 0) + { + print ''.$langs->trans("Validate").''; + } else { + $langs->load("errors"); + print ''.$langs->trans("Validate").''; + } + } + } - // Close / Cancel - if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) - { - print ''.$langs->trans("Disable").''; - } + // Close / Cancel + if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) + { + print ''.$langs->trans("Disable").''; + } - // Re-open - if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) - { - print ''.$langs->trans("ReOpen").''; - } + // Re-open + if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) + { + print ''.$langs->trans("ReOpen").''; + } - // Create MO - if ($conf->mrp->enabled) - { - if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) - { - print ''.$langs->trans("CreateMO").''; - } - } + // Create MO + if ($conf->mrp->enabled) + { + if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) + { + print ''.$langs->trans("CreateMO").''; + } + } - // Clone - if ($permissiontoadd) - { - print ''.$langs->trans("ToClone").''; - } + // Clone + if ($permissiontoadd) + { + print ''.$langs->trans("ToClone").''; + } - /* + /* if ($user->rights->bom->write) { if ($object->status == 1) @@ -679,14 +679,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } */ - if ($permissiontodelete) - { - print ''.$langs->trans('Delete').''."\n"; - } else { - print ''.$langs->trans('Delete').''."\n"; - } - } - print '
'."\n"; + if ($permissiontodelete) + { + print ''.$langs->trans('Delete').''."\n"; + } else { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; } @@ -697,41 +697,41 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action != 'presend') { - print '
'; - print ''; // ancre + print '
'; + print ''; // ancre - // Documents - $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref.'/'.$objref.'.pdf'; - $filedir = $conf->bom->dir_output.'/'.$objref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + // Documents + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->bom->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
'; + print '
'; - $MAXEVENT = 10; + $MAXEVENT = 10; - $morehtmlright = ''; - $morehtmlright .= $langs->trans("SeeAll"); - $morehtmlright .= ''; + $morehtmlright = ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright); - print '
'; + print '
'; } //Select mail models is same action as presend - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) $action = 'presend'; // Presend form $modelmail = 'bom'; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 74eb88393df..2a675cc60e1 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -31,8 +31,8 @@ // 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"; - exit; + print "Error: this template page cannot be called directly as an URL"; + exit; } @@ -52,34 +52,34 @@ print "\n"; $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { - print ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - print ''; + print ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; print '
'.$langs->trans('AddNewLine').''; print ''; print ''.$langs->trans('Qty').''; if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - print ''; - print $langs->trans('Unit'); - print ''; + print ''; + print ''; + print $langs->trans('Unit'); + print ''; } print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''; print ''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''; print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; print ' '; - print ''; + print ''; } print ''; $coldisplay = 0; // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $coldisplay++; - echo ''; + $coldisplay++; + echo ''; } $coldisplay++; @@ -111,7 +111,7 @@ print ''; if ($conf->global->PRODUCT_USE_UNITS) { - $coldisplay++; + $coldisplay++; print ''; print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units"); print ''; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 79cc42c2874..4a84a25e5ca 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -35,727 +35,727 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/api_projects.class.php'; */ class Categories extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'label', - 'type' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'label', + 'type' + ); - static $TYPES = array( - 0 => 'product', - 1 => 'supplier', - 2 => 'customer', - 3 => 'member', - 4 => 'contact', - 5 => 'account', - 6 => 'project', - //7 => 'user', - //8 => 'bank_line', - //9 => 'warehouse', - //10 => 'actioncomm', - ); + static $TYPES = array( + 0 => 'product', + 1 => 'supplier', + 2 => 'customer', + 3 => 'member', + 4 => 'contact', + 5 => 'account', + 6 => 'project', + //7 => 'user', + //8 => 'bank_line', + //9 => 'warehouse', + //10 => 'actioncomm', + ); - /** - * @var Categorie $category {@type Categorie} - */ - public $category; + /** + * @var Categorie $category {@type Categorie} + */ + public $category; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->category = new Categorie($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->category = new Categorie($this->db); + } - /** - * Get properties of a category object - * - * Return an array with category informations - * - * @param int $id ID of category - * @param bool $include_childs Include child categories list (true or false) - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id, $include_childs = false) - { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + /** + * Get properties of a category object + * + * Return an array with category informations + * + * @param int $id ID of category + * @param bool $include_childs Include child categories list (true or false) + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id, $include_childs = false) + { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if ($include_childs) { - $cats = $this->category->get_filles(); - if (!is_array($cats)) { - throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); - } - $this->category->childs = []; - foreach ($cats as $cat) { - $this->category->childs[] = $this->_cleanObjectDatas($cat); - } - } + if ($include_childs) { + $cats = $this->category->get_filles(); + if (!is_array($cats)) { + throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); + } + $this->category->childs = []; + foreach ($cats as $cat) { + $this->category->childs[] = $this->_cleanObjectDatas($cat); + } + } - return $this->_cleanObjectDatas($this->category); - } + return $this->_cleanObjectDatas($this->category); + } - /** - * List categories - * - * Get a list of categories - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @return array Array of category objects - * - * @throws RestException - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') - { - global $db, $conf; + /** + * List categories + * + * Get a list of categories + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of category objects + * + * @throws RestException + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t"; - $sql .= ' WHERE t.entity IN ('.getEntity('category').')'; - if (!empty($type)) - { - $sql .= ' AND t.type='.array_search($type, Categories::$TYPES); - } - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('category').')'; + if (!empty($type)) + { + $sql .= ' AND t.type='.array_search($type, Categories::$TYPES); + } + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; - $sql .= $db->plimit($limit + 1, $offset); - } + $sql .= $db->plimit($limit + 1, $offset); + } - $result = $db->query($sql); - if ($result) - { - $i = 0; - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { - $obj = $db->fetch_object($result); - $category_static = new Categorie($db); - if ($category_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($category_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No category found'); - } - return $obj_ret; - } + $result = $db->query($sql); + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $category_static = new Categorie($db); + if ($category_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($category_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No category found'); + } + return $obj_ret; + } - /** - * Create category object - * - * @param array $request_data Request data - * @return int ID of category - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->categorie->creer) { - throw new RestException(401); - } + /** + * Create category object + * + * @param array $request_data Request data + * @return int ID of category + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { + throw new RestException(401); + } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->category->$field = $value; - } - if ($this->category->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error when creating category', array_merge(array($this->category->error), $this->category->errors)); - } - return $this->category->id; - } + foreach ($request_data as $field => $value) { + $this->category->$field = $value; + } + if ($this->category->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error when creating category', array_merge(array($this->category->error), $this->category->errors)); + } + return $this->category->id; + } - /** - * Update category - * - * @param int $id Id of category to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->categorie->creer) { - throw new RestException(401); - } + /** + * Update category + * + * @param int $id Id of category to update + * @param array $request_data Datas + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $this->category->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $this->category->$field = $value; + } - if ($this->category->update(DolibarrApiAccess::$user) > 0) { - return $this->get($id); + if ($this->category->update(DolibarrApiAccess::$user) > 0) { + return $this->get($id); } else { - throw new RestException(500, $this->category->error); - } - } + throw new RestException(500, $this->category->error); + } + } - /** - * Delete category - * - * @param int $id Category ID - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->categorie->supprimer) { - throw new RestException(401); - } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + /** + * Delete category + * + * @param int $id Category ID + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->categorie->supprimer) { + throw new RestException(401); + } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->category->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when delete category'); - } + if (!$this->category->delete(DolibarrApiAccess::$user)) { + throw new RestException(401, 'error when delete category'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Category deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Category deleted' + ) + ); + } - /** - * List categories of an object - * - * Get the list of categories linked to an object - * - * @param int $id Object ID - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @return array Array of category objects - * - * @throws RestException - * - * @url GET /object/{type}/{id} - */ - public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) - { - if (!in_array($type, [ - Categorie::TYPE_PRODUCT, - Categorie::TYPE_CONTACT, - Categorie::TYPE_CUSTOMER, - Categorie::TYPE_SUPPLIER, - Categorie::TYPE_MEMBER, - Categorie::TYPE_PROJECT - ])) { - throw new RestException(401); - } + /** + * List categories of an object + * + * Get the list of categories linked to an object + * + * @param int $id Object ID + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @return array Array of category objects + * + * @throws RestException + * + * @url GET /object/{type}/{id} + */ + public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + { + if (!in_array($type, [ + Categorie::TYPE_PRODUCT, + Categorie::TYPE_CONTACT, + Categorie::TYPE_CUSTOMER, + Categorie::TYPE_SUPPLIER, + Categorie::TYPE_MEMBER, + Categorie::TYPE_PROJECT + ])) { + throw new RestException(401); + } - if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { - 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) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) { - throw new RestException(401); - } + if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + 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) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } - $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); + $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - if (!is_array($categories)) { - if ($categories == 0) { - throw new RestException(404, 'No category found for this object'); - } - throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); - } - return $categories; - } + if (!is_array($categories)) { + if ($categories == 0) { + throw new RestException(404, 'No category found for this object'); + } + throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); + } + return $categories; + } - /** - * Link an object to a category by id - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param int $object_id ID of object - * - * @return array - * @throws RestException - * - * @url POST {id}/objects/{type}/{object_id} - */ - public function linkObjectById($id, $type, $object_id) - { - if (empty($type) || empty($object_id)) { - throw new RestException(401); - } + /** + * Link an object to a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/{object_id} + */ + public function linkObjectById($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch($object_id); - if ($result > 0) { - $result = $this->category->add_type($object, $type); - if ($result < 0) { - if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { - throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); - } - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch($object_id); + if ($result > 0) { + $result = $this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully linked to the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - /** - * Link an object to a category by ref - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param string $object_ref Reference of object - * - * @return array - * @throws RestException - * - * @url POST {id}/objects/{type}/ref/{object_ref} - */ - public function linkObjectByRef($id, $type, $object_ref) - { - if (empty($type) || empty($object_ref)) { - throw new RestException(401); - } + /** + * Link an object to a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/ref/{object_ref} + */ + public function linkObjectByRef($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch('', $object_ref); - if ($result > 0) { - $result = $this->category->add_type($object, $type); - if ($result < 0) { - if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { - throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); - } - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch('', $object_ref); + if ($result > 0) { + $result = $this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully linked to the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - /** - * Unlink an object from a category by id - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param int $object_id ID of the object - * - * @return array - * @throws RestException - * - * @url DELETE {id}/objects/{type}/{object_id} - */ - public function unlinkObjectById($id, $type, $object_id) - { - if (empty($type) || empty($object_id)) { - throw new RestException(401); - } + /** + * Unlink an object from a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/{object_id} + */ + public function unlinkObjectById($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch((int) $object_id); - if ($result > 0) { - $result = $this->category->del_type($object, $type); - if ($result < 0) { - throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch((int) $object_id); + if ($result > 0) { + $result = $this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully unlinked from the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - /** - * Unlink an object from a category by ref - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param string $object_ref Reference of the object - * - * @return array - * @throws RestException - * - * @url DELETE {id}/objects/{type}/ref/{object_ref} - */ - public function unlinkObjectByRef($id, $type, $object_ref) - { - if (empty($type) || empty($object_ref)) { - throw new RestException(401); - } + /** + * Unlink an object from a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/ref/{object_ref} + */ + public function unlinkObjectByRef($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch('', (string) $object_ref); - if ($result > 0) { - $result = $this->category->del_type($object, $type); - if ($result < 0) { - throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch('', (string) $object_ref); + if ($result > 0) { + $result = $this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully unlinked from the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param Categorie $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Categorie $object Object to clean + * @return array Array of cleaned object properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - // Remove fields not relevent to categories - unset($object->country); - unset($object->country_id); - unset($object->country_code); - unset($object->total_ht); - unset($object->total_ht); - unset($object->total_localtax1); - unset($object->total_localtax2); - unset($object->total_ttc); - unset($object->total_tva); - unset($object->lines); - unset($object->fk_incoterms); - unset($object->label_incoterms); - unset($object->location_incoterms); - unset($object->civility_id); - unset($object->name); - unset($object->lastname); - unset($object->firstname); - unset($object->shipping_method_id); - unset($object->fk_delivery_address); - unset($object->cond_reglement); - unset($object->cond_reglement_id); - unset($object->mode_reglement_id); - unset($object->barcode_type_coder); - unset($object->barcode_type_label); - unset($object->barcode_type_code); - unset($object->barcode_type); - unset($object->canvas); - unset($object->cats); - unset($object->motherof); - unset($object->context); - unset($object->socid); - unset($object->thirdparty); - unset($object->contact); - unset($object->contact_id); - unset($object->user); - unset($object->fk_account); - unset($object->fk_project); - unset($object->note); - unset($object->statut); + // Remove fields not relevent to categories + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->total_ht); + unset($object->total_ht); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->total_tva); + unset($object->lines); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + unset($object->civility_id); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->shipping_method_id); + unset($object->fk_delivery_address); + unset($object->cond_reglement); + unset($object->cond_reglement_id); + unset($object->mode_reglement_id); + unset($object->barcode_type_coder); + unset($object->barcode_type_label); + unset($object->barcode_type_code); + unset($object->barcode_type); + unset($object->canvas); + unset($object->cats); + unset($object->motherof); + unset($object->context); + unset($object->socid); + unset($object->thirdparty); + unset($object->contact); + unset($object->contact_id); + unset($object->user); + unset($object->fk_account); + unset($object->fk_project); + unset($object->note); + unset($object->statut); - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array|null $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $category = array(); - foreach (Categories::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $category[$field] = $data[$field]; - } - return $category; - } + /** + * Validate fields before create or update object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $category = array(); + foreach (Categories::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $category[$field] = $data[$field]; + } + return $category; + } - /** - * Get the list of objects in a category. - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') - * @param int $onlyids Return only ids of objects (consume less memory) - * - * @return mixed - * - * @url GET {id}/objects - */ - public function getObjects($id, $type, $onlyids = 0) - { + /** + * Get the list of objects in a category. + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') + * @param int $onlyids Return only ids of objects (consume less memory) + * + * @return mixed + * + * @url GET {id}/objects + */ + public function getObjects($id, $type, $onlyids = 0) + { dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } - if (empty($type)) - { + if (empty($type)) + { throw new RestException(500, 'The "type" parameter is required.'); - } + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); @@ -768,8 +768,8 @@ class Categories extends DolibarrApi } $objects = $result; - $cleaned_objects = array(); - if ($type == 'member') { + $cleaned_objects = array(); + if ($type == 'member') { $objects_api = new Members(); } elseif ($type == 'customer' || $type == 'supplier') { $objects_api = new Thirdparties(); @@ -781,11 +781,11 @@ class Categories extends DolibarrApi $objects_api = new Projects(); } if (is_object($objects_api)) { - foreach ($objects as $obj) { - $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj); - } + foreach ($objects as $obj) { + $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj); + } } return $cleaned_objects; - } + } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6c27b9e82ff..f9cf55e9a8c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -52,10 +52,10 @@ class Categorie extends CommonObject const TYPE_USER = 'user'; const TYPE_PROJECT = 'project'; const TYPE_ACCOUNT = 'bank_account'; - const TYPE_BANK_LINE = 'bank_line'; - const TYPE_WAREHOUSE = 'warehouse'; - const TYPE_ACTIONCOMM = 'actioncomm'; - const TYPE_WEBSITE_PAGE = 'website_page'; + const TYPE_BANK_LINE = 'bank_line'; + const TYPE_WAREHOUSE = 'warehouse'; + const TYPE_ACTIONCOMM = 'actioncomm'; + const TYPE_WEBSITE_PAGE = 'website_page'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -73,15 +73,15 @@ class Categorie extends CommonObject 'member' => 3, 'contact' => 4, 'bank_account' => 5, - 'project' => 6, + 'project' => 6, 'user' => 7, 'bank_line' => 8, 'warehouse' => 9, - 'actioncomm' => 10, + 'actioncomm' => 10, 'website_page' => 11 ); - /** + /** * @var array Code mapping from ID * * @note This array should be removed in future, once previous constants are moved to the string value. Deprecated @@ -97,7 +97,7 @@ class Categorie extends CommonObject 7 => 'user', 8 => 'bank_line', 9 => 'warehouse', - 10 => 'actioncomm', + 10 => 'actioncomm', ); /** @@ -109,10 +109,10 @@ class Categorie extends CommonObject 'customer' => 'soc', 'supplier' => 'soc', 'contact' => 'socpeople', - 'bank_account' => 'account', - ); + 'bank_account' => 'account', + ); - /** + /** * @var array Category tables mapping from type string (llx_categorie_...) when value does not match * * @note Move to const array when PHP 5.6 will be our minimum target @@ -120,10 +120,10 @@ class Categorie extends CommonObject protected $MAP_CAT_TABLE = array( 'customer' => 'societe', 'supplier' => 'fournisseur', - 'bank_account'=> 'account', + 'bank_account'=> 'account', ); - /** + /** * @var array Object class mapping from type string * * @note Move to const array when PHP 5.6 will be our minimum target @@ -137,33 +137,33 @@ class Categorie extends CommonObject 'user' => 'User', 'account' => 'Account', // old for bank account 'bank_account' => 'Account', - 'project' => 'Project', - 'warehouse'=> 'Entrepot', - 'actioncomm' => 'ActionComm', + 'project' => 'Project', + 'warehouse'=> 'Entrepot', + 'actioncomm' => 'ActionComm', 'website_page' => 'WebsitePage' ); - /** - * @var array Title Area mapping from type string - * - * @note Move to const array when PHP 5.6 will be our minimum target - */ - public static $MAP_TYPE_TITLE_AREA = array( - 'product' => 'ProductsCategoriesArea', - 'customer' => 'CustomersCategoriesArea', - 'supplier' => 'SuppliersCategoriesArea', - 'member' => 'MembersCategoriesArea', - 'contact' => 'ContactsCategoriesArea', - 'user' => 'UsersCategoriesArea', - 'account' => 'AccountsCategoriesArea', // old for bank account - 'bank_account' => 'AccountsCategoriesArea', - 'project' => 'ProjectsCategoriesArea', - 'warehouse'=> 'StocksCategoriesArea', - 'actioncomm' => 'ActioncommCategoriesArea', - 'website_page' => 'WebsitePageCategoriesArea' - ); + /** + * @var array Title Area mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + public static $MAP_TYPE_TITLE_AREA = array( + 'product' => 'ProductsCategoriesArea', + 'customer' => 'CustomersCategoriesArea', + 'supplier' => 'SuppliersCategoriesArea', + 'member' => 'MembersCategoriesArea', + 'contact' => 'ContactsCategoriesArea', + 'user' => 'UsersCategoriesArea', + 'account' => 'AccountsCategoriesArea', // old for bank account + 'bank_account' => 'AccountsCategoriesArea', + 'project' => 'ProjectsCategoriesArea', + 'warehouse'=> 'StocksCategoriesArea', + 'actioncomm' => 'ActioncommCategoriesArea', + 'website_page' => 'WebsitePageCategoriesArea' + ); - /** + /** * @var array Object table mapping from type string (table llx_...) when value of key does not match table name. * * @note Move to const array when PHP 5.6 will be our minimum target @@ -175,7 +175,7 @@ class Categorie extends CommonObject 'contact' => 'socpeople', 'account' => 'bank_account', // old for bank account 'project' => 'projet', - 'warehouse'=> 'entrepot' + 'warehouse'=> 'entrepot' ); /** @@ -189,13 +189,13 @@ class Categorie extends CommonObject public $table_element = 'categorie'; /** - * @var int ID - */ + * @var int ID + */ public $fk_parent; /** - * @var string Category label - */ + * @var string Category label + */ public $label; /** @@ -225,8 +225,8 @@ class Categorie extends CommonObject * @see Categorie::TYPE_USER * @see Categorie::TYPE_PROJECT * @see Categorie::TYPE_BANK_LINE - * @see Categorie::TYPE_WAREHOUSE - * @see Categorie::TYPE_ACTIONCOMM + * @see Categorie::TYPE_WAREHOUSE + * @see Categorie::TYPE_ACTIONCOMM */ public $type; @@ -235,7 +235,7 @@ class Categorie extends CommonObject */ public $cats = array(); - /** + /** * @var array Mother of table */ public $motherof = array(); @@ -464,20 +464,20 @@ class Categorie extends CommonObject if (!$error) { - // Call trigger - $result = $this->call_trigger('CATEGORY_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CATEGORY_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers } - if (!$error) - { - $this->db->commit(); - return $id; - } else { - $this->db->rollback(); - return -3; - } + if (!$error) + { + $this->db->commit(); + return $id; + } else { + $this->db->rollback(); + return -3; + } } else { $this->db->rollback(); return -2; @@ -550,10 +550,10 @@ class Categorie extends CommonObject if (!$error) { - // Call trigger - $result = $this->call_trigger('CATEGORY_MODIFY', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CATEGORY_MODIFY', $user); + if ($result < 0) { $error++; $this->db->rollback(); return -1; } + // End call triggers } $this->db->commit(); @@ -570,7 +570,7 @@ class Categorie extends CommonObject * Delete a category from database * * @param User $user Object user that ask to delete - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 KO >0 OK */ public function delete($user, $notrigger = 0) @@ -579,7 +579,7 @@ class Categorie extends CommonObject $error = 0; - // Clean parameters + // Clean parameters $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); dol_syslog(get_class($this)."::remove"); @@ -588,10 +588,10 @@ class Categorie extends CommonObject if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CATEGORY_DELETE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('CATEGORY_DELETE', $user); + if ($result < 0) $error++; + // End call triggers } /* FIX #1317 : Check for child category and move up 1 level*/ @@ -608,26 +608,26 @@ class Categorie extends CommonObject } } - $arraydelete = array( - 'categorie_societe' => 'fk_categorie', - 'categorie_fournisseur' => 'fk_categorie', - 'categorie_product' => 'fk_categorie', - 'categorie_member' => 'fk_categorie', - 'categorie_contact' => 'fk_categorie', - 'categorie_account' => 'fk_categorie', - 'bank_class' => 'fk_categ', - 'categorie_lang' => 'fk_category', - 'categorie' => 'rowid', - ); - foreach ($arraydelete as $key => $value) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; - $sql .= " WHERE ".$value." = ".$this->id; - if (!$this->db->query($sql)) { - $this->errors[] = $this->db->lasterror(); - dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); - $error++; - } - } + $arraydelete = array( + 'categorie_societe' => 'fk_categorie', + 'categorie_fournisseur' => 'fk_categorie', + 'categorie_product' => 'fk_categorie', + 'categorie_member' => 'fk_categorie', + 'categorie_contact' => 'fk_categorie', + 'categorie_account' => 'fk_categorie', + 'bank_class' => 'fk_categ', + 'categorie_lang' => 'fk_category', + 'categorie' => 'rowid', + ); + foreach ($arraydelete as $key => $value) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; + $sql .= " WHERE ".$value." = ".$this->id; + if (!$this->db->query($sql)) { + $this->errors[] = $this->db->lasterror(); + dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); + $error++; + } + } // Removed extrafields if (!$error) @@ -650,7 +650,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link an object to the category * @@ -660,7 +660,7 @@ class Categorie extends CommonObject */ public function add_type($obj, $type = '') { - // phpcs:enable + // phpcs:enable global $user, $langs, $conf; $error = 0; @@ -669,9 +669,9 @@ class Categorie extends CommonObject if (empty($type)) $type = $obj->element; - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); $sql .= " (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).")"; $sql .= " VALUES (".$this->id.", ".$obj->id.")"; @@ -689,7 +689,7 @@ class Categorie extends CommonObject { if ($this->db->num_rows($resql) > 0) { - $objparent = $this->db->fetch_object($resql); + $objparent = $this->db->fetch_object($resql); if (!empty($objparent->fk_parent)) { @@ -712,29 +712,29 @@ class Categorie extends CommonObject if ($error) { - $this->db->rollback(); + $this->db->rollback(); return -1; } } - // Call trigger + // Call trigger $this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_LINK', $user); - if ($result < 0) { $error++; } - // End call triggers + if ($result < 0) { $error++; } + // End call triggers if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return -2; + $this->db->rollback(); + return -2; } } else { - $this->db->rollback(); + $this->db->rollback(); if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error = $this->db->lasterrno(); @@ -746,7 +746,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete object from category * @@ -757,7 +757,7 @@ class Categorie extends CommonObject */ public function del_type($obj, $type) { - // phpcs:enable + // phpcs:enable global $user, $langs, $conf; $error = 0; @@ -771,31 +771,31 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); } - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); $sql .= " WHERE fk_categorie = ".$this->id; $sql .= " AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".$obj->id; dol_syslog(get_class($this).'::del_type', LOG_DEBUG); if ($this->db->query($sql)) { - // Call trigger + // Call trigger $this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_UNLINK', $user); - if ($result < 0) { $error++; } - // End call triggers + if ($result < 0) { $error++; } + // End call triggers if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return -2; + $this->db->rollback(); + return -2; } } else { - $this->db->rollback(); + $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } @@ -842,16 +842,16 @@ class Categorie extends CommonObject { while ($rec = $this->db->fetch_array($resql)) { - if ($onlyids) { - $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; - } else { - $classnameforobj = $this->MAP_OBJ_CLASS[$type]; + if ($onlyids) { + $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; + } else { + $classnameforobj = $this->MAP_OBJ_CLASS[$type]; - $obj = new $classnameforobj($this->db); - $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]); + $obj = new $classnameforobj($this->db); + $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]); - $objs[] = $obj; - } + $objs[] = $obj; + } } return $objs; } else { @@ -990,7 +990,7 @@ class Categorie extends CommonObject return $categories; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return direct childs id of a category into an array * @@ -998,7 +998,7 @@ class Categorie extends CommonObject */ public function get_filles() { - // phpcs:enable + // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE fk_parent = ".$this->id; $sql .= " AND entity IN (".getEntity('category').")"; @@ -1020,7 +1020,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the array this->motherof that is array(id_son=>id_parent, ...) * @@ -1028,8 +1028,8 @@ class Categorie extends CommonObject */ protected function load_motherof() { - // phpcs:enable - $this->motherof = array(); + // phpcs:enable + $this->motherof = array(); // Load array[child]=parent $sql = "SELECT fk_parent as id_parent, rowid as id_son"; @@ -1052,7 +1052,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Rebuilding the category tree as an array * Return an array of table('id','id_mere',...) trie selon arbre et avec: @@ -1065,17 +1065,17 @@ class Categorie extends CommonObject * * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member', ...) * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. - * $markafterid can be an : - * - int (id of category) - * - string (categories ids separated by comma) - * - array (list of categories ids) - * @param int $include [=0] Removed or 1=Keep only + * $markafterid can be an : + * - int (id of category) + * - string (categories ids separated by comma) + * - array (list of categories ids) + * @param int $include [=0] Removed or 1=Keep only * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error */ public function get_full_arbo($type, $markafterid = 0, $include = 0) { - // phpcs:enable - global $conf, $langs; + // phpcs:enable + global $conf, $langs; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; if (is_null($type)) { @@ -1083,23 +1083,23 @@ class Categorie extends CommonObject return -1; } - if (is_string($markafterid)) - { - $markafterid = explode(',', $markafterid); - } elseif (is_numeric($markafterid)) - { - if ($markafterid > 0) - { - $markafterid = array($markafterid); - } else { - $markafterid = array(); - } - } elseif (!is_array($markafterid)) - { - $markafterid = array(); - } + if (is_string($markafterid)) + { + $markafterid = explode(',', $markafterid); + } elseif (is_numeric($markafterid)) + { + if ($markafterid > 0) + { + $markafterid = array($markafterid); + } else { + $markafterid = array(); + } + } elseif (!is_array($markafterid)) + { + $markafterid = array(); + } - $this->cats = array(); + $this->cats = array(); // Init this->motherof that is array(id_son=>id_parent, ...) $this->load_motherof(); @@ -1143,27 +1143,27 @@ class Categorie extends CommonObject $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } - // Include or exclude leaf including $markafterid from tree - if (count($markafterid) > 0) - { - $keyfiltercatid = '('.implode('|', $markafterid).')'; + // Include or exclude leaf including $markafterid from tree + if (count($markafterid) > 0) + { + $keyfiltercatid = '('.implode('|', $markafterid).')'; - //print "Look to discard category ".$markafterid."\n"; - $keyfilter1 = '^'.$keyfiltercatid.'$'; - $keyfilter2 = '_'.$keyfiltercatid.'$'; - $keyfilter3 = '^'.$keyfiltercatid.'_'; - $keyfilter4 = '_'.$keyfiltercatid.'_'; - foreach ($this->cats as $key => $val) - { - $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) - || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); + //print "Look to discard category ".$markafterid."\n"; + $keyfilter1 = '^'.$keyfiltercatid.'$'; + $keyfilter2 = '_'.$keyfiltercatid.'$'; + $keyfilter3 = '^'.$keyfiltercatid.'_'; + $keyfilter4 = '_'.$keyfiltercatid.'_'; + foreach ($this->cats as $key => $val) + { + $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) + || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); - if (($test && !$include) || (!$test && $include)) - { - unset($this->cats[$key]); - } - } - } + if (($test && !$include) || (!$test && $include)) + { + unset($this->cats[$key]); + } + } + } dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG); $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); @@ -1173,7 +1173,7 @@ class Categorie extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel. * It is called by get_full_arbo() @@ -1184,10 +1184,10 @@ class Categorie extends CommonObject * @return void * @see get_full_arbo() */ - public function build_path_from_id_categ($id_categ, $protection = 1000) - { - // phpcs:enable - dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); + public function build_path_from_id_categ($id_categ, $protection = 1000) + { + // phpcs:enable + dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); if (!empty($this->cats[$id_categ]['fullpath'])) { @@ -1218,10 +1218,10 @@ class Categorie extends CommonObject $nbunderscore = substr_count($this->cats[$id_categ]['fullpath'], '_'); $this->cats[$id_categ]['level'] = ($nbunderscore ? $nbunderscore : null); - return; - } + return; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display content of $this->cats * @@ -1229,7 +1229,7 @@ class Categorie extends CommonObject */ public function debug_cats() { - // phpcs:enable + // phpcs:enable // Display $this->cats foreach ($this->cats as $key => $val) { @@ -1244,7 +1244,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns all categories * @@ -1254,7 +1254,7 @@ class Categorie extends CommonObject */ public function get_all_categories($type = null, $parent = false) { - // phpcs:enable + // phpcs:enable if (!is_numeric($type)) $type = $this->MAP_ID[$type]; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; @@ -1290,11 +1290,11 @@ class Categorie extends CommonObject */ public function get_main_categories($type = null) { - // phpcs:enable - return $this->get_all_categories($type, true); + // phpcs:enable + return $this->get_all_categories($type, true); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * @@ -1302,7 +1302,7 @@ class Categorie extends CommonObject */ public function already_exists() { - // phpcs:enable + // phpcs:enable $type = $this->type; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; @@ -1344,7 +1344,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the path of the category, with the names of the categories * separated by $sep (" >> " by default) @@ -1357,7 +1357,7 @@ class Categorie extends CommonObject */ public function print_all_ways($sep = ' >> ', $url = '', $nocolor = 0, $addpicto = 0) { - // phpcs:enable + // phpcs:enable $ways = array(); $allways = $this->get_all_ways(); // Load array of categories @@ -1368,26 +1368,26 @@ class Categorie extends CommonObject $forced_color = ''; foreach ($way as $cat) { - $i++; + $i++; - if (empty($nocolor)) - { - $forced_color = 'toreplace'; - if ($i == count($way)) - { - // Check contrast with background and correct text color - $forced_color = 'categtextwhite'; - if ($cat->color) - { - if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; - } - } - } + if (empty($nocolor)) + { + $forced_color = 'toreplace'; + if ($i == count($way)) + { + // Check contrast with background and correct text color + $forced_color = 'categtextwhite'; + if ($cat->color) + { + if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; + } + } + } if ($url == '') { - $link = ''; - $linkend = ''; - $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; + $link = ''; + $linkend = ''; + $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; } elseif ($url == 'none') { $link = ''; $linkend = ''; @@ -1405,7 +1405,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the list of parent categories * @@ -1413,7 +1413,7 @@ class Categorie extends CommonObject */ public function get_meres() { - // phpcs:enable + // phpcs:enable $parents = array(); $sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie"; @@ -1439,7 +1439,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns in a table all possible paths to get to the category * starting with the major categories represented by Tables of categories @@ -1448,7 +1448,7 @@ class Categorie extends CommonObject */ public function get_all_ways() { - // phpcs:enable + // phpcs:enable $ways = array(); $parents = $this->get_meres(); @@ -1490,60 +1490,60 @@ class Categorie extends CommonObject if ($type === Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code { - // Load bank groups - $sql = "SELECT c.label, c.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; - $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; - $sql .= " ORDER BY c.label"; + // Load bank groups + $sql = "SELECT c.label, c.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; + $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; + $sql .= " ORDER BY c.label"; - $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { - if ($mode == 'id') { - $cats[] = $obj->rowid; - } elseif ($mode == 'label') { - $cats[] = $obj->label; - } else { - $cat = new Categorie($this->db); - $cat->id = $obj->rowid; - $cat->label = $obj->label; - $cats[] = $cat; - } - } - } else { - dol_print_error($this->db); - return -1; - } + $res = $this->db->query($sql); + if ($res) + { + while ($obj = $this->db->fetch_object($res)) + { + if ($mode == 'id') { + $cats[] = $obj->rowid; + } elseif ($mode == 'label') { + $cats[] = $obj->label; + } else { + $cat = new Categorie($this->db); + $cat->id = $obj->rowid; + $cat->label = $obj->label; + $cats[] = $cat; + } + } + } else { + dol_print_error($this->db); + return -1; + } } else { - $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; - $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; - $sql .= " AND c.entity IN (".getEntity('category').")"; + $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; + $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; + $sql .= " AND c.entity IN (".getEntity('category').")"; - $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { - if ($mode == 'id') { - $cats[] = $obj->rowid; - } elseif ($mode == 'label') { - $cats[] = $obj->label; - } else { - $cat = new Categorie($this->db); - $cat->fetch($obj->fk_categorie); - $cats[] = $cat; - } - } - } else { - dol_print_error($this->db); - return -1; - } - } + $res = $this->db->query($sql); + if ($res) + { + while ($obj = $this->db->fetch_object($res)) + { + if ($mode == 'id') { + $cats[] = $obj->rowid; + } elseif ($mode == 'label') { + $cats[] = $obj->label; + } else { + $cat = new Categorie($this->db); + $cat->fetch($obj->fk_categorie); + $cats[] = $cat; + } + } + } else { + dol_print_error($this->db); + return -1; + } + } - return $cats; + return $cats; } @@ -1553,7 +1553,7 @@ class Categorie extends CommonObject * * @param int $id Id * @param string $nom Name - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. * @param boolean $exact Exact string search (true/false) * @param boolean $case Case sensitive (true/false) * @return Categorie[]|int Array of Categorie, -1 if error @@ -1567,15 +1567,15 @@ class Categorie extends CommonObject $cats = array(); - // For backward compatibility - if (is_numeric($type)) { - // We want to reverse lookup - $map_type = array_flip($this->MAP_ID); - $type = $map_type[$type]; - dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); - } + // For backward compatibility + if (is_numeric($type)) { + // We want to reverse lookup + $map_type = array_flip($this->MAP_ID); + $type = $map_type[$type]; + dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); + } - // Generation requete recherche + // Generation requete recherche $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE type = ".$this->MAP_ID[$type]; $sql .= " AND entity IN (".getEntity('category').")"; @@ -1638,14 +1638,14 @@ class Categorie extends CommonObject $picto = 'category'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * @@ -1655,7 +1655,7 @@ class Categorie extends CommonObject */ public function add_photo($sdir, $file) { - // phpcs:enable + // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/"; @@ -1695,7 +1695,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tableau de toutes les photos de la categorie * @@ -1705,7 +1705,7 @@ class Categorie extends CommonObject */ public function liste_photos($dir, $nbmax = 0) { - // phpcs:enable + // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $nbphoto = 0; @@ -1716,43 +1716,43 @@ class Categorie extends CommonObject if (file_exists($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) - { - $nbphoto++; - $photo = $file; + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) + { + $nbphoto++; + $photo = $file; - // On determine nom du fichier vignette - $photo_vignette = ''; - if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) - { - $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; - } + // On determine nom du fichier vignette + $photo_vignette = ''; + if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) + { + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; + } - // Objet - $obj = array(); - $obj['photo'] = $photo; - if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; - else $obj['photo_vignette'] = ""; + // Objet + $obj = array(); + $obj['photo'] = $photo; + if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; + else $obj['photo_vignette'] = ""; - $tabobj[$nbphoto - 1] = $obj; + $tabobj[$nbphoto - 1] = $obj; - // On continue ou on arrete de boucler - if ($nbmax && $nbphoto >= $nbmax) break; - } - } + // On continue ou on arrete de boucler + if ($nbmax && $nbphoto >= $nbmax) break; + } + } - closedir($handle); - } + closedir($handle); + } } return $tabobj; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Efface la photo de la categorie et sa vignette * @@ -1761,10 +1761,10 @@ class Categorie extends CommonObject */ public function delete_photo($file) { - // phpcs:enable - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // phpcs:enable + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette $filename = preg_replace('/'.preg_quote($dir, '/').'/i', '', $file); // Nom du fichier @@ -1782,7 +1782,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load size of image file * @@ -1791,7 +1791,7 @@ class Categorie extends CommonObject */ public function get_image_size($file) { - // phpcs:enable + // phpcs:enable $infoImg = getimagesize($file); // Recuperation des infos de l'image $this->imgWidth = $infoImg[0]; // Largeur de l'image $this->imgHeight = $infoImg[1]; // Hauteur de l'image @@ -1806,63 +1806,63 @@ class Categorie extends CommonObject */ public function setMultiLangs($user) { - global $langs; + global $langs; - $langs_available = $langs->get_available_languages(); - $current_lang = $langs->getDefaultLang(); + $langs_available = $langs->get_available_languages(); + $current_lang = $langs->getDefaultLang(); - foreach ($langs_available as $key => $value) - { - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; - $sql .= " WHERE fk_category=".$this->id; - $sql .= " AND lang='".$key."'"; + foreach ($langs_available as $key => $value) + { + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; + $sql .= " WHERE fk_category=".$this->id; + $sql .= " AND lang='".$key."'"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($key == $current_lang) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { - $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; - $sql2 .= " SET label='".$this->db->escape($this->label)."',"; - $sql2 .= " description='".$this->db->escape($this->description)."'"; - $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; - } - dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { - $this->error = $this->db->lasterror(); - return -1; - } - } elseif (isset($this->multilangs["$key"])) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { - $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; - $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; - } + if ($key == $current_lang) + { + if ($this->db->num_rows($result)) // si aucune ligne dans la base + { + $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; + $sql2 .= " SET label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + } + dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); + if (!$this->db->query($sql2)) + { + $this->error = $this->db->lasterror(); + return -1; + } + } elseif (isset($this->multilangs["$key"])) + { + if ($this->db->num_rows($result)) // si aucune ligne dans la base + { + $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; + $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + } - // on ne sauvegarde pas des champs vides - if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) - dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { - $this->error = $this->db->lasterror(); - return -1; - } - } - } + // on ne sauvegarde pas des champs vides + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) + dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); + if (!$this->db->query($sql2)) + { + $this->error = $this->db->lasterror(); + return -1; + } + } + } // Call trigger $result = $this->call_trigger('CATEGORY_SET_MULTILANGS', $user); @@ -1872,7 +1872,7 @@ class Categorie extends CommonObject } // End call triggers - return 1; + return 1; } /** @@ -1882,33 +1882,33 @@ class Categorie extends CommonObject */ public function getMultiLangs() { - global $langs; + global $langs; - $current_lang = $langs->getDefaultLang(); + $current_lang = $langs->getDefaultLang(); - $sql = "SELECT lang, label, description"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; - $sql .= " WHERE fk_category=".$this->id; + $sql = "SELECT lang, label, description"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; + $sql .= " WHERE fk_category=".$this->id; - $result = $this->db->query($sql); - if ($result) - { - while ($obj = $this->db->fetch_object($result)) - { - //print 'lang='.$obj->lang.' current='.$current_lang.'
'; - if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. - { - $this->label = $obj->label; - $this->description = $obj->description; - } - $this->multilangs["$obj->lang"]["label"] = $obj->label; - $this->multilangs["$obj->lang"]["description"] = $obj->description; - } - return 1; - } else { - $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; - return -1; - } + $result = $this->db->query($sql); + if ($result) + { + while ($obj = $this->db->fetch_object($result)) + { + //print 'lang='.$obj->lang.' current='.$current_lang.'
'; + if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. + { + $this->label = $obj->label; + $this->description = $obj->description; + } + $this->multilangs["$obj->lang"]["label"] = $obj->label; + $this->multilangs["$obj->lang"]["description"] = $obj->description; + } + return 1; + } else { + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; + return -1; + } } /** @@ -1919,47 +1919,47 @@ class Categorie extends CommonObject */ public function getLibStatut($mode) { - return ''; + return ''; } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - dol_syslog(get_class($this)."::initAsSpecimen"); + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + dol_syslog(get_class($this)."::initAsSpecimen"); - // Initialise parametres - $this->id = 0; - $this->fk_parent = 0; - $this->label = 'SPECIMEN'; - $this->specimen = 1; - $this->description = 'This is a description'; - $this->socid = 1; - $this->type = self::TYPE_PRODUCT; - } + // Initialise parametres + $this->id = 0; + $this->fk_parent = 0; + $this->label = 'SPECIMEN'; + $this->specimen = 1; + $this->description = 'This is a description'; + $this->socid = 1; + $this->type = self::TYPE_PRODUCT; + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'categorie_societe' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'categorie_societe' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); + } /** * Return the addtional SQL JOIN query for filtering a list by a category diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f3612133100..a181586815f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -58,23 +58,23 @@ $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); $confirm = GETPOST('confirm', 'alpha'); -$fulldayevent = GETPOST('fullday'); +$fulldayevent = GETPOST('fullday', 'alpha'); -$aphour = GETPOST('aphour'); -$apmin = GETPOST('apmin'); -$p2hour = GETPOST('p2hour'); -$p2min = GETPOST('p2min'); +$aphour = GETPOST('aphour', 'int'); +$apmin = GETPOST('apmin', 'int'); +$p2hour = GETPOST('p2hour', 'int'); +$p2min = GETPOST('p2min', 'int'); -$addreminder = GETPOST('addreminder'); -$offsetvalue = GETPOST('offsetvalue'); -$offsetunit = GETPOST('offsetunittype_duration'); -$remindertype = GETPOST('selectremindertype'); -$modelmail = GETPOST('actioncommsendmodel_mail'); +$addreminder = GETPOST('addreminder', 'alpha'); +$offsetvalue = GETPOST('offsetvalue', 'int'); +$offsetunit = GETPOST('offsetunittype_duration', 'aZ09'); +$remindertype = GETPOST('selectremindertype', 'aZ09'); +$modelmail = GETPOST('actioncommsendmodel_mail', 'int'); //var_dump($_POST); exit; -$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); -$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); +$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); +$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); // Security check $socid = GETPOST('socid', 'int'); @@ -391,19 +391,7 @@ if (empty($reshook) && $action == 'add') if ($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); - if ($offsetunit == 'minute'){ - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); - } elseif ($offsetunit == 'hour'){ - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h'); - } elseif ($offsetunit == 'day') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd'); - } elseif ($offsetunit == 'week') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'w'); - } elseif ($offsetunit == 'month') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'm'); - } elseif ($offsetunit == 'year') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y'); - } + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); $actionCommReminder->dateremind = $dateremind; $actionCommReminder->typeremind = $remindertype; @@ -418,15 +406,20 @@ if (empty($reshook) && $action == 'add') if ($res <= 0){ // If error - $db->rollback(); + $error++; $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); + $error = $langs->trans('ErrorReminderActionCommCreation').' '.$actionCommReminder->error; + setEventMessages($error, $actionCommReminder->errors, 'errors'); $action = 'create'; $donotclearsession = 1; } } - $db->commit(); + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + if (!empty($backtopage)) { dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); @@ -929,9 +922,9 @@ if ($action == 'create') print '     -     '; //print ' - '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); } print ''; @@ -1208,7 +1201,7 @@ if ($action == 'create') //Time Type print ''.$langs->trans("TimeType").''; - print $form->selectTypeDuration('offsetunit'); + print $form->selectTypeDuration('offsetunit', 'i'); print ''; //Reminder Type diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 37ddf2f43ae..5514172182e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -41,307 +41,307 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php' */ class ActionComm extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'action'; + /** + * @var string ID to identify managed object + */ + public $element = 'action'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'actioncomm'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'actioncomm'; - /** - * @var string Name of id column - */ - public $table_rowid = 'id'; + /** + * @var string Name of id column + */ + public $table_rowid = 'id'; - /** - * @var string Name of icon for actioncomm object. Filename of icon is object_action.png - */ - public $picto = 'action'; + /** + * @var string Name of icon for actioncomm object. Filename of icon is object_action.png + */ + public $picto = 'action'; - /** - * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - */ - public $ismultientitymanaged = 1; + /** + * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 1; - /** - * @var integer 0=Default - * 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * 2=Same than 1 but accept record if fksoc is empty - */ - public $restrictiononfksoc = 2; + /** + * @var integer 0=Default + * 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * 2=Same than 1 but accept record if fksoc is empty + */ + public $restrictiononfksoc = 2; - /** - * @var int Id of the event - */ - public $id; + /** + * @var int Id of the event + */ + public $id; - /** - * @var int Id of the event. Use $id as possible - */ - public $ref; + /** + * @var int Id of the event. Use $id as possible + */ + public $ref; - /** - * @var int Id into parent table llx_c_actioncomm (used only if option to use type is set) - */ - public $type_id; + /** + * @var int Id into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type_id; - /** - * @var string Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. - */ - public $type_code; + /** + * @var string Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. + */ + public $type_code; - /** - * @var string Type label - */ - public $type_label; + /** + * @var string Type label + */ + public $type_label; - /** - * @var string Label into parent table llx_c_actioncomm (used only if option to use type is set) - */ - public $type; + /** + * @var string Label into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type; - /** - * @var string Color into parent table llx_c_actioncomm (used only if option to use type is set) - */ - public $type_color; + /** + * @var string Color into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type_color; - /** - * @var string Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) - */ - public $code; + /** + * @var string Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) + */ + public $code; - /** - * @var string Agenda event label - */ - public $label; + /** + * @var string Agenda event label + */ + public $label; - /** - * @var integer Date creation record (datec) - */ - public $datec; + /** + * @var integer Date creation record (datec) + */ + public $datec; - /** - * @var integer Date end record (datef) - */ - public $datef; + /** + * @var integer Date end record (datef) + */ + public $datef; - /** - * @var integer Duration (duree) - */ - public $duree; + /** + * @var integer Duration (duree) + */ + public $duree; - /** - * @var integer Date modification record (tms) - */ - public $datem; + /** + * @var integer Date modification record (tms) + */ + public $datem; - /** - * @var User Object user that create action - * @deprecated - * @see $authorid - */ - public $author; + /** + * @var User Object user that create action + * @deprecated + * @see $authorid + */ + public $author; - /** - * @var User Object user that modified action - * @deprecated - * @see $usermodid - */ - public $usermod; + /** + * @var User Object user that modified action + * @deprecated + * @see $usermodid + */ + public $usermod; - /** - * @var int Id user that create action - */ - public $authorid; + /** + * @var int Id user that create action + */ + public $authorid; - /** - * @var int Id user that modified action - */ - public $usermodid; + /** + * @var int Id user that modified action + */ + public $usermodid; - /** - * @var integer Date action start (datep) - */ - public $datep; + /** + * @var integer Date action start (datep) + */ + public $datep; - /** - * @var integer Date action end (datep2) - */ - public $datep2; + /** + * @var integer Date action end (datep2) + */ + public $datep2; - /** - * @var int -1=Unkown duration - * @deprecated - */ - public $durationp = -1; + /** + * @var int -1=Unkown duration + * @deprecated + */ + public $durationp = -1; - /** - * @var int 1=Event on full day - */ - public $fulldayevent = 0; + /** + * @var int 1=Event on full day + */ + public $fulldayevent = 0; - /** - * @var integer Percentage - */ - public $percentage; + /** + * @var integer Percentage + */ + public $percentage; - /** - * @var string Location - */ - public $location; + /** + * @var string Location + */ + public $location; - /** - * @var int Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events) - */ - public $transparency; + /** + * @var int Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events) + */ + public $transparency; - /** - * @var int (0 By default) - */ - public $priority; + /** + * @var int (0 By default) + */ + public $priority; - /** - * @var int[] Array of user ids - */ - public $userassigned = array(); + /** + * @var int[] Array of user ids + */ + public $userassigned = array(); - /** - * @var int Id of user owner = fk_user_action into table - */ - public $userownerid; + /** + * @var int Id of user owner = fk_user_action into table + */ + public $userownerid; - /** - * @var int Id of user done (deprecated) - * @deprecated - */ - public $userdoneid; + /** + * @var int Id of user done (deprecated) + * @deprecated + */ + public $userdoneid; - /** - * @var int[] Array of contact ids - */ - public $socpeopleassigned = array(); + /** + * @var int[] Array of contact ids + */ + public $socpeopleassigned = array(); - /** - * @var int[] Array of other contact emails (not user, not contact) - */ - public $otherassigned = array(); + /** + * @var int[] Array of other contact emails (not user, not contact) + */ + public $otherassigned = array(); - /** - * @var User Object user of owner - * @deprecated - * @see $userownerid - */ - public $usertodo; + /** + * @var User Object user of owner + * @deprecated + * @see $userownerid + */ + public $usertodo; - /** - * @var User Object user that did action - * @deprecated - * @see $userdoneid - */ - public $userdone; + /** + * @var User Object user that did action + * @deprecated + * @see $userdoneid + */ + public $userdone; - /** - * @var int thirdparty id linked to action - */ - public $socid; + /** + * @var int thirdparty id linked to action + */ + public $socid; - /** - * @var int socpeople id linked to action - */ - public $contactid; + /** + * @var int socpeople id linked to action + */ + public $contactid; - /** - * @var Societe|null Company linked to action (optional) - * @deprecated - * @see $socid - */ - public $societe; + /** + * @var Societe|null Company linked to action (optional) + * @deprecated + * @see $socid + */ + public $societe; - /** - * @var Contact|null Contact linked to action (optional) - * @deprecated - * @see $contactid - */ - public $contact; + /** + * @var Contact|null Contact linked to action (optional) + * @deprecated + * @see $contactid + */ + public $contact; - // Properties for links to other objects - /** - * @var int Id of linked object - */ - public $fk_element; // Id of record + // Properties for links to other objects + /** + * @var int Id of linked object + */ + public $fk_element; // Id of record - /** - * @var int Id of record alternative for API - */ - public $elementid; + /** + * @var int Id of record alternative for API + */ + public $elementid; - /** - * @var string Type of record. This if property ->element of object linked to. - */ - public $elementtype; + /** + * @var string Type of record. This if property ->element of object linked to. + */ + public $elementtype; - /** - * @var string Ical name - */ - public $icalname; + /** + * @var string Ical name + */ + public $icalname; - /** - * @var string Ical color - */ - public $icalcolor; + /** + * @var string Ical color + */ + public $icalcolor; - /** - * @var string Extraparam - */ - public $extraparams; + /** + * @var string Extraparam + */ + public $extraparams; - /** - * @var array Actions - */ - public $actions = array(); + /** + * @var array Actions + */ + public $actions = array(); - /** - * @var string Email msgid - */ - public $email_msgid; + /** + * @var string Email msgid + */ + public $email_msgid; - /** - * @var string Email from - */ - public $email_from; + /** + * @var string Email from + */ + public $email_from; - /** - * @var string Email sender - */ - public $email_sender; + /** + * @var string Email sender + */ + public $email_sender; - /** - * @var string Email to - */ - public $email_to; + /** + * @var string Email to + */ + public $email_to; - /** - * @var string Email tocc - */ - public $email_tocc; - /** - * @var string Email tobcc - */ - public $email_tobcc; + /** + * @var string Email tocc + */ + public $email_tocc; + /** + * @var string Email tobcc + */ + public $email_tobcc; - /** - * @var string Email subject - */ - public $email_subject; + /** + * @var string Email subject + */ + public $email_subject; - /** - * @var string Email errors to - */ - public $errors_to; + /** + * @var string Email errors to + */ + public $errors_to; /** * Typical value for a event that is in a todo state @@ -358,186 +358,186 @@ class ActionComm extends CommonObject */ const EVENT_FINISHED = 100; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } - /** - * Add an action/event into database. - * $this->type_id OR $this->type_code must be set. - * - * @param User $user Object user making action - * @param int $notrigger 1 = disable triggers, 0 = enable triggers - * @return int Id of created event, < 0 if KO - */ - public function create(User $user, $notrigger = 0) - { - global $langs, $conf, $hookmanager; + /** + * Add an action/event into database. + * $this->type_id OR $this->type_code must be set. + * + * @param User $user Object user making action + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int Id of created event, < 0 if KO + */ + public function create(User $user, $notrigger = 0) + { + global $langs, $conf, $hookmanager; - $error = 0; - $now = dol_now(); + $error = 0; + $now = dol_now(); - // Check parameters - if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 - { - dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); - $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; - return -1; - } + // Check parameters + if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 + { + dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); + $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; + return -1; + } - // Clean parameters - $this->label = dol_trunc(trim($this->label), 128); - $this->location = dol_trunc(trim($this->location), 128); - $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); - if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; - if (empty($this->fulldayevent)) $this->fulldayevent = 0; - if (empty($this->transparency)) $this->transparency = 0; - if ($this->percentage > 100) $this->percentage = 100; - //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated - //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); - if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; - //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; - if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; - // For backward compatibility - if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; - if ($this->elementtype == 'commande') $this->elementtype = 'order'; - if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; + // Clean parameters + $this->label = dol_trunc(trim($this->label), 128); + $this->location = dol_trunc(trim($this->location), 128); + $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); + if (empty($this->percentage)) $this->percentage = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; + if (empty($this->fulldayevent)) $this->fulldayevent = 0; + if (empty($this->transparency)) $this->transparency = 0; + if ($this->percentage > 100) $this->percentage = 100; + //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; + if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated + //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); + if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; + //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; + if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; + // For backward compatibility + if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; + if ($this->elementtype == 'commande') $this->elementtype = 'order'; + if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; - if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array - { - $tmpid = $this->userassigned; - $this->userassigned = array(); - $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); - } + if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array + { + $tmpid = $this->userassigned; + $this->userassigned = array(); + $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); + } - $userownerid = $this->userownerid; - $userdoneid = $this->userdoneid; + $userownerid = $this->userownerid; + $userdoneid = $this->userdoneid; - // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). - if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) - $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); + // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). + if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) + $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); - if (!$this->type_id || !$this->type_code) - { - $key = empty($this->type_id) ? $this->type_code : $this->type_id; + if (!$this->type_id || !$this->type_code) + { + $key = empty($this->type_id) ? $this->type_code : $this->type_id; - // Get id from code - $cactioncomm = new CActionComm($this->db); - $result = $cactioncomm->fetch($key); + // Get id from code + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($key); - if ($result > 0) - { - $this->type_id = $cactioncomm->id; - $this->type_code = $cactioncomm->code; - } elseif ($result == 0) - { - $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; - return -1; - } else { - $this->error = $cactioncomm->error; - return -1; - } - } - $code = empty($this->code) ? $this->type_code : $this->code; + if ($result > 0) + { + $this->type_id = $cactioncomm->id; + $this->type_code = $cactioncomm->code; + } elseif ($result == 0) + { + $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; + return -1; + } else { + $this->error = $cactioncomm->error; + return -1; + } + } + $code = empty($this->code) ? $this->type_code : $this->code; - // Check parameters - if (!$this->type_id) - { - $this->error = "ErrorWrongParameters"; - return -1; - } + // Check parameters + if (!$this->type_id) + { + $this->error = "ErrorWrongParameters"; + return -1; + } - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; - $sql .= "(datec,"; - $sql .= "datep,"; - $sql .= "datep2,"; - $sql .= "durationp,"; // deprecated - $sql .= "fk_action,"; - $sql .= "code,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; + $sql .= "(datec,"; + $sql .= "datep,"; + $sql .= "datep2,"; + $sql .= "durationp,"; // deprecated + $sql .= "fk_action,"; + $sql .= "code,"; $sql .= "ref_ext,"; - $sql .= "fk_soc,"; - $sql .= "fk_project,"; - $sql .= "note,"; - $sql .= "fk_contact,"; - $sql .= "fk_user_author,"; - $sql .= "fk_user_action,"; - $sql .= "fk_user_done,"; - $sql .= "label,percent,priority,fulldayevent,location,"; - $sql .= "transparency,"; - $sql .= "fk_element,"; - $sql .= "elementtype,"; - $sql .= "entity,"; - $sql .= "extraparams,"; + $sql .= "fk_soc,"; + $sql .= "fk_project,"; + $sql .= "note,"; + $sql .= "fk_contact,"; + $sql .= "fk_user_author,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_done,"; + $sql .= "label,percent,priority,fulldayevent,location,"; + $sql .= "transparency,"; + $sql .= "fk_element,"; + $sql .= "elementtype,"; + $sql .= "entity,"; + $sql .= "extraparams,"; // Fields emails - $sql .= "email_msgid,"; - $sql .= "email_from,"; - $sql .= "email_sender,"; - $sql .= "email_to,"; - $sql .= "email_tocc,"; - $sql .= "email_tobcc,"; - $sql .= "email_subject,"; - $sql .= "errors_to"; - $sql .= ") VALUES ("; - $sql .= "'".$this->db->idate($now)."', "; - $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; - $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; - $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated - $sql .= (isset($this->type_id) ? $this->type_id : "null").","; - $sql .= ($code ? ("'".$this->db->escape($code)."'") : "null").", "; - $sql .= ($this->ref_ext ? ("'".$this->db->idate($this->ref_ext)."'") : "null").", "; - $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; - $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; - $sql .= " '".$this->db->escape($this->note_private)."', "; - $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned - $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; - $sql .= ($userownerid > 0 ? $userownerid : "null").", "; - $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; - $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."', "; - $sql .= "'".$this->db->escape($this->transparency)."', "; - $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; - $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; - $sql .= $conf->entity.","; - $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; - // Fields emails - $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; - $sql .= (!empty($this->email_from) ? "'".$this->db->escape($this->email_from)."'" : "null").", "; - $sql .= (!empty($this->email_sender) ? "'".$this->db->escape($this->email_sender)."'" : "null").", "; - $sql .= (!empty($this->email_to) ? "'".$this->db->escape($this->email_to)."'" : "null").", "; - $sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", "; - $sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", "; - $sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", "; - $sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null"); - $sql .= ")"; + $sql .= "email_msgid,"; + $sql .= "email_from,"; + $sql .= "email_sender,"; + $sql .= "email_to,"; + $sql .= "email_tocc,"; + $sql .= "email_tobcc,"; + $sql .= "email_subject,"; + $sql .= "errors_to"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."', "; + $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; + $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; + $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated + $sql .= (isset($this->type_id) ? $this->type_id : "null").","; + $sql .= ($code ? ("'".$this->db->escape($code)."'") : "null").", "; + $sql .= ($this->ref_ext ? ("'".$this->db->idate($this->ref_ext)."'") : "null").", "; + $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; + $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; + $sql .= " '".$this->db->escape($this->note_private)."', "; + $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned + $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; + $sql .= ($userownerid > 0 ? $userownerid : "null").", "; + $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; + $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."', "; + $sql .= "'".$this->db->escape($this->transparency)."', "; + $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; + $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; + $sql .= $conf->entity.","; + $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; + // Fields emails + $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; + $sql .= (!empty($this->email_from) ? "'".$this->db->escape($this->email_from)."'" : "null").", "; + $sql .= (!empty($this->email_sender) ? "'".$this->db->escape($this->email_sender)."'" : "null").", "; + $sql .= (!empty($this->email_to) ? "'".$this->db->escape($this->email_to)."'" : "null").", "; + $sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", "; + $sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", "; + $sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", "; + $sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null"); + $sql .= ")"; - dol_syslog(get_class($this)."::add", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); + dol_syslog(get_class($this)."::add", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); - // Now insert assigned users + // Now insert assigned users if (!$error) { //dol_syslog(var_export($this->userassigned, true)); foreach ($this->userassigned as $key => $val) { - if (!is_array($val)) // For backward compatibility when val=id - { - $val = array('id'=>$val); - } + if (!is_array($val)) // For backward compatibility when val=id + { + $val = array('id'=>$val); + } - if ($val['id'] > 0) - { + if ($val['id'] > 0) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; @@ -546,10 +546,10 @@ class ActionComm extends CommonObject { $error++; dol_syslog('Error to process userassigned: '.$this->db->lasterror(), LOG_ERR); - $this->errors[] = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; - } + } } } @@ -573,54 +573,54 @@ class ActionComm extends CommonObject } } - if (!$error) - { - // Actions on extra fields - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + if (!$error) + { + // Actions on extra fields + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('ACTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('ACTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -1; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Load an object from its id and create a new one in database - * - * @param User $fuser Object user making action + /** + * Load an object from its id and create a new one in database + * + * @param User $fuser Object user making action * @param int $socid Id of thirdparty - * @return int New id of clone - */ - public function createFromClone(User $fuser, $socid) - { - global $db, $conf, $hookmanager; + * @return int New id of clone + */ + public function createFromClone(User $fuser, $socid) + { + global $db, $conf, $hookmanager; - $error = 0; - $now = dol_now(); + $error = 0; + $now = dol_now(); - $this->db->begin(); + $this->db->begin(); // Load source object $objFrom = clone $this; @@ -723,7 +723,7 @@ class ActionComm extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->id; - $this->entity = $obj->entity; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->ref_ext = $obj->ref_ext; @@ -767,7 +767,7 @@ class ActionComm extends CommonObject $this->transparency = $obj->transparency; $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->contact_id = $obj->fk_contact; // To have fetch_contact method working + $this->contact_id = $obj->fk_contact; // To have fetch_contact method working $this->fk_project = $obj->fk_project; // To have fetch_projet method working //$this->societe->id = $obj->fk_soc; // deprecated @@ -808,9 +808,9 @@ class ActionComm extends CommonObject // If owner is known, we must but id first into list if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list. - while ($obj = $this->db->fetch_object($resql)) - { - if ($obj->fk_element > 0) + while ($obj = $this->db->fetch_object($resql)) + { + if ($obj->fk_element > 0) { switch ($obj->element_type) { case 'user': @@ -822,86 +822,86 @@ class ActionComm extends CommonObject break; } } - } + } - return 1; + return 1; } else { dol_print_error($this->db); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Initialize this->userassigned array with list of id of user assigned to event - * - * @param bool $override Override $this->userownerid when empty. TODO This should be false by default. True is here to fix corrupted data. - * @return int <0 if KO, >0 if OK - */ - public function fetch_userassigned($override = true) - { - // phpcs:enable - $sql = "SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql .= " WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Initialize this->userassigned array with list of id of user assigned to event + * + * @param bool $override Override $this->userownerid when empty. TODO This should be false by default. True is here to fix corrupted data. + * @return int <0 if KO, >0 if OK + */ + public function fetch_userassigned($override = true) + { + // phpcs:enable + $sql = "SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql .= " WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; - $resql2 = $this->db->query($sql); - if ($resql2) - { - $this->userassigned = array(); + $resql2 = $this->db->query($sql); + if ($resql2) + { + $this->userassigned = array(); - // If owner is known, we must but id first into list - if ($this->userownerid > 0) - { - // Set first so will be first into list. - $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); - } + // If owner is known, we must but id first into list + if ($this->userownerid > 0) + { + // Set first so will be first into list. + $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); + } - while ($obj = $this->db->fetch_object($resql2)) - { - if ($obj->fk_element > 0) - { - $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, - 'mandatory'=>$obj->mandatory, - 'answer_status'=>$obj->answer_status, - 'transparency'=>$obj->transparency); - } + while ($obj = $this->db->fetch_object($resql2)) + { + if ($obj->fk_element > 0) + { + $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, + 'mandatory'=>$obj->mandatory, + 'answer_status'=>$obj->answer_status, + 'transparency'=>$obj->transparency); + } - if ($override === true) - { - // If not defined (should not happened, we fix this) - if (empty($this->userownerid)) - { - $this->userownerid = $obj->fk_element; - } - } - } + if ($override === true) + { + // If not defined (should not happened, we fix this) + if (empty($this->userownerid)) + { + $this->userownerid = $obj->fk_element; + } + } + } - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Delete event from database - * - * @param int $notrigger 1 = disable triggers, 0 = enable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete($notrigger = 0) - { - global $user; + /** + * Delete event from database + * + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete($notrigger = 0) + { + global $user; - $error = 0; + $error = 0; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $this->db->begin(); + $this->db->begin(); - // remove categorie association - if (!$error) { + // remove categorie association + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_actioncomm"; $sql .= " WHERE fk_actioncomm=".$this->id; @@ -910,148 +910,148 @@ class ActionComm extends CommonObject $this->error = $this->db->lasterror(); $error++; } - } + } - // remove actioncomm_resources - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql .= " WHERE fk_actioncomm=".$this->id; + // remove actioncomm_resources + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql .= " WHERE fk_actioncomm=".$this->id; - $res = $this->db->query($sql); - if (!$res) { - $this->error = $this->db->lasterror(); - $error++; - } - } + $res = $this->db->query($sql); + if (!$res) { + $this->error = $this->db->lasterror(); + $error++; + } + } - // Removed extrafields - if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); - } - } + // Removed extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); + } + } - // remove actioncomm - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; - $sql .= " WHERE id=".$this->id; + // remove actioncomm + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; + $sql .= " WHERE id=".$this->id; - $res = $this->db->query($sql); - if (!$res) { - $this->error = $this->db->lasterror(); - $error++; - } - } + $res = $this->db->query($sql); + if (!$res) { + $this->error = $this->db->lasterror(); + $error++; + } + } - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('ACTION_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error) + { + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('ACTION_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Update action into database - * If percentage = 100, on met a jour date 100% - * - * @param User $user Object user making change - * @param int $notrigger 1 = disable triggers, 0 = enable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - global $langs, $conf, $hookmanager; + /** + * Update action into database + * If percentage = 100, on met a jour date 100% + * + * @param User $user Object user making change + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + global $langs, $conf, $hookmanager; - $error = 0; + $error = 0; - // Clean parameters - $this->label = trim($this->label); - $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); - if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; - if (empty($this->transparency)) $this->transparency = 0; - if (empty($this->fulldayevent)) $this->fulldayevent = 0; - if ($this->percentage > 100) $this->percentage = 100; - //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated - //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); - if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; - //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; - if ($this->fk_project < 0) $this->fk_project = 0; + // Clean parameters + $this->label = trim($this->label); + $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); + if (empty($this->percentage)) $this->percentage = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; + if (empty($this->transparency)) $this->transparency = 0; + if (empty($this->fulldayevent)) $this->fulldayevent = 0; + if ($this->percentage > 100) $this->percentage = 100; + //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; + if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated + //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); + if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; + //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; + if ($this->fk_project < 0) $this->fk_project = 0; - // Check parameters - if ($this->percentage == 0 && $this->userdoneid > 0) - { - $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; - return -1; - } + // Check parameters + if ($this->percentage == 0 && $this->userdoneid > 0) + { + $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; + return -1; + } - $socid = (($this->socid > 0) ? $this->socid : 0); - $contactid = (($this->contact_id > 0) ? $this->contact_id : 0); + $socid = (($this->socid > 0) ? $this->socid : 0); + $contactid = (($this->contact_id > 0) ? $this->contact_id : 0); $userownerid = ($this->userownerid ? $this->userownerid : 0); $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; - $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; - if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; - $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); - $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); - $sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated - $sql .= ", note = '".$this->db->escape($this->note_private)."'"; - $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null"); - $sql .= ", fk_soc =".($socid > 0 ? $socid : "null"); - $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null"); - $sql .= ", priority = '".$this->db->escape($this->priority)."'"; - $sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; - $sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null"); - $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; - $sql .= ", fk_user_mod = ".$user->id; - $sql .= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'" : "null"); - $sql .= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'" : "null"); - if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); - if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); - $sql .= " WHERE id=".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; + $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; + if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); + $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); + $sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated + $sql .= ", note = '".$this->db->escape($this->note_private)."'"; + $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", fk_soc =".($socid > 0 ? $socid : "null"); + $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null"); + $sql .= ", priority = '".$this->db->escape($this->priority)."'"; + $sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; + $sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null"); + $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; + $sql .= ", fk_user_mod = ".$user->id; + $sql .= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'" : "null"); + $sql .= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'" : "null"); + if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); + if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); + $sql .= " WHERE id=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - if ($this->db->query($sql)) - { + dol_syslog(get_class($this)."::update", LOG_DEBUG); + if ($this->db->query($sql)) + { $action = 'update'; - // Actions on extra fields - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - // Now insert assignedusers + // Now insert assignedusers if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; @@ -1059,10 +1059,10 @@ class ActionComm extends CommonObject foreach ($this->userassigned as $key => $val) { - if (!is_array($val)) // For backward compatibility when val=id - { - $val = array('id'=>$val); - } + if (!is_array($val)) // For backward compatibility when val=id + { + $val = array('id'=>$val); + } $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; @@ -1070,7 +1070,7 @@ class ActionComm extends CommonObject if (!$resql) { $error++; - $this->errors[] = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -1098,272 +1098,272 @@ class ActionComm extends CommonObject } } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('ACTION_MODIFY', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('ACTION_MODIFY', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - dol_syslog(get_class($this)."::update ".join(',', $this->errors), LOG_ERR); - return -2; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + dol_syslog(get_class($this)."::update ".join(',', $this->errors), LOG_ERR); + return -2; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Load all objects with filters. - * @todo WARNING: This make a fetch on all records instead of making one request with a join. - * - * @param DoliDb $db Database handler - * @param int $socid Filter by thirdparty - * @param int $fk_element Id of element action is linked to - * @param string $elementtype Type of element action is linked to - * @param string $filter Other filter - * @param string $sortfield Sort on this field - * @param string $sortorder ASC or DESC - * @param string $limit Limit number of answers - * @return array|string Error string if KO, array with actions if OK - */ - public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) - { - global $conf, $langs; + /** + * Load all objects with filters. + * @todo WARNING: This make a fetch on all records instead of making one request with a join. + * + * @param DoliDb $db Database handler + * @param int $socid Filter by thirdparty + * @param int $fk_element Id of element action is linked to + * @param string $elementtype Type of element action is linked to + * @param string $filter Other filter + * @param string $sortfield Sort on this field + * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers + * @return array|string Error string if KO, array with actions if OK + */ + public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) + { + global $conf, $langs; - $resarray = array(); + $resarray = array(); - dol_syslog(get_class()."::getActions", LOG_DEBUG); + dol_syslog(get_class()."::getActions", LOG_DEBUG); - $sql = "SELECT a.id"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; - if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; - if (!empty($elementtype)) - { - if ($elementtype == 'project') { - $sql .= ' AND a.fk_project = '.$fk_element; - } - elseif ($elementtype == 'contact') { - $sql .= ' AND a.id IN'; - $sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE"; - $sql .= " element_type = 'socpeople' AND fk_element = ".$fk_element.')'; - } - else { - $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; - } - } - if (!empty($filter)) $sql .= $filter; + $sql = "SELECT a.id"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; + if (!empty($elementtype)) + { + if ($elementtype == 'project') { + $sql .= ' AND a.fk_project = '.$fk_element; + } + elseif ($elementtype == 'contact') { + $sql .= ' AND a.id IN'; + $sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE"; + $sql .= " element_type = 'socpeople' AND fk_element = ".$fk_element.')'; + } + else { + $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; + } + } + if (!empty($filter)) $sql .= $filter; if ($sortorder && $sortfield) $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit, 0); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - if ($num) - { - for ($i = 0; $i < $num; $i++) - { - $obj = $db->fetch_object($resql); - $actioncommstatic = new ActionComm($db); - $actioncommstatic->fetch($obj->id); - $resarray[$i] = $actioncommstatic; - } - } - $db->free($resql); - return $resarray; - } else { - return $db->lasterror(); - } - } + if ($num) + { + for ($i = 0; $i < $num; $i++) + { + $obj = $db->fetch_object($resql); + $actioncommstatic = new ActionComm($db); + $actioncommstatic->fetch($obj->id); + $resarray[$i] = $actioncommstatic; + } + } + $db->free($resql); + return $resarray; + } else { + return $db->lasterror(); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Objet user - * @param int $load_state_board Charge indicateurs this->nb de tableau de bord - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK - */ - public function load_board($user, $load_state_board = 0) - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @param int $load_state_board Charge indicateurs this->nb de tableau de bord + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + */ + public function load_board($user, $load_state_board = 0) + { + // phpcs:enable + global $conf, $langs; - if (empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; - else { - $this->nb = array(); - $sql = "SELECT count(a.id) as nb"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql .= " WHERE 1 = 1"; - if (empty($load_state_board)) $sql .= " AND a.percent >= 0 AND a.percent < 100"; - $sql .= " AND a.entity IN (".getEntity('agenda').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; - if ($user->socid) $sql .= " AND a.fk_soc = ".$user->socid; - if (!$user->rights->agenda->allactions->read) $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")"; + if (empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; + else { + $this->nb = array(); + $sql = "SELECT count(a.id) as nb"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql .= " WHERE 1 = 1"; + if (empty($load_state_board)) $sql .= " AND a.percent >= 0 AND a.percent < 100"; + $sql .= " AND a.entity IN (".getEntity('agenda').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; + if ($user->socid) $sql .= " AND a.fk_soc = ".$user->socid; + if (!$user->rights->agenda->allactions->read) $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")"; - $resql = $this->db->query($sql); - if ($resql) - { - if (empty($load_state_board)) { - $agenda_static = new ActionComm($this->db); - $response = new WorkboardResponse(); - $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24; - $response->label = $langs->trans("ActionsToDo"); - $response->labelShort = $langs->trans("ActionsToDoShort"); - $response->url = DOL_URL_ROOT.'/comm/action/list.php?action=show_list&actioncode=0&status=todo&mainmenu=agenda'; - if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1'; - $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); - } - // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { - if (empty($load_state_board)) { - $response->nbtodo++; - $agenda_static->datep = $this->db->jdate($obj->dp); - if ($agenda_static->hasDelay()) $response->nbtodolate++; - } else $this->nb["actionscomm"] = $obj->nb; - } + $resql = $this->db->query($sql); + if ($resql) + { + if (empty($load_state_board)) { + $agenda_static = new ActionComm($this->db); + $response = new WorkboardResponse(); + $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("ActionsToDo"); + $response->labelShort = $langs->trans("ActionsToDoShort"); + $response->url = DOL_URL_ROOT.'/comm/action/list.php?action=show_list&actioncode=0&status=todo&mainmenu=agenda'; + if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1'; + $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); + } + // This assignment in condition is not a bug. It allows walking the results. + while ($obj = $this->db->fetch_object($resql)) + { + if (empty($load_state_board)) { + $response->nbtodo++; + $agenda_static->datep = $this->db->jdate($obj->dp); + if ($agenda_static->hasDelay()) $response->nbtodolate++; + } else $this->nb["actionscomm"] = $obj->nb; + } - $this->db->free($resql); - if (empty($load_state_board)) return $response; - else return 1; - } else { - dol_print_error($this->db); - $this->error = $this->db->error(); - return -1; - } - } + $this->db->free($resql); + if (empty($load_state_board)) return $response; + else return 1; + } else { + dol_print_error($this->db); + $this->error = $this->db->error(); + return -1; + } + } - /** - * Charge les informations d'ordre info dans l'objet facture - * - * @param int $id Id de la facture a charger - * @return void - */ - public function info($id) - { - $sql = 'SELECT '; - $sql .= ' a.id,'; - $sql .= ' datec,'; - $sql .= ' tms as datem,'; - $sql .= ' fk_user_author,'; - $sql .= ' fk_user_mod'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql .= ' WHERE a.id = '.$id; + /** + * Charge les informations d'ordre info dans l'objet facture + * + * @param int $id Id de la facture a charger + * @return void + */ + public function info($id) + { + $sql = 'SELECT '; + $sql .= ' a.id,'; + $sql .= ' datec,'; + $sql .= ' tms as datem,'; + $sql .= ' fk_user_author,'; + $sql .= ' fk_user_mod'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + $sql .= ' WHERE a.id = '.$id; - dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->id; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_mod) - { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_mod); - $this->user_modification = $muser; - } + dol_syslog(get_class($this)."::info", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->id; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + if ($obj->fk_user_mod) + { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_mod); + $this->user_modification = $muser; + } - $this->date_creation = $this->db->jdate($obj->datec); - if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + $this->date_creation = $this->db->jdate($obj->datec); + if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } - /** - * Return label of status - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @return string String with status - */ - public function getLibStatut($mode, $hidenastatus = 0) - { - return $this->LibStatut($this->percentage, $mode, $hidenastatus, $this->datep); - } + /** + * Return label of status + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @return string String with status + */ + public function getLibStatut($mode, $hidenastatus = 0) + { + return $this->LibStatut($this->percentage, $mode, $hidenastatus, $this->datep); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of action status - * - * @param int $percent Percent - * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @param int $datestart Date start of event - * @return string Label - */ - public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of action status + * + * @param int $percent Percent + * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @param int $datestart Date start of event + * @return string Label + */ + public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') + { + // phpcs:enable + global $langs; - $labelStatus = $langs->trans('StatusNotApplicable'); - if ($percent == -1 && !$hidenastatus) $labelStatus = $langs->trans('StatusNotApplicable'); - elseif ($percent == 0) $labelStatus = $langs->trans('StatusActionToDo').' (0%)'; - elseif ($percent > 0 && $percent < 100) $labelStatus = $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; - elseif ($percent >= 100) $labelStatus = $langs->trans('StatusActionDone').' (100%)'; + $labelStatus = $langs->trans('StatusNotApplicable'); + if ($percent == -1 && !$hidenastatus) $labelStatus = $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) $labelStatus = $langs->trans('StatusActionToDo').' (0%)'; + elseif ($percent > 0 && $percent < 100) $labelStatus = $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + elseif ($percent >= 100) $labelStatus = $langs->trans('StatusActionDone').' (100%)'; - $labelStatusShort = $langs->trans('StatusNotApplicable'); - if ($percent == -1 && !$hidenastatus) $labelStatusShort = $langs->trans('NA'); - elseif ($percent == 0) $labelStatusShort = '0%'; - elseif ($percent > 0 && $percent < 100) $labelStatusShort = $percent.'%'; - elseif ($percent >= 100) $labelStatusShort = '100%'; + $labelStatusShort = $langs->trans('StatusNotApplicable'); + if ($percent == -1 && !$hidenastatus) $labelStatusShort = $langs->trans('NA'); + elseif ($percent == 0) $labelStatusShort = '0%'; + elseif ($percent > 0 && $percent < 100) $labelStatusShort = $percent.'%'; + elseif ($percent >= 100) $labelStatusShort = '100%'; - $statusType = 'status9'; - if ($percent == -1 && !$hidenastatus) $statusType = 'status9'; - if ($percent == 0) $statusType = 'status1'; - if ($percent > 0 && $percent < 100) $statusType = 'status3'; - if ($percent >= 100) $statusType = 'status6'; + $statusType = 'status9'; + if ($percent == -1 && !$hidenastatus) $statusType = 'status9'; + if ($percent == 0) $statusType = 'status1'; + if ($percent > 0 && $percent < 100) $statusType = 'status3'; + if ($percent >= 100) $statusType = 'status6'; - return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); - } + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); + } - /** - * Return URL of event - * Use $this->id, $this->type_code, $this->label and $this->type_label - * - * @param int $withpicto 0 = No picto, 1 = Include picto into link, 2 = Only picto - * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. - * @param string $classname Force style class on a link - * @param string $option '' = Link to action, 'birthday'= Link to contact, 'holiday' = Link to leave - * @param int $overwritepicto 1 = Overwrite picto - * @param int $notooltip 1 = Disable tooltip - * @param int $save_lastsearch_value -1 = Auto, 0 = No save of lastsearch_values when clicking, 1 = Save lastsearch_values whenclicking - * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) - { - global $conf, $langs, $user, $hookmanager, $action; + /** + * Return URL of event + * Use $this->id, $this->type_code, $this->label and $this->type_label + * + * @param int $withpicto 0 = No picto, 1 = Include picto into link, 2 = Only picto + * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. + * @param string $classname Force style class on a link + * @param string $option '' = Link to action, 'birthday'= Link to contact, 'holiday' = Link to leave + * @param int $overwritepicto 1 = Overwrite picto + * @param int $notooltip 1 = Disable tooltip + * @param int $save_lastsearch_value -1 = Auto, 0 = No save of lastsearch_values when clicking, 1 = Save lastsearch_values whenclicking + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) + { + global $conf, $langs, $user, $hookmanager, $action; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $canread = 0; if ($user->rights->agenda->myactions->read && $this->authorid == $user->id) $canread = 1; // Can read my event @@ -1371,10 +1371,10 @@ class ActionComm extends CommonObject if ($user->rights->agenda->allactions->read) $canread = 1; // Can read all event of other if (!$canread) { - $option = 'nolink'; + $option = 'nolink'; } - $label = $this->label; + $label = $this->label; if (empty($label)) $label = $this->libelle; // For backward compatibility $result = ''; @@ -1387,7 +1387,7 @@ class ActionComm extends CommonObject } if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); + if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } $tooltip = ''.$langs->trans('Action').''; @@ -1402,22 +1402,22 @@ class ActionComm extends CommonObject if (isset($this->transparency)) $tooltip .= '
'.$langs->trans('Busy').': '.yn($this->transparency); if (!empty($this->note_private)) - $tooltip .= '
'.$langs->trans('Note').': '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '
', $this->note_private)); + $tooltip .= '
'.$langs->trans('Note').': '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '
', $this->note_private)); $linkclose = ''; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowAction"); - $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; - $linkclose .= ' class="'.$classname.' classfortooltip"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowAction"); + $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; + $linkclose .= ' class="'.$classname.' classfortooltip"'; - /* + /* $hookmanager->initHooks(array('actiondao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -1429,7 +1429,7 @@ class ActionComm extends CommonObject if ($option == 'birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; elseif ($option == 'holiday') - $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; if ($option !== 'nolink') { @@ -1448,170 +1448,170 @@ class ActionComm extends CommonObject $linkend = ''; } - if ($withpicto == 2) - { - $libelle = $label; - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; - $libelleshort = ''; - } else { - $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; - if ($maxlength < 0) $libelleshort = $this->ref; - else $libelleshort = dol_trunc($libelle, $maxlength); - } + if ($withpicto == 2) + { + $libelle = $label; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; + $libelleshort = ''; + } else { + $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; + if ($maxlength < 0) $libelleshort = $this->ref; + else $libelleshort = dol_trunc($libelle, $maxlength); + } - if ($withpicto) - { - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () - { - if ($labeltype) - { - $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); - } - } - } + if ($withpicto) + { + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () + { + if ($labeltype) + { + $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); + } + } + } - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), ($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - $result .= $libelleshort; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), ($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= $libelleshort; + $result .= $linkend; - global $action; - $hookmanager->initHooks(array('actiondao')); - $parameters = array('id'=>$this->id, 'getnomurl'=>$result); - $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action; + $hookmanager->initHooks(array('actiondao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Sets object to supplied categories. - * - * Deletes object from existing categories not supplied. - * Adds it to non existing supplied categories. - * Existing categories are left untouch. - * - * @param int[]|int $categories Category or categories IDs - * @return void - */ - public function setCategories($categories) - { - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } + /** + * Sets object to supplied categories. + * + * Deletes object from existing categories not supplied. + * Adds it to non existing supplied categories. + * Existing categories are left untouch. + * + * @param int[]|int $categories Category or categories IDs + * @return void + */ + public function setCategories($categories) + { + // Handle single category + if (!is_array($categories)) { + $categories = array($categories); + } - // Get current categories - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, Categorie::TYPE_ACTIONCOMM, 'id'); + // Get current categories + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $c = new Categorie($this->db); + $existing = $c->containing($this->id, Categorie::TYPE_ACTIONCOMM, 'id'); - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $categories); + $to_add = array_diff($categories, $existing); + } else { + $to_del = array(); // Nothing to delete + $to_add = $categories; + } - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, Categorie::TYPE_ACTIONCOMM); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, Categorie::TYPE_ACTIONCOMM); - } - } - return; - } + // Process + foreach ($to_del as $del) { + if ($c->fetch($del) > 0) { + $c->del_type($this, Categorie::TYPE_ACTIONCOMM); + } + } + foreach ($to_add as $add) { + if ($c->fetch($add) > 0) { + $c->add_type($this, Categorie::TYPE_ACTIONCOMM); + } + } + return; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Export events from database into a cal file. - * - * @param string $format The format of the export 'vcal', 'ical/ics' or 'rss' - * @param string $type The type of the export 'event' or 'journal' - * @param integer $cachedelay Do not rebuild file if date older than cachedelay seconds - * @param string $filename The name for the exported file. - * @param array $filters Array of filters. Example array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...) - * @param integer $exportholiday 0 = don't integrate holidays into the export, 1 = integrate holidays into the export - * @return integer -1 = error on build export file, 0 = export okay - */ - public function build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday = 0) - { - global $hookmanager; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Export events from database into a cal file. + * + * @param string $format The format of the export 'vcal', 'ical/ics' or 'rss' + * @param string $type The type of the export 'event' or 'journal' + * @param integer $cachedelay Do not rebuild file if date older than cachedelay seconds + * @param string $filename The name for the exported file. + * @param array $filters Array of filters. Example array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...) + * @param integer $exportholiday 0 = don't integrate holidays into the export, 1 = integrate holidays into the export + * @return integer -1 = error on build export file, 0 = export okay + */ + public function build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday = 0) + { + global $hookmanager; - // phpcs:enable - global $conf, $langs, $dolibarr_main_url_root, $mysoc; + // phpcs:enable + global $conf, $langs, $dolibarr_main_url_root, $mysoc; - require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; - require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; - require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; - dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); + dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); - // Check parameters - if (empty($format)) return -1; + // Check parameters + if (empty($format)) return -1; - // Clean parameters - if (!$filename) - { - $extension = 'vcs'; - if ($format == 'ical') $extension = 'ics'; - $filename = $format.'.'.$extension; - } + // Clean parameters + if (!$filename) + { + $extension = 'vcs'; + if ($format == 'ical') $extension = 'ics'; + $filename = $format.'.'.$extension; + } - // Create dir and define output file (definitive and temporary) - $result = dol_mkdir($conf->agenda->dir_temp); - $outputfile = $conf->agenda->dir_temp.'/'.$filename; + // Create dir and define output file (definitive and temporary) + $result = dol_mkdir($conf->agenda->dir_temp); + $outputfile = $conf->agenda->dir_temp.'/'.$filename; - $result = 0; + $result = 0; - $buildfile = true; - $login = ''; $logina = ''; $logind = ''; $logint = ''; + $buildfile = true; + $login = ''; $logina = ''; $logind = ''; $logint = ''; - $now = dol_now(); + $now = dol_now(); - if ($cachedelay) - { - $nowgmt = dol_now(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) - { - dol_syslog(get_class($this)."::build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled"); - $buildfile = false; - } - } + if ($cachedelay) + { + $nowgmt = dol_now(); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) + { + dol_syslog(get_class($this)."::build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled"); + $buildfile = false; + } + } - if ($buildfile) - { - // Build event array - $eventarray = array(); + if ($buildfile) + { + // Build event array + $eventarray = array(); - $sql = "SELECT a.id,"; - $sql .= " a.datep,"; // Start - $sql .= " a.datep2,"; // End - $sql .= " a.durationp,"; // deprecated - $sql .= " a.datec, a.tms as datem,"; - $sql .= " a.label, a.code, a.note, a.fk_action as type_id,"; - $sql .= " a.fk_soc,"; - $sql .= " a.fk_user_author, a.fk_user_mod,"; - $sql .= " a.fk_user_action,"; - $sql .= " a.fk_contact, a.percent as percentage,"; - $sql .= " a.fk_element, a.elementtype,"; - $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; - $sql .= " u.firstname, u.lastname, u.email,"; - $sql .= " s.nom as socname,"; - $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label"; - $sql .= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + $sql = "SELECT a.id,"; + $sql .= " a.datep,"; // Start + $sql .= " a.datep2,"; // End + $sql .= " a.durationp,"; // deprecated + $sql .= " a.datec, a.tms as datem,"; + $sql .= " a.label, a.code, a.note, a.fk_action as type_id,"; + $sql .= " a.fk_soc,"; + $sql .= " a.fk_user_author, a.fk_user_mod,"; + $sql .= " a.fk_user_action,"; + $sql .= " a.fk_contact, a.percent as percentage,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; + $sql .= " u.firstname, u.lastname, u.email,"; + $sql .= " s.nom as socname,"; + $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label"; + $sql .= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; $parameters = array('filters' => $filters); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook @@ -1620,129 +1620,129 @@ class ActionComm extends CommonObject // We must filter on assignement table if ($filters['logint']) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql .= " WHERE a.fk_action=c.id"; - $sql .= " AND a.entity IN (".getEntity('agenda').")"; - foreach ($filters as $key => $value) - { - if ($key == 'notolderthan' && $value != '') $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; - if ($key == 'year') $sql .= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; - if ($key == 'id') $sql .= " AND a.id=".(is_numeric($value) ? $value : 0); - if ($key == 'idfrom') $sql .= " AND a.id >= ".(is_numeric($value) ? $value : 0); - if ($key == 'idto') $sql .= " AND a.id <= ".(is_numeric($value) ? $value : 0); - if ($key == 'project') $sql .= " AND a.fk_project=".(is_numeric($value) ? $value : 0); - if ($key == 'actiontype') $sql .= " AND c.type = '".$this->db->escape($value)."'"; - if ($key == 'notactiontype') $sql .= " AND c.type <> '".$this->db->escape($value)."'"; - // We must filter on assignement table + $sql .= " AND a.entity IN (".getEntity('agenda').")"; + foreach ($filters as $key => $value) + { + if ($key == 'notolderthan' && $value != '') $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; + if ($key == 'year') $sql .= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; + if ($key == 'id') $sql .= " AND a.id=".(is_numeric($value) ? $value : 0); + if ($key == 'idfrom') $sql .= " AND a.id >= ".(is_numeric($value) ? $value : 0); + if ($key == 'idto') $sql .= " AND a.id <= ".(is_numeric($value) ? $value : 0); + if ($key == 'project') $sql .= " AND a.fk_project=".(is_numeric($value) ? $value : 0); + if ($key == 'actiontype') $sql .= " AND c.type = '".$this->db->escape($value)."'"; + if ($key == 'notactiontype') $sql .= " AND c.type <> '".$this->db->escape($value)."'"; + // We must filter on assignement table if ($key == 'logint') $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; - if ($key == 'logina') - { - $logina = $value; - $condition = '='; - if (preg_match('/^!/', $logina)) - { - $logina = preg_replace('/^!/', '', $logina); - $condition = '<>'; - } - $userforfilter = new User($this->db); - $result = $userforfilter->fetch('', $logina); - if ($result > 0) $sql .= " AND a.fk_user_author ".$condition." ".$userforfilter->id; - elseif ($result < 0 || $condition == '=') $sql .= " AND a.fk_user_author = 0"; - } - if ($key == 'logint') - { - $logint = $value; - $condition = '='; - if (preg_match('/^!/', $logint)) - { - $logint = preg_replace('/^!/', '', $logint); - $condition = '<>'; - } - $userforfilter = new User($this->db); - $result = $userforfilter->fetch('', $logint); - if ($result > 0) $sql .= " AND ar.fk_element = ".$userforfilter->id; - elseif ($result < 0 || $condition == '=') $sql .= " AND ar.fk_element = 0"; - } - } + if ($key == 'logina') + { + $logina = $value; + $condition = '='; + if (preg_match('/^!/', $logina)) + { + $logina = preg_replace('/^!/', '', $logina); + $condition = '<>'; + } + $userforfilter = new User($this->db); + $result = $userforfilter->fetch('', $logina); + if ($result > 0) $sql .= " AND a.fk_user_author ".$condition." ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql .= " AND a.fk_user_author = 0"; + } + if ($key == 'logint') + { + $logint = $value; + $condition = '='; + if (preg_match('/^!/', $logint)) + { + $logint = preg_replace('/^!/', '', $logint); + $condition = '<>'; + } + $userforfilter = new User($this->db); + $result = $userforfilter->fetch('', $logint); + if ($result > 0) $sql .= " AND ar.fk_element = ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql .= " AND ar.fk_element = 0"; + } + } - $sql .= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import + $sql .= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import $parameters = array('filters' => $filters); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " ORDER by datep"; - //print $sql;exit; + $sql .= " ORDER by datep"; + //print $sql;exit; - dol_syslog(get_class($this)."::build_exportfile select events", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Note: Output of sql request is encoded in $conf->file->character_set_client - // This assignment in condition is not a bug. It allows walking the results. + dol_syslog(get_class($this)."::build_exportfile select events", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + // Note: Output of sql request is encoded in $conf->file->character_set_client + // This assignment in condition is not a bug. It allows walking the results. $diff = 0; - while ($obj = $this->db->fetch_object($resql)) - { - $qualified = true; + while ($obj = $this->db->fetch_object($resql)) + { + $qualified = true; - // 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author' - $event = array(); - $event['uid'] = 'dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; - $event['type'] = $type; - $datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + // 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author' + $event = array(); + $event['uid'] = 'dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; + $event['type'] = $type; + $datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - // fix for -> Warning: A non-numeric value encountered - if (is_numeric($this->db->jdate($obj->datep2))) - { - $dateend = $this->db->jdate($obj->datep2) - - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - } else { - // use start date as fall-back to avoid import erros on empty end date - $dateend = $datestart; - } + // fix for -> Warning: A non-numeric value encountered + if (is_numeric($this->db->jdate($obj->datep2))) + { + $dateend = $this->db->jdate($obj->datep2) + - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + } else { + // use start date as fall-back to avoid import erros on empty end date + $dateend = $datestart; + } - $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0; - $event['summary'] = $obj->label.($obj->socname ? " (".$obj->socname.")" : ""); - $event['desc'] = $obj->note; - $event['startdate'] = $datestart; - $event['enddate'] = $dateend; // Not required with type 'journal' - $event['duration'] = $duration; // Not required with type 'journal' - $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); - $event['priority'] = $obj->priority; - $event['fulldayevent'] = $obj->fulldayevent; - $event['location'] = $obj->location; - $event['transparency'] = (($obj->transparency > 0) ? 'OPAQUE' : 'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) - $event['category'] = $obj->type_label; - $event['email'] = $obj->email; + $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0; + $event['summary'] = $obj->label.($obj->socname ? " (".$obj->socname.")" : ""); + $event['desc'] = $obj->note; + $event['startdate'] = $datestart; + $event['enddate'] = $dateend; // Not required with type 'journal' + $event['duration'] = $duration; // Not required with type 'journal' + $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); + $event['priority'] = $obj->priority; + $event['fulldayevent'] = $obj->fulldayevent; + $event['location'] = $obj->location; + $event['transparency'] = (($obj->transparency > 0) ? 'OPAQUE' : 'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) + $event['category'] = $obj->type_label; + $event['email'] = $obj->email; // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $url = $urlwithroot.'/comm/action/card.php?id='.$obj->id; - $event['url'] = $url; - $event['created'] = $this->db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - $event['modified'] = $this->db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + $url = $urlwithroot.'/comm/action/card.php?id='.$obj->id; + $event['url'] = $url; + $event['created'] = $this->db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + $event['modified'] = $this->db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties - $this->id = $obj->id; - $this->fetch_userassigned(false); + // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties + $this->id = $obj->id; + $this->fetch_userassigned(false); - $assignedUserArray = array(); + $assignedUserArray = array(); - foreach ($this->userassigned as $key => $value) - { - $assignedUser = new User($this->db); - $assignedUser->fetch($value['id']); + foreach ($this->userassigned as $key => $value) + { + $assignedUser = new User($this->db); + $assignedUser->fetch($value['id']); - $assignedUserArray[$key] = $assignedUser; - } + $assignedUserArray[$key] = $assignedUser; + } - $event['assignedUsers'] = $assignedUserArray; + $event['assignedUsers'] = $assignedUserArray; - if ($qualified && $datestart) - { - $eventarray[] = $event; - } - $diff++; - } + if ($qualified && $datestart) + { + $eventarray[] = $event; + } + $diff++; + } $parameters = array('filters' => $filters, 'eventarray' => &$eventarray); $reshook = $hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook @@ -1750,175 +1750,175 @@ class ActionComm extends CommonObject { $eventarray = $hookmanager->resArray; } - } else { - $this->error = $this->db->lasterror(); - return -1; - } + } else { + $this->error = $this->db->lasterror(); + return -1; + } if ($exportholiday == 1) - { - $langs->load("holidays"); - $title = $langs->trans("Holidays"); + { + $langs->load("holidays"); + $title = $langs->trans("Holidays"); - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; - $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.rowid = x.fk_user"; - $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) - $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) + $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $event = array(); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $event = array(); - if ($obj->halfday == -1) - { - $event['fulldayevent'] = false; + if ($obj->halfday == -1) + { + $event['fulldayevent'] = false; - $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); - $timestampEnd = dol_stringtotime($obj->date_end." 12:00:00", 0); - } elseif ($obj->halfday == 1) - { - $event['fulldayevent'] = false; + $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); + $timestampEnd = dol_stringtotime($obj->date_end." 12:00:00", 0); + } elseif ($obj->halfday == 1) + { + $event['fulldayevent'] = false; - $timestampStart = dol_stringtotime($obj->date_start." 12:00:00", 0); - $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); - } else { - $event['fulldayevent'] = true; + $timestampStart = dol_stringtotime($obj->date_start." 12:00:00", 0); + $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); + } else { + $event['fulldayevent'] = true; - $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); - $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); - } + $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); + $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); + } - if (!empty($conf->global->AGENDA_EXPORT_FIX_TZ)) - { - $timestampStart = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); - $timestampEnd = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); - } + if (!empty($conf->global->AGENDA_EXPORT_FIX_TZ)) + { + $timestampStart = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); + $timestampEnd = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); + } - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; - $url = $urlwithroot.'/holiday/card.php?id='.$obj->rowid; + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; + $url = $urlwithroot.'/holiday/card.php?id='.$obj->rowid; - $event['uid'] = 'dolibarrholiday-'.$this->db->database_name.'-'.$obj->rowid."@".$_SERVER["SERVER_NAME"]; - $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); - $event['type'] = 'event'; - $event['category'] = "Holiday"; - $event['transparency'] = 'OPAQUE'; - $event['email'] = $obj->email; - $event['created'] = $timestampStart; - $event['modified'] = $timestampStart; - $event['startdate'] = $timestampStart; - $event['enddate'] = $timestampEnd; - $event['duration'] = $timestampEnd - $timestampStart; - $event['url'] = $url; + $event['uid'] = 'dolibarrholiday-'.$this->db->database_name.'-'.$obj->rowid."@".$_SERVER["SERVER_NAME"]; + $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); + $event['type'] = 'event'; + $event['category'] = "Holiday"; + $event['transparency'] = 'OPAQUE'; + $event['email'] = $obj->email; + $event['created'] = $timestampStart; + $event['modified'] = $timestampStart; + $event['startdate'] = $timestampStart; + $event['enddate'] = $timestampEnd; + $event['duration'] = $timestampEnd - $timestampStart; + $event['url'] = $url; - if ($obj->status == 2) - { - // 2 = leave wait for approval - $event['summary'] = $title." - ".$obj->lastname." (wait for approval)"; - } else { - // 3 = leave approved - $event['summary'] = $title." - ".$obj->lastname; - } + if ($obj->status == 2) + { + // 2 = leave wait for approval + $event['summary'] = $title." - ".$obj->lastname." (wait for approval)"; + } else { + // 3 = leave approved + $event['summary'] = $title." - ".$obj->lastname; + } - $eventarray[] = $event; + $eventarray[] = $event; - $i++; - } - } - } + $i++; + } + } + } - $langs->load("agenda"); + $langs->load("agenda"); - // Define title and desc - $more = ''; - if ($login) $more = $langs->transnoentities("User").' '.$login; - if ($logina) $more = $langs->transnoentities("ActionsAskedBy").' '.$logina; - if ($logint) $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; - if ($logind) $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; - if ($more) - { - $title = 'Dolibarr actions '.$mysoc->name.' - '.$more; - $desc = $more; - $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; - } else { - $title = 'Dolibarr actions '.$mysoc->name; - $desc = $langs->transnoentities('ListOfActions'); - $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; - } + // Define title and desc + $more = ''; + if ($login) $more = $langs->transnoentities("User").' '.$login; + if ($logina) $more = $langs->transnoentities("ActionsAskedBy").' '.$logina; + if ($logint) $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; + if ($logind) $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; + if ($more) + { + $title = 'Dolibarr actions '.$mysoc->name.' - '.$more; + $desc = $more; + $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; + } else { + $title = 'Dolibarr actions '.$mysoc->name; + $desc = $langs->transnoentities('ListOfActions'); + $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; + } - // Create temp file - $outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + // Create temp file + $outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp'); // Temporary file (allow call of function by different threads + @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); - // Write file - if ($format == 'vcal') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); - elseif ($format == 'ical') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); - elseif ($format == 'rss') $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); + // Write file + if ($format == 'vcal') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); + elseif ($format == 'ical') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); + elseif ($format == 'rss') $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); - if ($result >= 0) - { - if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; - else { - $this->error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile; - dol_syslog(get_class($this)."::build_exportfile ".$this->error, LOG_ERR); - dol_delete_file($outputfiletmp, 0, 1); - $result = -1; - } - } else { - dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); - dol_delete_file($outputfiletmp, 0, 1); - $langs->load("errors"); - $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile); - } - } + if ($result >= 0) + { + if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; + else { + $this->error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile; + dol_syslog(get_class($this)."::build_exportfile ".$this->error, LOG_ERR); + dol_delete_file($outputfiletmp, 0, 1); + $result = -1; + } + } else { + dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); + dol_delete_file($outputfiletmp, 0, 1); + $langs->load("errors"); + $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile); + } + } - return $result; - } + return $result; + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return int >0 if ok - */ - public function initAsSpecimen() - { - global $user; + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return int >0 if ok + */ + public function initAsSpecimen() + { + global $user; - $now = dol_now(); + $now = dol_now(); - // Initialise parametres - $this->id = 0; - $this->specimen = 1; + // Initialise parametres + $this->id = 0; + $this->specimen = 1; - $this->type_code = 'AC_OTH'; - $this->code = 'AC_SPECIMEN_CODE'; - $this->label = 'Label of event Specimen'; - $this->datec = $now; - $this->datem = $now; - $this->datep = $now; - $this->datef = $now; - $this->fulldayevent = 0; - $this->percentage = 0; - $this->location = 'Location'; - $this->transparency = 1; // 1 means opaque - $this->priority = 1; - //$this->note_public = "This is a 'public' note."; + $this->type_code = 'AC_OTH'; + $this->code = 'AC_SPECIMEN_CODE'; + $this->label = 'Label of event Specimen'; + $this->datec = $now; + $this->datem = $now; + $this->datep = $now; + $this->datef = $now; + $this->fulldayevent = 0; + $this->percentage = 0; + $this->location = 'Location'; + $this->transparency = 1; // 1 means opaque + $this->priority = 1; + //$this->note_public = "This is a 'public' note."; $this->note_private = "This is a 'private' note."; - $this->userownerid = $user->id; - $this->userassigned[$user->id] = array('id'=>$user->id, 'transparency'=> 1); - return 1; - } + $this->userownerid = $user->id; + $this->userassigned[$user->id] = array('id'=>$user->id, 'transparency'=> 1); + return 1; + } /** * Function used to replace a thirdparty id with another one. diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 2d327cfc409..16384edfcde 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -50,6 +50,9 @@ class ActionCommReminder extends CommonObject */ public $picto = 'generic'; + const STATUS_TODO = 0; + const STATUS_DONE = 1; + /** * 'type' if the field format. @@ -79,7 +82,7 @@ class ActionCommReminder extends CommonObject 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), - 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"m, h, d, w",), + 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"y, m, d, w, h, i",), 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), 'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1, 'index'=>1,), 'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>0), @@ -121,9 +124,6 @@ class ActionCommReminder extends CommonObject */ public $fk_email_template; - const STATUS_TODO = 0; - const STATUS_DONE = 1; - // END MODULEBUILDER PROPERTIES diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index ce3a9f26509..64c24c9c8e8 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -76,7 +76,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } $action = GETPOST('action', 'alpha'); @@ -91,19 +91,19 @@ $type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST $maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); if ($dateselect > 0) { - $day=GETPOST('dateselectday', 'int'); - $month=GETPOST('dateselectmonth', 'int'); - $year=GETPOST('dateselectyear', 'int'); + $day = GETPOST('dateselectday', 'int'); + $month = GETPOST('dateselectmonth', 'int'); + $year = GETPOST('dateselectyear', 'int'); } // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } @@ -119,13 +119,13 @@ if ($action == 'default') // When action is default, we want a calendar view and $action = (($defaultview != 'show_list') ? $defaultview : 'show_month'); } if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day // Load translation files required by the page @@ -141,46 +141,46 @@ $hookmanager->initHooks(array('agenda')); if (GETPOST("viewlist", 'alpha') || $action == 'show_list') { - $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - if ($key == 'token') continue; - $param .= '&'.$key.'='.urlencode($val); - } - } - if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list'; - //print $param; - header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); - exit; + $param = ''; + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); + } + } + if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list'; + //print $param; + header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); + exit; } if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') { - $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - if ($key == 'token') continue; - $param .= '&'.$key.'='.urlencode($val); - } - } - //print $param; - header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); - exit; + $param = ''; + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); + } + } + //print $param; + header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); + exit; } if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -226,21 +226,21 @@ $listofextcals = array(); // Define list of external calendars (global admin setup) if (empty($conf->global->AGENDA_DISABLE_EXT)) { - $i = 0; - while ($i < $MAXAGENDA) - { - $i++; - $source = 'AGENDA_EXT_SRC'.$i; - $name = 'AGENDA_EXT_NAME'.$i; - $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; - $color = 'AGENDA_EXT_COLOR'.$i; - $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; - if (!empty($conf->global->$source) && !empty($conf->global->$name)) - { - // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' - $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); - } - } + $i = 0; + while ($i < $MAXAGENDA) + { + $i++; + $source = 'AGENDA_EXT_SRC'.$i; + $name = 'AGENDA_EXT_NAME'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; + $color = 'AGENDA_EXT_COLOR'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; + if (!empty($conf->global->$source) && !empty($conf->global->$name)) + { + // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' + $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); + } + } } // Define list of external calendars (user setup) if (empty($user->conf->AGENDA_DISABLE_EXT)) @@ -251,7 +251,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) $i++; $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i; $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i; - $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; @@ -265,65 +265,65 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) if (empty($action) || $action == 'show_month') { - $prev = dol_get_prev_month($month, $year); - $prev_year = $prev['year']; - $prev_month = $prev['month']; - $next = dol_get_next_month($month, $year); - $next_year = $next['year']; - $next_month = $next['month']; + $prev = dol_get_prev_month($month, $year); + $prev_year = $prev['year']; + $prev_month = $prev['month']; + $next = dol_get_next_month($month, $year); + $next_year = $next['year']; + $next_month = $next['month']; - $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month - // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) - $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday - $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); - if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); - $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; - if ($next_day < 6) $next_day += 7; - $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month + // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) + $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday + $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); + if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); + $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; + if ($next_day < 6) $next_day += 7; + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } if ($action == 'show_week') { - $prev = dol_get_first_day_week($day, $month, $year); - $prev_year = $prev['prev_year']; - $prev_month = $prev['prev_month']; - $prev_day = $prev['prev_day']; - $first_day = $prev['first_day']; - $first_month = $prev['first_month']; - $first_year = $prev['first_year']; + $prev = dol_get_first_day_week($day, $month, $year); + $prev_year = $prev['prev_year']; + $prev_month = $prev['prev_month']; + $prev_day = $prev['prev_day']; + $first_day = $prev['first_day']; + $first_month = $prev['first_month']; + $first_year = $prev['first_year']; - $week = $prev['week']; + $week = $prev['week']; - $day = (int) $day; - $next = dol_get_next_week($first_day, $week, $first_month, $first_year); - $next_year = $next['year']; - $next_month = $next['month']; - $next_day = $next['day']; + $day = (int) $day; + $next = dol_get_next_week($first_day, $week, $first_month, $first_year); + $next_year = $next['year']; + $next_month = $next['month']; + $next_day = $next['day']; - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); - $tmpday = $first_day; + $tmpday = $first_day; } if ($action == 'show_day') { - $prev = dol_get_prev_day($day, $month, $year); - $prev_year = $prev['year']; - $prev_month = $prev['month']; - $prev_day = $prev['day']; - $next = dol_get_next_day($day, $month, $year); - $next_year = $next['year']; - $next_month = $next['month']; - $next_day = $next['day']; + $prev = dol_get_prev_day($day, $month, $year); + $prev_year = $prev['year']; + $prev_month = $prev['month']; + $prev_day = $prev['day']; + $next = dol_get_next_day($day, $month, $year); + $next_year = $next['year']; + $next_month = $next['month']; + $next_day = $next['day']; - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); - $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; @@ -356,30 +356,30 @@ $param .= "&maxprint=".urlencode($maxprint); // Show navigation bar if (empty($action) || $action == 'show_month') { - $nav = "  \n"; - $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); - $nav .= " \n"; - $nav .= "   \n"; - $nav .= "   ".$langs->trans("Today")." "; - $picto = 'calendar'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   ".$langs->trans("Today")." "; + $picto = 'calendar'; } if ($action == 'show_week') { - $nav = "trans("Previous"))."\">  \n"; - $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; - $nav .= " \n"; - $nav .= "   trans("Next"))."\">\n"; - $nav .= "   ".$langs->trans("Today")." "; - $picto = 'calendarweek'; + $nav = "trans("Previous"))."\">  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; + $nav .= " \n"; + $nav .= "   trans("Next"))."\">\n"; + $nav .= "   ".$langs->trans("Today")." "; + $picto = 'calendarweek'; } if ($action == 'show_day') { - $nav = "  \n"; - $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); - $nav .= " \n"; - $nav .= "   \n"; - $nav .= "   ".$langs->trans("Today")." "; - $picto = 'calendarday'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   ".$langs->trans("Today")." "; + $picto = 'calendarday'; } $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); @@ -471,21 +471,21 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - // Code to enable drag and drop + // Code to enable drag and drop $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n"; - // Code to submit form + // Code to submit form $s .= 'console.log("submit form to record new event");'."\n"; - //$s.='console.log(event.target);'; + //$s.='console.log(event.target);'; $s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n"; $s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n"; $s .= 'var frm=jQuery("#searchFormList");'."\n"; $s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n"; $s .= 'console.log(newurl);'."\n"; $s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n"; - $s .= '});'."\n"; - } - $s .= '});'."\n"; - $s .= ''."\n"; + $s .= '});'."\n"; + } + $s .= '});'."\n"; + $s .= ''."\n"; // Local calendar $s .= '
'.$langs->trans("LocalAgenda").'  
'; @@ -513,26 +513,26 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on $s .= '
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } else // If javascript off { $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); - if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; - $link = ''; - if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); - else $link .= $langs->trans("AgendaHideBirthdayEvents"); - $link .= ''; + $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); + if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; + $link = ''; + if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); + else $link .= $langs->trans("AgendaHideBirthdayEvents"); + $link .= ''; } // Load events from database into $eventarray @@ -561,26 +561,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -590,28 +590,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -622,10 +622,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY datep'; @@ -1090,8 +1090,8 @@ if (count($listofextcals)) // Transparency (see https://www.kanzaki.com/docs/ical/transp.html) if ($icalevent['TRANSP']) { - if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free - if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy + if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free + if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy // TODO: MS outlook states // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free @@ -1156,12 +1156,12 @@ if (count($listofextcals)) $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); if (!empty($hookmanager->resArray['eventarray'])) { - foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { - if (!isset($eventarray[$keyDate])) { - $eventarray[$keyDate] = array(); - } - $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); - } + foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { + if (!isset($eventarray[$keyDate])) { + $eventarray[$keyDate] = array(); + } + $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); + } } // Sort events @@ -1180,7 +1180,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $color_file; + include_once $color_file; } if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); @@ -1207,7 +1207,7 @@ if (empty($action) || $action == 'show_month') // View by month print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print ''; - print '
'; + print '
'; print ''; print ' '; // Column title of weeks numbers @@ -1215,7 +1215,7 @@ if (empty($action) || $action == 'show_month') // View by month $i = 0; while ($i < 7) { - print '
'; + print ' '; $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); if (!empty($conf->dol_optimize_smallscreen)) { @@ -1308,12 +1308,12 @@ if (empty($action) || $action == 'show_month') // View by month print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print ''; - print '
'; + print '
'; print ''; print ' '; $i = 0; while ($i < 7) { - echo ' \n"; + echo ' \n"; $i++; } echo " \n"; @@ -1368,11 +1368,10 @@ if (empty($action) || $action == 'show_month') // View by month print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print ''; - print '
'; + print '
'; echo '
'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
'; echo ' '; - echo ' '; echo ' \n"; echo " \n"; @@ -1385,39 +1384,39 @@ if (empty($action) || $action == 'show_month') // View by month echo " \n"; */ - echo '
'.$langs->trans("Day".$arraytimestamp['wday'])."
'; + echo '
'; print '
'; - /* WIP View per hour */ - $useviewhour = 0; - if ($useviewhour) - { - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + /* WIP View per hour */ + $useviewhour = 0; + if ($useviewhour) + { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file + $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file - echo '
'; + echo '
'; echo '
'; - $maxnbofchar = 80; + $maxnbofchar = 80; - $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); - $minhour = round($tmp[0], 0); - $maxhour = round($tmp[1], 0); - if ($minhour > 23) $minhour = 23; - if ($maxhour < 1) $maxhour = 1; - if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } + $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); + $minhour = round($tmp[0], 0); + $maxhour = round($tmp[1], 0); + if ($minhour > 23) $minhour = 23; + if ($maxhour < 1) $maxhour = 1; + if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } - $i = 0; - $j = 0; + $i = 0; + $j = 0; while ($i < 24) { - echo '
'."\n"; - echo '
'.dol_print_date($i * 3600, 'hour', 'gmt').'
'; - echo '
'."\n"; - echo '
'."\n"; - $i++; - $j++; + echo '
'."\n"; + echo '
'.dol_print_date($i * 3600, 'hour', 'gmt').'
'; + echo '
'."\n"; + echo '
'."\n"; + $i++; + $j++; } echo '
'; @@ -1425,13 +1424,13 @@ if (empty($action) || $action == 'show_month') // View by month show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); print '
'; - } else { - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + } else { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); - print '
'; - } + print '
'; + } } print "\n".''; @@ -1872,11 +1871,11 @@ function dol_color_minus($color, $minus, $minusunit = 16) $newcolor = $color; if ($minusunit == 16) { - $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); - $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); - $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); + $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); + $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); + $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); } else { - // Not yet implemented + // Not yet implemented } return $newcolor; } @@ -1891,39 +1890,39 @@ function dol_color_minus($color, $minus, $minusunit = 16) function sort_events_by_date($a, $b) { // Sort holidays at first - if ($a->type_code === 'HOLIDAY') - { - return -1; - } + if ($a->type_code === 'HOLIDAY') + { + return -1; + } - if ($b->type_code === 'HOLIDAY') - { - return 1; - } + if ($b->type_code === 'HOLIDAY') + { + return 1; + } - // datep => Event start time - // datef => Event end time + // datep => Event start time + // datef => Event end time - // Events have different start time - if ($a->datep !== $b->datep) - { - return $a->datep - $b->datep; - } + // Events have different start time + if ($a->datep !== $b->datep) + { + return $a->datep - $b->datep; + } - // Events have same start time and no end time - if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) - { - return sort_events_by_percentage($a, $b); - } + // Events have same start time and no end time + if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) + { + return sort_events_by_percentage($a, $b); + } - // Events have the same start time and same end time - if ($b->datef === $a->datef) - { - return sort_events_by_percentage($a, $b); - } + // Events have the same start time and same end time + if ($b->datef === $a->datef) + { + return sort_events_by_percentage($a, $b); + } - // Events have the same start time, but have different end time -> longest event first - return $b->datef - $a->datef; + // Events have the same start time, but have different end time -> longest event first + return $b->datef - $a->datef; } /** @@ -1935,18 +1934,18 @@ function sort_events_by_date($a, $b) */ function sort_events_by_percentage($a, $b) { - // Sort events with no percentage before each other - // (usefull to sort holidays, sick days or similar on the top) + // Sort events with no percentage before each other + // (usefull to sort holidays, sick days or similar on the top) - if ($a->percentage < 0) - { - return -1; - } + if ($a->percentage < 0) + { + return -1; + } - if ($b->percentage < 0) - { - return 1; - } + if ($b->percentage < 0) + { + return 1; + } - return $b->percentage - $a->percentage; + return $b->percentage - $a->percentage; } diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 31274bee5fd..20ba2928de1 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -160,7 +160,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST('cancel', 'alpha')) { - $action='list'; $massaction=''; + $action = 'list'; $massaction = ''; } if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) @@ -708,7 +708,7 @@ if ($resql) $labeltype = $langs->trans("Message"); } else { if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; - if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code + if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code } print dol_trunc($labeltype, 28); print ''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index ea81c4e35b9..ccccc93da4f 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -211,7 +211,6 @@ if (empty($reshook)) $substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER5__'] = $other5; $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) - $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility $substitutionarray['__CHECK_READ__'] = ''; $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 619203c4dca..db59fd5f942 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -472,6 +472,8 @@ if ($resql) 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), + 'prevalidate'=>$langs->trans("Validate"), + 'presign'=>$langs->trans("Sign"), ); if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close"); @@ -502,6 +504,16 @@ if ($resql) $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + if ($massaction == 'prevalidate') + { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + } + + if ($massaction == 'presign') + { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1); + } + if ($sall) { foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -1270,10 +1282,72 @@ if ($resql) $delallowed = $user->rights->propal->creer; print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + + if ($action == 'validate') { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 0) { + if ($tmpproposal->valid($user)){ + setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors'); + $error++; + } + } + dol_print_error($db); + $error++; + } + if ($error){ + $db->rollback(); + } else { + $db->commit(); + } + } + } + + if ($action == "sign") { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 1) { + $tmpproposal->statut = 2; + if ($tmpproposal->update($user)) { + setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs'); + } else { + dol_print_error($db); + $error++; + } + } else { + setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors'); + $error++; + } + } else { + dol_print_error($db); + $error++; + } + } + if ($error){ + $db->rollback(); + } else { + $db->commit(); + } + } + } } else { - dol_print_error($db); + dol_print_error($db); } -// End of page -llxFooter(); -$db->close(); + // End of page + llxFooter(); + $db->close(); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index cc7db3db852..e4d432b234a 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -348,7 +348,8 @@ class Orders extends DolibarrApi $request_data->fk_unit, $request_data->origin, $request_data->origin_id, - $request_data->multicurrency_subprice + $request_data->multicurrency_subprice, + $request_data->ref_ext ); if ($updateRes > 0) { @@ -406,7 +407,9 @@ class Orders extends DolibarrApi $request_data->special_code, $request_data->array_options, $request_data->fk_unit, - $request_data->multicurrency_subprice + $request_data->multicurrency_subprice, + 0, + $request_data->ref_ext ); if ($updateRes > 0) { @@ -456,6 +459,40 @@ class Orders extends DolibarrApi } } + /** + * Get contacts of given order + * + * Return an array with contact informations + * + * @param int $id ID of order + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * + * @url GET {id}/contacts + * + * @return array data without useless information + * + * @throws RestException + */ + public function getContacts($id, $type = '') + { + if (! DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } + + $result = $this->commande->fetch($id); + if ( ! $result ) { + throw new RestException(404, 'Order not found'); + } + + if ( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $contacts = $this->commande->liste_contact(-1, 'external', 0, $type); + + return $this->_cleanObjectDatas($contacts); + } + /** * Add a contact type of given order * @@ -487,15 +524,24 @@ class Orders extends DolibarrApi $result = $this->commande->add_contact($contactid, $type, 'external'); - if (!$result) { + if ($result < 0) { throw new RestException(500, 'Error when added the contact'); } - return $this->commande; + if ($result == 0) { + throw new RestException(304, 'contact already added'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the order' + ) + ); } /** - * Delete a contact type of given order + * Unlink a contact type of given order * * @param int $id Id of order to update * @param int $rowid Row key of the contact in the array contact_ids. @@ -510,26 +556,31 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $rowid) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (!$result) { + if (! $result) { throw new RestException(404, 'Order not found'); } - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->commande->delete_contact($rowid); + $result = $this->commande->delete_linked_contact($rowid); if (!$result) { throw new RestException(500, 'Error when deleted the contact'); } - return $this->commande; + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact unlinked from order' + ) + ); } /** diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 77ba4456c1c..73dd2cee9fb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1004,6 +1004,11 @@ class Commande extends CommonOrder $origintype = $this->element; } + // ref_ext + if (empty($line->ref_ext)) { + $line->ref_ext = ''; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -1029,7 +1034,9 @@ class Commande extends CommonOrder $line->array_options, $line->fk_unit, $origintype, - $originid + $originid, + 0, + $line->ref_ext ); if ($result < 0) { @@ -1215,6 +1222,13 @@ class Commande extends CommonOrder $this->date_validation = ''; if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = ''; + // Do not clone ref_ext + $num = count($this->lines); + for ($i = 0; $i < $num; $i++) + { + $this->lines[$i]->ref_ext = ''; + } + // Create clone $this->context['createfromclone'] = 'createfromclone'; $result = $this->create($user); @@ -1423,6 +1437,7 @@ class Commande extends CommonOrder * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param double $pu_ht_devise Unit price in currency + * @param string $ref_ext line external reference * @return int >0 if OK, <0 if KO * * @see add_product() @@ -1432,13 +1447,13 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $ref_ext = '') { global $mysoc, $conf, $langs, $user; $logtext = "::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent"; $logtext .= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start"; - $logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise"; + $logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise, ref_ext=$ref_ext"; dol_syslog(get_class($this).$logtext, LOG_DEBUG); if ($this->statut == self::STATUS_DRAFT) @@ -1446,6 +1461,7 @@ class Commande extends CommonOrder include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters + if (empty($remise_percent)) $remise_percent = 0; if (empty($qty)) $qty = 0; if (empty($info_bits)) $info_bits = 0; @@ -1455,6 +1471,7 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2 = 0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($this->fk_multicurrency)) $this->fk_multicurrency = 0; + if (empty($ref_ext)) $ref_ext = ''; $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -1570,6 +1587,7 @@ class Commande extends CommonOrder $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; + $this->line->ref_ext = $ref_ext; $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -1977,7 +1995,7 @@ class Commande extends CommonOrder // phpcs:enable $this->lines = array(); - $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,'; + $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,'; $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,'; $sql .= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,'; $sql .= ' l.fk_unit,'; @@ -2012,6 +2030,7 @@ class Commande extends CommonOrder $line->description = $objp->description; // Description line $line->product_type = $objp->product_type; $line->qty = $objp->qty; + $line->ref_ext = $objp->ref_ext; $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; @@ -2981,13 +3000,14 @@ class Commande extends CommonOrder * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Amount in currency * @param int $notrigger disable line update trigger + * @param string $ref_ext external reference * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') { global $conf, $mysoc, $langs, $user; - dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code"); + dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code, ref_ext=$ref_ext"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; if ($this->statut == Commande::STATUS_DRAFT) @@ -3000,6 +3020,7 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2 = 0; if (empty($remise_percent)) $remise_percent = 0; if (empty($special_code) || $special_code == 3) $special_code = 0; + if (empty($ref_ext)) $ref_ext = ''; if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); @@ -3104,6 +3125,7 @@ class Commande extends CommonOrder $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; + $this->line->ref_ext = $ref_ext; $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -3970,6 +3992,8 @@ class OrderLine extends CommonOrderLine */ public $label; + public $ref_ext; + public $fk_remise_except; public $rang = 0; public $fk_fournprice; @@ -4014,7 +4038,7 @@ class OrderLine extends CommonOrderLine public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,'; - $sql .= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; + $sql .= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice, cd.ref_ext,'; $sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,'; $sql .= ' cd.fk_unit,'; $sql .= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,'; @@ -4036,6 +4060,7 @@ class OrderLine extends CommonOrderLine $this->qty = $objp->qty; $this->price = $objp->price; $this->subprice = $objp->subprice; + $this->ref_ext = $objp->ref_ext; $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -4205,6 +4230,7 @@ class OrderLine extends CommonOrderLine if (empty($this->special_code)) $this->special_code = 0; if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->ref_ext)) $this->ref_ext = ''; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4224,7 +4250,7 @@ class OrderLine extends CommonOrderLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; - $sql .= ' (fk_commande, fk_parent_line, label, description, qty, '; + $sql .= ' (fk_commande, fk_parent_line, label, description, qty, ref_ext,'; $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql .= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,'; $sql .= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,'; @@ -4237,6 +4263,7 @@ class OrderLine extends CommonOrderLine $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " '".$this->db->escape($this->desc)."',"; $sql .= " '".price2num($this->qty)."',"; + $sql .= " '".$this->db->escape($this->ref_ext)."',"; $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; $sql .= " '".price2num($this->tva_tx)."',"; $sql .= " '".price2num($this->localtax1_tx)."',"; @@ -4347,6 +4374,7 @@ class OrderLine extends CommonOrderLine if (empty($this->product_type)) $this->product_type = 0; if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->ref_ext)) $this->ref_ext = ''; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4372,6 +4400,7 @@ class OrderLine extends CommonOrderLine $sql .= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= " , qty=".price2num($this->qty); + $sql .= " , ref_ext='".$this->db->escape($this->ref_ext)."'"; $sql .= " , subprice=".price2num($this->subprice).""; $sql .= " , remise_percent=".price2num($this->remise_percent).""; $sql .= " , price=".price2num($this->price).""; // TODO A virer diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e40c614ea08..20f705a8ed9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -818,6 +818,11 @@ class Facture extends CommonInvoice $origintype = $this->element; } + // init ref_ext + if (empty($line->ref_ext)) { + $line->ref_ext = ''; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -847,7 +852,8 @@ class Facture extends CommonInvoice $line->situation_percent, $line->fk_prev_id, $line->fk_unit, - $line->pu_ht_devise + $line->pu_ht_devise, + $line->ref_ext ); if ($result < 0) { @@ -1073,6 +1079,7 @@ class Facture extends CommonInvoice $facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1; $facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2; $facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc; + $facture->lines[$i]->ref_ext = ''; } } @@ -1190,6 +1197,8 @@ class Facture extends CommonInvoice $object->lines[$i]->date_end = $newLast; } } + + $object->lines[$i]->ref_ext = ''; // Do not clone ref_ext } // Create clone @@ -1658,7 +1667,7 @@ class Facture extends CommonInvoice $this->lines = array(); $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice, l.ref_ext,'; $sql .= ' l.situation_percent, l.fk_prev_id,'; $sql .= ' l.rang, l.special_code,'; $sql .= ' l.date_start as date_start, l.date_end as date_end,'; @@ -1697,6 +1706,7 @@ class Facture extends CommonInvoice $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; + $line->ref_ext = $objp->ref_ext; // line external ref $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; @@ -1819,6 +1829,7 @@ class Facture extends CommonInvoice // Clean parameters if (empty($this->type)) $this->type = self::TYPE_STANDARD; if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->ref_ext)) $this->ref_ext = trim($this->ref_ext); if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); if (isset($this->increment)) $this->increment = trim($this->increment); if (isset($this->close_code)) $this->close_code = trim($this->close_code); @@ -1837,6 +1848,7 @@ class Facture extends CommonInvoice // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; $sql .= " type=".(isset($this->type) ? $this->db->escape($this->type) : "null").","; $sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").","; $sql .= " increment=".(isset($this->increment) ? "'".$this->db->escape($this->increment)."'" : "null").","; @@ -2930,6 +2942,7 @@ class Facture extends CommonInvoice * @param int $fk_prev_id Previous situation line id reference * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency + * @param string $ref_ext External reference of the line * @return int <0 if KO, Id of line if OK */ public function addline( @@ -2961,7 +2974,8 @@ class Facture extends CommonInvoice $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, - $pu_ht_devise = 0 + $pu_ht_devise = 0, + $ref_ext = '' ) { // Deprecation warning if ($label) { @@ -2989,6 +3003,7 @@ class Facture extends CommonInvoice if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($fk_prev_id)) $fk_prev_id = 'null'; if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (empty($ref_ext)) $ref_ext = ''; $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -3082,6 +3097,7 @@ class Facture extends CommonInvoice $this->line->fk_facture = $this->id; $this->line->label = $label; // deprecated $this->line->desc = $desc; + $this->line->ref_ext = $ref_ext; $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise @@ -3157,7 +3173,7 @@ class Facture extends CommonInvoice return -2; } } else { - dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); + dol_syslog(get_class($this)."::addline status of invoice must be Draft to allow use of ->addline()", LOG_ERR); return -3; } } @@ -3189,9 +3205,10 @@ class Facture extends CommonInvoice * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger + * @param string $ref_ext External reference of the line * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') { global $conf, $user; // Deprecation warning @@ -3229,6 +3246,7 @@ class Facture extends CommonInvoice if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($special_code) || $special_code == 3) $special_code = 0; if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (empty($ref_ext)) $ref_ext = ''; $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -3319,6 +3337,7 @@ class Facture extends CommonInvoice $this->line->rowid = $rowid; $this->line->label = $label; $this->line->desc = $desc; + $this->line->ref_ext = $ref_ext; $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative $this->line->vat_src_code = $vat_src_code; @@ -4722,6 +4741,7 @@ class FactureLigne extends CommonInvoiceLine public $label; //! Description ligne public $desc; + public $ref_ext; // External reference of the line public $localtax1_type; // Local tax 1 type public $localtax2_type; // Local tax 2 type @@ -4792,7 +4812,7 @@ class FactureLigne extends CommonInvoiceLine public function fetch($rowid) { $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; - $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; + $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice, fd.ref_ext,'; $sql .= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; $sql .= ' fd.fk_code_ventilation,'; @@ -4820,6 +4840,7 @@ class FactureLigne extends CommonInvoiceLine $this->desc = $objp->description; $this->qty = $objp->qty; $this->subprice = $objp->subprice; + $this->ref_ext = $objp->ref_ext; $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -4902,6 +4923,7 @@ class FactureLigne extends CommonInvoiceLine if (empty($this->remise_percent)) $this->remise_percent = 0; if (empty($this->info_bits)) $this->info_bits = 0; if (empty($this->subprice)) $this->subprice = 0; + if (empty($this->ref_ext)) $this->ref_ext = ''; if (empty($this->special_code)) $this->special_code = 0; if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->fk_prev_id)) $this->fk_prev_id = 0; @@ -4948,7 +4970,7 @@ class FactureLigne extends CommonInvoiceLine $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; $sql .= ' (fk_facture, fk_parent_line, label, description, qty,'; $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, ref_ext, fk_remise_except,'; $sql .= ' date_start, date_end, fk_code_ventilation, '; $sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; $sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; @@ -4971,6 +4993,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= " ".((int) $this->product_type).","; $sql .= " ".price2num($this->remise_percent).","; $sql .= " ".price2num($this->subprice).","; + $sql .= " '".$this->db->escape($this->ref_ext)."',"; $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").","; $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").","; @@ -5097,6 +5120,7 @@ class FactureLigne extends CommonInvoiceLine // Clean parameters $this->desc = trim($this->desc); + if (empty($this->ref_ext)) $this->ref_ext = ''; if (empty($this->tva_tx)) $this->tva_tx = 0; if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; @@ -5136,6 +5160,7 @@ class FactureLigne extends CommonInvoiceLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= " ref_ext='".$this->db->escape($this->ref_ext)."'"; $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", subprice=".price2num($this->subprice).""; $sql .= ", remise_percent=".price2num($this->remise_percent).""; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index a313f47cc13..eb11950304f 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -159,8 +159,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; - $sql.= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; + $sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; // Add Group from hooks $parameters = array(); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 4ec2b5d3443..6349660c59c 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -81,38 +81,38 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($action == 'confirm_delete') - { - $res = $object->delete($user); - if ($res > 0) - { - if ($object->type == 'bank-transfer') { - header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php'); - } else { - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php'); - } - exit; - } - } + if ($action == 'confirm_delete') + { + $res = $object->delete($user); + if ($res > 0) + { + if ($object->type == 'bank-transfer') { + header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php'); + } else { + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php'); + } + exit; + } + } - // Seems to no be used and replaced with $action == 'infocredit' - if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') - { - $res = $object->set_credite(); - if ($res >= 0) - { - header("Location: card.php?id=".$id); - exit; - } - } + // Seems to no be used and replaced with $action == 'infocredit' + if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') + { + $res = $object->set_credite(); + if ($res >= 0) + { + header("Location: card.php?id=".$id); + exit; + } + } - if ($action == 'infotrans' && $user->rights->prelevement->bons->send) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + if ($action == 'infotrans' && $user->rights->prelevement->bons->send) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - /* + /* if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref) { $dir = $conf->prelevement->dir_output.'/receipts'; @@ -133,24 +133,24 @@ if (empty($reshook)) $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha')); - if ($error) - { - header("Location: card.php?id=".$id."&error=$error"); - exit; - } - } + if ($error) + { + header("Location: card.php?id=".$id."&error=$error"); + exit; + } + } // Set direct debit order to credited, create payment and close invoices if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) { $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $error = $object->set_infocredit($user, $dt); - if ($error) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $error = $object->set_infocredit($user, $dt); + if ($error) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 1bea234abfc..567a1ab8951 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -318,7 +318,7 @@ class BonPrelevement extends CommonObject $this->type = $obj->type; $this->status = $obj->status; - $this->statut = $obj->status; // For backward compatibility + $this->statut = $obj->status; // For backward compatibility $this->fetched = 1; @@ -510,7 +510,7 @@ class BonPrelevement extends CommonObject $paiement->num_paiement = $this->ref; // For backward compatibility $paiement->id_prelevement = $this->id; - $paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode + $paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode if ($paiement_id < 0) { $error++; @@ -540,7 +540,7 @@ class BonPrelevement extends CommonObject // Update withdrawal line // TODO: Translate to ligneprelevement.class.php - if (! $error) { + if (!$error) { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql .= " SET statut = 2"; $sql .= " WHERE fk_prelevement_bons = ".$this->id; @@ -884,7 +884,7 @@ class BonPrelevement extends CommonObject $sql .= " AND f.rowid = pfd.fk_facture_fourn"; } $sql .= " AND s.rowid = f.fk_soc"; - $sql .= " AND f.fk_statut = 1"; // Invoice validated + $sql .= " AND f.fk_statut = 1"; // Invoice validated $sql .= " AND f.paye = 0"; $sql .= " AND pfd.traite = 0"; $sql .= " AND f.total_ttc > 0"; @@ -1179,7 +1179,7 @@ class BonPrelevement extends CommonObject /* * Update total defined after generation of file */ - if (! $error) { + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " SET amount = ".price2num($this->total); $sql .= " WHERE rowid = ".$this->id; @@ -1542,7 +1542,7 @@ class BonPrelevement extends CommonObject { $obj = $this->db->fetch_object($resql); - if (! empty($cachearraytotestduplicate[$obj->idfac])) { + if (!empty($cachearraytotestduplicate[$obj->idfac])) { $this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid); $this->invoice_in_error[$obj->idfac] = $this->error; $result = -2; @@ -1657,7 +1657,7 @@ class BonPrelevement extends CommonObject { $obj = $this->db->fetch_object($resql); - if (! empty($cachearraytotestduplicate[$obj->idfac])) { + if (!empty($cachearraytotestduplicate[$obj->idfac])) { $this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid); $this->invoice_in_error[$obj->idfac] = $this->error; $result = -2; @@ -2192,7 +2192,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ - $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV + $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2254,7 +2254,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ - $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV + $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV /*$XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index f8d67de48c2..842b8b169f5 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -84,10 +84,10 @@ if (empty($reshook)) $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; } $bprev = new BonPrelevement($db); - $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); + $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); - // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) - $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); + // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); if ($result < 0) { setEventMessages($bprev->error, $bprev->errors, 'errors'); } elseif ($result == 0) { @@ -188,30 +188,30 @@ print '
'; print ''; print ''; if ($nb) { - if ($pricetowithdraw) { - print $langs->trans('ExecutionDate').' '; - $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - print $form->selectDate($datere, 're'); + if ($pricetowithdraw) { + print $langs->trans('ExecutionDate').' '; + $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + print $form->selectDate($datere, 're'); - if ($mysoc->isInEEC()) { - $title = $langs->trans("CreateForSepa"); - if ($type == 'bank-transfer') { - $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer"); - } + if ($mysoc->isInEEC()) { + $title = $langs->trans("CreateForSepa"); + if ($type == 'bank-transfer') { + $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer"); + } - if ($type != 'bank-transfer') { - print ''; - } - print ''; - } else { - $title = $langs->trans("CreateAll"); - if ($type == 'bank-transfer') { - $title = $langs->trans("CreateFileForPaymentByBankTransfer"); - } - print ''.$title."\n"; + if ($type != 'bank-transfer') { + print ''; + } + print ''; + } else { + $title = $langs->trans("CreateAll"); + if ($type == 'bank-transfer') { + $title = $langs->trans("CreateFileForPaymentByBankTransfer"); + } + print ''.$title."\n"; } } else { if ($mysoc->isInEEC()) @@ -301,12 +301,12 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $param = ''; + $param = ''; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($socid) $param .= '&socid='.urlencode($socid); - if ($option) $param .= "&option=".urlencode($option); + if ($option) $param .= "&option=".urlencode($option); - print ''; + print ''; print ''; print ''; if (!empty($limit)) { @@ -317,12 +317,12 @@ if ($resql) if ($type == 'bank-transfer') { $title = $langs->trans("InvoiceWaitingPaymentByBankTransfer"); } - print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit); - $tradinvoice = "Invoice"; - if ($type == 'bank-transfer') { - $tradinvoice = "SupplierInvoice"; - } + $tradinvoice = "Invoice"; + if ($type == 'bank-transfer') { + $tradinvoice = "SupplierInvoice"; + } print ''; print ''; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index fcdb2f01404..c4cb6f0c7c4 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -82,8 +82,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts")); if ($id > 0 || $ref) { if ($object->fetch($id, $ref) >= 0) - { - $head = prelevement_prepare_head($object); + { + $head = prelevement_prepare_head($object); dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -151,9 +151,9 @@ if ($id > 0 || $ref) print ''; dol_fiche_end(); - } else { - dol_print_error($db); - } + } else { + dol_print_error($db); + } } @@ -191,13 +191,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -212,13 +212,13 @@ if ($resql) // Lines of title fields print ''; - if ($optioncss != '') print ''; + if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -245,38 +245,38 @@ if ($resql) $invoicetmpsupplier = new FactureFournisseur($db); while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); + { + $obj = $db->fetch_object($resql); - if ($obj->type == 'bank-transfer') { - $invoicetmp = $invoicetmpsupplier; - } else { - $invoicetmp = $invoicetmpcustomer; - } - $invoicetmp->fetch($obj->facid); + if ($obj->type == 'bank-transfer') { + $invoicetmp = $invoicetmpsupplier; + } else { + $invoicetmp = $invoicetmpcustomer; + } + $invoicetmp->fetch($obj->facid); - $thirdpartytmp->fetch($obj->socid); + $thirdpartytmp->fetch($obj->socid); - print ''; + print ''; - print "\n"; + print "\n"; - print '\n"; + print '\n"; - // Amount of invoice - print '\n"; + // Amount of invoice + print '\n"; - // Amount requested - print '\n"; + // Amount requested + print '\n"; - // Status of requests - print '"; + print ""; - print ""; + print ""; - print "\n"; + print "\n"; - $totalinvoices += $obj->total_ttc; - $totalamount_requested += $obj->amount_requested; + $totalinvoices += $obj->total_ttc; + $totalamount_requested += $obj->amount_requested; - $i++; - } + $i++; + } if ($num > 0) - { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print '\n"; - print '\n"; - print ''; - print ''; - print "\n"; - } + print "\n"; + print ''; + print ''; + print "\n"; + } print "
"; - print $invoicetmp->getNomUrl(1); - print ""; + print $invoicetmp->getNomUrl(1); + print "'; - print $thirdpartytmp->getNomUrl(1); - print "'; + print $thirdpartytmp->getNomUrl(1); + print "'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($obj->amount_requested)."'.price($obj->amount_requested)."'; + // Status of requests + print ''; - if ($obj->statut == 0) { + if ($obj->statut == 0) { print '-'; } elseif ($obj->statut == 2) { if ($obj->type == 'bank-transfer') { @@ -288,34 +288,34 @@ if ($resql) print ''.$langs->trans("StatusRefused").''; } - print "
'.$langs->trans("Total").' '; + { + print '
'.$langs->trans("Total").' '; //if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); // It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only. - if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); print "'; + print ''; print price($totalamount_requested); - print "  
  
"; print '
'; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index bddebaedda5..2cfc40bb30c 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -76,8 +76,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts")); if ($prev_id > 0 || $ref) { if ($object->fetch($prev_id, $ref) >= 0) - { - $head = prelevement_prepare_head($object); + { + $head = prelevement_prepare_head($object); dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -145,9 +145,9 @@ if ($prev_id > 0 || $ref) print '
'; dol_fiche_end(); - } else { - dol_print_error($db); - } + } else { + dol_print_error($db); + } } @@ -205,44 +205,44 @@ if ($resql) if ($num > 0) { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - print ''; + print ''; - print ''; - print img_picto('', 'statut'.$obj->statut).' '; - print substr('000000'.$obj->rowid, -6); - print ''; - print ''.$obj->name."\n"; + print ''; + print img_picto('', 'statut'.$obj->statut).' '; + print substr('000000'.$obj->rowid, -6); + print ''; + print ''.$obj->name."\n"; - print ''.price($obj->amount)."\n"; - print ''.$rej->motifs[$obj->motif].''; + print ''.price($obj->amount)."\n"; + print ''.$rej->motifs[$obj->motif].''; - print ''.yn($obj->afacturer).''; - print ''.$obj->fk_facture.''; - print "\n"; + print ''.yn($obj->afacturer).''; + print ''.$obj->fk_facture.''; + print "\n"; - $total += $obj->amount; + $total += $obj->amount; - $i++; - } + $i++; + } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } if ($num > 0) - { - print ' '; - print ''.$langs->trans("Total").''; - print ''.price($total)."\n"; - print ' '; - print "\n"; - } - print "\n"; - print '
'; + { + print ' '; + print ''.$langs->trans("Total").''; + print ''.price($total)."\n"; + print ' '; + print "\n"; + } + print "\n"; + print ''; $db->free($resql); } else { diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 97ae42c3122..0331861ea03 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -71,9 +71,9 @@ $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } // Security check @@ -102,45 +102,45 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } // Creation utilisateur depuis contact - if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) - { - // Recuperation contact actuel - $result = $object->fetch($id); + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) + { + // Recuperation contact actuel + $result = $object->fetch($id); - if ($result > 0) - { - $db->begin(); + if ($result > 0) + { + $db->begin(); - // Creation user - $nuser = new User($db); - $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) + // Creation user + $nuser = new User($db); + $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) - if ($result > 0) - { - $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) - if ($result2) - { - $db->commit(); - } else { - $error = $nuser->error; $errors = $nuser->errors; - $db->rollback(); - } - } else { - $error = $nuser->error; $errors = $nuser->errors; - $db->rollback(); - } - } else { - $error = $object->error; $errors = $object->errors; - } - } + if ($result > 0) + { + $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) + if ($result2) + { + $db->commit(); + } else { + $error = $nuser->error; $errors = $nuser->errors; + $db->rollback(); + } + } else { + $error = $nuser->error; $errors = $nuser->errors; + $db->rollback(); + } + } else { + $error = $object->error; $errors = $object->errors; + } + } // Confirmation desactivation @@ -174,50 +174,50 @@ if (empty($reshook)) { $db->begin(); - if ($canvas) $object->canvas = $canvas; + if ($canvas) $object->canvas = $canvas; - $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); - $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); + $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); + $object->socid = GETPOST("socid", 'int'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->country_id = GETPOST("country_id", 'int'); - $object->state_id = GETPOST("state_id", 'int'); - //$object->jabberid = GETPOST("jabberid", 'alpha'); - //$object->skype = GETPOST("skype", 'alpha'); - //$object->twitter = GETPOST("twitter", 'alpha'); - //$object->facebook = GETPOST("facebook", 'alpha'); - //$object->linkedin = GETPOST("linkedin", 'alpha'); - $object->socialnetworks = array(); - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); - } - } - } - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); - $object->roles = GETPOST("roles", 'array'); + $object->poste = GETPOST("poste", 'alpha'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); + $object->country_id = GETPOST("country_id", 'int'); + $object->state_id = GETPOST("state_id", 'int'); + //$object->jabberid = GETPOST("jabberid", 'alpha'); + //$object->skype = GETPOST("skype", 'alpha'); + //$object->twitter = GETPOST("twitter", 'alpha'); + //$object->facebook = GETPOST("facebook", 'alpha'); + //$object->linkedin = GETPOST("linkedin", 'alpha'); + $object->socialnetworks = array(); + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); - $object->statut = 1; //Defult status to Actif + $object->statut = 1; //Defult status to Actif - // Note: Correct date should be completed with location to have exact GM time of birth. - $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int')); - $object->birthday_alert = GETPOST("birthday_alert", 'alpha'); + // Note: Correct date should be completed with location to have exact GM time of birth. + $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int')); + $object->birthday_alert = GETPOST("birthday_alert", 'alpha'); - // Fill array 'array_options' with data from add form + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { @@ -225,19 +225,19 @@ if (empty($reshook)) $action = 'create'; } - if (!GETPOST("lastname")) - { - $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); - $action = 'create'; - } + if (!GETPOST("lastname")) + { + $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); + $action = 'create'; + } - if (!$error) - { - $id = $object->create($user); - if ($id <= 0) - { - $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); - $action = 'create'; + if (!$error) + { + $id = $object->create($user); + if ($id <= 0) + { + $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); + $action = 'create'; } else { // Categories association $contcats = GETPOST('contcats', 'array'); @@ -259,51 +259,51 @@ if (empty($reshook)) } } } - } + } - if (!$error && $id > 0) - { - $db->commit(); - if (!empty($backtopage)) $url = $backtopage; - else $url = 'card.php?id='.$id; - header("Location: ".$url); - exit; - } else { - $db->rollback(); - } - } + if (!$error && $id > 0) + { + $db->commit(); + if (!empty($backtopage)) $url = $backtopage; + else $url = 'card.php?id='.$id; + header("Location: ".$url); + exit; + } else { + $db->rollback(); + } + } - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) - { - $result = $object->fetch($id); + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) + { + $result = $object->fetch($id); $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname"); - $object->old_firstname = GETPOST("old_firstname"); + $object->old_lastname = GETPOST("old_lastname"); + $object->old_firstname = GETPOST("old_firstname"); - $result = $object->delete(); - if ($result > 0) - { - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: ".DOL_URL_ROOT.'/contact/list.php'); - exit; - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $result = $object->delete(); + if ($result > 0) + { + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } else { + header("Location: ".DOL_URL_ROOT.'/contact/list.php'); + exit; + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } - if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) - { - if (empty($_POST["lastname"])) - { - $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); - $action = 'edit'; - } + if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) + { + if (empty($_POST["lastname"])) + { + $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); + $action = 'edit'; + } if (!$error) { @@ -312,155 +312,155 @@ if (empty($reshook)) // Photo save $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos"; - $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if (GETPOST('deletephoto') && $object->photo) - { - $fileimg = $dir.'/'.$object->photo; - $dirthumbs = $dir.'/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - $object->photo = ''; - } - if ($file_OK) - { - if (image_format_supported($_FILES['photo']['name']) > 0) - { - dol_mkdir($dir); + $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); + if (GETPOST('deletephoto') && $object->photo) + { + $fileimg = $dir.'/'.$object->photo; + $dirthumbs = $dir.'/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + $object->photo = ''; + } + if ($file_OK) + { + if (image_format_supported($_FILES['photo']['name']) > 0) + { + dol_mkdir($dir); - if (@is_dir($dir)) - { - $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); + if (@is_dir($dir)) + { + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (!$result > 0) - { - $errors[] = "ErrorFailedToSaveFile"; - } else { - $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + if (!$result > 0) + { + $errors[] = "ErrorFailedToSaveFile"; + } else { + $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - // Create thumbs - $object->addThumbs($newfile); - } - } - } else { - $errors[] = "ErrorBadImageFormat"; - } - } else { - switch ($_FILES['photo']['error']) - { - case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini - case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $errors[] = "ErrorFileSizeTooLarge"; - break; - case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; - } - } + // Create thumbs + $object->addThumbs($newfile); + } + } + } else { + $errors[] = "ErrorBadImageFormat"; + } + } else { + switch ($_FILES['photo']['error']) + { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } $object->oldcopy = clone $object; $object->old_lastname = GETPOST("old_lastname", 'alpha'); $object->old_firstname = GETPOST("old_firstname", 'alpha'); - $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); + $object->socid = GETPOST("socid", 'int'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->civility_code = GETPOST("civility_code", 'alpha'); + $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->state_id = GETPOST("state_id", 'int'); - $object->country_id = GETPOST("country_id", 'int'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); + $object->state_id = GETPOST("state_id", 'int'); + $object->country_id = GETPOST("country_id", 'int'); - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); - //$object->jabberid = GETPOST("jabberid", 'alpha'); - //$object->skype = GETPOST("skype", 'alpha'); - //$object->twitter = GETPOST("twitter", 'alpha'); - //$object->facebook = GETPOST("facebook", 'alpha'); - //$object->linkedin = GETPOST("linkedin", 'alpha'); + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); + //$object->jabberid = GETPOST("jabberid", 'alpha'); + //$object->skype = GETPOST("skype", 'alpha'); + //$object->twitter = GETPOST("twitter", 'alpha'); + //$object->facebook = GETPOST("facebook", 'alpha'); + //$object->linkedin = GETPOST("linkedin", 'alpha'); $object->socialnetworks = array(); - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); - } - } - } - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); - $object->roles = GETPOST("roles", 'array'); + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); - // Fill array 'array_options' with data from add form + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (!$error) { - $result = $object->update($contactid, $user); + $result = $object->update($contactid, $user); - if ($result > 0) { - // Categories association - $categories = GETPOST('contcats', 'array'); - $object->setCategories($categories); + if ($result > 0) { + // Categories association + $categories = GETPOST('contcats', 'array'); + $object->setCategories($categories); - $no_email = GETPOST('no_email', 'int'); + $no_email = GETPOST('no_email', 'int'); - // Update mass emailing flag into table mailing_unsubscribe - if (GETPOSTISSET('no_email') && $object->email) - { - if ($no_email) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - if (empty($noemail)) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql = $db->query($sql); - } - } - } else { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); - $resql = $db->query($sql); - } + // Update mass emailing flag into table mailing_unsubscribe + if (GETPOSTISSET('no_email') && $object->email) + { + if ($no_email) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + if (empty($noemail)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql = $db->query($sql); + } + } + } else { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); + $resql = $db->query($sql); + } - $object->no_email = $no_email; - } + $object->no_email = $no_email; + } - $object->old_lastname = ''; - $object->old_firstname = ''; - $action = 'view'; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } + $object->old_lastname = ''; + $object->old_firstname = ''; + $action = 'view'; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; + } } - } + } - if (!$error && empty($errors)) - { - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - } - } + if (!$error && empty($errors)) + { + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } + } - if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) - { + if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) + { $object->fetch($id); $object->fk_prospectlevel = GETPOST('prospect_contact_level_id', 'alpha'); $result = $object->update($object->id, $user); @@ -476,7 +476,7 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - // Actions to send emails + // Actions to send emails $triggersendname = 'CONTACT_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromcontact'; @@ -501,87 +501,87 @@ $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans(" if ($socid > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($socid); + $objsoc = new Societe($db); + $objsoc->fetch($socid); } if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - if (empty($object->error) && $id) + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if (empty($object->error) && $id) { $object = new Contact($db); $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->display_canvas($action); // Show template } else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- - // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } - } + // Confirm deleting contact + if ($user->rights->societe->contact->supprimer) + { + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } + } - /* + /* * Onglets */ - $head = array(); - if ($id > 0) - { - // Si edition contact deja existant - $object = new Contact($db); - $res = $object->fetch($id, $user); - if ($res < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + $head = array(); + if ($id > 0) + { + // Si edition contact deja existant + $object = new Contact($db); + $res = $object->fetch($id, $user); + if ($res < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } - $object->fetchRoles(); + $object->fetchRoles(); - // Show tabs - $head = contact_prepare_head($object); + // Show tabs + $head = contact_prepare_head($object); - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - } + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + } - if ($user->rights->societe->contact->creer) - { - if ($action == 'create') - { - /* + if ($user->rights->societe->contact->creer) + { + if ($action == 'create') + { + /* * Fiche en mode creation */ - $object->canvas = $canvas; + $object->canvas = $canvas; - $object->state_id = GETPOST("state_id"); + $object->state_id = GETPOST("state_id"); - // We set country_id, country_code and label for the selected country - $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); - if ($object->country_id) - { - $tmparray = getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; - } + // We set country_id, country_code and label for the selected country + $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); + if ($object->country_id) + { + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; + } - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $linkback = ''; - print load_fiche_titre($title, $linkback, 'address'); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $linkback = ''; + print load_fiche_titre($title, $linkback, 'address'); - // Show errors - dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); + // Show errors + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) + { print "\n".''."\n"; - } + } - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($objsoc)) { print ''; - } + } - dol_fiche_head($head, 'card', '', 0, ''); + dol_fiche_head($head, 'card', '', 0, ''); - print ''; + print '
'; - // Name - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($socid > 0) - { - print ''; - print ''; - print ''; - print ''; - } else { - print ''; - } - } - - // Civility - print ''; - - print ''; - print ''; - - $colspan = 3; - if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2; - - // Address - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party - print ''; - print ''; - - if ($conf->use_javascript_ajax && $socid > 0) - { - $rowspan = 3; - if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++; - - print ''; - } - print ''; - - // Zip / Town - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party - print ''; - - // Country - print ''; - - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) - { - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) - { - print ''; - } - - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party - - // Phone / Fax - print ''; - print ''; - if ($conf->browser->layout == 'phone') print ''; - print ''; - print ''; - - print ''; - print ''; - if ($conf->browser->layout == 'phone') print ''; - print ''; - print ''; - print ''; - - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party - - // Email - print ''; - print ''; + // Name + print ''; + print ''; print ''; - if (!empty($conf->mailing->enabled)) - { - $noemail = ''; - if (empty($noemail) && !empty($object->email)) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - } - } + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - } - print ''; + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($socid > 0) + { + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + } + } - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - print ''; - print ''; - print ''; - print ''; - } elseif (!empty($object->socialnetworks[$key])) { - print ''; - } - } - } - // if (! empty($conf->socialnetworks->enabled)) - // { - // // Jabber - // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - // { - // print ''; - // print ''; - // } - // // Skype - // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - // { - // print ''; - // print ''; - // } - // // Twitter - // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - // { - // print ''; - // print ''; - // } - // // Facebook - // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - // { - // print ''; - // print ''; - // } - // // LinkedIn - // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - // { - // print ''; - // print ''; - // } - // } + // Civility + print ''; - // Visibility - print ''; + print ''; + print ''; + + $colspan = 3; + if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2; + + // Address + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party + print ''; + print ''; + + if ($conf->use_javascript_ajax && $socid > 0) + { + $rowspan = 3; + if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++; + + print ''; + } + print ''; + + // Zip / Town + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party + print ''; + + // Country + print ''; + + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print ''; + } + + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party + + // Phone / Fax + print ''; + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + print ''; + + print ''; + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + print ''; + print ''; + + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party + + // Email + print ''; + print ''; + print ''; + + if (!empty($conf->mailing->enabled)) + { + $noemail = ''; + if (empty($noemail) && !empty($object->email)) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + } + } + + print ''; + print ''; + print ''; + print ''; + } + print ''; + + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } + } + } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print ''; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print ''; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print ''; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print ''; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print ''; + // } + // } + + // Visibility + print ''; // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -823,84 +823,84 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; } - // Contact by default - if (!empty($socid)) { - print ''; - print ''; - } + // Contact by default + if (!empty($socid)) { + print ''; + print ''; + } - // Other attributes - $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit', $parameters); - } + // Other attributes + $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit', $parameters); + } - print "
lastname).'" autofocus="autofocus">
firstname).'">
'; - print $objsoc->getNomUrl(1, 'contact'); - print '
'; - print $form->select_company($socid, 'socid', '', 'SelectThirdParty'); - print '
'; - print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); - print '
poste).'">
'; - print ''.$langs->trans('CopyAddressFromSoc').''; - print '
/ '; - print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ? GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOST("town", 'alpha') ? GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print '
'; - print img_picto('', 'globe-americas', 'class="paddingrightonly"'); - print $form->select_country((GETPOST("country_id", 'alpha') ? GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print '
'; - } else { - print '
'; - } - - if ($object->country_id) - { - print $formcompany->select_state(GETPOST("state_id", 'alpha') ? GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); - } else { - print $countrynotdefined; - } - print '
'.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''; - print img_picto('', 'object_phoning'); - print '
'.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).''; - print img_picto('', 'object_phoning'); - print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''; - print img_picto('', 'object_phoning_mobile'); - print '
'.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; - print img_picto('', 'object_phoning_fax'); - print '
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''; - print img_picto('', 'object_email'); - print '
lastname).'" autofocus="autofocus">
firstname).'">
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).'
'; + print $objsoc->getNomUrl(1, 'contact'); + print '
'; + print $form->select_company($socid, 'socid', '', 'SelectThirdParty'); + print '
'; - print ''; - print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; + print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); + print '
'; - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); - print '
poste).'">
'; + print ''.$langs->trans('CopyAddressFromSoc').''; + print '
/ '; + print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ? GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOST("town", 'alpha') ? GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print '
'; + print img_picto('', 'globe-americas', 'class="paddingrightonly"'); + print $form->select_country((GETPOST("country_id", 'alpha') ? GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'; + } else { + print '
'; + } + + if ($object->country_id) + { + print $formcompany->select_state(GETPOST("state_id", 'alpha') ? GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); + } else { + print $countrynotdefined; + } + print '
'.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''; + print img_picto('', 'object_phoning'); + print '
'.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).''; + print img_picto('', 'object_phoning'); + print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''; + print img_picto('', 'object_phoning_mobile'); + print '
'.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + print img_picto('', 'object_phoning_fax'); + print '
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''; + print img_picto('', 'object_email'); + print '
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).'
'; + print ''; + print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); + print '
'.$langs->trans("ContactByDefaultFor").''; - $contactType = $object->listeTypeContacts('external', '', 1); - print $form->multiselectarray('roles', $contactType); - print '
'.$langs->trans("ContactByDefaultFor").''; + $contactType = $object->listeTypeContacts('external', '', 1); + print $form->multiselectarray('roles', $contactType); + print '

"; + print "
"; print '
'; - // Add personnal information - print load_fiche_titre('
'.$langs->trans("PersonalInformations").'
', '', ''); + // Add personnal information + print load_fiche_titre('
'.$langs->trans("PersonalInformations").'
', '', ''); - print ''; + print '
'; - // Date To Birth - print ''; + // Date To Birth + print ''; - print ''; - print ''; + print ''; + print ''; - print "
'; - $form = new Form($db); - if ($object->birthday) - { - print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); - } else { - print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0); - } - print '
'; + $form = new Form($db); + if ($object->birthday) + { + print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); + } else { + print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0); + } + print ': '; - if ($object->birthday_alert) - { - print ''; - } else { - print ''; - } - print '
: '; + if ($object->birthday_alert) + { + print ''; + } else { + print ''; + } + print '
"; + print ""; - dol_fiche_end(); + dol_fiche_end(); - print '
'; - print ''; - if (!empty($backtopage)) - { - print '     '; - print ''; - } else { - print '     '; - print ''; - } - print '
'; + print '
'; + print ''; + if (!empty($backtopage)) + { + print '     '; + print ''; + } else { + print '     '; + print ''; + } + print '
'; - print ""; - } elseif ($action == 'edit' && !empty($id)) - { - /* + print ""; + } elseif ($action == 'edit' && !empty($id)) + { + /* * Fiche en mode edition */ - // We set country_id, and country_code label of the chosen country - if (isset($_POST["country_id"]) || $object->country_id) - { - $tmparray = getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; - } + // We set country_id, and country_code label of the chosen country + if (isset($_POST["country_id"]) || $object->country_id) + { + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; + } $objsoc = new Societe($db); $objsoc->fetch($object->socid); @@ -908,8 +908,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Show errors dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) + { print "\n".''."\n"; - } + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($backtopage)) print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($backtopage)) print ''; - dol_fiche_head($head, 'card', $title, 0, 'contact'); + dol_fiche_head($head, 'card', $title, 0, 'contact'); - print ''; + print '
'; - // Ref/ID - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) - { - print ''; - } + // Ref/ID + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + { + print ''; + } - // Lastname - print ''; - print ''; - print ''; - print ''; - // Firstname - print ''; - print ''; - print ''; + // Lastname + print ''; + print ''; + print ''; + print ''; + // Firstname + print ''; + print ''; + print ''; - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - print ''; - print ''; - print ''; - } + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + print ''; + print ''; + print ''; + } - // Civility - print ''; + // Civility + print ''; - print ''; - print ''; + print ''; + print ''; - // Address - print ''; - print ''; + // Address + print ''; + print ''; - // Zip / Town - print ''; + // Zip / Town + print ''; - // Country - print ''; + // Country + print ''; - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) - { - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) - { - print ''; - } + print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id'); + print ''; + } - // Phone - print ''; - print ''; - print ''; - print ''; + // Phone + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - // EMail - print ''; - print ''; - if (!empty($conf->mailing->enabled)) - { - $langs->load("mails"); - print ''; - print ''; - } else { - print ''; - } - print ''; - - // Unsubscribe - print ''; - if (!empty($conf->mailing->enabled)) - { - $noemail = ''; - if (empty($noemail) && !empty($object->email)) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - } - } - - print ''; - print ''; - } else { + // EMail + print ''; + print ''; + if (!empty($conf->mailing->enabled)) + { + $langs->load("mails"); + print ''; + print ''; + } else { print ''; } - print ''; + print ''; - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - print ''; - print ''; - print ''; - print ''; - } elseif (!empty($object->socialnetworks[$key])) { - print ''; - } - } - } - // if (! empty($conf->socialnetworks->enabled)) - // { - // // Jabber ID - // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - // { - // print ''; - // print ''; - // } - // // Skype - // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - // { - // print ''; - // print ''; - // } - // // Twitter - // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - // { - // print ''; - // print ''; - // } - // // Facebook - // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - // { - // print ''; - // print ''; - // } - // // LinkedIn - // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - // { - // print ''; - // print ''; - // } - // } + // Unsubscribe + print ''; + if (!empty($conf->mailing->enabled)) + { + $noemail = ''; + if (empty($noemail) && !empty($object->email)) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + } + } - // Visibility - print ''; + print ''; + print ''; + } else { + print ''; + } + print ''; - // Note Public - print ''; + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } + } + } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber ID + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print ''; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print ''; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print ''; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print ''; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print ''; + // } + // } - // Note Private - print ''; + // Visibility + print ''; - // Status - print ''; - print ''; + // Note Public + print ''; + + // Note Private + print ''; + + // Status + print ''; + print ''; // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -1162,196 +1162,196 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Contact by default - if (!empty($object->socid)) { - print ''; - print ''; - } + if (!empty($object->socid)) { + print ''; + print ''; + } - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit', $parameters); - } + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit', $parameters); + } - $object->load_ref_elements(); + $object->load_ref_elements(); - if (!empty($conf->commande->enabled)) - { - print ''; - } + if (!empty($conf->commande->enabled)) + { + print ''; + } - if (!empty($conf->propal->enabled)) - { - print ''; - } + if (!empty($conf->propal->enabled)) + { + print ''; + } - if (!empty($conf->contrat->enabled)) - { - print ''; - } + if (!empty($conf->contrat->enabled)) + { + print ''; + } - if (!empty($conf->facture->enabled)) - { - print ''; - } + if (!empty($conf->facture->enabled)) + { + print ''; + } - // Login Dolibarr - print ''; + // Login Dolibarr + print ''; - // Photo - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; + print ''; - print '
'.$langs->trans("ID").''; - print $object->ref; - print '
'.$langs->trans("ID").''; + print $object->ref; + print '
lastname).'" autofocus="autofocus">
firstname).'">
lastname).'" autofocus="autofocus">
firstname).'">
'; - print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); - print '
'; + print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); + print '
'; - print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", "aZ09") : $object->civility_code, 'civility_code'); - print '
'; + print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", "aZ09") : $object->civility_code, 'civility_code'); + print '
poste).'">
poste).'">
'; - print '
'; - print ''; - print '
'; - if ($conf->use_javascript_ajax) print ''.$langs->trans('CopyAddressFromSoc').'
'; - print '
'; - print '
'; + print '
'; + print ''; + print '
'; + if ($conf->use_javascript_ajax) print ''.$langs->trans('CopyAddressFromSoc').'
'; + print '
'; + print '
/ '; - print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print '
/ '; + print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print '
'; - print img_picto('', 'globe-americas', 'class="paddingrightonly"'); - print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print '
'; + print img_picto('', 'globe-americas', 'class="paddingrightonly"'); + print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'; - } else { - print '
'; - } + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print '
'; + } else { + print '
'; + } - print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id'); - print '
'.$form->editfieldkey('PhonePro', 'phone_pro', GETPOST('phone_pro', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning'); - print ''.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning'); - print '
'.$form->editfieldkey('PhonePro', 'phone_pro', GETPOST('phone_pro', 'alpha'), $object, 0).''; + print img_picto('', 'object_phoning'); + print ''.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).''; + print img_picto('', 'object_phoning'); + print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0, 'string', '').''; - print img_picto('', 'object_phoning_mobile'); - print ''.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning_fax'); - print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0, 'string', '').''; + print img_picto('', 'object_phoning_mobile'); + print ''.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''; + print img_picto('', 'object_phoning_fax'); + print '
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; - print img_picto('', 'object_email'); - print ''.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; + print img_picto('', 'object_email'); + print ''.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'; - print ''; - print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv', $selectarray, $object->priv, 0); - print '
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
'; - $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); - print $doleditor->Create(1); - print '
'; + print ''; + print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; - $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); - print $doleditor->Create(1); - print '
'; + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv', $selectarray, $object->priv, 0); + print '
'.$langs->trans("Status").''; - print $object->getLibStatut(4); - print '
'; + $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print '
'; + $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans("Status").''; + print $object->getLibStatut(4); + print '
'.$langs->trans("ContactByDefaultFor").''; - print $formcompany->showRoles("roles", $object, 'edit', $object->roles); - print '
'.$langs->trans("ContactByDefaultFor").''; + print $formcompany->showRoles("roles", $object, 'edit', $object->roles); + print '
'.$langs->trans("ContactForOrders").''; - print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); - print '
'.$langs->trans("ContactForOrders").''; + print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); + print '
'.$langs->trans("ContactForProposals").''; - print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); - print '
'.$langs->trans("ContactForProposals").''; + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); + print '
'.$langs->trans("ContactForContracts").''; - print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); - print '
'.$langs->trans("ContactForContracts").''; + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); + print '
'.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); - print '
'.$langs->trans("ContactForInvoices").''; + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); + print '
'.$langs->trans("DolibarrLogin").''; - if ($object->user_id) - { - $dolibarr_user = new User($db); - $result = $dolibarr_user->fetch($object->user_id); - print $dolibarr_user->getLoginUrl(1); - } else print $langs->trans("NoDolibarrAccess"); - print '
'.$langs->trans("DolibarrLogin").''; + if ($object->user_id) + { + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); + print $dolibarr_user->getLoginUrl(1); + } else print $langs->trans("NoDolibarrAccess"); + print '
'.$langs->trans("PhotoFile").''; - if ($object->photo) { - print $form->showphoto('contact', $object); - print "
\n"; - } - print ''; - if ($object->photo) print ''; - //print ''; - print ''; - print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; + // Photo + print '
'.$langs->trans("PhotoFile").''; + if ($object->photo) { + print $form->showphoto('contact', $object); + print "
\n"; + } + print ''; + if ($object->photo) print ''; + //print ''; + print ''; + print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; - print '
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; - print "
"; - } - } + print ""; + } + } - if (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); - // View mode + // View mode - // Show errors - dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); + // Show errors + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - dol_fiche_head($head, 'card', $title, -1, 'contact'); + dol_fiche_head($head, 'card', $title, -1, 'contact'); - if ($action == 'create_user') - { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $login = dol_buildlogin($object->lastname, $object->firstname); + if ($action == 'create_user') + { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $login = dol_buildlogin($object->lastname, $object->firstname); - $generated_password = ''; - if (!$ldap_sid) // TODO ldap_sid ? - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password = getRandomPassword(false); - } - $password = $generated_password; + $generated_password = ''; + if (!$ldap_sid) // TODO ldap_sid ? + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $generated_password = getRandomPassword(false); + } + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password), - //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) - ); - $text = $langs->trans("ConfirmCreateContact").'
'; - if (!empty($conf->societe->enabled)) - { - if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); - else $text .= $langs->trans("UserWillBeInternalUser"); - } - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); - } + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password), + //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) + ); + $text = $langs->trans("ConfirmCreateContact").'
'; + if (!empty($conf->societe->enabled)) + { + if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); + else $text .= $langs->trans("UserWillBeInternalUser"); + } + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); + } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; - // Civility - print ''; + // Civility + print ''; - // Job / position - print ''; + // Job / position + print ''; - // Email - if (!empty($conf->mailing->enabled)) - { - $langs->load("mails"); - print ''; - print ''; - } + // Email + if (!empty($conf->mailing->enabled)) + { + $langs->load("mails"); + print ''; + print ''; + } - // Unsubscribe opt-out - if (!empty($conf->mailing->enabled)) - { - //print 'eee'.$object->email; - $noemail = $object->no_email; - if (empty($noemail) && !empty($object->email)) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - } - } - print ''; - } + // Unsubscribe opt-out + if (!empty($conf->mailing->enabled)) + { + //print 'eee'.$object->email; + $noemail = $object->no_email; + if (empty($noemail) && !empty($object->email)) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + } + } + print ''; + } - print ''; + print ''; - print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("PostOrFunction").''.$object->poste.'
'.$langs->trans("PostOrFunction").''.$object->poste.'
'.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'.$langs->trans("No_Email").''.yn($noemail).'
'.$langs->trans("No_Email").''.yn($noemail).'
'.$langs->trans("ContactVisibility").''; - print $object->LibPubPriv($object->priv); - print '
'.$langs->trans("ContactVisibility").''; + print $object->LibPubPriv($object->priv); + print '
'; - print '
'; + print ''; + print '
'; $object->fetch_thirdparty(); @@ -1396,10 +1396,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } - print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -1409,78 +1409,78 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; } - if (!empty($object->socid)) { - print ''; - print ''; - } + if (!empty($object->socid)) { + print ''; + print ''; + } - // Other attributes - $cols = 3; - $parameters = array('socid'=>$socid); - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + $cols = 3; + $parameters = array('socid'=>$socid); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - $object->load_ref_elements(); + $object->load_ref_elements(); - if (!empty($conf->propal->enabled)) - { - print ''; - } + if (!empty($conf->propal->enabled)) + { + print ''; + } - if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) - { - print ''; - } + if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) + { + print ''; + } - if (!empty($conf->contrat->enabled)) - { - print ''; - } + if (!empty($conf->contrat->enabled)) + { + print ''; + } - if (!empty($conf->facture->enabled)) - { - print ''; - } + if (!empty($conf->facture->enabled)) + { + print ''; + } - print ''; + print ''; - print ''; + print ''; - print "
'.$langs->trans("ContactByDefaultFor").''; - print $formcompany->showRoles("roles", $object, 'view'); - print '
'.$langs->trans("ContactByDefaultFor").''; + print $formcompany->showRoles("roles", $object, 'view'); + print '
'.$langs->trans("ContactForProposals").''; - print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); - print '
'.$langs->trans("ContactForProposals").''; + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); + print '
'; - if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); - print ''; - $none = $langs->trans("NoContactForAnyOrder"); - if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } - print $object->ref_commande ? $object->ref_commande : $none; - print '
'; + if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); + print ''; + $none = $langs->trans("NoContactForAnyOrder"); + if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } + print $object->ref_commande ? $object->ref_commande : $none; + print '
'.$langs->trans("ContactForContracts").''; - print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); - print '
'.$langs->trans("ContactForContracts").''; + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); + print '
'.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); - print '
'.$langs->trans("ContactForInvoices").''; + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); + print '
'.$langs->trans("DolibarrLogin").''; - if ($object->user_id) - { - $dolibarr_user = new User($db); - $result = $dolibarr_user->fetch($object->user_id); - print $dolibarr_user->getLoginUrl(1); - } else print $langs->trans("NoDolibarrAccess"); - print '
'.$langs->trans("DolibarrLogin").''; + if ($object->user_id) + { + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); + print $dolibarr_user->getLoginUrl(1); + } else print $langs->trans("NoDolibarrAccess"); + print '
'; - print $langs->trans("VCard").''; + print '
'; + print $langs->trans("VCard").''; print ''; print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); print $langs->trans("Download"); print ''; - print '
"; + print ""; - print '
'; - print '
'; + print '
'; + print '
'; - dol_fiche_end(); + dol_fiche_end(); - // Barre d'actions - print '
'; + // Barre d'actions + print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1498,66 +1498,66 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans('Modify').''; - } + { + print ''.$langs->trans('Modify').''; + } - if (!$object->user_id && $user->rights->user->user->creer) - { - print ''.$langs->trans("CreateDolibarrLogin").''; - } + if (!$object->user_id && $user->rights->user->user->creer) + { + print ''.$langs->trans("CreateDolibarrLogin").''; + } - // Activer - if ($object->statut == 0 && $user->rights->societe->contact->creer) - { - print ''.$langs->trans("Reactivate").''; - } - // Desactiver - if ($object->statut == 1 && $user->rights->societe->contact->creer) - { - print ''.$langs->trans("DisableUser").''; - } + // Activer + if ($object->statut == 0 && $user->rights->societe->contact->creer) + { + print ''.$langs->trans("Reactivate").''; + } + // Desactiver + if ($object->statut == 1 && $user->rights->societe->contact->creer) + { + print ''.$langs->trans("DisableUser").''; + } - // Delete - if ($user->rights->societe->contact->supprimer) - { - print ''.$langs->trans('Delete').''; - } - } + // Delete + if ($user->rights->societe->contact->supprimer) + { + print ''.$langs->trans('Delete').''; + } + } - print "
"; + print "
"; - //Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } - if ($action != 'presend') - { - print '
'; + if ($action != 'presend') + { + print '
'; - print '
'; + print '
'; - $MAXEVENT = 10; + $MAXEVENT = 10; - $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); + $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'contact', $object->socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'contact', $object->socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty - print '
'; - } + print '
'; + } - // Presend form - $modelmail = 'contact'; - $defaulttopic = 'Information'; - $diroutput = $conf->contact->dir_output; - $trackid = 'con'.$object->id; + // Presend form + $modelmail = 'contact'; + $defaulttopic = 'Information'; + $diroutput = $conf->contact->dir_output; + $trackid = 'con'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d7bcafc8363..a474df3b910 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -184,7 +184,7 @@ $arrayfields = array( 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); -if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { +if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { $arrayfields['p.fk_prospectcontactlevel'] = array('label'=>"ProspectLevelShort", 'checked'=>1, 'position'=>210); $arrayfields['p.fk_stcommcontact'] = array('label'=>"StatusProsp", 'checked'=>1, 'position'=>215); } @@ -270,8 +270,8 @@ if (empty($reshook)) } } $search_priv = ""; - $search_stcomm=''; - $search_level=''; + $search_stcomm = ''; + $search_level = ''; $search_status = -1; $search_categ = ''; $search_categ_thirdparty = ''; @@ -314,7 +314,7 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); -if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { +if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { $contactstatic->loadCacheOfProspStatus(); } @@ -323,17 +323,17 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C // Select every potentiels, and note each potentiels which fit in search parameters $tab_level = array(); $sql = "SELECT code, label, sortorder"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; -$sql.= " WHERE active > 0"; -$sql.= " ORDER BY sortorder"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; +$sql .= " WHERE active > 0"; +$sql .= " ORDER BY sortorder"; $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { // Compute level text - $level=$langs->trans($obj->code); - if ($level == $obj->code) $level=$langs->trans($obj->label); + $level = $langs->trans($obj->code); + if ($level == $obj->code) $level = $langs->trans($obj->label); $tab_level[$obj->code] = $level; } } @@ -343,7 +343,7 @@ $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; -$sql.= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; +$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; $sql .= " co.label as country, co.code as country_code"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -357,7 +357,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact"; if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ @@ -469,7 +469,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -515,10 +515,10 @@ if ($search_email != '') $param .= '&search_email='.urlencode($search_email) if ($search_no_email != '') $param .= '&search_no_email='.urlencode($search_no_email); if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_priv == '0' || $search_priv == '1') $param .= "&search_priv=".urlencode($search_priv); -if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm); +if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm); if (is_array($search_level) && count($search_level)) { foreach ($search_level as $slevel) { - $param.='&search_level[]='.urlencode($slevel); + $param .= '&search_level[]='.urlencode($slevel); } } if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); @@ -739,20 +739,20 @@ if (!empty($arrayfields['p.priv']['checked'])) print ''; } // Prospect level -if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) +if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { print ''; print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print ''; } // Prospect status -if (! empty($arrayfields['p.fk_stcommcontact']['checked'])) +if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { print ''; - $arraystcomm=array(); + $arraystcomm = array(); foreach ($contactstatic->cacheprospectstatus as $key => $val) { - $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); + $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); } print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap '); print ''; @@ -877,7 +877,7 @@ while ($i < min($num, $limit)) $contactstatic->country_code = $obj->country_code; $contactstatic->photo = $obj->photo; - $contactstatic->fk_prospectlevel=$obj->fk_prospectcontactlevel; + $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel; print ''; @@ -1007,7 +1007,7 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) + if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { // Prospect level print ''; @@ -1016,16 +1016,16 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.fk_stcommcontact']['checked'])) + if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { // Prospect status print '
'; - print '
' . $contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '
-
'; foreach ($contactstatic->cacheprospectstatus as $key => $val) { $titlealt = 'default'; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($obj->stcomm_id != $val['id']) print '' . img_action($titlealt, $val['code'], $val['picto']) . ''; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; } print '
'; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index a9c3fb713c5..ba1d296ac44 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -85,7 +85,7 @@ if ($action == 'add' && !empty($permissiontoadd)) $object->$key = $value; if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { - $object->$key = '(PROV)'; + $object->$key = '(PROV)'; } if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { @@ -105,7 +105,7 @@ if ($action == 'add' && !empty($permissiontoadd)) $result = $object->create($user); if ($result > 0) { - // Creation OK + // Creation OK $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation header("Location: ".$urltogo); @@ -154,7 +154,7 @@ if ($action == 'update' && !empty($permissiontoadd)) $value = ''; } } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { - $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup + $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup } elseif ($object->fields[$key]['type'] == 'boolean') { $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0); } else { @@ -223,11 +223,11 @@ if ($action == "update_extras" && !empty($permissiontoadd)) // Action to delete if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - if (!($object->id > 0)) - { - dol_print_error('', 'Error, object must be fetched before being deleted'); - exit; - } + if (!($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } $result = $object->delete($user); if ($result > 0) @@ -246,7 +246,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { if (method_exists('deleteline', $object)) { - $result = $object->deleteline($user, $lineid); // For backward compatibility + $result = $object->deleteline($user, $lineid); // For backward compatibility } else { $result = $object->deleteLine($user, $lineid); } @@ -385,11 +385,11 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - // ... - $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); - if (is_object($result) || $result > 0) + // ... + $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); + if (is_object($result) || $result > 0) { $newid = 0; if (is_object($result)) $newid = $result->id; @@ -397,7 +397,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object exit; } else { - setEventMessages($objectutil->error, $objectutil->errors, 'errors'); + setEventMessages($objectutil->error, $objectutil->errors, 'errors'); $action = ''; } } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 4cfa0531a08..da010380276 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -263,12 +263,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if (dol_strlen($sendto)) { - // Define $urlwithroot - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + // Define $urlwithroot + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $langs->load("commercial"); @@ -419,7 +419,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST // Initialisation of datas of object to call trigger if (is_object($object)) { - if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically + if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array. @@ -456,7 +456,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if ($error) { setEventMessages($object->error, $object->errors, 'errors'); - } + } } // End call of triggers } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 54a0cbef2a1..41e23819266 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -34,28 +34,28 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!isset($mode) || $mode != 'noajax') // For ajax call { - require_once '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; + require_once '../../main.inc.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; - $action = GETPOST('action', 'aZ09'); - $file = urldecode(GETPOST('file', 'alpha')); - $section = GETPOST("section", 'alpha'); - $module = GETPOST("module", 'alpha'); - $urlsource = GETPOST("urlsource", 'alpha'); - $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); + $action = GETPOST('action', 'aZ09'); + $file = urldecode(GETPOST('file', 'alpha')); + $section = GETPOST("section", 'alpha'); + $module = GETPOST("module", 'alpha'); + $urlsource = GETPOST("urlsource", 'alpha'); + $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); - $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); - $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 - $offset = $limit * $page; - $pageprev = $page - 1; - $pagenext = $page + 1; - if (!$sortorder) $sortorder = "ASC"; - if (!$sortfield) $sortfield = "name"; + $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; + $sortfield = GETPOST("sortfield", 'alpha'); + $sortorder = GETPOST("sortorder", 'alpha'); + $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + $offset = $limit * $page; + $pageprev = $page - 1; + $pagenext = $page + 1; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "name"; $rootdirfordoc = $conf->ecm->dir_output; @@ -63,30 +63,30 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $ecmdir = new EcmDirectory($db); if ($section > 0) { - $result = $ecmdir->fetch($section); - if (!$result > 0) - { - //dol_print_error($db,$ecmdir->error); - //exit; - } + $result = $ecmdir->fetch($section); + if (!$result > 0) + { + //dol_print_error($db,$ecmdir->error); + //exit; + } } } else // For no ajax call { $rootdirfordoc = $conf->ecm->dir_output; $ecmdir = new EcmDirectory($db); - $relativepath = ''; - if ($section > 0) - { - $result = $ecmdir->fetch($section); - if (!$result > 0) - { - dol_print_error($db, $ecmdir->error); - exit; - } + $relativepath = ''; + if ($section > 0) + { + $result = $ecmdir->fetch($section); + if (!$result > 0) + { + dol_print_error($db, $ecmdir->error); + exit; + } - $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' - } elseif (GETPOST('section_dir')) + $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' + } elseif (GETPOST('section_dir')) { $relativepath = GETPOST('section_dir'); } @@ -113,10 +113,10 @@ if ($user->socid > 0) $socid = $user->socid; // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) { - dol_syslog("Refused to deliver file ".$upload_dir); - // Do no show plain path in shown error message - dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); - exit; + dol_syslog("Refused to deliver file ".$upload_dir); + // Do no show plain path in shown error message + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); + exit; } // Check permissions @@ -145,10 +145,10 @@ if ($modulepart == 'medias') if (!isset($mode) || $mode != 'noajax') { // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); - top_httphead(); + top_httphead(); } $type = 'directory'; @@ -156,8 +156,8 @@ $type = 'directory'; // This test if file exists should be useless. We keep it to find bug more easily if (!dol_is_dir($upload_dir)) { - //dol_mkdir($upload_dir); - /*$langs->load("install"); + //dol_mkdir($upload_dir); + /*$langs->load("install"); dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir)); exit;*/ } @@ -173,76 +173,76 @@ if (!empty($pageid)) $param .= '&pageid='.urlencode($pageid); // Dir scan if ($type == 'directory') { - $formfile = new FormFile($db); + $formfile = new FormFile($db); - $maxlengthname = 40; - $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); - $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); + $maxlengthname = 40; + $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); + $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); - // Right area. If module is defined here, we are in automatic ecm. - $automodules = array( - 'company', - 'invoice', - 'invoice_supplier', - 'propal', - 'supplier_proposal', - 'order', - 'order_supplier', - 'contract', - 'product', - 'tax', - 'project', - 'fichinter', - 'user', - 'expensereport', - 'holiday', - 'recruitment-recruitmentcandidature', - 'banque', - 'mrp-mo' - ); + // Right area. If module is defined here, we are in automatic ecm. + $automodules = array( + 'company', + 'invoice', + 'invoice_supplier', + 'propal', + 'supplier_proposal', + 'order', + 'order_supplier', + 'contract', + 'product', + 'tax', + 'project', + 'fichinter', + 'user', + 'expensereport', + 'holiday', + 'recruitment-recruitmentcandidature', + 'banque', + 'mrp-mo' + ); - // TODO change for multicompany sharing - if ($module == 'company') $upload_dir = $conf->societe->dir_output; - elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output; - elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; - elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output; - elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; - elseif ($module == 'order') $upload_dir = $conf->commande->dir_output; - elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; - elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output; - elseif ($module == 'product') $upload_dir = $conf->product->dir_output; - elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output; - elseif ($module == 'project') $upload_dir = $conf->projet->dir_output; - elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; - elseif ($module == 'user') $upload_dir = $conf->user->dir_output; - elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; - elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; - elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; - elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; - elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo'; + // TODO change for multicompany sharing + if ($module == 'company') $upload_dir = $conf->societe->dir_output; + elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output; + elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; + elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output; + elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; + elseif ($module == 'order') $upload_dir = $conf->commande->dir_output; + elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; + elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output; + elseif ($module == 'product') $upload_dir = $conf->product->dir_output; + elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output; + elseif ($module == 'project') $upload_dir = $conf->projet->dir_output; + elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; + elseif ($module == 'user') $upload_dir = $conf->user->dir_output; + elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; + elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; + elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; + elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; + elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo'; - // Automatic list - if (in_array($module, $automodules)) - { - $param .= '&module='.$module; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); + // Automatic list + if (in_array($module, $automodules)) + { + $param .= '&module='.$module; + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); - $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); + $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. - $filter = preg_quote($search_doc_ref, '/'); - $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); + $filter = preg_quote($search_doc_ref, '/'); + $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); - $perm = $user->rights->ecm->upload; + $perm = $user->rights->ecm->upload; - $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); - } - // Manual list - else { - if ($module == 'medias') - { - /* + $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); + } + // Manual list + else { + if ($module == 'medias') + { + /* $_POST is array like 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) 'action' => string 'file_manager' (length=12) @@ -253,82 +253,82 @@ if ($type == 'directory') 'max_file_size' => string '2097152' (length=7) 'sendit' => string 'Envoyer fichier' (length=15) */ - $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); - if ($relativepath && $relativepath != '/') $relativepath .= '/'; - $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; - if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) - { - $param .= '&file_manager=1'; - if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); - if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); - //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); - } - } else { - $relativepath = $ecmdir->getRelativePath(); - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - } + $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); + if ($relativepath && $relativepath != '/') $relativepath .= '/'; + $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; + if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) + { + $param .= '&file_manager=1'; + if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); + if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); + //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); + } + } else { + $relativepath = $ecmdir->getRelativePath(); + $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; + } - // If $section defined with value 0 + // If $section defined with value 0 if (($section === '0' || empty($section)) && ($module != 'medias')) - { - $filearray = array(); - } else { - $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); - } + { + $filearray = array(); + } else { + $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); + } - if ($section) - { - $param .= '§ion='.$section; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; + if ($section) + { + $param .= '§ion='.$section; + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; - $textifempty = $langs->trans('NoFileFound'); - } elseif ($section === '0') - { - if ($module == 'ecm') $textifempty = '
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; - else $textifempty = $langs->trans('NoFileFound'); - } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); + $textifempty = $langs->trans('NoFileFound'); + } elseif ($section === '0') + { + if ($module == 'ecm') $textifempty = '
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; + else $textifempty = $langs->trans('NoFileFound'); + } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); - if ($module == 'medias') - { - $useinecm = 6; - $modulepart = 'medias'; - $perm = ($user->rights->website->write || $user->rights->emailing->creer); - $title = 'none'; - } elseif ($module == 'ecm') // DMS/ECM -> manual structure - { - if ($user->rights->ecm->read) - { - // Buttons: Preview - $useinecm = 2; - } + if ($module == 'medias') + { + $useinecm = 6; + $modulepart = 'medias'; + $perm = ($user->rights->website->write || $user->rights->emailing->creer); + $title = 'none'; + } elseif ($module == 'ecm') // DMS/ECM -> manual structure + { + if ($user->rights->ecm->read) + { + // Buttons: Preview + $useinecm = 2; + } - if ($user->rights->ecm->upload) - { - // Buttons: Preview + Delete - $useinecm = 4; - } + if ($user->rights->ecm->upload) + { + // Buttons: Preview + Delete + $useinecm = 4; + } - if ($user->rights->ecm->setup) - { - // Buttons: Preview + Delete + Edit - $useinecm = 5; - } + if ($user->rights->ecm->setup) + { + // Buttons: Preview + Delete + Edit + $useinecm = 5; + } - $perm = $user->rights->ecm->upload; - $modulepart = 'ecm'; - $title = ''; // Use default - } else { - $useinecm = 5; - $modulepart = 'ecm'; - $perm = $user->rights->ecm->upload; - $title = ''; // Use default - } + $perm = $user->rights->ecm->upload; + $modulepart = 'ecm'; + $title = ''; // Use default + } else { + $useinecm = 5; + $modulepart = 'ecm'; + $perm = $user->rights->ecm->upload; + $title = ''; // Use default + } - // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param - // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath - //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); - $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); - } + // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param + // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath + //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); + $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); + } } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index a98846a6309..5048bcd31e8 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -41,47 +41,47 @@ class CMailFile public $sendmode; public $sendsetup; - public $subject; // Topic: Subject of email - public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). + public $subject; // Topic: Subject of email + public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. - public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) - public $errors_to; // Errors-To: Email where to send errors. - public $addr_to; - public $addr_cc; - public $addr_bcc; - public $trackid; + public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) + public $errors_to; // Errors-To: Email where to send errors. + public $addr_to; + public $addr_cc; + public $addr_bcc; + public $trackid; - public $mixed_boundary; - public $related_boundary; - public $alternative_boundary; - public $deliveryreceipt; + public $mixed_boundary; + public $related_boundary; + public $alternative_boundary; + public $deliveryreceipt; - public $eol; - public $eol2; + public $eol; + public $eol2; /** * @var string Error code (or message) */ public $error = ''; - public $smtps; // Contains SMTPs object (if this method is used) - public $phpmailer; // Contains PHPMailer object (if this method is used) + public $smtps; // Contains SMTPs object (if this method is used) + public $phpmailer; // Contains PHPMailer object (if this method is used) /** * @var string CSS */ public $css; //! Defined css style for body background - public $styleCSS; + public $styleCSS; //! Defined background directly in body tag - public $bodyCSS; + public $bodyCSS; - public $msgid; - public $headers; - public $message; - /** + public $msgid; + public $headers; + public $message; + /** * @var array fullfilenames list (full path of filename on file system) */ public $filename_list = array(); @@ -95,21 +95,21 @@ class CMailFile public $mimefilename_list = array(); // Image - public $html; - public $image_boundary; - public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). - public $html_images = array(); - public $images_encoded = array(); - public $image_types = array( - 'gif' => 'image/gif', + public $html; + public $image_boundary; + public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). + public $html_images = array(); + public $images_encoded = array(); + public $image_types = array( + 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'bmp' => 'image/bmp', 'png' => 'image/png', 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - ); + 'tiff' => 'image/tiff', + ); /** @@ -147,7 +147,7 @@ class CMailFile // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; - $this->subject = $subject; + $this->subject = $subject; $this->addr_to = $to; $this->addr_from = $from; $this->msg = $msg; @@ -210,8 +210,8 @@ class CMailFile } if (empty($msg)) { - dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); - $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure) + dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); + $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure) } // Detect if message is HTML (use fast method) @@ -291,7 +291,7 @@ class CMailFile // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) { - $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO; + $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; } // We set all data according to choosed sending method. @@ -411,40 +411,40 @@ class CMailFile $this->smtps = $smtps; } elseif ($this->sendmode == 'swiftmailer') { // Use Swift Mailer library - $host = dol_getprefix('email'); + $host = dol_getprefix('email'); - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php'; - // egulias autoloader lib - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php'; + // egulias autoloader lib + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; - // Create the message - //$this->message = Swift_Message::newInstance(); - $this->message = new Swift_Message(); - //$this->message = new Swift_SignedMessage(); - // Adding a trackid header to a message - $headers = $this->message->getHeaders(); - $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host); - $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host; - $headerID = $this->msgid; - $msgid = $headers->get('Message-ID'); - $msgid->setId($headerID); - $headers->addIdHeader('References', $headerID); - // TODO if (! empty($moreinheader)) ... + // Create the message + //$this->message = Swift_Message::newInstance(); + $this->message = new Swift_Message(); + //$this->message = new Swift_SignedMessage(); + // Adding a trackid header to a message + $headers = $this->message->getHeaders(); + $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host); + $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host; + $headerID = $this->msgid; + $msgid = $headers->get('Message-ID'); + $msgid->setId($headerID); + $headers->addIdHeader('References', $headerID); + // TODO if (! empty($moreinheader)) ... - // Give the message a subject - try { - $result = $this->message->setSubject($this->subject); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } + // Give the message a subject + try { + $result = $this->message->setSubject($this->subject); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } - // Set the From address with an associative array - //$this->message->setFrom(array('john@doe.com' => 'John Doe')); - if (! empty($this->addr_from)) { - try { + // Set the From address with an associative array + //$this->message->setFrom(array('john@doe.com' => 'John Doe')); + if (! empty($this->addr_from)) { + try { if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) { // Prevent email spoofing for smtp server with a strict configuration $regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string @@ -459,35 +459,35 @@ class CMailFile } else { $result = $this->message->setFrom($this->getArrayAddress($this->addr_from)); } - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } - // Set the To addresses with an associative array - if (! empty($this->addr_to)) { - try { - $result = $this->message->setTo($this->getArrayAddress($this->addr_to)); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + // Set the To addresses with an associative array + if (! empty($this->addr_to)) { + try { + $result = $this->message->setTo($this->getArrayAddress($this->addr_to)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } - if (! empty($this->reply_to)) { - try { - $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to)); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + if (! empty($this->reply_to)) { + try { + $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } - try { - $result = $this->message->setCharSet($conf->file->character_set_client); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } + try { + $result = $this->message->setCharSet($conf->file->character_set_client); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } - if (!empty($this->html)) { + if (!empty($this->html)) { if (!empty($css)) { $this->css = $css; $this->buildCSS(); @@ -578,26 +578,26 @@ class CMailFile $sendingmode = $this->sendmode; if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { - // List of sending methods - $listofmethods = array(); - $listofmethods['mail'] = 'PHP mail function'; - //$listofmethods['simplemail']='Simplemail class'; - $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; + // List of sending methods + $listofmethods = array(); + $listofmethods['mail'] = 'PHP mail function'; + //$listofmethods['simplemail']='Simplemail class'; + $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; - // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. - // You ensure that every user is using its own SMTP server when using the mass emailing module. - $linktoadminemailbefore = ''; - $linktoadminemailend = ''; - $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); - $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); - $this->error .= '
'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); - $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); - if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) - { - $this->error .= '
'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); - $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); - } - return false; + // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. + // You ensure that every user is using its own SMTP server when using the mass emailing module. + $linktoadminemailbefore = ''; + $linktoadminemailend = ''; + $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); + $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); + $this->error .= '
'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); + $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); + if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) + { + $this->error .= '
'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); + $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); + } + return false; } // Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL @@ -828,9 +828,9 @@ class CMailFile } } elseif ($this->sendmode == 'swiftmailer') { - // Use Swift Mailer library - // ------------------------------------------ - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; + // Use Swift Mailer library + // ------------------------------------------ + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; // Clean parameters if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP'); @@ -849,22 +849,22 @@ class CMailFile //$smtps->_msgReplyTo = 'reply@web.com'; // Switch content encoding to base64 - avoid the doubledot issue with quoted-printable - $contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); - $this->message->setEncoder($contentEncoderBase64); + $contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + $this->message->setEncoder($contentEncoderBase64); // Create the Mailer using your created Transport $this->mailer = new Swift_Mailer($this->transport); - // DKIM SIGN - if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) { - $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; - $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; - $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; - $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector); - $this->message->attachSigner($signer->ignoreHeader('Return-Path')); - } + // DKIM SIGN + if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) { + $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector); + $this->message->attachSigner($signer->ignoreHeader('Return-Path')); + } - if (!empty($conf->global->MAIN_MAIL_DEBUG)) { + if (!empty($conf->global->MAIN_MAIL_DEBUG)) { // To use the ArrayLogger $this->logger = new Swift_Plugins_Loggers_ArrayLogger(); // Or to use the Echo Logger @@ -924,7 +924,7 @@ class CMailFile return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?='; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read a file on disk and return encoded content for emails (mode = 'mail') * @@ -933,7 +933,7 @@ class CMailFile */ private function _encode_file($sourcefile) { - // phpcs:enable + // phpcs:enable $newsourcefile = dol_osencode($sourcefile); if (is_readable($newsourcefile)) @@ -949,7 +949,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write content of a SMTP request into a dump file (mode = all) * Used for debugging. @@ -959,7 +959,7 @@ class CMailFile */ public function dump_mail() { - // phpcs:enable + // phpcs:enable global $conf, $dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir @@ -1040,7 +1040,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create SMTP headers (mode = 'mail') * @@ -1048,7 +1048,7 @@ class CMailFile */ public function write_smtpheaders() { - // phpcs:enable + // phpcs:enable global $conf; $out = ""; @@ -1104,7 +1104,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create header MIME (mode = 'mail') * @@ -1114,7 +1114,7 @@ class CMailFile */ public function write_mimeheaders($filename_list, $mimefilename_list) { - // phpcs:enable + // phpcs:enable $mimedone = 0; $out = ""; @@ -1135,7 +1135,7 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return email content (mode = 'mail') * @@ -1144,7 +1144,7 @@ class CMailFile */ public function write_body($msgtext) { - // phpcs:enable + // phpcs:enable global $conf; $out = ''; @@ -1235,7 +1235,7 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach file to email (mode = 'mail') * @@ -1246,7 +1246,7 @@ class CMailFile */ public function write_files($filename_list, $mimetype_list, $mimefilename_list) { - // phpcs:enable + // phpcs:enable $out = ''; $filename_list_size = count($filename_list); @@ -1282,7 +1282,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach an image to email (mode = 'mail') * @@ -1291,7 +1291,7 @@ class CMailFile */ public function write_images($images_list) { - // phpcs:enable + // phpcs:enable $out = ''; if (is_array($images_list)) @@ -1315,7 +1315,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Try to create a socket connection * @@ -1325,7 +1325,7 @@ class CMailFile */ public function check_server_port($host, $port) { - // phpcs:enable + // phpcs:enable global $conf; $_retVal = 0; @@ -1356,7 +1356,7 @@ class CMailFile dol_syslog("Try socket connection to host=".$host." port=".$port); //See if we can connect to the SMTP server - if ($socket = @fsockopen( + if ($socket = @fsockopen( $host, // Host to test, IP or domain. Add ssl:// for SSL/TLS. $port, // which Port number to use $errno, // actual system level error @@ -1377,7 +1377,7 @@ class CMailFile return $_retVal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This function has been modified as provided by SirSir to allow multiline responses when * using SMTP Extensions. @@ -1388,7 +1388,7 @@ class CMailFile */ public function server_parse($socket, $response) { - // phpcs:enable + // phpcs:enable $_retVal = true; // Indicates if Object was created or not $server_response = ''; @@ -1512,8 +1512,8 @@ class CMailFile * If format 2: 'john@doe.com' * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists - * If format 5: John Doe or john@doe.com if no label exists - * @see getArrayAddress() + * If format 5: John Doe or john@doe.com if no label exists + * @see getArrayAddress() */ public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { @@ -1541,10 +1541,10 @@ class CMailFile $i++; $newemail = ''; - if ($format == 5) { - $newemail = $name ? $name : $email; - $newemail = ''.$newemail.''; - } + if ($format == 5) { + $newemail = $name ? $name : $email; + $newemail = ''.$newemail.''; + } if ($format == 4) { $newemail = $name ? $name : $email; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8b7baaee7c9..d3abceb7097 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -222,9 +222,9 @@ abstract class CommonObject * @var string * @see getFullAddress(), isInEEC(), country */ - public $country_code; + public $country_code; - /** + /** * @var string * @see getFullAddress() */ @@ -240,7 +240,7 @@ abstract class CommonObject * @var string * @see getFullAddress(), $state */ - public $state_code; + public $state_code; /** * @var int @@ -252,15 +252,15 @@ abstract class CommonObject * @var string * @see getFullAddress(), $region_id, $region */ - public $region_code; + public $region_code; - /** - * @var string - * @see getFullAddress(), $region_id, $region_code - */ - public $region; + /** + * @var string + * @see getFullAddress(), $region_id, $region_code + */ + public $region; - /** + /** * @var int * @see fetch_barcode() */ @@ -416,25 +416,25 @@ abstract class CommonObject */ public $name; - /** - * @var string The lastname - */ + /** + * @var string The lastname + */ public $lastname; - /** - * @var string The firstname - */ + /** + * @var string The firstname + */ public $firstname; - /** - * @var string The civility code, not an integer - */ + /** + * @var string The civility code, not an integer + */ public $civility_id; // Dates /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; /** @@ -521,16 +521,16 @@ abstract class CommonObject */ public function getFormatedCustomerRef($objref) { - global $hookmanager; + global $hookmanager; - $parameters = array('objref'=>$objref); - $action = ''; - $reshook = $hookmanager->executeHooks('getFormatedCustomerRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) - { - return $hookmanager->resArray['objref']; - } - return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); + $parameters = array('objref'=>$objref); + $action = ''; + $reshook = $hookmanager->executeHooks('getFormatedCustomerRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) + { + return $hookmanager->resArray['objref']; + } + return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); } /** @@ -541,16 +541,16 @@ abstract class CommonObject */ public function getFormatedSupplierRef($objref) { - global $hookmanager; + global $hookmanager; - $parameters = array('objref'=>$objref); - $action = ''; - $reshook = $hookmanager->executeHooks('getFormatedSupplierRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) - { - return $hookmanager->resArray['objref']; - } - return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); + $parameters = array('objref'=>$objref); + $action = ''; + $reshook = $hookmanager->executeHooks('getFormatedSupplierRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) + { + return $hookmanager->resArray['objref']; + } + return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); } /** @@ -622,15 +622,15 @@ abstract class CommonObject $this->country = $tmparray['label']; } - if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_code))) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $tmparray = getState($this->state_id, 'all', 0, 1); + if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_code))) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + $tmparray = getState($this->state_id, 'all', 0, 1); $this->state_code = $tmparray['code']; $this->state = $tmparray['label']; $this->region_code = $tmparray['region_code']; $this->region = $tmparray['region']; - } + } return dol_format_address($this, $withcountry, $sep, '', 0, $extralangcode); } @@ -703,7 +703,7 @@ abstract class CommonObject if (!empty($extralanguages->attributes[$elementforaltlanguage]['address']) || !empty($extralanguages->attributes[$elementforaltlanguage]['town'])) { - $out .= "\n"; + $out .= "\n"; $this->fetchValuesForExtraLanguages(); if (!is_object($form)) $form = new Form($this->db); $htmltext = ''; @@ -721,11 +721,11 @@ abstract class CommonObject if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { - $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state; - } else { - $out .= ($outdone ? ' - ' : '').$this->state; - } + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { + $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state; + } else { + $out .= ($outdone ? ' - ' : '').$this->state; + } $outdone++; } @@ -764,8 +764,8 @@ abstract class CommonObject } if (!empty($this->url)) { - //$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank - $out .= dol_print_url($this->url, '_blank', 0, 1); + //$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank + $out .= dol_print_url($this->url, '_blank', 0, 1); $outdone++; } @@ -890,7 +890,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a link between element $this->element and a contact * @@ -902,7 +902,7 @@ abstract class CommonObject */ public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user, $langs; @@ -1007,7 +1007,7 @@ abstract class CommonObject } else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Copy contact from one element to current * @@ -1017,7 +1017,7 @@ abstract class CommonObject */ public function copy_linked_contact($objFrom, $source = 'internal') { - // phpcs:enable + // phpcs:enable $contacts = $objFrom->liste_contact(-1, $source); foreach ($contacts as $contact) { @@ -1030,7 +1030,7 @@ abstract class CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a link to contact line * @@ -1042,7 +1042,7 @@ abstract class CommonObject */ public function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) { - // phpcs:enable + // phpcs:enable // Insert into database $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; $sql .= " statut = ".$statut; @@ -1059,7 +1059,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to contact line * @@ -1069,7 +1069,7 @@ abstract class CommonObject */ public function delete_contact($rowid, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user; @@ -1096,7 +1096,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete all links between an object $this and all its contacts * @@ -1106,7 +1106,7 @@ abstract class CommonObject */ public function delete_linked_contact($source = '', $code = '') { - // phpcs:enable + // phpcs:enable $temp = array(); $typeContact = $this->liste_type_contact($source, '', 0, 0, $code); @@ -1131,7 +1131,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get array of all contacts for an object * @@ -1143,7 +1143,7 @@ abstract class CommonObject */ public function liste_contact($status = -1, $source = 'external', $list = 0, $code = '') { - // phpcs:enable + // phpcs:enable global $langs; $tab = array(); @@ -1234,7 +1234,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array with list of possible values for type of contacts * @@ -1247,7 +1247,7 @@ abstract class CommonObject */ public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') { - // phpcs:enable + // phpcs:enable global $langs; if (empty($order)) $order = 'position'; @@ -1430,7 +1430,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object contact with id=$this->contact_id into $this->contact * @@ -1439,7 +1439,7 @@ abstract class CommonObject */ public function fetch_contact($contactid = null) { - // phpcs:enable + // phpcs:enable if (empty($contactid)) $contactid = $this->contact_id; if (empty($contactid)) return 0; @@ -1451,7 +1451,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty * @@ -1460,7 +1460,7 @@ abstract class CommonObject */ public function fetch_thirdparty($force_thirdparty_id = 0) { - // phpcs:enable + // phpcs:enable global $conf; if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) @@ -1513,7 +1513,7 @@ abstract class CommonObject return $this->fetch($result->rowid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load data for barcode into properties ->barcode_type* * Properties ->barcode_type that is id of barcode. Type is used to find other properties, but @@ -1523,7 +1523,7 @@ abstract class CommonObject */ public function fetch_barcode() { - // phpcs:enable + // phpcs:enable global $conf; dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type); @@ -1562,7 +1562,7 @@ abstract class CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the project with id $this->fk_project into this->project * @@ -1570,7 +1570,7 @@ abstract class CommonObject */ public function fetch_projet() { - // phpcs:enable + // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (empty($this->fk_project) && !empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility @@ -1584,7 +1584,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the product with id $this->fk_product into this->product * @@ -1592,7 +1592,7 @@ abstract class CommonObject */ public function fetch_product() { - // phpcs:enable + // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (empty($this->fk_product)) return 0; @@ -1604,7 +1604,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the user with id $userid into this->user * @@ -1613,14 +1613,14 @@ abstract class CommonObject */ public function fetch_user($userid) { - // phpcs:enable + // phpcs:enable $user = new User($this->db); $result = $user->fetch($userid); $this->user = $user; return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read linked origin object * @@ -1628,10 +1628,10 @@ abstract class CommonObject */ public function fetch_origin() { - // phpcs:enable + // phpcs:enable if ($this->origin == 'shipping') $this->origin = 'expedition'; if ($this->origin == 'delivery') $this->origin = 'livraison'; - if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur'; + if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur'; $origin = $this->origin; @@ -1641,14 +1641,14 @@ abstract class CommonObject } /** - * Load object from specific field - * - * @param string $table Table element or element line - * @param string $field Field selected - * @param string $key Import key - * @param string $element Element name - * @return int <0 if KO, >0 if OK - */ + * Load object from specific field + * + * @param string $table Table element or element line + * @param string $field Field selected + * @param string $key Import key + * @param string $element Element name + * @return int <0 if KO, >0 if OK + */ public function fetchObjectFrom($table, $field, $key, $element = null) { global $conf; @@ -1783,7 +1783,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load properties id_previous and id_next by comparing $fieldid with $this->ref * @@ -1794,7 +1794,7 @@ abstract class CommonObject */ public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) { - // phpcs:enable + // phpcs:enable global $conf, $user; if (!$this->table_element) @@ -1824,7 +1824,7 @@ abstract class CommonObject } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; - $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) + $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; if (!empty($filter)) @@ -1877,7 +1877,7 @@ abstract class CommonObject } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; - $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) + $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; if (!empty($filter)) @@ -2217,29 +2217,29 @@ abstract class CommonObject */ public function setRetainedWarrantyPaymentTerms($id) { - dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms('.$id.')'); - if ($this->statut >= 0 || $this->element == 'societe') - { - $fieldname = 'retained_warranty_fk_cond_reglement'; + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'retained_warranty_fk_cond_reglement'; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$id; - $sql .= ' WHERE rowid='.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { - $this->retained_warranty_fk_cond_reglement = $id; - return 1; - } else { - dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); - $this->error = $this->db->error(); - return -1; - } - } else { - dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible'); - $this->error = 'Status of the object is incompatible '.$this->statut; - return -2; - } + if ($this->db->query($sql)) + { + $this->retained_warranty_fk_cond_reglement = $id; + return 1; + } else { + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); + $this->error = $this->db->error(); + return -1; + } + } else { + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible'); + $this->error = 'Status of the object is incompatible '.$this->statut; + return -2; + } } /** @@ -2384,7 +2384,7 @@ abstract class CommonObject if ($resql) { $this->model_pdf = $modelpdf; - $this->modelpdf = $modelpdf; // For bakward compatibility + $this->modelpdf = $modelpdf; // For bakward compatibility return 1; } else { dol_print_error($this->db); @@ -2452,7 +2452,7 @@ abstract class CommonObject // TODO: Move line related operations to CommonObjectLine? - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. @@ -2464,7 +2464,7 @@ abstract class CommonObject */ public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) { - // phpcs:enable + // phpcs:enable if (!$this->table_element_line) { dol_syslog(get_class($this)."::line_order was called on objet with property table_element_line not defined", LOG_ERR); @@ -2568,7 +2568,7 @@ abstract class CommonObject return $rows; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a lower rank * @@ -2578,7 +2578,7 @@ abstract class CommonObject */ public function line_up($rowid, $fk_parent_line = true) { - // phpcs:enable + // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); // Get rang of line @@ -2588,7 +2588,7 @@ abstract class CommonObject $this->updateLineUp($rowid, $rang); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a higher rank * @@ -2598,7 +2598,7 @@ abstract class CommonObject */ public function line_down($rowid, $fk_parent_line = true) { - // phpcs:enable + // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); // Get rang of line @@ -2633,7 +2633,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update position of line with ajax (rang) * @@ -2642,7 +2642,7 @@ abstract class CommonObject */ public function line_ajaxorder($rows) { - // phpcs:enable + // phpcs:enable $num = count($rows); for ($i = 0; $i < $num; $i++) { @@ -2752,7 +2752,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value used for position of line (rang) * @@ -2761,8 +2761,8 @@ abstract class CommonObject */ public function line_max($fk_parent_line = 0) { - // phpcs:enable - $positionfield = 'rang'; + // phpcs:enable + $positionfield = 'rang'; if ($this->table_element == 'bom') $positionfield = 'position'; // Search the last rang with fk_parent_line @@ -2800,7 +2800,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update external ref of element * @@ -2809,7 +2809,7 @@ abstract class CommonObject */ public function update_ref_ext($ref_ext) { - // phpcs:enable + // phpcs:enable if (!$this->table_element) { dol_syslog(get_class($this)."::update_ref_ext was called on objet with property table_element not defined", LOG_ERR); @@ -2831,7 +2831,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update note of element * @@ -2841,7 +2841,7 @@ abstract class CommonObject */ public function update_note($note, $suffix = '') { - // phpcs:enable + // phpcs:enable global $user; if (!$this->table_element) @@ -2883,7 +2883,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update public note (kept for backward compatibility) * @@ -2894,11 +2894,11 @@ abstract class CommonObject */ public function update_note_public($note) { - // phpcs:enable + // phpcs:enable return $this->update_note($note, '_public'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines). * Must be called at end of methods addline or updateline. @@ -2911,16 +2911,16 @@ abstract class CommonObject */ public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) { - // phpcs:enable + // phpcs:enable global $conf, $hookmanager, $action; - $parameters = array('exclspec' => $exclspec, 'roundingadjust' => $roundingadjust, 'nodatabaseupdate' => $nodatabaseupdate, 'seller' => $seller); - $reshook = $hookmanager->executeHooks('updateTotalPrice', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) { - return 1; // replacement code - } elseif ($reshook < 0) { - return -1; // failure - } // reshook = 0 => execute normal code + $parameters = array('exclspec' => $exclspec, 'roundingadjust' => $roundingadjust, 'nodatabaseupdate' => $nodatabaseupdate, 'seller' => $seller); + $reshook = $hookmanager->executeHooks('updateTotalPrice', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + return 1; // replacement code + } elseif ($reshook < 0) { + return -1; // failure + } // reshook = 0 => execute normal code // Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield) $MODULE = ""; @@ -3803,7 +3803,7 @@ abstract class CommonObject } $weight = $line->weight ? $line->weight : 0; - ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0; + ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0; $volume = $line->volume ? $line->volume : 0; ($volume == 0 && !empty($line->product->volume)) ? $volume = $line->product->volume : 0; @@ -3882,7 +3882,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return incoterms informations * TODO Use a cache for label get @@ -3891,7 +3891,7 @@ abstract class CommonObject */ public function display_incoterms() { - // phpcs:enable + // phpcs:enable $out = ''; $this->label_incoterms = ''; if (!empty($this->fk_incoterms)) @@ -4275,8 +4275,8 @@ abstract class CommonObject print ''.$langs->trans('Unit').''; } print ''.$langs->trans('ReductionShort').''; - print ''.$form->showCheckAddButtons('checkforselect', 1).''; - print ''; + print ''.$form->showCheckAddButtons('checkforselect', 1).''; + print ''; $i = 0; if (!empty($this->lines)) @@ -4333,7 +4333,7 @@ abstract class CommonObject if ($line->date_fin_reel) $date_end = $line->date_fin_reel; } - $this->tpl['id'] = $line->id; + $this->tpl['id'] = $line->id; $this->tpl['label'] = ''; if (!empty($line->fk_parent_line)) $this->tpl['label'] .= img_picto('', 'rightarrow'); @@ -4405,10 +4405,10 @@ abstract class CommonObject $this->tpl['description'] = ' '; } - // VAT Rate - $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); - $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; - if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; + // VAT Rate + $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; + if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; $this->tpl['price'] = price($line->subprice); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); @@ -4442,7 +4442,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add resources to the current object : add entry into llx_element_resources * Need $this->element & $this->id @@ -4455,7 +4455,7 @@ abstract class CommonObject */ public function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) { - // phpcs:enable + // phpcs:enable $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources ("; @@ -4486,7 +4486,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to resource line * @@ -4497,7 +4497,7 @@ abstract class CommonObject */ public function delete_resource($rowid, $element, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user; $this->db->begin(); @@ -4797,7 +4797,7 @@ abstract class CommonObject return -1; } } else { - if (! $filefound) { + if (!$filefound) { $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; dol_print_error('', $this->error); } else { @@ -5287,7 +5287,7 @@ abstract class CommonObject if ($this->array_options[$key] === '') $mandatorypb = true; if ($mandatorypb) { - dol_syslog("Mandatory extra field ".$key." is empty"); + dol_syslog("Mandatory extra field ".$key." is empty"); $this->errors[] = $langs->trans('ErrorFieldRequired', $attributeLabel); return -1; } @@ -5301,8 +5301,8 @@ abstract class CommonObject if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { $value = dol_eval($attrfieldcomputed, 1, 0); - dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); - $new_array_options[$key] = $value; + dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); + $new_array_options[$key] = $value; } else { $new_array_options[$key] = null; } @@ -5433,13 +5433,13 @@ abstract class CommonObject // We must insert a default value for fields for other entities that are mandatory to avoid not null error if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) { - foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) - { - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously - { - $sql .= ",".$tmpkey; - } - } + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously + { + $sql .= ",".$tmpkey; + } + } } $sql .= ") VALUES (".$this->id; @@ -5460,14 +5460,14 @@ abstract class CommonObject // We must insert a default value for fields for other entities that are mandatory to avoid not null error if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) { - foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) - { - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously - { - if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0"; - else $sql .= ", ''"; - } - } + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously + { + if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0"; + else $sql .= ", ''"; + } + } } $sql .= ")"; @@ -5796,38 +5796,38 @@ abstract class CommonObject } $out = ''; - $type = ''; - $param = array(); - $param['options'] = array(); - $reg = array(); - $size = $this->fields[$key]['size']; - // Because we work on extrafields - if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N'); - $type = 'link'; - } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4] => 'N'); - $type = 'link'; - } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[2].':'.$reg[3] => 'N'); - $type = 'link'; - } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); - $type = 'sellist'; - } elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { - $param['options'] = array(); - $type = 'varchar'; - $size = $reg[1]; - } elseif (preg_match('/varchar/', $val['type'])) { - $param['options'] = array(); - $type = 'varchar'; - } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { - $param['options'] = $this->fields[$key]['arrayofkeyval']; - $type = 'select'; - } else { - $param['options'] = array(); - $type = $this->fields[$key]['type']; - } + $type = ''; + $param = array(); + $param['options'] = array(); + $reg = array(); + $size = $this->fields[$key]['size']; + // Because we work on extrafields + if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N'); + $type = 'link'; + } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4] => 'N'); + $type = 'link'; + } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[2].':'.$reg[3] => 'N'); + $type = 'link'; + } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); + $type = 'sellist'; + } elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { + $param['options'] = array(); + $type = 'varchar'; + $size = $reg[1]; + } elseif (preg_match('/varchar/', $val['type'])) { + $param['options'] = array(); + $type = 'varchar'; + } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { + $param['options'] = $this->fields[$key]['arrayofkeyval']; + $type = 'select'; + } else { + $param['options'] = array(); + $type = $this->fields[$key]['type']; + } $label = $this->fields[$key]['label']; //$elementtype=$this->fields[$key]['elementtype']; // Seems not used @@ -5852,7 +5852,7 @@ abstract class CommonObject // Set value of $morecss. For this, we use in priority showsize from parameters, then $val['css'] then autodefine if (empty($morecss) && !empty($val['css'])) { - $morecss = $val['css']; + $morecss = $val['css']; } elseif (empty($morecss)) { if ($type == 'date') @@ -5962,7 +5962,7 @@ abstract class CommonObject } $out .= ''; + $ret .= ''; - if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.' . $name . 'select'); + if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.'.$name.'select'); // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button $ret .= ''; // Hidden button BEFORE so it is the one used when we submit with ENTER. - $ret .= ''; + $ret .= ''; $ret .= '
'; if (!empty($conf->use_javascript_ajax)) @@ -701,11 +701,11 @@ class Form } jQuery(document).ready(function () { - initCheckForSelect(0, "' . $name . '", "' . $cssclass . '"); - jQuery(".' . $cssclass . '").click(function() { - initCheckForSelect(1, "'.$name.'", "' . $cssclass . '"); + initCheckForSelect(0, "' . $name.'", "'.$cssclass.'"); + jQuery(".' . $cssclass.'").click(function() { + initCheckForSelect(1, "'.$name.'", "'.$cssclass.'"); }); - jQuery(".' . $name . 'select").change(function() { + jQuery(".' . $name.'select").change(function() { var massaction = $( this ).val(); var urlform = $( this ).closest("form").attr("action").replace("#show_files",""); if (massaction == "builddoc") @@ -717,14 +717,14 @@ class Form /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */ if ($(this).val() != \'0\') { - jQuery(".' . $name . 'confirmed").prop(\'disabled\', false); - jQuery(".' . $name . 'other").hide(); /* To disable if another div was open */ - jQuery(".' . $name . '"+massaction).show(); + jQuery(".' . $name.'confirmed").prop(\'disabled\', false); + jQuery(".' . $name.'other").hide(); /* To disable if another div was open */ + jQuery(".' . $name.'"+massaction).show(); } else { - jQuery(".' . $name . 'confirmed").prop(\'disabled\', true); - jQuery(".' . $name . 'other").hide(); /* To disable any div open */ + jQuery(".' . $name.'confirmed").prop(\'disabled\', true); + jQuery(".' . $name.'other").hide(); /* To disable any div open */ } }); }); @@ -2052,7 +2052,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for a customer * @@ -2076,18 +2076,18 @@ class Form * 'warehouseinternal' = count products from warehouses for internal correct/transfer only * @return array Array of keys for json */ - public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') + public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf, $user, $db; $out = ''; $outarray = array(); - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $langs->load('other'); - } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $langs->load('other'); + } $warehouseStatusArray = array(); if (!empty($warehouseStatus)) @@ -2110,9 +2110,9 @@ class Form $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; if (count($warehouseStatusArray)) { - $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock + $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock } else { - $selectFieldsGrouped = ", ".$db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; + $selectFieldsGrouped = ", ".$db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; } $sql = "SELECT "; @@ -2135,11 +2135,11 @@ class Form $sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; $selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; } - // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; - $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; - } + // Units + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; + $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; + } // Multilang : we add translation if (!empty($conf->global->MAIN_MULTILANGS)) @@ -2171,17 +2171,17 @@ class Form // include search in supplier ref if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; } //Price by customer if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; } - // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; - } + // Units + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; + } // Multilang : we add translation if (!empty($conf->global->MAIN_MULTILANGS)) { @@ -2289,7 +2289,7 @@ class Form if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); else $textifempty .= $langs->trans("All"); } else { - if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); + if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); } if ($showempty) $out .= ''; @@ -2429,43 +2429,43 @@ class Form if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - // Units - $outvalUnits = ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - if (!empty($objp->unit_short)) { - $outvalUnits .= ' - '.$objp->unit_short; - } - } - if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { - if (!empty($objp->weight) && $objp->weight_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->surface) && $objp->surface_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->volume) && $objp->volume_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - } - if ($outdurationvalue && $outdurationunit) { - $da = array( - 'h' => $langs->trans('Hour'), - 'd' => $langs->trans('Day'), - 'w' => $langs->trans('Week'), - 'm' => $langs->trans('Month'), - 'y' => $langs->trans('Year') - ); - if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); - } - } + // Units + $outvalUnits = ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($objp->unit_short)) { + $outvalUnits .= ' - '.$objp->unit_short; + } + } + if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { + if (!empty($objp->weight) && $objp->weight_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { + $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->surface) && $objp->surface_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->volume) && $objp->volume_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + } + } $opt = '\n"; $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) * @@ -2668,9 +2668,9 @@ class Form * @param string $morecss More CSS * @return void */ - public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; global $price_level, $status, $finished; @@ -2695,7 +2695,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers products * @@ -2712,9 +2712,9 @@ class Form * @param string $morecss Add more CSS * @return array Array of keys for json */ - public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf, $db; $out = ''; @@ -2723,28 +2723,28 @@ class Form $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO); $langs->load('stocks'); - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $langs->load('other'); - } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $langs->load('other'); + } $sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,"; $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; $sql .= " pfp.supplier_reputation"; - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; - } - if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; + } + if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".getEntity('product').") )"; if ($socid) $sql .= " AND pfp.fk_soc = ".$socid; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; - } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; + } $sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " AND p.tobuy = 1"; if (strval($filtertype) != '') $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype); @@ -2766,9 +2766,9 @@ class Form } if (count($scrit) > 1) $sql .= ")"; if (!empty($conf->barcode->enabled)) { - $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - } + $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + } $sql .= ')'; } $sql .= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; @@ -2807,41 +2807,41 @@ class Form $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; $outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : ''; - // Units - $outvalUnits = ''; - if ($conf->global->PRODUCT_USE_UNITS) { - if (!empty($objp->unit_short)) { - $outvalUnits .= ' - '.$objp->unit_short; - } - if (!empty($objp->weight) && $objp->weight_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->surface) && $objp->surface_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->volume) && $objp->volume_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if ($outdurationvalue && $outdurationunit) { - $da = array( - 'h' => $langs->trans('Hour'), - 'd' => $langs->trans('Day'), - 'w' => $langs->trans('Week'), - 'm' => $langs->trans('Month'), - 'y' => $langs->trans('Year') - ); - if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); - } - } - } + // Units + $outvalUnits = ''; + if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($objp->unit_short)) { + $outvalUnits .= ' - '.$objp->unit_short; + } + if (!empty($objp->weight) && $objp->weight_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { + $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->surface) && $objp->surface_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->volume) && $objp->volume_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + } + } + } $objRef = $objp->ref; if ($filterkey && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $objRef, 1); @@ -2868,7 +2868,7 @@ class Form } $outvallabel .= ' - '.dol_trunc($label, $maxlengtharticle); - // Units + // Units $optlabel .= $outvalUnits; $outvallabel .= $outvalUnits; @@ -2992,7 +2992,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers prices for a product * @@ -3001,9 +3001,9 @@ class Form * @param int $selected_supplier Pre-selected supplier if more than 1 result * @return string */ - public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') + public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $langs->load('stocks'); @@ -3099,7 +3099,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of delivery address * @@ -3109,9 +3109,9 @@ class Form * @param int $showempty Add an empty field * @return integer|null */ - public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) + public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) { - // phpcs:enable + // phpcs:enable // looking for users $sql = "SELECT a.rowid, a.label"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_address as a"; @@ -3149,15 +3149,15 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache list of payment terms * * @return int Nb of lines loaded, <0 if KO */ - public function load_cache_conditions_paiements() + public function load_cache_conditions_paiements() { - // phpcs:enable + // phpcs:enable global $langs; $num = count($this->cache_conditions_paiements); @@ -3196,15 +3196,15 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des délais de livraison possibles * * @return int Nb of lines loaded, <0 if KO */ - public function load_cache_availability() + public function load_cache_availability() { - // phpcs:enable + // phpcs:enable global $langs; $num = count($this->cache_availability); @@ -3252,7 +3252,7 @@ class Form * @param int $addempty Add empty entry * @return void */ - public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) + public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) { global $langs, $user; @@ -3282,7 +3282,7 @@ class Form * * @return int Nb of lines loaded, <0 if KO */ - public function loadCacheInputReason() + public function loadCacheInputReason() { global $langs; @@ -3334,7 +3334,7 @@ class Form * @param int $addempty Add an empty entry * @return void */ - public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) + public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) { global $langs, $user; @@ -3360,15 +3360,15 @@ class Form if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des types de paiements possibles * * @return int Nb of lines loaded, <0 if KO */ - public function load_cache_types_paiements() + public function load_cache_types_paiements() { - // phpcs:enable + // phpcs:enable global $langs; $num = count($this->cache_types_paiements); @@ -3412,7 +3412,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment modes. * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. @@ -3426,9 +3426,9 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') + public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $user, $conf; dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); @@ -3456,7 +3456,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment methods * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. @@ -3472,9 +3472,9 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $user, $conf; dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); @@ -3532,7 +3532,7 @@ class Form * @param string $htmlname Nom de la zone select * @return string Code of HTML select to chose tax or not */ - public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') + public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') { global $langs; @@ -3568,7 +3568,7 @@ class Form * @param string $moreattrib To add more attribute on select * @return void */ - public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') + public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') { global $langs, $conf, $user; @@ -3621,7 +3621,7 @@ class Form * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) + public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) { global $langs, $db; @@ -3652,7 +3652,7 @@ class Form * * @return string HTML select */ - public function selectSituationInvoices($selected = '', $socid = 0) + public function selectSituationInvoices($selected = '', $socid = 0) { global $langs; @@ -3673,17 +3673,17 @@ class Form $ref = 0; while ($obj = $this->db->fetch_object($resql)) { //Same cycle ? - if ($obj->situation_cycle_ref != $ref) { + if ($obj->situation_cycle_ref != $ref) { // Just seen this cycle - $ref = $obj->situation_cycle_ref; + $ref = $obj->situation_cycle_ref; //not final ? - if ($obj->situation_final != 1) { + if ($obj->situation_final != 1) { //Not prov? - if (substr($obj->ref, 1, 4) != 'PROV') { - if ($selected == $obj->rowid) { - $opt .= ''; + if (substr($obj->ref, 1, 4) != 'PROV') { + if ($selected == $obj->rowid) { + $opt .= ''; } else { - $opt .= ''; + $opt .= ''; } } } @@ -3707,7 +3707,7 @@ class Form * @param int $showempty Add a nempty line * @return string HTML select */ - public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) + public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) { global $langs; @@ -3725,17 +3725,17 @@ class Form while ($res = $this->db->fetch_object($resql)) { - $unitLabel = $res->label; - if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before - { - $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; - } + $unitLabel = $res->label; + if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before + { + $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; + } if ($selected == $res->rowid) { - $return .= ''; + $return .= ''; } else { - $return .= ''; + $return .= ''; } } $return .= ''; @@ -3743,7 +3743,7 @@ class Form return $return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list of bank accounts * @@ -3757,9 +3757,9 @@ class Form * @param string $morecss More CSS * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) */ - public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') + public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $langs->load("admin"); @@ -3826,7 +3826,7 @@ class Form */ public function selectEstablishments($selected = '', $htmlname = 'entity', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $langs->load("admin"); @@ -3886,7 +3886,7 @@ class Form * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) + public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) { global $langs; if ($htmlname != "none") { @@ -3910,7 +3910,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of categories having choosed type * @@ -3918,20 +3918,20 @@ class Form * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element). Not used if $outputmode = 1. * @param string $htmlname HTML field name * @param int $maxlength Maximum length for labels - * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. - * $markafterid can be an : - * - int (id of category) - * - string (categories ids seprated by comma) - * - array (list of categories ids) + * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. + * $markafterid can be an : + * - int (id of category) + * - string (categories ids seprated by comma) + * - array (list of categories ids) * @param int $outputmode 0=HTML select string, 1=Array - * @param int $include [=0] Removed or 1=Keep only - * @param string $morecss More CSS + * @param int $include [=0] Removed or 1=Keep only + * @param string $morecss More CSS * @return string * @see select_categories() */ - public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '') + public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $conf, $langs; $langs->load("categories"); @@ -3966,7 +3966,7 @@ class Form } else dol_print_error($this->db); } else { $cat = new Categorie($this->db); - $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); + $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); } $output = ''; foreach ($TDurationTypes as $key=>$typeduration) { @@ -5699,9 +5699,9 @@ class Form return $retstring; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Function to show a form to select a duration on a page + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to show a form to select a duration on a page * * @param string $prefix Prefix for input fields * @param int $iSecond Default preselected duration (number of seconds or '') @@ -5713,9 +5713,9 @@ class Form * @param int $nooutput Do not output html string but return it * @return string|void */ - public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) + public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) { - // phpcs:enable + // phpcs:enable global $langs; $retstring = ''; @@ -5843,16 +5843,16 @@ class Form $out = ''; if (!empty($conf->use_javascript_ajax) && !empty($conf->global->$confkeyforautocompletemode) && !$forcecombo) { - // No immediate load of all database - $placeholder = ''; - if ($preselectedvalue && empty($selected_input_value)) - { - $objecttmp->fetch($preselectedvalue); - $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref); - //unset($objecttmp); - } + // No immediate load of all database + $placeholder = ''; + if ($preselectedvalue && empty($selected_input_value)) + { + $objecttmp->fetch($preselectedvalue); + $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref); + //unset($objecttmp); + } - $objectdesc = $classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; + $objectdesc = $classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php'; // No immediate load of all database @@ -5914,7 +5914,7 @@ class Form * @return string|array Return HTML string * @see selectForForms() */ - public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0) + public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0) { global $conf, $langs, $user; @@ -5935,7 +5935,7 @@ class Form } else { // For backward compatibility $objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1); - } + } if (empty($fieldstoshow)) { @@ -6119,8 +6119,8 @@ class Form { foreach ($array as $key => $value) { - if (!is_array($value)) $array[$key] = $langs->trans($value); - else $array[$key]['label'] = $langs->trans($value['label']); + if (!is_array($value)) $array[$key] = $langs->trans($value); + else $array[$key]['label'] = $langs->trans($value['label']); } } @@ -6130,14 +6130,14 @@ class Form foreach ($array as $key => $tmpvalue) { - if (is_array($tmpvalue)) $value = $tmpvalue['label']; - else $value = $tmpvalue; + if (is_array($tmpvalue)) $value = $tmpvalue['label']; + else $value = $tmpvalue; $disabled = ''; $style = ''; if (!empty($disablebademail)) { - if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) - || ($disablebademail == 2 && preg_match('/---/', $value))) + if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) + || ($disablebademail == 2 && preg_match('/---/', $value))) { $disabled = ' disabled'; $style = ' class="warning"'; @@ -6165,10 +6165,10 @@ class Form if ($nohtmlescape) $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"'; if (is_array($tmpvalue)) { - foreach ($tmpvalue as $keyforvalue => $valueforvalue) - { - if (preg_match('/^data-/', $keyforvalue)) $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"'; - } + foreach ($tmpvalue as $keyforvalue => $valueforvalue) + { + if (preg_match('/^data-/', $keyforvalue)) $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"'; + } } $out .= '>'; //var_dump($selectOptionValue); @@ -6282,11 +6282,11 @@ class Form return $out; } - /** - * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. - * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. - * - * @param string $htmlname Name of html select area + /** + * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. + * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. + * + * @param string $htmlname Name of html select area * @param string $array Array (key=>array('text'=>'A text', 'url'=>'An url'), ...) * @param string $id Preselected key * @param string $moreparam Add more parameters onto the select tag @@ -6423,8 +6423,8 @@ class Form $out = ''; if ($addjscombo < 0) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1; - else $addjscombo = 0; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1; + else $addjscombo = 0; } // Add code for jquery to use multiselect @@ -6495,7 +6495,7 @@ class Form $newval = ($key_in_label ? $key.' - '.$newval : $newval); $out .= '