diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index 3cfc4f8ba23..c2f8cc12765 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -13,5 +13,5 @@ jobs: - name: Exakat uses: docker://exakat/exakat-ga with: - ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' + ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' ignore_dirs: '/htdocs/includes,/build,/dev,/doc,/scripts,/test' \ No newline at end of file diff --git a/COPYRIGHT b/COPYRIGHT index d43f4d506f1..adf7d38c04b 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -39,7 +39,7 @@ TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes JS libraries: Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea. -ChartJS 2.9.3 MIT License Yes JS library for graph +ChartJS 2.9.4 MIT License Yes JS library for graph jQuery 3.5.1 MIT License Yes JS library jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css diff --git a/ChangeLog b/ChangeLog index 4745cea7736..782528daae8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ NEW: Accountancy - change menu disposition NEW: Accountancy - on transfers, select the periodicity by default NEW: Accountancy - Add export for Gestinum (v3 & v5) NEW: new currency rate editor +NEW: add a widget to show the customers with outstanding limits reached NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr NEW: add a counter of number of words for pages in website module NEW: add alert before changing thirdparty in TakePOS @@ -30,7 +31,7 @@ NEW: add column payment term into list of supplier invoices NEW: add column quantity in product margin page NEW: add column vat rate in page to define accounting account on product/service NEW: add costprice in fields of products list -NEW: added an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE +NEW: add an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE NEW: add employee link in expense report binding page NEW: add EORI No. as ProfID5 NEW: add export for various payments @@ -167,7 +168,8 @@ NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding am NEW: ticket classification on create from email collector NEW: Ticket message notifications when edited from public interface NEW: translate classification labels in ticket -NEW: Add VAT and juridical status for Algeria +NEW: VAT rate for Angola #15606 +NEW: VAT and juridical status for Algeria NEW: VAT report - Invert constant to show by default zero VAT in reports NEW: website page fields selection NEW: Weighing Scale compatibility with TakePOS connector @@ -178,13 +180,10 @@ NEW: #15065 Add option to put the product label in bold in the PDF templates if For developers: --------------- -NEW: Hook on propal card NEW: add __MEMBER_TYPE__ substitution key +NEW: add __TYPE__ substitution key NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open page into a popup -NEW: add hooks on stats pages NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) -NEW: API get contacts list of a given order -NEW: API endpoint getContacts and Clean results NEW: Add some fields to link website page to an other object NEW: fill ECM src object fields in dol_add_file_process NEW: conf to allow to show the full tree in warehouse popup @@ -194,10 +193,6 @@ NEW: can add event to log into blockedlog module with a constant NEW: add property cssview when declaring fields of an object NEW: Can use dynamic code into the 'enabled' property of DAO fields NEW: allow to edit "demand reason" field though API -NEW: API can update a payment -NEW: API get member by thirdparty -NEW: API get thirdparty by barcode -NEW: API get users by email / login NEW: fetch contact by email with REST API NEW: field ref_ext in llx_commandedet NEW: fields ref_ext for Attributes and Combinations @@ -210,15 +205,27 @@ NEW: standardizes API thirdparties by email like other object NEW: Thirdparty REST API: endpoint to set price level NEW: use new category API for project list view NEW: Triggers Attributes and Attributes values -NEW: add hooks on newpayment page to allow external payment modules NEW: added incoterms data into the substitution array -NEW: add formConfirm hook on product page NEW: add send context for ticket NEW: add a message in error_log after detection of SQL or script injection -NEW: add two hooks printFieldListFrom and printFieldSearchParam -NEW: add __TYPE__ substitution key NEW: add validation of MX domain for emails NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) +NEW: Graphics can be horizontal bars + +APIs +NEW: API get contacts list of a given order +NEW: API endpoint getContacts and Clean results +NEW: API can update a payment +NEW: API get member by thirdparty +NEW: API get thirdparty by barcode +NEW: API get users by email / login + +HOOKs +NEW: Hook on propal card +NEW: add hooks on newpayment page to allow external payment modules +NEW: add hooks on stats pages +NEW: add formConfirm hook on product page +NEW: add two hooks printFieldListFrom and printFieldSearchParam WARNING: @@ -238,6 +245,7 @@ Following changes may create regressions for some external modules, but were nec * The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of simple amount. * The method select_thirdparty(), deprecated since 3.8, into html.form.class.php has been removed. * Depreciate all methods with name ->valide(). Use instead methods ->validate(). +* Function showStripePaymentUrl, getStripePaymentUrl, showPaypalPaymentUrl and getPaypalPaymentUrl has been removed. The generic one showOnlinePaymentUrl and getOnlinePaymentUrl are always used. ***** ChangeLog for 12.0.3 compared to 12.0.2 ***** @@ -266,7 +274,7 @@ FIX: Look and feel v12: First tab must be name of object FIX: missing entity check FIX: missing param for hook FIX: Missing transaction on PO actions -FIX: MySql Strict mode +FIX: MySQL Strict mode FIX: param entity in html form file FIX: Problems on FEC format FIX: round stock value on product list @@ -374,8 +382,8 @@ FIX: SQL Problem in customer invoice list FIX: SQL Problem in social contribution list FIX: SQL Problem in supplier invoice list FIX: SQL syntax error when editing extrafields -FIX: Sql type -FIX: takepos 12 hook +FIX: SQL type +FIX: TakePOS 12 hook FIX: Update form erased extrafields that were hidden FIX: Update of extrafields date FIX: Update of extrafiels on draft object @@ -389,7 +397,7 @@ For users: NEW: Module MO (Manufacturing Order) is available as stable module. NEW: Receipt printer module moved from 'development' to 'experimental' -NEW: Add option MAIN_VIEW_LINE_NUMBER_IN_LIST for some lists. +NEW: add option MAIN_VIEW_LINE_NUMBER_IN_LIST for some lists NEW: add numbering module for TakePOS module NEW: 2 new options when creating an invoice from time spent on a project : by period or by task NEW: Accountancy add column thirdparty on binding page @@ -400,19 +408,19 @@ NEW: Accountancy - Add possibility to manage a short alternative label for accou NEW: Accountancy - General ledger - Add an option to search not reconciled lines NEW: Add accountancy code of thirdparty in contact and supplier export NEW: support webp image format -NEW: Add checkbox "overwrite if exists" into ECM/DMS module +NEW: add checkbox "overwrite if exists" into ECM/DMS module NEW: add a link to notes in members list NEW: add a parameter to group same products in TakePOS NEW: add a parameter to sort product by label in TakePOS -NEW: Add a profil to import contact categories -NEW: Add company extrafields into order export +NEW: add a profil to import contact categories +NEW: add company extrafields into order export NEW: add const CASHDESK_FORCE_DECREASE_STOCK to force batch decrementation NEW: add const TAKEPOS_NUMPAD_USE_PAYMENT_ICON to use icons on payment buttons NEW: add csv separator setup in module admin NEW: add dedicated substitutions keys for extrafields of type date and datetime NEW: add default warehouse for dispatch -NEW: Add due date in feature "Export accounting documents" -NEW: Add duration information for fichinter +NEW: add due date in feature "Export accounting documents" +NEW: add duration information for fichinter NEW: Start support of Dark theme into ELDY theme NEW: Add field author public alias for blog post on website module NEW: Add "finished" field on product list diff --git a/README.md b/README.md index 139bdc00b6a..29f7da1792b 100644 --- a/README.md +++ b/README.md @@ -140,15 +140,18 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Other general features - Localization in most major languages +- Multi-Language Support - Multi-Users and groups with finely grained rights -- Multi-currency -- Multi-company by adding of an external module +- Multi-Currency +- Multi-Company (by adding of an external module) + - Very user friendly and easy to use - customizable Dashboard - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- APIs +- APIs (REST, SOAP) - Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture) + - Support a lot of country specific features: - Spanish Tax RE and ISPF - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) diff --git a/SECURITY.md b/SECURITY.md index 56e1da679ed..77307516f73 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,8 +12,7 @@ This file contains some policies about the security reports on Dolibarr ERP CRM ## Reporting a Vulnerability -To report a vulnerability, please send an email to security@dolibarr.org -In most cases, after fixing the security, we make an answer by email to say the issue has been fixed. +To report a vulnerability, please use GitHub security advisory (alternatively send an email to security@dolibarr.org) ## Hunting vulnerabilities on Dolibarr diff --git a/build/README b/build/README index f7e8ebfe60b..14f2b92ae39 100644 --- a/build/README +++ b/build/README @@ -1,48 +1,62 @@ README (English) + +Path: /dolibarr/build/README + ################################################## Building packages ################################################## All sub-directories of "build" directory contains files (setup or binary tools) required to build automatically Dolibarr packages. -There are several tools: +There are several tools: - To build full Dolibarr packages, launch the script > Launch command perl makepack-dolibarr.pl -Note: Prerequisites to build tgz, debian, rpm package +-------------------------------------------------------------------------------------------------- + + +Prerequisites to build tgz, debian, rpm package: + > apt-get install tar dpkg dpatch p7zip-full rpm zip -Note: Prerequisites to build autoexe DoliWamp package: + +-------------------------------------------------------------------------------------------------- + +Prerequisites to build autoexe DoliWamp package: > apt-get install wine q4wine > Launch "wine cmd" to check a drive Z: pointing to / exists. > Install InnoSetup - For example by running isetup-5.3.9.exe (http://www.jrsoftware.org) + For example by running isetup-5.5.8.exe (https://www.jrsoftware.org) https://files.jrsoftware.org/is/5/ > Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB - For example by running wampserver3.2.0_x64.exe (http://www.wampserver.com). See file build/exe/doliwamp.iss to know the doliwamp version currently setup. + For example by running wampserver3.2.0_x64.exe (https://www.wampserver.com). + See file build/exe/doliwamp.iss to know the doliwamp version currently setup. > Add path to ISCC into PATH windows var: Launch wine cmd, then regedit and add entry int HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATH > To build manually the .exe from Windows (running from makepack-dolibarr.pl script is however recommanded), open file build/exe/doliwamp.iss and click on button "Compile". The .exe file will be build into directory build. - +-------------------------------------------------------------------------------------------------- - To build a theme package, launch the script > perl makepack-dolibarrtheme.pl +-------------------------------------------------------------------------------------------------- - To build a package for a module, launch the script > perl makepack-dolibarrmodule.pl +-------------------------------------------------------------------------------------------------- - To build developper documentation, launch the script > perl dolibarr-doxygen-build.pl +-------------------------------------------------------------------------------------------------- Note: The build directory and all its contents is absolutely not required to make Dolibarr working. diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 85212d9c5ba..17a935f6234 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -503,7 +503,10 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/mysql/README`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/pgsql/README`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/mssql`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/mssql`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/sqlite3`; + + $ret=`rm -fr $BUILDROOT/$PROJECT/node_modules`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/ansible`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/codesniffer`; @@ -578,23 +581,36 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/workstation*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; + # Removed other test files $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`; $ret=`rm -fr $BUILDROOT/$PROJECT/test`; $ret=`rm -fr $BUILDROOT/$PROJECT/Thumbs.db $BUILDROOT/$PROJECT/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/*/Thumbs.db`; $ret=`rm -f $BUILDROOT/$PROJECT/.cvsignore $BUILDROOT/$PROJECT/*/.cvsignore $BUILDROOT/$PROJECT/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.cvsignore`; $ret=`rm -f $BUILDROOT/$PROJECT/.gitignore $BUILDROOT/$PROJECT/*/.gitignore $BUILDROOT/$PROJECT/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.gitignore`; + + # Removed files installed by the awful composer $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/geoip/sample*.*`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/bin`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/adapters`; # Keep this removal in case we embed libraries $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball for official debian, not for the rest - + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/composer`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/doctrine`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/select2/release.sh`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/doc`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/example`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/test`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/example`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/test`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mobiledetect/mobiledetectlib/.gitmodules`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mobiledetect/mobiledetectlib/docs`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/.github`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/docs`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/samples`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/scripts`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/src`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/test`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/parsedown/LICENSE.txt`; @@ -609,21 +625,17 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/tests`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/LICENSE`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-*`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-*`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/ae_fonts_*`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`; - $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/LICENSE.TXT`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/examples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; - + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/webmozart`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/autoload.php`; - - $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; } # Build package for each target diff --git a/composer.json b/composer.json index 9fede994525..a943fbe0aa3 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "nnnick/chartjs" : "^2.9", "stripe/stripe-php" : "6.43.1", "maximebf/debugbar" : "1.15.1", - "symfony/var-dumper": "3" + "symfony/var-dumper" : "3" }, "require-dev" : { "php-parallel-lint/php-parallel-lint" : "^0", diff --git a/composer.lock b/composer.lock index 5afe0ca34f2..e0462435f5e 100644 --- a/composer.lock +++ b/composer.lock @@ -6,6 +6,53 @@ ], "content-hash": "1dbd2d05cc0836acfca5988f29005cf2", "packages": [ + { + "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": "ckeditor/ckeditor", "version": "4.12.1", @@ -217,16 +264,16 @@ }, { "name": "nnnick/chartjs", - "version": "v2.9.3", + "version": "v2.9.4", "source": { "type": "git", "url": "https://github.com/chartjs/Chart.js.git", - "reference": "06f73dc3590084b2c464bf08189c7aee2b6b92d2" + "reference": "9bd4cf82fda9f50a5fb50b72843e06ab88124278" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chartjs/Chart.js/zipball/06f73dc3590084b2c464bf08189c7aee2b6b92d2", - "reference": "06f73dc3590084b2c464bf08189c7aee2b6b92d2", + "url": "https://api.github.com/repos/chartjs/Chart.js/zipball/9bd4cf82fda9f50a5fb50b72843e06ab88124278", + "reference": "9bd4cf82fda9f50a5fb50b72843e06ab88124278", "shasum": "" }, "require": { @@ -254,7 +301,11 @@ "JS", "chart" ], - "time": "2019-11-14T18:37:30+00:00" + "support": { + "issues": "https://github.com/chartjs/Chart.js/issues", + "source": "https://github.com/chartjs/Chart.js/tree/v2.9.4" + }, + "time": "2020-10-19T12:22:11+00:00" }, { "name": "phpoffice/phpexcel", @@ -314,53 +365,6 @@ "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", @@ -2037,159 +2041,6 @@ ], "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", @@ -2312,5 +2163,5 @@ "ext-curl": "*" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/dev/examples/zapier/package.json b/dev/examples/zapier/package.json index 5b5827b22b2..4266a6f00b1 100644 --- a/dev/examples/zapier/package.json +++ b/dev/examples/zapier/package.json @@ -15,7 +15,7 @@ "npm": ">=5.6.0" }, "dependencies": { - "zapier-platform-core": "10.1.1" + "zapier-platform-core": "10.1.2" }, "devDependencies": { "mocha": "^5.2.0", diff --git a/dev/translation/erp_comparison_translation.txt b/dev/translation/erp_comparison_translation.txt deleted file mode 100644 index 6cf7c4f7c60..00000000000 --- a/dev/translation/erp_comparison_translation.txt +++ /dev/null @@ -1,25 +0,0 @@ -comparison of terms - - -Dolibarr SAP ERP Odoo -------------------------------------------------------------------------- -Thirdparty Contact partner Partner/Contact (company) -Contact/address Contact person Partner/Contact (individual) - -Financial Finance (FI) Accounting -Accounting - - -Income / Expense ?? Profit / Loss -Balance ?? Net profit -Subledger account Subledger account ?? - -CRM Sales & Distribution Sales -Proposal ?? Quotation - - - -Proposal is ok but proposition looks better (proposal is for a detailed proposition). -We can say also "business proposition or business proposal". -In India they are using "Quotation". - diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 2bd2a84841e..6d621a7e101 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -187,7 +187,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } - if (isset($_POST["country"]) && ($_POST["country"] == '0') && ($id != 2)) + if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) { $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index cd17e5a1538..d1cee5ff59d 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -247,7 +247,7 @@ if ($action == 'create') { // Chart of accounts type print ''.$langs->trans("Pcgtype").''; print ''; - print ''; + print ''; print ''; print ''; @@ -309,7 +309,7 @@ if ($action == 'create') { // Chart of accounts type print ''.$langs->trans("Pcgtype").''; print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 2e51d3d1b38..53dfb1cd5f9 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -168,7 +168,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } } - if (isset($_POST["code"])) + if (GETPOSTISSET("code")) { if ($_POST["code"] == '0') { diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index b250459bdce..d0f43cfe3dd 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2017 Florian Henry * Copyright (C) 2013-2018 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -128,8 +128,7 @@ if ($action == "confirm_update") { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - if ($mode != '_tmp') - { + if ($mode != '_tmp') { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } @@ -165,14 +164,14 @@ if ($action == "confirm_update") { $object->label_operation = $label_operation; $object->debit = $debit; $object->credit = $credit; - $object->doc_date = GETPOST('doc_date', 'alpha'); - $object->doc_type = GETPOST('doc_type', 'alpha'); + $object->doc_date = (string) GETPOST('doc_date', 'alpha'); + $object->doc_type = (string) GETPOST('doc_type', 'alpha'); $object->piece_num = $piece_num; - $object->doc_ref = GETPOST('doc_ref', 'alpha'); + $object->doc_ref = (string) GETPOST('doc_ref', 'alpha'); $object->code_journal = $journal_code; $object->journal_label = $journal_label; - $object->fk_doc = (int) GETPOST('fk_doc', 'int'); - $object->fk_docdet = (int) GETPOST('fk_docdet', 'int'); + $object->fk_doc = GETPOSTINT('fk_doc'); + $object->fk_docdet = GETPOSTINT('fk_docdet'); if (floatval($debit) != 0.0) { $object->montant = $debit; // deprecated @@ -190,8 +189,7 @@ if ($action == "confirm_update") { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - if ($mode != '_tmp') - { + if ($mode != '_tmp') { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 097eb38b47f..92de49d66ed 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -108,7 +108,7 @@ $hookmanager->initHooks(array('bookkeepinglist')); $formaccounting = new FormAccounting($db); $form = new Form($db); -if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) +if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values')) { @@ -632,19 +632,19 @@ $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $obj if (empty($reshook)) { // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton = '' . img_picto($langs->trans("Activated"), 'switch_on') . ' '; + $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; } else { - $newcardbutton = '' . img_picto($langs->trans("Disabled"), 'switch_off') . ' '; + $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; } - $newcardbutton .= '' . $langs->trans("IncludeDocsAlreadyExported") . ''; + $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; - $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList") . ' (' . $listofformat[$formatexportset] . ')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"] . '?action=export_file' . ($param ? '&' . $param : ''), $user->rights->accounting->mouvements->export); + $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); $url = './card.php?action=create'; - if (!empty($socid)) $url .= '&socid=' . $socid; + if (!empty($socid)) $url .= '&socid='.$socid; $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer); } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 80d8b4961c8..18661f8a887 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -379,12 +379,12 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param); - $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); + $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= '   '; - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 0a70034aaa6..3bc0351b09b 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -380,8 +380,8 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); + $newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 51e66f3360c..3423f096794 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -57,8 +57,8 @@ class AccountancyExport public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA10 = 120; - public static $EXPORT_TYPE_GESTINUMV3 = 130; - public static $EXPORT_TYPE_GESTINUMV5 = 135; + public static $EXPORT_TYPE_GESTINUMV3 = 130; + public static $EXPORT_TYPE_GESTINUMV5 = 135; public static $EXPORT_TYPE_FEC = 1000; @@ -115,11 +115,11 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), - self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), + self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), - self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), - self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), + self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), + self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), ); @@ -148,12 +148,12 @@ class AccountancyExport self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', - self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', - self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne', - self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', - self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', - self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', - self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', + self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', + self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne', + self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', + self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', + self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', + self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -208,9 +208,9 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => array( 'label' => $langs->trans('Modelcsv_agiris'), ), - self::$EXPORT_TYPE_OPENCONCERTO => array( - 'label' => $langs->trans('Modelcsv_openconcerto'), - ), + self::$EXPORT_TYPE_OPENCONCERTO => array( + 'label' => $langs->trans('Modelcsv_openconcerto'), + ), self::$EXPORT_TYPE_SAGE50_SWISS => array( 'label' => $langs->trans('Modelcsv_Sage50_Swiss'), ), @@ -218,18 +218,18 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_charlemagne'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), - self::$EXPORT_TYPE_LDCOMPTA => array( - 'label' => $langs->trans('Modelcsv_LDCompta'), - ), + self::$EXPORT_TYPE_LDCOMPTA => array( + 'label' => $langs->trans('Modelcsv_LDCompta'), + ), self::$EXPORT_TYPE_LDCOMPTA10 => array( - 'label' => $langs->trans('Modelcsv_LDCompta10'), - ), - self::$EXPORT_TYPE_GESTINUMV3 => array( - 'label' => $langs->trans('Modelcsv_Gestinumv3'), - ), - self::$EXPORT_TYPE_GESTINUMV5 => array( - 'label' => $langs->trans('Modelcsv_Gestinumv5'), - ), + 'label' => $langs->trans('Modelcsv_LDCompta10'), + ), + self::$EXPORT_TYPE_GESTINUMV3 => array( + 'label' => $langs->trans('Modelcsv_Gestinumv3'), + ), + self::$EXPORT_TYPE_GESTINUMV5 => array( + 'label' => $langs->trans('Modelcsv_Gestinumv5'), + ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', @@ -307,21 +307,21 @@ class AccountancyExport case self::$EXPORT_TYPE_CHARLEMAGNE : $this->exportCharlemagne($TData); break; - case self::$EXPORT_TYPE_LDCOMPTA : - $this->exportLDCompta($TData); - break; - case self::$EXPORT_TYPE_LDCOMPTA10 : - $this->exportLDCompta10($TData); - break; - case self::$EXPORT_TYPE_GESTINUMV3 : - $this->exportGestimumV3($TData); - break; - case self::$EXPORT_TYPE_GESTINUMV5 : - $this->exportGestimumV5($TData); - break; - case self::$EXPORT_TYPE_FEC : - $this->exportFEC($TData); - break; + case self::$EXPORT_TYPE_LDCOMPTA : + $this->exportLDCompta($TData); + break; + case self::$EXPORT_TYPE_LDCOMPTA10 : + $this->exportLDCompta10($TData); + break; + case self::$EXPORT_TYPE_GESTINUMV3 : + $this->exportGestimumV3($TData); + break; + case self::$EXPORT_TYPE_GESTINUMV5 : + $this->exportGestimumV5($TData); + break; + case self::$EXPORT_TYPE_FEC : + $this->exportFEC($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -1484,136 +1484,136 @@ class AccountancyExport } } - /** - * Export format : Gestimum V3 - * - * @param array $objectLines data - * - * @return void - */ - public function exportGestimumV3($objectLines) + /** + * Export format : Gestimum V3 + * + * @param array $objectLines data + * + * @return void + */ + public function exportGestimumV3($objectLines) { - global $langs; + global $langs; - $this->separator = ','; + $this->separator = ','; - $invoices_infos = array(); - $supplier_invoices_infos = array(); - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + $invoices_infos = array(); + $supplier_invoices_infos = array(); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - $invoice_ref = $line->doc_ref; - $company_name = ""; + $invoice_ref = $line->doc_ref; + $company_name = ""; - if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) { - if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) || - ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) { - if ($line->doc_type == 'customer_invoice') { - // Get new customer invoice ref and company name - $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; - $sql .= ' WHERE f.rowid = ' . $line->fk_doc; - $resql = $this->db->query($sql); - if ($resql) { - if ($obj = $this->db->fetch_object($resql)) { - // Save invoice infos - $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom); - $invoice_ref = $obj->facnumber; - $company_name = $obj->nom; - } - } - } else { - // Get new supplier invoice ref and company name - $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; - $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; - $resql = $this->db->query($sql); - if ($resql) { - if ($obj = $this->db->fetch_object($resql)) { - // Save invoice infos - $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom); - $invoice_ref = $obj->ref; - $company_name = $obj->nom; - } - } - } - } elseif ($line->doc_type == 'customer_invoice') { - // Retrieve invoice infos - $invoice_ref = $invoices_infos[$line->fk_doc]['ref']; - $company_name = $invoices_infos[$line->fk_doc]['company_name']; - } else { - // Retrieve invoice infos - $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref']; - $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name']; - } - } + if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) { + if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) || + ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) { + if ($line->doc_type == 'customer_invoice') { + // Get new customer invoice ref and company name + $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; + $sql .= ' WHERE f.rowid = ' . $line->fk_doc; + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + // Save invoice infos + $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom); + $invoice_ref = $obj->facnumber; + $company_name = $obj->nom; + } + } + } else { + // Get new supplier invoice ref and company name + $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; + $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + // Save invoice infos + $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom); + $invoice_ref = $obj->ref; + $company_name = $obj->nom; + } + } + } + } elseif ($line->doc_type == 'customer_invoice') { + // Retrieve invoice infos + $invoice_ref = $invoices_infos[$line->fk_doc]['ref']; + $company_name = $invoices_infos[$line->fk_doc]['company_name']; + } else { + // Retrieve invoice infos + $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref']; + $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name']; + } + } - print $line->id . $this->separator; - print $date . $this->separator; - print substr($line->code_journal, 0, 4) . $this->separator; + print $line->id . $this->separator; + print $date . $this->separator; + print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { - print length_accountg($line->subledger_account) . $this->separator; - } else { - print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; - } - //Libellé Auto - print $this->separator; - //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; - //Libellé manuel - print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator; - //Numéro de pièce - print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; - //Devise - print 'EUR' . $this->separator; - //Montant - print price2num(abs($line->montant)) . $this->separator; - //Sens - print $line->sens . $this->separator; - //Code lettrage - print $this->separator; - //Date Echéance - print $date; - print $this->end_line; - } - } + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + print length_accountg($line->subledger_account) . $this->separator; + } else { + print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; + } + //Libellé Auto + print $this->separator; + //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; + //Libellé manuel + print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator; + //Numéro de pièce + print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; + //Devise + print 'EUR' . $this->separator; + //Montant + print price2num(abs($line->montant)) . $this->separator; + //Sens + print $line->sens . $this->separator; + //Code lettrage + print $this->separator; + //Date Echéance + print $date; + print $this->end_line; + } + } - /** - * Export format : Gestimum V5 - * - * @param array $objectLines data - * - * @return void - */ - public function exportGestimumV5($objectLines) + /** + * Export format : Gestimum V5 + * + * @param array $objectLines data + * + * @return void + */ + public function exportGestimumV5($objectLines) { - $this->separator = ','; + $this->separator = ','; - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d%m%Y'); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $line->id . $this->separator; - print $date . $this->separator; - print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { - print length_accountg($line->subledger_account) . $this->separator; - } else { - print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; - } - print $this->separator; - //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; - print '"'.dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1).'"' . $this->separator; - print '"'.dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1).'"'.$this->separator; - print price2num($line->montant).$this->separator; - print $line->sens.$this->separator; - print $date . $this->separator; - print $this->separator; - print $this->separator; - print 'EUR'; - print $this->end_line; - } - } + print $line->id . $this->separator; + print $date . $this->separator; + print substr($line->code_journal, 0, 4) . $this->separator; + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + print length_accountg($line->subledger_account) . $this->separator; + } else { + print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; + } + print $this->separator; + //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1).'"' . $this->separator; + print '"'.dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1).'"'.$this->separator; + print price2num($line->montant).$this->separator; + print $line->sens.$this->separator; + print $date . $this->separator; + print $this->separator; + print $this->separator; + print 'EUR'; + print $this->end_line; + } + } /** * trunc diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index c002abf2a89..a76be081471 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -37,7 +37,7 @@ class AccountingJournal extends CommonObject public $table_element = 'accounting_journal'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Fieldname with ID of parent key if this field has a parent */ public $fk_element = ''; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 20010cc8f5c..834af1ff06a 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2016-2020 Laurent Destailleur * Copyright (C) 2016-2019 Alexandre Spangaro * Copyright (C) 2019 Frédéric France * @@ -103,13 +103,19 @@ if ($conf->accounting->enabled) // STEPS $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").''); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'', $s); + print $s; print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").''); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'', $s); + print $s; print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").''); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'', $s); + print $s; print "
\n"; print "
\n"; @@ -118,60 +124,45 @@ if ($conf->accounting->enabled) print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $s); + print $s; print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'')."\n"; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n"; + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'', $s); + print $s; print "
\n"; $step++; $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}'); + $s = str_replace('{s}', $textlink, $s); + print $s; print "
\n"; if (!empty($conf->tax->enabled)) { $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}'); + $s = str_replace('{s}', $textlink, $s); + print $s; print "
\n"; } - /*if (! empty($conf->salaries->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - // htdocs/admin/salaries.php - print "
\n"; - print "
\n"; - }*/ if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'', $s); + print $s; print "
\n"; } - /* - if (! empty($conf->loan->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
\n"; - } - if (! empty($conf->don->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
\n"; - } - if (! empty($conf->adherents->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
\n"; - }*/ $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").''); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'', $s); + print $s; print "
\n"; @@ -188,26 +179,34 @@ if ($conf->accounting->enabled) $langs->loadLangs(array('bills', 'trips')); $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'')."\n"; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '{s}')."\n"; + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'', $s); + print $s; print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'')."\n"; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '{s}')."\n"; + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'', $s); + print $s; print "
\n"; if (!empty($conf->expensereport->enabled) || !empty($conf->deplacement->enabled)) { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'')."\n"; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n"; + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'', $s); + print $s; print "
\n"; } $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n"; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n"; + print $s; print "
\n"; $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."
\n"; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."
\n"; + print $s; print "
\n"; print '
'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4e1a64cd20c..d353041234f 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -7,7 +7,7 @@ * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2017-2018 Frédéric France + * Copyright (C) 2017-2020 Frédéric France * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Eric Seigne * @@ -73,15 +73,18 @@ $date_endmonth = GETPOST('date_endmonth', 'int'); $date_endday = GETPOST('date_endday', 'int'); $date_endyear = GETPOST('date_endyear', 'int'); $in_bookkeeping = GETPOST('in_bookkeeping', 'aZ09'); -if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; +if ($in_bookkeeping == '') { + $in_bookkeeping = 'notyet'; +} $now = dol_now(); $action = GETPOST('action', 'aZ09'); // Security check -if ($user->socid > 0 && empty($id_journal)) +if ($user->socid > 0 && empty($id_journal)) { accessforbidden(); +} /* @@ -93,8 +96,7 @@ $error = 0; $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); -if (empty($date_startmonth) || empty($date_endmonth)) -{ +if (empty($date_startmonth) || empty($date_endmonth)) { // Period by default on transfer $dates = getDefaultDatesForTransfer(); $date_start = $dates['date_start']; @@ -103,8 +105,7 @@ if (empty($date_startmonth) || empty($date_endmonth)) $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 -{ +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); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } @@ -124,19 +125,18 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=".$id_journal; $sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy -if ($date_start && $date_end) +if ($date_start && $date_end) { $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'"; +} // Define begin binding date if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND b.dateo >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } // Already in bookkeeping or not -if ($in_bookkeeping == 'already') -{ +if ($in_bookkeeping == 'already') { $sql .= " AND (b.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; } -if ($in_bookkeeping == 'notyet') -{ +if ($in_bookkeeping == 'notyet') { $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; } $sql .= " ORDER BY b.datev"; @@ -177,9 +177,9 @@ if ($result) { //print $sql; // Variables - $account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word - $account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word - $account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word + $account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word + $account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word + $account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word $account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_subscription = (!empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word @@ -198,23 +198,28 @@ if ($result) { // one line for bank record = tabbq // one line for thirdparty record = tabtp $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); $lineisapurchase = -1; $lineisasale = -1; // Old method to detect if it's a sale or purchase - if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase = 1; - if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale = 1; - // Try a more reliable method to detect if record is a supplier payment or a customer payment - if ($lineisapurchase < 0) - { - if ($obj->typeop_payment_supplier == 'payment_supplier') $lineisapurchase = 1; + if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') { + $lineisapurchase = 1; } - if ($lineisasale < 0) - { - if ($obj->typeop_payment == 'payment') $lineisasale = 1; + if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') { + $lineisasale = 1; + } + // Try a more reliable method to detect if record is a supplier payment or a customer payment + if ($lineisapurchase < 0) { + if ($obj->typeop_payment_supplier == 'payment_supplier') { + $lineisapurchase = 1; + } + } + if ($lineisasale < 0) { + if ($obj->typeop_payment == 'payment') { + $lineisasale = 1; + } } //var_dump($obj->type_payment); var_dump($obj->type_payment_supplier); //var_dump($lineisapurchase); //var_dump($lineisasale); @@ -224,28 +229,30 @@ if ($result) { // Set accountancy code for thirdparty (example: '411CU...' or '411' if no subledger account defined on customer) $compta_soc = 'NotDefined'; - if ($lineisapurchase > 0) + if ($lineisapurchase > 0) { $compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier); - if ($lineisasale > 0) + } + if ($lineisasale > 0) { $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $account_customer); + } $tabcompany[$obj->rowid] = array( - 'id' => $obj->socid, - 'name' => $obj->name, - 'code_compta' => $compta_soc, - 'email' => $obj->email + 'id' => $obj->socid, + 'name' => $obj->name, + 'code_compta' => $compta_soc, + 'email' => $obj->email ); // Set accountancy code for user $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : ''); $tabuser[$obj->rowid] = array( - 'id' => $obj->userid, - 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'email' => $obj->useremail, - 'accountancy_code' => $compta_user + 'id' => $obj->userid, + 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'email' => $obj->useremail, + 'accountancy_code' => $compta_user ); // Variable bookkeeping ($obj->rowid is Bank Id) @@ -264,10 +271,6 @@ if ($result) { // Load of url links to the line into llx_bank $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) - //var_dump($i); - //var_dump($tabpay); - //var_dump($tabcompany); - // By default $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. $tabtype[$obj->rowid] = 'unknown'; @@ -277,17 +280,14 @@ if ($result) { if (is_array($links) && count($links) > 0) { // Now loop on each link of record in bank. foreach ($links as $key => $val) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) - { + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) { // So we excluded 'company' and 'user' here. We want only payment lines // We save tabtype for a future use, to remember what kind of payment it is $tabpay[$obj->rowid]['type'] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type']; - } elseif (in_array($links[$key]['type'], array('company', 'user'))) - { - if ($tabpay[$obj->rowid]['type'] == 'unknown') - { + } elseif (in_array($links[$key]['type'], array('company', 'user'))) { + if ($tabpay[$obj->rowid]['type'] == 'unknown') { // We can guess here it is a bank record for a thirdparty company or a user. // But we won't be able to record somewhere else than into a waiting account, because there is no other journal to record the contreparty. } @@ -312,16 +312,23 @@ if ($result) { $societestatic->name = $links[$key]['label']; $societestatic->email = $tabcompany[$obj->rowid]['email']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); - if ($compta_soc) $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + if ($compta_soc) { + $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + } } elseif ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; $userstatic->name = $links[$key]['label']; $userstatic->email = $tabuser[$obj->rowid]['email']; $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; - if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); - else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. - if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount; + if ($userstatic->id > 0) { + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); + } else { + $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. + } + if ($compta_user) { + $tabtp[$obj->rowid][$compta_user] += $obj->amount; + } } elseif ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id']; @@ -329,8 +336,9 @@ if ($result) { $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); $reg = array(); if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { - if ($reg[1] == 'socialcontribution') + if ($reg[1] == 'socialcontribution') { $reg[1] = 'SocialContribution'; + } $chargestatic->label = $langs->trans($reg[1]); } else { $chargestatic->label = $links[$key]['label']; @@ -430,20 +438,19 @@ if ($result) { // If no links were found to know the amount on thirdparty, we try to guess it. // This may happens on bank entries without the links lines to 'company'. - if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) // If we dont find 'company' link because it is an old 'withdraw' record - { + if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we dont find 'company' link because it is an old 'withdraw' record foreach ($links as $key => $val) { if ($links[$key]['type'] == 'payment') { // Get thirdparty $tmppayment->fetch($links[$key]['url_id']); $arrayofamounts = $tmppayment->getAmountsArray(); - foreach ($arrayofamounts as $invoiceid => $amount) - { - $tmpinvoice->fetch($invoiceid); - $tmpinvoice->fetch_thirdparty(); - if ($tmpinvoice->thirdparty->code_compta) - { - $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta] += $amount; + if (is_array($arrayofamounts)) { + foreach ($arrayofamounts as $invoiceid => $amount) { + $tmpinvoice->fetch($invoiceid); + $tmpinvoice->fetch_thirdparty(); + if ($tmpinvoice->thirdparty->code_compta) { + $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta] += $amount; + } } } } @@ -451,7 +458,9 @@ if ($result) { } // If no links were found to know the amount on thirdparty, we init it to account 'NotDefined'. - if (empty($tabtp[$obj->rowid])) $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; + if (empty($tabtp[$obj->rowid])) { + $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; + } // Check account number is ok /*if ($action == 'writebookkeeping') // Make test now in such a case @@ -492,8 +501,7 @@ if (!$error && $action == 'writebookkeeping') { $now = dol_now(); $error = 0; - foreach ($tabpay as $key => $val) // $key is rowid into llx_bank - { + foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); @@ -511,17 +519,18 @@ if (!$error && $action == 'writebookkeeping') { var_dump($tabbq);exit;*/ // Bank - if (!$errorforline && is_array($tabbq[$key])) - { + if (!$errorforline && is_array($tabbq[$key])) { // Line into bank account - foreach ($tabbq[$key] as $k => $mt) - { - if ($mt) - { + foreach ($tabbq[$key] as $k => $mt) { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + if (!empty($val['lib'])) { + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + } $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); - if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); + if (!empty($val['soclib'])) { + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); + } $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -554,8 +563,7 @@ if (!$error && $action == 'writebookkeeping') { $result = $bookkeeping->create($user); if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists $error++; $errorforline++; setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); @@ -570,18 +578,16 @@ if (!$error && $action == 'writebookkeeping') { } // Third party - if (!$errorforline) - { - if (is_array($tabtp[$key])) - { + if (!$errorforline) { + if (is_array($tabtp[$key])) { // Line into thirdparty account foreach ($tabtp[$key] as $k => $mt) { - if ($mt) - { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); - if ($tabtype[$key] == 'banktransfert') - { + if (!empty($val['lib'])) { + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); + } + if ($tabtype[$key] == 'banktransfert') { $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); } else { $reflabel .= dol_string_nohtmltag($val['soclib']); @@ -681,8 +687,7 @@ if (!$error && $action == 'writebookkeeping') { $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else { - if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty. - { + if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. // Temporary account $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -700,8 +705,7 @@ if (!$error && $action == 'writebookkeeping') { $result = $bookkeeping->create($user); if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists $error++; $errorforline++; setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); @@ -715,10 +719,11 @@ if (!$error && $action == 'writebookkeeping') { } } else { // If thirdparty unknown, output the waiting account foreach ($tabbq[$key] as $k => $mt) { - if ($mt) - { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + if (!empty($val['lib'])) { + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + } $reflabel .= dol_string_nohtmltag('WaitingAccount'); $bookkeeping = new BookKeeping($db); @@ -745,8 +750,7 @@ if (!$error && $action == 'writebookkeeping') { $result = $bookkeeping->create($user); if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists $error++; $errorforline++; setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); @@ -761,23 +765,20 @@ if (!$error && $action == 'writebookkeeping') { } } - if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) - { + if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { $error++; $errorforline++; setEventMessages('Try to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); } - if (!$errorforline) - { + if (!$errorforline) { $db->commit(); } else { //print 'KO for line '.$key.' '.$error.'
'; $db->rollback(); $MAXNBERRORS = 5; - if ($error >= $MAXNBERRORS) - { + if ($error >= $MAXNBERRORS) { setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); break; // Break in the foreach } @@ -786,8 +787,7 @@ if (!$error && $action == 'writebookkeeping') { if (empty($error) && count($tabpay) > 0) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); - } elseif (count($tabpay) == $error) - { + } elseif (count($tabpay) == $error) { setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); } else { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); @@ -796,8 +796,7 @@ if (!$error && $action == 'writebookkeeping') { $action = ''; // Must reload data, so we make a redirect - if (count($tabpay) != $error) - { + if (count($tabpay) != $error) { $param = 'id_journal='.$id_journal; $param .= '&date_startday='.$date_startday; $param .= '&date_startmonth='.$date_startmonth; @@ -835,20 +834,22 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; print "\n"; - foreach ($tabpay as $key => $val) - { + foreach ($tabpay as $key => $val) { $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); // Bank foreach ($tabbq[$key] as $k => $mt) { - if ($mt) - { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + if (!empty($val['lib'])) { + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + } $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); - if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); + if (!empty($val['soclib'])) { + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); + } print '"'.$key.'"'.$sep; print '"'.$date.'"'.$sep; @@ -868,12 +869,12 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! // Third party if (is_array($tabtp[$key])) { foreach ($tabtp[$key] as $k => $mt) { - if ($mt) - { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); - if ($tabtype[$key] == 'banktransfert') - { + if (!empty($val['lib'])) { + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); + } + if ($tabtype[$key] == 'banktransfert') { $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); } else { $reflabel .= dol_string_nohtmltag($val['soclib']); @@ -905,10 +906,11 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } } else { // If thirdparty unkown, output the waiting account foreach ($tabbq[$key] as $k => $mt) { - if ($mt) - { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + if (!empty($val['lib'])) { + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + } $reflabel .= dol_string_nohtmltag('WaitingAccount'); print '"'.$key.'"'.$sep; @@ -965,16 +967,18 @@ if (empty($action) || $action == 'view') { // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) $sql = 'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE entity = '.$conf->entity.' AND fk_accountancy_journal IS NULL AND clos=0'; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj->nb > 0) - { + if ($obj->nb > 0) { print '
'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); - print ' : '.$langs->trans("AccountancyAreaDescBank", 9, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").''); + $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 9, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'', $desc); + print $desc; print '
'; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } // Button to write into Ledger @@ -988,14 +992,19 @@ if (empty($action) || $action == 'view') { print '
'; - if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { + print ''; + } if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { print ''; } else { - if ($in_bookkeeping == 'notyet') print ''; - else print ''.$langs->trans("WriteBookKeeping").''; + if ($in_bookkeeping == 'notyet') { + print ''; + } else { + print ''.$langs->trans("WriteBookKeeping").''; + } } print '
'; @@ -1038,21 +1047,22 @@ if (empty($action) || $action == 'view') { $r = ''; - foreach ($tabpay as $key => $val) // $key is rowid in llx_bank - { + foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); // Bank - foreach ($tabbq[$key] as $k => $mt) - { - if ($mt) - { + foreach ($tabbq[$key] as $k => $mt) { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= $val['lib']." - "; + if (!empty($val['lib'])) { + $reflabel .= $val['lib']." - "; + } $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; - if (!empty($val['soclib'])) $reflabel .= " - ".$val['soclib']; + if (!empty($val['soclib'])) { + $reflabel .= " - ".$val['soclib']; + } //var_dump($tabpay[$key]); print ''; @@ -1062,10 +1072,11 @@ if (empty($action) || $action == 'view') { // Ledger account print ""; $accounttoshow = length_accountg($k); - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') - { + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { print ''.$langs->trans("BankAccountNotDefined").''; - } else print $accounttoshow; + } else { + print $accounttoshow; + } print ""; // Subledger account print ""; @@ -1089,12 +1100,12 @@ if (empty($action) || $action == 'view') { // Third party if (is_array($tabtp[$key])) { foreach ($tabtp[$key] as $k => $mt) { - if ($mt) - { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= $val['lib'].($val['soclib'] ? " - " : ""); - if ($tabtype[$key] == 'banktransfert') - { + if (!empty($val['lib'])) { + $reflabel .= $val['lib'].($val['soclib'] ? " - " : ""); + } + if ($tabtype[$key] == 'banktransfert') { $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; } else { $reflabel .= $val['soclib']; @@ -1108,21 +1119,32 @@ if (empty($action) || $action == 'view') { print ""; $account_ledger = $k; // Try to force general ledger account depending on type - if ($tabtype[$key] == 'payment') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - if ($tabtype[$key] == 'payment_supplier') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; - if ($tabtype[$key] == 'payment_expensereport') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; - if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; - if ($tabtype[$key] == 'payment_various') $account_ledger = $tabpay[$key]["account_various"]; + if ($tabtype[$key] == 'payment') { + $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + } + if ($tabtype[$key] == 'payment_supplier') { + $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + } + if ($tabtype[$key] == 'payment_expensereport') { + $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + } + if ($tabtype[$key] == 'payment_salary') { + $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + } + if ($tabtype[$key] == 'payment_vat') { + $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; + } + if ($tabtype[$key] == 'member') { + $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; + } + if ($tabtype[$key] == 'payment_various') { + $account_ledger = $tabpay[$key]["account_various"]; + } $accounttoshow = length_accountg($account_ledger); - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') - { - if ($tabtype[$key] == 'unknown') - { + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { + if ($tabtype[$key] == 'unknown') { // We will accept writing, but into a waiting account - if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1') - { + if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1') { print ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').''; } else { print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account @@ -1130,32 +1152,42 @@ if (empty($action) || $action == 'view') { } else { // We will refuse writing $errorstring = 'UnknownAccountForThirdpartyBlocking'; - if ($tabtype[$key] == 'payment') $errorstring = 'MainAccountForCustomersNotDefined'; - if ($tabtype[$key] == 'payment_supplier') $errorstring = 'MainAccountForSuppliersNotDefined'; - if ($tabtype[$key] == 'payment_expensereport') $errorstring = 'MainAccountForUsersNotDefined'; - if ($tabtype[$key] == 'payment_salary') $errorstring = 'MainAccountForUsersNotDefined'; - if ($tabtype[$key] == 'payment_vat') $errorstring = 'MainAccountForVatPaymentNotDefined'; - if ($tabtype[$key] == 'member') $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; + if ($tabtype[$key] == 'payment') { + $errorstring = 'MainAccountForCustomersNotDefined'; + } + if ($tabtype[$key] == 'payment_supplier') { + $errorstring = 'MainAccountForSuppliersNotDefined'; + } + if ($tabtype[$key] == 'payment_expensereport') { + $errorstring = 'MainAccountForUsersNotDefined'; + } + if ($tabtype[$key] == 'payment_salary') { + $errorstring = 'MainAccountForUsersNotDefined'; + } + if ($tabtype[$key] == 'payment_vat') { + $errorstring = 'MainAccountForVatPaymentNotDefined'; + } + if ($tabtype[$key] == 'member') { + $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; + } print ''.$langs->trans($errorstring).''; } - } else print $accounttoshow; + } else { + print $accounttoshow; + } print ""; // Subledger account print ""; - if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) // Type of payment with subledger - { + if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payment with subledger $accounttoshowsubledger = length_accounta($k); - if ($accounttoshow != $accounttoshowsubledger) - { - if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') - { + if ($accounttoshow != $accounttoshowsubledger) { + if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { /*var_dump($tabpay[$key]); var_dump($tabtype[$key]); var_dump($tabbq[$key]);*/ //print ''.$langs->trans("ThirdpartyAccountNotDefined").''; - if (!empty($tabcompany[$key]['code_compta'])) - { + if (!empty($tabcompany[$key]['code_compta'])) { if (in_array($tabtype[$key], array('payment_various'))) { // For such case, if subledger is not defined, we won't use subledger accounts. print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").''; @@ -1165,7 +1197,9 @@ if (empty($action) || $action == 'view') { } else { print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").''; } - } else print $accounttoshowsubledger; + } else { + print $accounttoshowsubledger; + } } } print ""; @@ -1178,10 +1212,11 @@ if (empty($action) || $action == 'view') { } } else { // Waiting account foreach ($tabbq[$key] as $k => $mt) { - if ($mt) - { + if ($mt) { $reflabel = ''; - if (!empty($val['lib'])) $reflabel .= $val['lib']." - "; + if (!empty($val['lib'])) { + $reflabel .= $val['lib']." - "; + } $reflabel .= 'WaitingAccount'; print ''; @@ -1265,78 +1300,67 @@ function getSourceDocRef($val, $typerecord) } $sqlmid = ''; - if ($typerecord == 'payment') - { + if ($typerecord == 'payment') { $sqlmid = 'SELECT payfac.fk_facture as id, f.ref as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=".$val["paymentid"]; $ref = $langs->transnoentitiesnoconv("Invoice"); - } elseif ($typerecord == 'payment_supplier') - { + } elseif ($typerecord == 'payment_supplier') { $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".$val["paymentsupplierid"]; $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); - } elseif ($typerecord == 'payment_expensereport') - { + } elseif ($typerecord == 'payment_expensereport') { $sqlmid = 'SELECT e.rowid as id, e.ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; $sqlmid .= " WHERE pe.rowid=".$val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; $ref = $langs->transnoentitiesnoconv("ExpenseReport"); - } elseif ($typerecord == 'payment_salary') - { + } elseif ($typerecord == 'payment_salary') { $sqlmid = 'SELECT s.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sqlmid .= " WHERE s.rowid=".$val["paymentsalid"]; $ref = $langs->transnoentitiesnoconv("SalaryPayment"); - } elseif ($typerecord == 'sc') - { + } elseif ($typerecord == 'sc') { $sqlmid = 'SELECT sc.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; $sqlmid .= " WHERE sc.rowid=".$val["paymentscid"]; $ref = $langs->transnoentitiesnoconv("SocialContribution"); - } elseif ($typerecord == 'payment_vat') - { + } elseif ($typerecord == 'payment_vat') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; $sqlmid .= " WHERE v.rowid=".$val["paymentvatid"]; $ref = $langs->transnoentitiesnoconv("PaymentVat"); - } elseif ($typerecord == 'payment_donation') - { + } elseif ($typerecord == 'payment_donation') { $sqlmid = 'SELECT payd.fk_donation as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; $sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"]; $ref = $langs->transnoentitiesnoconv("Donation"); - } elseif ($typerecord == 'payment_loan') - { + } elseif ($typerecord == 'payment_loan') { $sqlmid = 'SELECT l.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; $sqlmid .= " WHERE l.rowid=".$val["paymentloanid"]; $ref = $langs->transnoentitiesnoconv("LoanPayment"); - } elseif ($typerecord == 'payment_various') - { + } elseif ($typerecord == 'payment_various') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sqlmid .= " WHERE v.rowid=".$val["paymentvariousid"]; $ref = $langs->transnoentitiesnoconv("VariousPayment"); } // Add warning - if (empty($sqlmid)) - { + if (empty($sqlmid)) { dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); } - if ($sqlmid) - { + if ($sqlmid) { dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); - if ($resultmid) - { - while ($objmid = $db->fetch_object($resultmid)) - { + if ($resultmid) { + while ($objmid = $db->fetch_object($resultmid)) { $ref .= ' '.$objmid->ref; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b1331cd1dc7..9f44e02aafa 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -621,18 +621,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '""' . $sep; - print '"' . $langs->trans("VAT") . ' - ' . join(', ', $def_tva[$key][$k]) . ' %"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) . ' %' . ($numtax ? ' - Localtax ' . $numtax : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"'; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '""'.$sep; + print '"'.$langs->trans("VAT").' - '.join(', ', $def_tva[$key][$k]).' %"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; } } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index edd553b0d1b..4a26b8ddb5e 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -382,14 +382,12 @@ if (empty($reshook)) { if ($action == 'add' && $user->rights->adherent->creer) { if ($canvas) $object->canvas = $canvas; $birthdate = ''; - if (isset($_POST["birthday"]) && $_POST["birthday"] - && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) { - $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) { + $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); } $datesubscription = ''; - if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) { - $datesubscription = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) { + $datesubscription = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", "int"), GETPOST("reyear", "int")); } $typeid = GETPOST("typeid", 'int'); @@ -1075,7 +1073,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Password").'pass).'">'; + print ''.$langs->trans("Password").'pass).'">'; } // Morphy $morphys["phy"] = $langs->trans("Physical"); @@ -1134,7 +1132,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // EMail print ''.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').''; - print ''.img_picto('', 'object_email').' email).'">'; + print ''.img_picto('', 'object_email').' email).'">'; // Address print ''.$langs->trans("Address").''; @@ -1151,14 +1149,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Country //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined print ''.$langs->trans('Country').''; - print $form->select_country(isset($_POST["country_id"]) ? $_POST["country_id"] : $object->country_id, 'country_id'); + print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; // State if (empty($conf->global->MEMBER_DISABLE_STATE)) { print ''.$langs->trans('State').''; - print $formcompany->select_state($object->state_id, isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id); + print $formcompany->select_state($object->state_id, GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id); print ''; } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 15494596e0f..5df6db52f3d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -79,8 +79,8 @@ class Adherent extends CommonObject public $pass; /** - * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) - */ + * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + */ public $pass_indatabase; /** @@ -103,6 +103,7 @@ class Adherent extends CommonObject * @var int Thirdparty ID */ public $fk_soc; + public $socid; /** * @var string Address @@ -1262,14 +1263,15 @@ class Adherent extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; - if ($rowid) - $sql .= " AND d.rowid=".$rowid; - elseif ($ref || $fk_soc) { + if ($rowid) { + $sql .= " AND d.rowid=".((int) $rowid); + } elseif ($ref || $fk_soc) { $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if ($ref) + if ($ref) { $sql .= " AND d.rowid='".$this->db->escape($ref)."'"; - elseif ($fk_soc > 0) - $sql .= " AND d.fk_soc=".$fk_soc; + } elseif ($fk_soc > 0) { + $sql .= " AND d.fk_soc=".((int) $fk_soc); + } } elseif ($ref_ext) { $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 713812b639b..b6349bf9dc2 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -250,10 +250,10 @@ class Subscription extends CommonObject $this->db->begin(); - if (!is_numeric($this->amount)) { - $this->error = 'BadValueForParameterAmount'; - return -1; - } + if (!is_numeric($this->amount)) { + $this->error = 'BadValueForParameterAmount'; + return -1; + } $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; $sql .= " fk_type = ".$this->fk_type.","; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 611542b8ebc..1c4e42da1fe 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -333,7 +333,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $listofpaths = array(); $listofnames = array(); $listofmimes = array(); - if (is_object($object->invoice)) { + if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) { $invoicediroutput = $conf->facture->dir_output; $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); $file = $fileparams['fullname']; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index d3b918b9849..e9e6be408c8 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -719,7 +719,7 @@ if ($rowid > 0) { print ''.$langs->trans("Ref").''.$object->id.''; - print ''.$langs->trans("Label").''; + print ''.$langs->trans("Label").''; print ''.$langs->trans("Status").''; print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index e661bde6ea7..f2c3b785160 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('members', 'languages')); $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); +$ref = GETPOST('ref', 'alphanohtml'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); @@ -67,15 +68,17 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad $object->fetch($id); $current_lang = $langs->getDefaultLang(); + $forcelangprod = GETPOST("forcelangprod", 'aZ09'); + // update of object - if ($_POST["forcelangprod"] == $current_lang) { - $object->label = $_POST["libelle"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); - $object->other = dol_htmlcleanlastbr($_POST["other"]); + if ($forcelangprod == $current_lang) { + $object->label = GETPOST("libelle", 'alphanohtml'); + $object->description = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); + $object->other = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); } else { - $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); - $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); + $object->multilangs[$forcelangprod]["label"] = GETPOST("libelle", 'alphanohtml'); + $object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); + $object->multilangs[$forcelangprod]["other"] = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); } // backup into database @@ -95,13 +98,13 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a foreach ($object->multilangs as $key => $value) { // saving new values in the object if ($key == $current_lang) { - $object->label = $_POST["libelle-".$key]; - $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); - $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); + $object->label = GETPOST("libelle-".$key, 'alphanohtml'); + $object->description = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); + $object->other = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); } else { - $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); - $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); + $object->multilangs[$key]["label"] = GETPOST("libelle-".$key, 'alphanohtml'); + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); + $object->multilangs[$key]["other"] = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); } } @@ -205,7 +208,7 @@ if ($action == 'edit') { print '
'; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 88babe27385..d21ffdb1630 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -391,7 +391,7 @@ foreach ($dirmodels as $reldir) { // Preview print ''."\n"; @@ -412,7 +414,7 @@ foreach ($dirmodels as $reldir) print ''; print ''; print "\n"; -foreach ($boxtoadd as $box) -{ - if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) - { +foreach ($boxtoadd as $box) { + if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) { $logo = $box->boximg; } else { $logo = preg_replace("/^object_/i", "", $box->boximg); @@ -349,14 +332,17 @@ foreach ($boxtoadd as $box) print "\n".''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -368,8 +354,7 @@ foreach ($boxtoadd as $box) print ''."\n"; } -if (!count($boxtoadd) && count($boxactivated)) -{ +if (!count($boxtoadd) && count($boxactivated)) { print ''; } print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); @@ -264,7 +267,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { print '
'.$langs->trans('Language').''; print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 2ffbf15d7ce..c1f77f4995e 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -292,7 +292,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index db3bc348716..34c3af89c53 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -232,8 +232,10 @@ foreach ($dirmodels as $reldir) // 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); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 19450905c23..63c3350fd9d 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -31,7 +31,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'boxes', 'accountancy')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $rowid = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); @@ -46,39 +48,34 @@ $boxes = array(); * Actions */ -if ($action == 'addconst') -{ +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); } if ($action == 'add') { $error = 0; + $boxids = GETPOST('boxid', 'array'); + $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=... - { + if (is_array($boxids)) { + foreach ($boxids 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) - { + 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) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $distinctfkuser[$obj->fk_user] = $obj->fk_user; $i++; @@ -91,26 +88,28 @@ if ($action == 'add') { $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 != '') - { + 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)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $boxorder = $obj->box_order; - if (preg_match('/A/', $boxorder)) $nbboxonleft++; - if (preg_match('/B/', $boxorder)) $nbboxonright++; + if (preg_match('/A/', $boxorder)) { + $nbboxonleft++; + } + if (preg_match('/B/', $boxorder)) { + $nbboxonright++; + } $arrayofexistingboxid[$obj->box_id] = 1; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } if (empty($arrayofexistingboxid[$boxid['value']])) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; @@ -121,8 +120,7 @@ if ($action == 'add') { dol_syslog("boxes.php activate box", LOG_DEBUG); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); $error++; } @@ -134,8 +132,7 @@ if ($action == 'add') { } } } - if (!$error) - { + if (!$error) { $db->commit(); $action = ''; } else { @@ -143,15 +140,13 @@ if ($action == 'add') { } } -if ($action == 'delete') -{ +if ($action == 'delete') { $sql = "SELECT box_id FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE rowid=".$rowid; + $sql .= " WHERE rowid=".((int) $rowid); $resql = $db->query($sql); $obj = $db->fetch_object($resql); - if (!empty($obj->box_id)) - { + 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) @@ -169,8 +164,7 @@ if ($action == 'delete') } } -if ($action == 'switch') -{ +if ($action == 'switch') { // We switch values of field box_order for the 2 lines of table boxes $db->begin(); @@ -182,12 +176,10 @@ if ($action == 'switch') $resultupdatefrom = 0; $resultupdateto = 0; - if (is_object($objfrom) && is_object($objto)) - { + if (is_object($objfrom) && is_object($objto)) { $newfirst = $objto->box_order; $newsecond = $objfrom->box_order; - if ($newfirst == $newsecond) - { + 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); @@ -195,16 +187,19 @@ if ($action == 'switch') $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$db->escape($newfirst)."' WHERE rowid=".((int) $objfrom->rowid); dol_syslog($sql); $resultupdatefrom = $db->query($sql); - if (!$resultupdatefrom) { dol_print_error($db); } + if (!$resultupdatefrom) { + dol_print_error($db); + } $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$db->escape($newsecond)."' WHERE rowid=".((int) $objto->rowid); dol_syslog($sql); $resultupdateto = $db->query($sql); - if (!$resultupdateto) { dol_print_error($db); } + if (!$resultupdateto) { + dol_print_error($db); + } } - if ($resultupdatefrom && $resultupdateto) - { + if ($resultupdatefrom && $resultupdateto) { $db->commit(); } else { $db->rollback(); @@ -241,33 +236,31 @@ $sql .= " ORDER by b.position, b.box_order"; dol_syslog("Search available boxes", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); // Check record to know if we must recalculate sort order $i = 0; $decalage = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $boxes[$obj->position][$obj->box_id] = 1; $i++; array_push($actives, $obj->box_id); - if ($obj->box_order == '' || $obj->box_order == '0' || $decalage) $decalage++; + if ($obj->box_order == '' || $obj->box_order == '0' || $decalage) { + $decalage++; + } // We renumber the order of the boxes if one of them is in '' // This occurs just after an insert. - if ($decalage) - { + if ($decalage) { $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$db->escape($decalage)."' WHERE rowid=".$obj->rowid; $db->query($sql); } } - if ($decalage) - { + if ($decalage) { // If we have renumbered, we correct the field box_order // This occurs just after an insert. $sql = "SELECT box_order"; @@ -277,32 +270,24 @@ if ($resql) dol_syslog("Execute requests to renumber box order", LOG_DEBUG); $result = $db->query($sql); - if ($result) - { - while ($record = $db->fetch_array($result)) - { - if (dol_strlen($record['box_order']) == 1) - { - if (preg_match("/[13579]{1}/", substr($record['box_order'], -1))) - { + if ($result) { + while ($record = $db->fetch_array($result)) { + if (dol_strlen($record['box_order']) == 1) { + if (preg_match("/[13579]{1}/", substr($record['box_order'], -1))) { $box_order = "A0".$record['box_order']; $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$db->escape($box_order)."' WHERE entity = ".$conf->entity." AND box_order = '".$db->escape($record['box_order'])."'"; $resql = $db->query($sql); - } elseif (preg_match("/[02468]{1}/", substr($record['box_order'], -1))) - { + } elseif (preg_match("/[02468]{1}/", substr($record['box_order'], -1))) { $box_order = "B0".$record['box_order']; $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$db->escape($box_order)."' WHERE entity = ".$conf->entity." AND box_order = '".$db->escape($record['box_order'])."'"; $resql = $db->query($sql); } - } elseif (dol_strlen($record['box_order']) == 2) - { - if (preg_match("/[13579]{1}/", substr($record['box_order'], -1))) - { + } elseif (dol_strlen($record['box_order']) == 2) { + if (preg_match("/[13579]{1}/", substr($record['box_order'], -1))) { $box_order = "A".$record['box_order']; $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$db->escape($box_order)."' WHERE entity = ".$conf->entity." AND box_order = '".$db->escape($record['box_order'])."'"; $resql = $db->query($sql); - } elseif (preg_match("/[02468]{1}/", substr($record['box_order'], -1))) - { + } elseif (preg_match("/[02468]{1}/", substr($record['box_order'], -1))) { $box_order = "B".$record['box_order']; $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$db->escape($box_order)."' WHERE entity = ".$conf->entity." AND box_order = '".$db->escape($record['box_order'])."'"; $resql = $db->query($sql); @@ -337,10 +322,8 @@ print ''.$langs->trans("SourceFile").''.$langs->trans("ActivateOn").'
'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); - if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; + if (!empty($box->class) && preg_match('/graph_/', $box->class)) { + print ' ('.$langs->trans("Graph").')'; + } print ''; - if ($box->note == '(WarningUsingThisBoxSlowDown)') - { + if ($box->note == '(WarningUsingThisBoxSlowDown)') { $langs->load("errors"); print $langs->trans("WarningUsingThisBoxSlowDown"); - } else print ($box->note ? $box->note : ' '); + } else { + print ($box->note ? $box->note : ' '); + } print ''.$box->sourcefile.'
'.$langs->trans("AllWidgetsWereEnabled").'
'."\n"; @@ -399,10 +384,8 @@ print ''."\n"; $box_order = 1; $foundrupture = 1; -foreach ($boxactivated as $key => $box) -{ - if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) - { +foreach ($boxactivated as $key => $box) { + if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) { $logo = $box->boximg; } else { $logo = preg_replace("/^object_/i", "", $box->boximg); @@ -411,14 +394,17 @@ foreach ($boxactivated as $key => $box) 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").')'; + if (!empty($box->class) && preg_match('/graph_/', $box->class)) { + print ' ('.$langs->trans("Graph").')'; + } print ''; print ''; - if ($box->note == '(WarningUsingThisBoxSlowDown)') - { + if ($box->note == '(WarningUsingThisBoxSlowDown)') { $langs->load("errors"); print img_warning('', 0).' '.$langs->trans("WarningUsingThisBoxSlowDown"); - } else print ($box->note ? $box->note : ' '); + } else { + print ($box->note ? $box->note : ' '); + } print ''; print ''.(empty($pos_name[$box->position]) ? '' : $langs->trans($pos_name[$box->position])).''; $hasnext = ($key < (count($boxactivated) - 1)); @@ -447,6 +433,7 @@ print load_fiche_titre($langs->trans("Other"), '', ''); print '
'; print ''; print ''; +print '
'; print ''; print ''; @@ -472,6 +459,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVA } print '
'; +print '
'; print '
'; print '
'; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 4fee30d274e..8c2acb5dc8b 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -168,8 +168,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 594052500ca..25a220e8e2d 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -297,8 +297,10 @@ foreach ($dirmodels as $reldir) // 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); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -482,7 +484,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 8b900f552c8..51d7f84aae7 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -406,11 +406,12 @@ print ''; print ''."\n"; +// Zip print ''; -print ''."\n"; +print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; // Country print ''; @@ -727,7 +728,7 @@ if ($mysoc->useLocalTax(1)) print '
'; $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code); $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."\n" : ""); - print ""; + print '"; if (!isOnlyOneLocalTax(1)) { print '
: '; @@ -750,9 +751,9 @@ if ($mysoc->useLocalTax(1)) } else { if (empty($mysoc->country_code)) { - print ''.$countrynotdefined.''; + print ''.$countrynotdefined.''; } else { - print ''.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).''; + print ''.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).''; } } @@ -772,7 +773,7 @@ if ($mysoc->useLocalTax(2)) print "global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).""; print ''; print '
'; - print ""; + print '"; $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code); $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."\n" : ""); if (!isOnlyOneLocalTax(2)) @@ -796,9 +797,9 @@ if ($mysoc->useLocalTax(2)) } else { if (empty($mysoc->country_code)) { - print ''.$countrynotdefined.''; + print ''.$countrynotdefined.''; } else { - print ''.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).''; + print ''.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).''; } } @@ -824,9 +825,9 @@ if ($mysoc->useRevenueStamp()) } else { if (empty($mysoc->country_code)) { - print ''.$countrynotdefined.''; + print ''.$countrynotdefined.''; } else { - print ''.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).''; + print ''.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).''; } } diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index bfdff79cc1f..b5e4c0ddf45 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -229,7 +229,11 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -410,7 +414,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'contract').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 5ff7f022ba4..d605f75c511 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -188,7 +188,7 @@ if ($action == 'update') if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; // Update values for ($i = 0; $i < 4; $i++) { - if (isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); } } diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index d9c1b2ebe17..b1606268205 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -229,7 +229,8 @@ foreach ($dirmodels as $reldir) print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -397,7 +398,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'sending').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index a185071c227..d06f8a2ce31 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -682,7 +682,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) { // Discard check of mandatory fields for country for some tables if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory - if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory + if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory // Discard check of mandatory fiedls for other fields if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; @@ -690,7 +690,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'dayrule' && empty($_POST['dayrule'])) continue; if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position' - if ((!isset($_POST[$value]) || $_POST[$value] == '') + if ((!GETPOSTISSET($value) || GETPOST($value) == '') && (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto')) // Fields that are not mandatory && (!($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 ) @@ -719,7 +719,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } } // Other checks - if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system', 'systemauto'))) { + if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) { $ok = 0; setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); } @@ -757,7 +757,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null - if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code + if ($id == 10 && GETPOSTISSET("code")) // Spaces are not allowed into code { $_POST["code"] = preg_replace('/\s/', '', $_POST["code"]); } diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index fd3361515fb..9e8b957d541 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -223,21 +223,6 @@ $help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électro llxHeader('', 'EmailCollector', $help_url); -// Example : Adding jquery code -print ''; - // Part to create if ($action == 'create') { print load_fiche_titre($langs->trans("NewEmailCollector", $langs->transnoentitiesnoconv("EmailCollector"))); @@ -433,6 +418,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!$connection) { $morehtml .= 'Failed to open IMAP connection '.$connectstringsource; + $morehtml .= '
'.imap_last_error(); + //var_dump(imap_errors()) } else { $morehtml .= imap_num_msg($connection); } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index b446851b539..9a09c62b818 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -234,7 +234,8 @@ foreach ($dirmodels as $reldir) print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -414,7 +415,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index f572226c379..a93f5c3c608 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -238,8 +238,10 @@ foreach ($dirmodels as $reldir) // 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); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -409,7 +411,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'intervention').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 35dd1002b12..00dcb7c3180 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -313,8 +313,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -547,7 +549,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 64660b67365..e3178d946a0 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -291,8 +291,10 @@ foreach ($dirmodels as $reldir) // 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); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -465,7 +467,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'intervention').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index be09a062703..eca8319d661 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -229,7 +229,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -423,7 +426,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'contract').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index ec6ab640125..ad2cd408471 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -241,8 +241,8 @@ print ''; clearstatcache(); print '
'; -print ''; -print ''; +print '
'.$langs->trans("Language").'
'; +print ''; print ''; // Default language diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 43c4cc84776..34da6f7d34e 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -100,9 +100,12 @@ if ($action == 'update') $form = new Form($db); -llxHeader(); +$title = $langs->trans("LimitsSetup"); +$help_url = ''; -print load_fiche_titre($langs->trans("LimitsSetup"), '', 'title_setup'); +llxHeader('', $title, $help_url); + +print load_fiche_titre($title, '', 'title_setup'); $aCurrencies = array($conf->currency); // Default currency always first position @@ -125,7 +128,8 @@ if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY if (!empty($aCurrencies) && count($aCurrencies) > 1) { $head = multicurrencyLimitPrepareHead($aCurrencies); - print dol_get_fiche_head($head, $currencycode, '', -1, "multicurrency"); + + print dol_get_fiche_head($head, $currencycode, '', -1, ''); } } @@ -172,6 +176,7 @@ if ($action == 'edit') print ''; print '
'; } else { + print '
'; print '
'.img_picto('', 'language').' '.$langs->trans("Language").'
'; print ''; @@ -191,6 +196,7 @@ if ($action == 'edit') print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.(isset($conf->global->$mainroundingruletot) ? $conf->global->$mainroundingruletot : $conf->global->MAIN_ROUNDING_RULE_TOT).'
'; + print '
'; print '
'; print ''.$langs->trans("Modify").''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index a89480314a6..77f4d14dc77 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -178,6 +178,7 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true); + jQuery(".smtp_method").hide(); jQuery(".dkim").hide(); '; if ($linuxlike) @@ -191,7 +192,7 @@ if ($action == 'edit') print ' jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true); jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true); - jQuery("#smtp_server_mess").hide(); + jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide();'; } print ' @@ -220,7 +221,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_SMTP_PORT").show(); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide(); - jQuery(".dkim").hide(); + jQuery(".smtp_method").show(); + jQuery(".dkim").hide(); } if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\') { @@ -246,6 +248,7 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_SMTP_PORT").show(); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide(); + jQuery(".smtp_method").show(); jQuery(".dkim").show(); } } @@ -318,13 +321,15 @@ if ($action == 'edit') print ''; // Host server - print ''; - if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') - { + print ''; + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { + print ''; print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; + print ''; } else { + print ''; $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ''); $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); @@ -333,17 +338,19 @@ if ($action == 'edit') // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; + print ' '.$langs->trans("SeeLinkToOnlineDocumentation").''; } else { $text = !empty($mainserver) ? $mainserver : $smtpserver; $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print ''; } + print ''; } - print ''; + print ''; // Port print ''; @@ -856,8 +863,8 @@ if ($action == 'edit') include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); - $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromname = (GETPOSTISSET('fromname') ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (GETPOSTISSET('frommail') ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->fromid = $user->id; $formmail->fromalsorobot = 1; $formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); @@ -865,13 +872,13 @@ if ($action == 'edit') $formmail->withsubstit = 1; $formmail->withfrom = 1; $formmail->witherrorsto = 1; - $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); - $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty - $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty - $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withto = (!empty($_POST['sendto']) ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!empty($_POST['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test")); $formmail->withtopicreadonly = 0; $formmail->withfile = 2; - $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); $formmail->withbodyreadonly = 0; $formmail->withcancel = 1; $formmail->withdeliveryreceipt = 1; diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index faa72f4fc7c..84cc97d86d4 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -564,20 +564,20 @@ if ($action == 'edit') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); $formmail->withfromreadonly = 0; $formmail->withsubstit = 0; $formmail->withfrom = 1; $formmail->witherrorsto = 1; - $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); - $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty - $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty - $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withto = (!GETPOST('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!GETPOST(['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!GETPOST(['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test")); $formmail->withtopicreadonly = 0; $formmail->withfile = 2; - $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); $formmail->withbodyreadonly = 0; $formmail->withcancel = 1; $formmail->withdeliveryreceipt = 1; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 872c0d414eb..6538d5c3011 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -271,7 +271,7 @@ if (empty($reshook)) { // Rename some POST variables into a generic name 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') + if ((!GETPOSTISSET($value) || GETPOST($value) == '' || GETPOST($value) == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { $ok = 0; $fieldnamekey = $listfield[$f]; @@ -1074,7 +1074,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; if ($context == 'edit' && !empty($obj->{$fieldlist[$field]}) && !in_array($obj->{$fieldlist[$field]}, array_keys($elementList))) { - // Current tempalte type is an unknown type, so we must keep it as it is. + // Current template type is an unknown type, so we must keep it as it is. print ''; print $obj->{$fieldlist[$field]}; } else { diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 49dc61a270a..1e1c3db3fad 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -530,20 +530,20 @@ if ($action == 'edit') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromname = (GETPOSTISSET('fromname') ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (GETPOSTISSET('frommail') ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); $formmail->withfromreadonly = 0; $formmail->withsubstit = 0; $formmail->withfrom = 1; $formmail->witherrorsto = 1; - $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); - $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty - $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty - $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withto = (!empty($_POST['sendto']) ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!empty($_POST['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test")); $formmail->withtopicreadonly = 0; $formmail->withfile = 2; - $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); $formmail->withbodyreadonly = 0; $formmail->withcancel = 1; $formmail->withdeliveryreceipt = 1; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index d7e0962239b..e9984316394 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -28,7 +28,9 @@ * \brief Page to activate/disable all modules */ -if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +if (!defined('CSRFCHECK_WITH_TOKEN')) { + define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +} require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -41,7 +43,9 @@ require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; $langs->loadLangs(array("errors", "admin", "modulebuilder")); $mode = GETPOSTISSET('mode') ? GETPOST('mode', 'alpha') : (empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common'); -if (empty($mode)) $mode = 'common'; +if (empty($mode)) { + $mode = 'common'; +} $action = GETPOST('action', 'aZ09'); //var_dump($_POST);exit; $value = GETPOST('value', 'alpha'); @@ -62,8 +66,9 @@ $options['search'] = GETPOST('search_keyword', 'alpha'); $dolistore = new Dolistore(false); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $familyinfo = array( 'hr'=>array('position'=>'001', 'label'=>$langs->trans("ModuleFamilyHr")), @@ -81,12 +86,19 @@ $familyinfo = array( ); $param = ''; -if (!GETPOST('buttonreset', 'alpha')) -{ - if ($search_keyword) $param .= '&search_keyword='.urlencode($search_keyword); - if ($search_status && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); - if ($search_nature && $search_nature != '-1') $param .= '&search_nature='.urlencode($search_nature); - if ($search_version && $search_version != '-1') $param .= '&search_version='.urlencode($search_version); +if (!GETPOST('buttonreset', 'alpha')) { + if ($search_keyword) { + $param .= '&search_keyword='.urlencode($search_keyword); + } + if ($search_status && $search_status != '-1') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_nature && $search_nature != '-1') { + $param .= '&search_nature='.urlencode($search_nature); + } + if ($search_version && $search_version != '-1') { + $param .= '&search_version='.urlencode($search_version); + } } $dirins = DOL_DOCUMENT_ROOT.'/custom'; @@ -104,18 +116,18 @@ $formconfirm = ''; $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (GETPOST('buttonreset', 'alpha')) -{ +if (GETPOST('buttonreset', 'alpha')) { $search_keyword = ''; $search_status = ''; $search_nature = ''; $search_version = ''; } -if ($action == 'install') -{ +if ($action == 'install') { $error = 0; // $original_file should match format module_modulename-x.y[.z].zip @@ -123,54 +135,45 @@ if ($action == 'install') $original_file = preg_replace('/\(\d+\)\.zip$/i', '.zip', $original_file); $newfile = $conf->admin->dir_temp.'/'.$original_file.'/'.$original_file; - if (!$original_file) - { + if (!$original_file) { $langs->load("Error"); setEventMessages($langs->trans("ErrorModuleFileRequired"), null, 'warnings'); $error++; } else { - if (!$error && !preg_match('/\.zip$/i', $original_file)) - { + if (!$error && !preg_match('/\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors'); $error++; } - if (!$error && !preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) - { + if (!$error && !preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'module_*-x.y*.zip'), null, 'errors'); $error++; } - if (empty($_FILES['fileinstall']['tmp_name'])) - { + if (empty($_FILES['fileinstall']['tmp_name'])) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); $error++; } } - if (!$error) - { - if ($original_file) - { + if (!$error) { + if ($original_file) { @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file); dol_mkdir($conf->admin->dir_temp.'/'.$original_file); } $tmpdir = preg_replace('/\.zip$/i', '', $original_file).'.dir'; - if ($tmpdir) - { + if ($tmpdir) { @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$tmpdir); dol_mkdir($conf->admin->dir_temp.'/'.$tmpdir); } $result = dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'], $newfile, 1, 0, $_FILES['fileinstall']['error']); - if ($result > 0) - { + if ($result > 0) { $result = dol_uncompress($newfile, $conf->admin->dir_temp.'/'.$tmpdir); - if (!empty($result['error'])) - { + if (!empty($result['error'])) { $langs->load("errors"); setEventMessages($langs->trans($result['error'], $original_file), null, 'errors'); $error++; @@ -181,19 +184,16 @@ if ($action == 'install') // Search dir $modulename $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example ./mymodule - if (!dol_is_dir($modulenamedir)) - { + if (!dol_is_dir($modulenamedir)) { $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example ./htdocs/mymodule //var_dump($modulenamedir); - if (!dol_is_dir($modulenamedir)) - { + if (!dol_is_dir($modulenamedir)) { setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'
'.$langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat2", $modulename, 'htdocs/'.$modulename), null, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { // TODO Make more test } @@ -209,18 +209,22 @@ if ($action == 'install') //var_dump($modulenamearrays);exit; foreach ($modulenamearrays as $modulenameval) { - if (strpos($modulenameval, '#') === 0) continue; // Discard comments - if (strpos($modulenameval, '//') === 0) continue; // Discard comments - if (!trim($modulenameval)) continue; + if (strpos($modulenameval, '#') === 0) { + continue; // Discard comments + } + if (strpos($modulenameval, '//') === 0) { + continue; // Discard comments + } + if (!trim($modulenameval)) { + continue; + } // Now we install the module - if (!$error) - { + if (!$error) { @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the zip file dol_syslog("We copy now directory ".$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval." into target dir ".$dirins.'/'.$modulenameval); $result = dolCopyDir($modulenamedir, $dirins.'/'.$modulenameval, '0444', 1); - if ($result <= 0) - { + if ($result <= 0) { dol_syslog('Failed to call dolCopyDir result='.$result." with param ".$modulenamedir." and ".$dirins.'/'.$modulenameval, LOG_WARNING); $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyDir", $modulenamedir, $dirins.'/'.$modulenameval), null, 'errors'); @@ -235,40 +239,39 @@ if ($action == 'install') } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")), null, 'warnings'); } } -if ($action == 'set' && $user->admin) -{ +if ($action == 'set' && $user->admin) { $resarray = activateModule($value); - if (!empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); - else { + if (!empty($resarray['errors'])) { + setEventMessages('', $resarray['errors'], 'errors'); + } else { //var_dump($resarray);exit; - if ($resarray['nbperms'] > 0) - { + if ($resarray['nbperms'] > 0) { $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; $resqltmp = $db->query($tmpsql); - if ($resqltmp) - { + if ($resqltmp) { $obj = $db->fetch_object($resqltmp); //var_dump($obj->nb);exit; - if ($obj && $obj->nb > 1) - { + if ($obj && $obj->nb > 1) { $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); setEventMessages($msg, null, 'warnings'); } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } } header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; -} elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') -{ +} elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') { $result = unActivateModule($value); - if ($result) setEventMessages($result, null, 'errors'); + if ($result) { + setEventMessages($result, null, 'errors'); + } header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; } @@ -285,8 +288,7 @@ $morejs = array(); $morecss = array("/admin/dolistore/css/dolistore.css"); // Set dir where external modules are installed -if (!dol_is_dir($dirins)) -{ +if (!dol_is_dir($dirins)) { dol_mkdir($dirins); } $dirins_ok = (dol_is_dir($dirins)); @@ -310,25 +312,19 @@ $i = 0; // is a sequencer of modules found $j = 0; // j is module number. Automatically affected if module number not defined. $modNameLoaded = array(); -foreach ($modulesdir as $dir) -{ +foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
"; dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)"); $handle = @opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); - if ($modName) - { - if (!empty($modNameLoaded[$modName])) // In cache of already loaded modules ? - { + if ($modName) { + if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ? $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; setEventMessages($mesg, null, 'warnings'); dol_syslog($mesg, LOG_ERR); @@ -337,14 +333,12 @@ foreach ($modulesdir as $dir) try { $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. - if (class_exists($modName)) - { + if (class_exists($modName)) { try { $objMod = new $modName($db); $modNameLoaded[$modName] = $dir; - if (!$objMod->numero > 0 && $modName != 'modUser') - { - dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); + if (!$objMod->numero > 0 && $modName != 'modUser') { + dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); } $j = $objMod->numero; @@ -352,21 +346,26 @@ foreach ($modulesdir as $dir) // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; - if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) { + $modulequalified = 0; + } + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) { + $modulequalified = 0; + } + if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) { + $modulequalified = 0; + } // We discard modules according to property ->hidden - if (!empty($objMod->hidden)) $modulequalified = 0; + if (!empty($objMod->hidden)) { + $modulequalified = 0; + } - if ($modulequalified > 0) - { + if ($modulequalified > 0) { $publisher = dol_escape_htmltag($objMod->getPublisher()); $external = ($objMod->isCoreOrExternalModule() == 'external'); - if ($external) - { - if ($publisher) - { + if ($external) { + if ($publisher) { $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; } else { $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); @@ -387,25 +386,21 @@ foreach ($modulesdir as $dir) } $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); - if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) - { + if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) { $moduleposition = '80'; // External modules at end by default } // Add list of warnings to show into arrayofwarnings and arrayofwarningsext - if (!empty($objMod->warnings_activation)) - { + if (!empty($objMod->warnings_activation)) { $arrayofwarnings[$modName] = $objMod->warnings_activation; } - if (!empty($objMod->warnings_activation_ext)) - { + if (!empty($objMod->warnings_activation_ext)) { $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; } $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); - if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) - { + if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). if (is_numeric($familyposition)) { $familyposition = sprintf("%03d", (int) $familyposition + 100); @@ -416,21 +411,26 @@ foreach ($modulesdir as $dir) // Set categ[$i] $specialstring = 'unknown'; - if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; - if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories - else $categ[$specialstring] = 1; + if ($objMod->version == 'development' || $objMod->version == 'experimental') { + $specialstring = 'expdev'; + } + if (isset($categ[$specialstring])) { + $categ[$specialstring]++; // Array of all different modules categories + } else { + $categ[$specialstring] = 1; + } $j++; $i++; - } else dol_syslog("Module ".get_class($objMod)." not qualified"); - } catch (Exception $e) - { + } else { + dol_syslog("Module ".get_class($objMod)." not qualified"); + } + } catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } } else { print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } - } catch (Exception $e) - { + } catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } } @@ -442,12 +442,13 @@ foreach ($modulesdir as $dir) } } -if ($action == 'reset_confirm' && $user->admin) -{ +if ($action == 'reset_confirm' && $user->admin) { if (!empty($modules[$value])) { $objMod = $modules[$value]; - if (!empty($objMod->langfiles)) $langs->loadLangs($objMod->langfiles); + if (!empty($objMod->langfiles)) { + $langs->loadLangs($objMod->langfiles); + } $form = new Form($db); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1); @@ -464,16 +465,27 @@ asort($orders); $nbofactivatedmodules = count($conf->modules); $moreinfo = $langs->trans("TitleNumberOfActivatedModules"); $moreinfo2 = ($nbofactivatedmodules - 1)." / ".count($modules); -if ($nbofactivatedmodules <= 1) $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); +if ($nbofactivatedmodules <= 1) { + $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); +} print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup'); // Start to show page -if ($mode == 'common') print ''.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."
\n"; -if ($mode == 'commonkanban') print ''.$langs->trans("ModulesDesc", img_picto('', 'switch_off'))."
\n"; -if ($mode == 'marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; -if ($mode == 'deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; -if ($mode == 'develop') print ''.$langs->trans("ModulesDevelopDesc")."
\n"; +if ($mode == 'common' || $mode == 'commonkanban') { + $desc = $langs->trans("ModulesDesc", '{picto}'); + $desc = str_replace('{picto}', img_picto('', 'switch_off'), $desc); + print ''.$desc."
\n"; +} +if ($mode == 'marketplace') { + print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; +} +if ($mode == 'deploy') { + print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; +} +if ($mode == 'develop') { + print ''.$langs->trans("ModulesDevelopDesc")."
\n"; +} $head = modules_prepare_head(); @@ -481,22 +493,20 @@ $head = modules_prepare_head(); print "
\n"; -if ($mode == 'common' || $mode == 'commonkanban') -{ +if ($mode == 'common' || $mode == 'commonkanban') { dol_set_focus('#search_keyword'); print '
'; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; print ''; print ''; - $newmode = $mode; - if ($newmode == 'common') $newmode = 'commonkanban'; - - print dol_get_fiche_head($head, $newmode, '', -1); + print dol_get_fiche_head($head, 'modules', '', -1); $moreforfilter = '
'; @@ -514,12 +524,17 @@ if ($mode == 'common' || $mode == 'commonkanban') $moreforfilter .= '
'; $moreforfilter .= $langs->trans('Origin').': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200', 1); $moreforfilter .= '
'; - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) - { + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable")); - if ($conf->global->MAIN_FEATURES_LEVEL < 0) $array_version['deprecated'] = $langs->trans("Deprecated"); - if ($conf->global->MAIN_FEATURES_LEVEL > 0) $array_version['experimental'] = $langs->trans("Experimental"); - if ($conf->global->MAIN_FEATURES_LEVEL > 1) $array_version['development'] = $langs->trans("Development"); + if ($conf->global->MAIN_FEATURES_LEVEL < 0) { + $array_version['deprecated'] = $langs->trans("Deprecated"); + } + if ($conf->global->MAIN_FEATURES_LEVEL > 0) { + $array_version['experimental'] = $langs->trans("Experimental"); + } + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { + $array_version['development'] = $langs->trans("Development"); + } $moreforfilter .= '
'; $moreforfilter .= $langs->trans('Version').': '.$form->selectarray('search_version', $array_version, $search_version, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); $moreforfilter .= '
'; @@ -537,8 +552,7 @@ if ($mode == 'common' || $mode == 'commonkanban') $moreforfilter .= '
'; - if (!empty($moreforfilter)) - { + if (!empty($moreforfilter)) { print $moreforfilter; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -552,14 +566,15 @@ if ($mode == 'common' || $mode == 'commonkanban') $object = new stdClass(); $parameters = array(); $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } // Show list of modules $oldfamily = ''; $linenum = 0; - foreach ($orders as $key => $value) - { + foreach ($orders as $key => $value) { $linenum++; $tab = explode('_', $value); $familykey = $tab[1]; @@ -569,12 +584,13 @@ if ($mode == 'common' || $mode == 'commonkanban') $objMod = $modules[$modName]; //print $objMod->name." - ".$key." - ".$objMod->version."
"; - if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') { + continue; // Discard if not for current tab + } - if (!$objMod->getName()) - { + if (!$objMod->getName()) { dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING); - continue; + continue; } $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); @@ -587,48 +603,65 @@ if ($mode == 'common' || $mode == 'commonkanban') $moduleauthor = $objMod->getPublisher(); // We discard showing according to filters - if ($search_keyword) - { + if ($search_keyword) { $qualified = 0; if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename) || preg_match('/'.preg_quote($search_keyword).'/i', $moduletechnicalname) || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc) || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong) || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor) - ) $qualified = 1; - if (!$qualified) continue; + ) { + $qualified = 1; + } + if (!$qualified) { + continue; + } } - if ($search_status) - { - if ($search_status == 'active' && empty($conf->global->$const_name)) continue; - if ($search_status == 'disabled' && !empty($conf->global->$const_name)) continue; + if ($search_status) { + if ($search_status == 'active' && empty($conf->global->$const_name)) { + continue; + } + if ($search_status == 'disabled' && !empty($conf->global->$const_name)) { + continue; + } } - if ($search_nature) - { - if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') continue; + if ($search_nature) { + if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') { + continue; + } $reg = array(); - if (preg_match('/^external_(.*)$/', $search_nature, $reg)) - { + if (preg_match('/^external_(.*)$/', $search_nature, $reg)) { //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher()); $publisher = dol_escape_htmltag($objMod->getPublisher()); - if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) continue; - if (!$reg[1] && !empty($publisher)) continue; + if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) { + continue; + } + if (!$reg[1] && !empty($publisher)) { + continue; + } + } + if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') { + continue; } - if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') continue; } - if ($search_version) - { - if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') continue; - if ($objMod->version != 'development' && ($search_version == 'development')) continue; - if ($objMod->version != 'experimental' && ($search_version == 'experimental')) continue; - if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) continue; + if ($search_version) { + if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') { + continue; + } + if ($objMod->version != 'development' && ($search_version == 'development')) { + continue; + } + if ($objMod->version != 'experimental' && ($search_version == 'experimental')) { + continue; + } + if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) { + continue; + } } // Load all lang files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach ($objMod->langfiles as $domain) - { + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { + foreach ($objMod->langfiles as $domain) { $langs->load($domain); } } @@ -655,8 +688,7 @@ if ($mode == 'common' || $mode == 'commonkanban') $atleastoneforfamily++; - if ($familykey != $oldfamily) - { + if ($familykey != $oldfamily) { $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label']; $oldfamily = $familykey; } @@ -664,17 +696,22 @@ if ($mode == 'common' || $mode == 'commonkanban') // Version (with picto warning or not) $version = $objMod->getVersion(0); $versiontrans = ''; - if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); - if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); - if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); + if (preg_match('/development/i', $version)) { + $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); + } + if (preg_match('/experimental/i', $version)) { + $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); + } + if (preg_match('/deprecated/i', $version)) { + $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); + } if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { $versiontrans .= $objMod->getVersion(1); } // Define imginfo $imginfo = "info"; - if ($objMod->isCoreOrExternalModule() == 'external') - { + if ($objMod->isCoreOrExternalModule() == 'external') { $imginfo = "info_black"; } @@ -682,25 +719,24 @@ if ($mode == 'common' || $mode == 'commonkanban') $codetoconfig = ''; // Activate/Disable and Setup (2 columns) - if (!empty($conf->global->$const_name)) // If module is already activated - { + if (!empty($conf->global->$const_name)) { // If module is already activated // Set $codeenabledisable $disableSetup = 0; - if (!empty($arrayofwarnings[$modName])) - { + if (!empty($arrayofwarnings[$modName])) { $codeenabledisable .= ''."\n"; } - if (!empty($objMod->disabled)) - { + if (!empty($objMod->disabled)) { $codeenabledisable .= $langs->trans("Disabled"); - } elseif (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) - { - if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) $codeenabledisable .= $langs->trans("Used"); - else { + } elseif (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) { + if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { + $codeenabledisable .= $langs->trans("Used"); + } else { $codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium valignmiddle'); //print $langs->trans("Required"); } - if (!empty($conf->multicompany->enabled) && $user->entity) $disableSetup++; + if (!empty($conf->multicompany->enabled) && $user->entity) { + $disableSetup++; + } } else { if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { $codeenabledisable .= 'warnings_unactivation[$mysoc->country_code].'&value='.$modName.'&mode='.$mode.$param.'">'; @@ -714,29 +750,32 @@ if ($mode == 'common' || $mode == 'commonkanban') } // Set $codetoconfig - if (!empty($objMod->config_page_url) && !$disableSetup) - { + if (!empty($objMod->config_page_url) && !$disableSetup) { $backtourlparam = ''; - if ($search_keyword != '') $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.$search_keyword; // No urlencode here, done later - if ($search_nature > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.$search_nature; - if ($search_version > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.$search_version; - if ($search_status > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.$search_status; + if ($search_keyword != '') { + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.$search_keyword; // No urlencode here, done later + } + if ($search_nature > -1) { + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.$search_nature; + } + if ($search_version > -1) { + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.$search_version; + } + if ($search_status > -1) { + $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.$search_status; + } $backtourl = $_SERVER["PHP_SELF"].$backtourlparam; $regs = array(); - if (is_array($objMod->config_page_url)) - { + if (is_array($objMod->config_page_url)) { $i = 0; - foreach ($objMod->config_page_url as $page) - { + foreach ($objMod->config_page_url as $page) { $urlpage = $page; - if ($i++) - { + if ($i++) { $codetoconfig .= ''.img_picto(ucfirst($page), "setup").''; // print ''.ucfirst($page).' '; } else { - if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) - { + if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { @@ -745,8 +784,7 @@ if ($mode == 'common' || $mode == 'commonkanban') } } } - } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) - { + } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; @@ -757,42 +795,36 @@ if ($mode == 'common' || $mode == 'commonkanban') } else // Module not yet activated { // Set $codeenabledisable - if (!empty($objMod->always_enabled)) - { + if (!empty($objMod->always_enabled)) { // Should never happened - } elseif (!empty($objMod->disabled)) - { + } elseif (!empty($objMod->disabled)) { $codeenabledisable .= $langs->trans("Disabled"); } else { // Module qualified for activation $warningmessage = ''; - if (!empty($arrayofwarnings[$modName])) - { + if (!empty($arrayofwarnings[$modName])) { $codeenabledisable .= ''."\n"; - foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) - { - if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) - { + foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) { + if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) { $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); } } } - if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) - { + if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) { $codeenabledisable .= ''."\n"; - foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) - { + foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) { $keymodulelowercase = strtolower(preg_replace('/^mod/', '', $keymodule)); - if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on - { - foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) - { - if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) - { + if (in_array($keymodulelowercase, $conf->modules)) { // If module that request warning is on + foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) { + if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) { $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); $warningmessage .= ($warningmessage ? "\n" : "").($warningmessage ? "\n" : "").$langs->trans("Module").' : '.$objMod->getName(); - if (!empty($objMod->editor_name)) $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name; - if (!empty($objMod->editor_name)) $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); + if (!empty($objMod->editor_name)) { + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name; + } + if (!empty($objMod->editor_name)) { + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); + } } } } @@ -800,7 +832,9 @@ if ($mode == 'common' || $mode == 'commonkanban') } $codeenabledisable .= ''."\n"; $codeenabledisable .= 'trans("Disabled"), 'switch_off'); $codeenabledisable .= "\n"; @@ -815,17 +849,21 @@ if ($mode == 'common' || $mode == 'commonkanban') print $objMod->getKanbanView($codeenabledisable, $codetoconfig); } else { print ''."\n"; - if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print ''.$linenum.''; + if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) { + print ''.$linenum.''; + } // Picto + Name of module print ' '; $alttext = ''; //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version); //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin); - if (!empty($objMod->picto)) - { - if (preg_match('/^\//i', $objMod->picto)) print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1); - else print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"'); + if (!empty($objMod->picto)) { + if (preg_match('/^\//i', $objMod->picto)) { + print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1); + } else { + print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"'); + } } else { print img_object($alttext, 'generic', 'class="valignmiddle paddingrightonly"'); } @@ -873,8 +911,7 @@ if ($mode == 'common' || $mode == 'commonkanban') } } - if ($oldfamily) - { + if ($oldfamily) { if ($mode == 'commonkanban') { print '
'; } else { @@ -893,8 +930,7 @@ if ($mode == 'common' || $mode == 'commonkanban') print ''; } -if ($mode == 'marketplace') -{ +if ($mode == 'marketplace') { print dol_get_fiche_head($head, $mode, '', -1); // Marketplace @@ -920,8 +956,7 @@ if ($mode == 'marketplace') print '
'; - if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1) - { + if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1) { // $options is array with filter criterias //var_dump($options); $dolistore->getRemoteCategories(); @@ -937,17 +972,17 @@ if ($mode == 'marketplace') print '
'; ?> - -
trans('Keyword') ?>: -
-
-
- - trans('Reset') ?> - -   + +
trans('Keyword') ?>: +
- + + trans('Reset') ?> + +   +
+ '; @@ -958,48 +993,45 @@ if ($mode == 'marketplace') ?> -
-
    - get_categories(); ?> -
-
-
- - - get_products($categorie); ?> - -
-
+
+
    + get_categories(); ?> +
+
+
+ + + get_products($categorie); ?> + +
+
- '.$urldolibarrmodules.''; $message = ''; - if (!empty($allowonlineinstall)) - { - if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) - { + if (!empty($allowonlineinstall)) { + if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) { $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); $allowfromweb = -1; } else { - if ($dirins_ok) - { - if (!is_writable(dol_osencode($dirins))) - { + if ($dirins_ok) { + if (!is_writable(dol_osencode($dirins))) { $langs->load("errors"); $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning'); $allowfromweb = 0; @@ -1014,8 +1046,7 @@ if ($mode == 'deploy') $allowfromweb = 0; } - if ($allowfromweb < 1) - { + if ($allowfromweb < 1) { print $langs->trans("SomethingMakeInstallFromWebNotPossible"); print $message; //print $langs->trans("SomethingMakeInstallFromWebNotPossible2"); @@ -1024,10 +1055,8 @@ if ($mode == 'deploy') print '
'; - if ($allowfromweb >= 0) - { - if ($allowfromweb == 1) - { + if ($allowfromweb >= 0) { + if ($allowfromweb == 1) { //print $langs->trans("ThisIsProcessToFollow").'
'; } else { print $langs->trans("ThisIsAlternativeProcessToFollow").'
'; @@ -1038,8 +1067,7 @@ if ($mode == 'deploy') print ''.$langs->trans("StepNb", 3).': '; } - if ($allowfromweb == 1) - { + if ($allowfromweb == 1) { print $langs->trans("UnpackPackageInModulesRoot", $dirins).'
'; print '
'; @@ -1053,36 +1081,48 @@ if ($mode == 'deploy') $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb $maxphp = @ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; - if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; - if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; - if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; + if (preg_match('/k$/i', $maxphp)) { + $maxphp = $maxphp * 1; + } + if (preg_match('/m$/i', $maxphp)) { + $maxphp = $maxphp * 1024; + } + if (preg_match('/g$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024 * 1024; + } $maxphp2 = @ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; - if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; - if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; - if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1; + } + if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024; + } + if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + } // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; $maxphptoshow = $maxphptoshowparam = ''; - if ($maxphp > 0) - { + if ($maxphp > 0) { $maxmin = min($max, $maxphp); $maxphptoshow = $maxphp; $maxphptoshowparam = 'upload_max_filesize'; } - if ($maxphp2 > 0) - { + if ($maxphp2 > 0) { $maxmin = min($max, $maxphp2); - if ($maxphp2 < $maxphp) - { + if ($maxphp2 < $maxphp) { $maxphptoshow = $maxphp2; $maxphptoshowparam = 'post_max_size'; } } - if ($maxmin > 0) - { + if ($maxmin > 0) { print ''; - $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; @@ -469,7 +454,7 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; print ''."\n"; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 868abac9e54..8444c4e1812 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -183,19 +183,19 @@ class BOM extends CommonObject public $table_element_line = 'bom_bomline'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Fieldname with ID of parent key if this field has a parent */ public $fk_element = 'fk_bom'; /** - * @var int Name of subtable class that manage subtable lines + * @var string Name of subtable class that manage subtable lines */ public $class_element_line = 'BOMLine'; - /** - * @var array List of child tables. To test if we can delete object. - */ - //protected $childtables=array(); + // /** + // * @var array List of child tables. To test if we can delete object. + // */ + // protected $childtables=array(); /** * @var array List of child tables. To know object to delete on cascade. diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e182a91d32a..03610100c9c 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -769,6 +769,7 @@ class Categories extends DolibarrApi $objects = $result; $cleaned_objects = array(); + $objects_api = null; if ($type == 'member') { $objects_api = new Members(); } elseif ($type == 'customer' || $type == 'supplier') { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 3aca92708a7..f55b3403546 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1891,13 +1891,12 @@ class Categorie extends CommonObject return ""; } + $searchCategorySqlList = array(); foreach ($searchList as $searchCategory) { if (intval($searchCategory) == -2) { $searchCategorySqlList[] = " cp.fk_categorie IS NULL"; } elseif (intval($searchCategory) > 0) { - $searchCategorySqlList[] = " ".$rowIdName - ." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type - ." WHERE fk_categorie = ".$searchCategory.")"; + $searchCategorySqlList[] = " ".$rowIdName." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type." WHERE fk_categorie = ".((int) $searchCategory).")"; } } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 7f673a1ecff..864de6e2e98 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -294,7 +294,7 @@ if ($user->rights->categorie->creer) if ($user->rights->categorie->supprimer) { - print 'id.'&type='.$type.'">'.$langs->trans("Delete").''; + print 'id.'&type='.$type.'">'.$langs->trans("Delete").''; } print ""; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6dfdf41e679..f26ad2a36e2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -280,7 +280,7 @@ if (empty($reshook) && $action == 'add') } } } - $object->fk_project = isset($_POST["projectid"]) ? $_POST["projectid"] : 0; + $object->fk_project = GETPOSTISSET("projectid") ? GETPOST("projectid", 'int') : 0; $taskid = GETPOST('taskid', 'int'); if (!empty($taskid)) { @@ -324,7 +324,7 @@ if (empty($reshook) && $action == 'add') $object->note_private = trim(GETPOST("note", "restricthtml")); - if (isset($_POST["contactid"])) $object->contact = $contact; + if (GETPOSTISSET("contactid")) $object->contact = $contact; if (GETPOST('socid', 'int') > 0) { @@ -1051,8 +1051,8 @@ if ($action == 'create') print ''; print '"; } @@ -1578,7 +1578,7 @@ if ($id > 0) foreach ($cats as $cat) { $arrayselected[] = $cat->id; } - print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b7b25e28d3c..5a9b0afa336 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -524,7 +524,7 @@ class ActionComm extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->ref =$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); + $this->ref = $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); // Now insert assigned users if (!$error) @@ -2186,7 +2186,7 @@ class ActionComm extends CommonObject $this->db->commit(); return 0; } else { - $this->db->commit(); // We commit also on error, to have the error message recorded. + $this->db->commit(); // We commit also on error, to have the error message recorded. $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; return $error; } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 313aaa0e2e4..83b3c0514aa 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -336,7 +336,7 @@ if ($status == 'todo') $title = $langs->trans("ToDoActions"); */ $param = ''; -if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { +if ($actioncode || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); } else $param .= "&search_actioncode=".urlencode($actioncode); @@ -1492,19 +1492,19 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($nonew <= 0) { - print '
'; + print '
'."\n"; + print '
'."\n"; } if ($nonew < 0) diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 4f292047700..c5f81e358cc 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -122,8 +122,8 @@ $tmparray = explode('-', $tmp); $begin_d = 1; $end_d = 53; -if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action = 'show_month'; $day = ''; @@ -227,13 +227,13 @@ if ($status == 'done') $title = $langs->trans("DoneActions"); if ($status == 'todo') $title = $langs->trans("ToDoActions"); $param = ''; -if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { +if ($actioncode || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); } else $param .= "&search_actioncode=".urlencode($actioncode); } if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status); if ($filter) $param .= "&search_filter=".urlencode($filter); if ($filtert) $param .= "&search_filtert=".urlencode($filtert); if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 8983dbff7f6..6161b6c820b 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -125,8 +125,8 @@ if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; if ($end_d < 1 || $end_d > 7) $end_d = 7; if ($end_d < $begin_d) $end_d = $begin_d + 1; -if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action = 'show_month'; $day = ''; @@ -227,13 +227,13 @@ if ($status == 'done') $title = $langs->trans("DoneActions"); if ($status == 'todo') $title = $langs->trans("ToDoActions"); $param = ''; -if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { +if ($actioncode || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); } else $param .= "&search_actioncode=".urlencode($actioncode); } if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status); if ($filter) $param .= "&search_filter=".urlencode($filter); if ($filtert) $param .= "&search_filtert=".urlencode($filtert); if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 47c8431072d..fe41203e946 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -86,6 +86,15 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartycomm', 'globalcard')); +// Security check +$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); + +if ($object->id > 0) { + if (!($object->client > 0) || empty($user->rights->societe->lire)) { + accessforbidden(); + } +} + $now = dol_now(); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 8ce38ba4ea3..7524de9055f 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -233,7 +233,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $supplierproposalstatic->total_ht = $obj->total_ht; $supplierproposalstatic->total_tva = $obj->total_tva; $supplierproposalstatic->total_ttc = $obj->total_ttc; - $supplierproposalstatic->statut = $obj->status; + $supplierproposalstatic->statut = $obj->status; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 52f0f467226..1625542842b 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -805,14 +805,14 @@ if ($action == 'create') { } $text = ''; - if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) { + if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) { $text .= $langs->trans("MailingNeedCommand"); $text .= '
'; $text .= '

'; } $text .= $langs->trans('ConfirmSendingEmailing').'
'; $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', $formquestion, '', 1, 330, 600); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', '', '', 1, 330, 600); } } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 8a4ebfa90c9..b7f20319229 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -54,7 +54,7 @@ class AdvanceTargetingMailing extends CommonObject public $name; /** - * @var int element id + * @var int element id (it's not the name of a field) */ public $fk_element; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index b2f728ac5f5..db64dd65fe9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -343,7 +343,7 @@ if (empty($reshook)) $object->ref = GETPOST('ref'); $object->datep = $datep; $object->date = $datep; - $object->date_livraison = $date_delivery; // deprecated + $object->date_livraison = $date_delivery; // deprecated $object->delivery_date = $date_delivery; $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); @@ -366,9 +366,6 @@ if (empty($reshook)) $object->statut = Propal::STATUS_DRAFT; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - - // the create is done below and further more the existing create_from function is quite hilarating - //$id = $object->create_from($user); } else { setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors'); } @@ -550,9 +547,8 @@ if (empty($reshook)) if ($id > 0) { - // Insertion contact par defaut si defini - if (GETPOST('contactid') > 0) - { + // Insert default contacts if defined + if (GETPOST('contactid') > 0) { $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { @@ -1347,7 +1343,8 @@ if (empty($reshook)) { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { @@ -2411,7 +2408,8 @@ if ($action == 'create') if ($action != 'editline') { // Validate - if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0) + if (($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0) + || ($object->statut == Propal::STATUS_DRAFT && !empty($conf->global->PROPAL_ENABLE_NEGATIVE) && count($object->lines) > 0)) { if ($usercanvalidate) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index bc588f430d9..5c4ed9e2edf 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -66,7 +66,7 @@ class Propal extends CommonObject public $table_element_line = 'propaldet'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Fieldname with ID of parent key if this field has a parent */ public $fk_element = 'fk_propal'; @@ -155,7 +155,7 @@ class Propal extends CommonObject * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. /** * @var integer|string $delivery_date; @@ -208,7 +208,6 @@ class Propal extends CommonObject public $demand_reason_id; public $demand_reason_code; - public $products = array(); public $extraparams = array(); /** @@ -355,15 +354,13 @@ class Propal extends CommonObject $this->socid = $socid; $this->id = $propalid; - $this->products = array(); - $this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add line into array products + * Add line into array ->lines * $this->thirdparty should be loaded * * @param int $idproduct Product Id to add @@ -372,7 +369,6 @@ class Propal extends CommonObject * @return int <0 if KO, >0 if OK * * TODO Replace calls to this function by generation objet Ligne - * inserted into table $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0) { @@ -1103,7 +1099,7 @@ class Propal extends CommonObject if ($this->id) { $this->ref = '(PROV'.$this->id.')'; - $sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".((int) $this->id); dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1115,7 +1111,7 @@ class Propal extends CommonObject } // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { foreach ($this->linked_objects as $origin => $tmp_origin_id) { @@ -1279,24 +1275,6 @@ class Propal extends CommonObject } } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Insert into DB a proposal object completely defined by its data members (ex, results from copy). - * - * @param User $user User that create - * @return int Id of the new object if ok, <0 if ko - * @see create() - */ - public function create_from($user) - { - // phpcs:enable - // i love this function because $this->products is not used in create function... - $this->products = $this->lines; - - return $this->create($user); - } - /** * Load an object from its id and create a new one in database * @@ -1525,7 +1503,7 @@ class Propal extends CommonObject $this->date = $this->db->jdate($obj->dp); // Proposal date $this->datep = $this->db->jdate($obj->dp); // deprecated $this->fin_validite = $this->db->jdate($obj->dfv); - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; $this->availability_id = $obj->fk_availability; @@ -2944,7 +2922,7 @@ class Propal extends CommonObject $tabletodelete = $this->table_element_line; $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; - if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { + if (!$this->db->query($sqlef) || !$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2977,7 +2955,7 @@ class Propal extends CommonObject if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); - if (! $res) { + if (!$res) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2988,7 +2966,7 @@ class Propal extends CommonObject // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } @@ -3775,7 +3753,10 @@ class PropaleLigne extends CommonObjectLine public $product_type = Product::TYPE_PRODUCT; public $qty; + public $tva_tx; + public $vat_src_code; + public $subprice; public $remise_percent; public $fk_remise_except; @@ -3827,6 +3808,11 @@ class PropaleLigne extends CommonObjectLine * @see $product_label */ public $libelle; + /** + * @deprecated + * @see $product_label + */ + public $label; /** * Product label * @var string diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 4d70b11cdfe..af3679de945 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -79,7 +79,8 @@ if ($action == 'addcontact' && $user->rights->propale->creer) if ($object->id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index bba2d61a422..d8f523f16da 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -188,7 +188,7 @@ $arrayfields = array( 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; /* diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 8b9c6b34dee..34feb8bbe44 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -37,11 +37,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; +$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; if ($mode == 'customer' && !$user->rights->propale->lire) accessforbidden(); if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) accessforbidden(); -$object_status = GETPOST('object_status'); +$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -55,7 +55,7 @@ if ($user->socid > 0) } $nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; //$startyear=$year-2; $startyear = $year - 1; $endyear = $year; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1d00389534d..80ff2180801 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -276,7 +276,7 @@ if (empty($reshook)) $object->fk_account = GETPOST('fk_account', 'int'); $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->date_livraison = $datelivraison; // deprecated + $object->date_livraison = $datelivraison; // deprecated $object->delivery_date = $datelivraison; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->warehouse_id = GETPOST('warehouse_id', 'int'); @@ -453,26 +453,14 @@ if (empty($reshook)) if (!$error) { $object_id = $object->create($user); - - // If some invoice's lines already known - $NBLINES = 8; - for ($i = 1; $i <= $NBLINES; $i++) { - if ($_POST['idprod'.$i]) { - $xid = 'idprod'.$i; - $xqty = 'qty'.$i; - $xremise = 'remise_percent'.$i; - $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); - } - } } } // Insert default contacts if defined if ($object_id > 0) { - if (GETPOST('contactid')) - { - $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); + if (GETPOST('contactid', 'int')) { + $result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external'); if ($result < 0) { setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors'); $error++; @@ -931,6 +919,7 @@ if (empty($reshook)) if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records + $object->fetch_thirdparty(); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1378,7 +1367,8 @@ if (empty($reshook)) { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ad3c9a10043..0b68095c5d0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -184,7 +184,7 @@ class Commande extends CommonOrder * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) @@ -199,6 +199,7 @@ class Commande extends CommonOrder public $rang; public $special_code; public $source; // Order mode. How we received order (by phone, by email, ...) + public $extraparams = array(); public $linked_objects = array(); @@ -368,8 +369,6 @@ class Commande extends CommonOrder $this->remise = 0; $this->remise_percent = 0; - - $this->products = array(); } /** @@ -1360,7 +1359,7 @@ class Commande extends CommonOrder $this->fk_account = $object->fk_account; $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; - $this->date_livraison = $object->date_livraison; // deprecated + $this->date_livraison = $object->date_livraison; // deprecated $this->delivery_date = $object->date_livraison; $this->shipping_method_id = $object->shipping_method_id; $this->warehouse_id = $object->warehouse_id; @@ -1690,7 +1689,6 @@ class Commande extends CommonOrder * @return void * * TODO Remplacer les appels a cette fonction par generation objet Ligne - * insere dans tableau $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') { @@ -1752,15 +1750,13 @@ class Commande extends CommonOrder $prods_arbo = $prod->get_arbo_each_prod(); if(count($prods_arbo) > 0) { - foreach($prods_arbo as $key => $value) - { - // print "id : ".$value[1].' :qty: '.$value[0].'
'; - if(! in_array($value[1],$this->products)) - $this->add_product($value[1], $value[0]); - - } - } - + foreach($prods_arbo as $key => $value) + { + // print "id : ".$value[1].' :qty: '.$value[0].'
'; + if not in lines { + $this->add_product($value[1], $value[0]); + } + } } **/ } @@ -1871,7 +1867,7 @@ class Commande extends CommonOrder $this->availability = $obj->availability_label; $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; $this->warehouse_id = ($obj->fk_warehouse > 0) ? $obj->fk_warehouse : null; @@ -3277,6 +3273,7 @@ class Commande extends CommonOrder $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").","; $sql .= " fk_account=".($this->fk_account > 0 ? $this->fk_account : "null").","; + $sql .= " fk_input_reason=".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null").","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; @@ -3362,7 +3359,7 @@ class Commande extends CommonOrder $tabletodelete = $this->table_element_line; $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; - if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { + if (!$this->db->query($sqlef) || !$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -3395,7 +3392,7 @@ class Commande extends CommonOrder if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); - if (! $res) { + if (!$res) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -3406,7 +3403,7 @@ class Commande extends CommonOrder // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index a3c31d4cf7b..7df7dbea130 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -56,7 +56,8 @@ if ($action == 'addcontact' && $user->rights->commande->creer) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 14b05b587b3..72a5e179f25 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -109,7 +109,7 @@ $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 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -142,38 +142,38 @@ if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; $checkedtypetiers = 0; $arrayfields = array( - 'c.ref'=>array('label'=>"Ref", 'checked'=>1), - 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>1), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), - 's.town'=>array('label'=>"Town", 'checked'=>1), - 's.zip'=>array('label'=>"Zip", 'checked'=>1), - 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), - 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), - 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), - 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1), - 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)), - 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), - 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), - 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), - 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), - 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), - 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), - 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))), - 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), - 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))), - 'shippable'=>array('label'=>"Shippable", 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->expedition->enabled))) + 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>20), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>25), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>35), + 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>40), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), + 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), + 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), + 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), + 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), + 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10, 'position'=>115), + 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500, 'position'=>120), + 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500, 'position'=>125), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500, 'position'=>130), + 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135), + 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), + 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>990, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>145), + 'shippable'=>array('label'=>"Shippable", 'checked'=>1, 'position'=>995, 'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>150), + 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000, 'position'=>155) ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -448,10 +448,10 @@ if ($resql) if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_datecloture_start) $param .= '&search_datecloture_start='.urlencode($search_datecloture_start); if ($search_datecloture_end) $param .= '&search_datecloture_end='.urlencode($search_datecloture_end); - if ($search_dateorder_start) $param .= '&search_dateorder_start_day=' . dol_print_date($search_dateorder_start, '%d') . '&search_dateorder_start_month=' . dol_print_date($search_dateorder_start, '%m') . '&search_dateorder_start_year=' . dol_print_date($search_dateorder_start, '%Y'); - if ($search_dateorder_end) $param .= '&search_dateorder_end_day=' . dol_print_date($search_dateorder_end, '%d') . '&search_dateorder_end_month=' . dol_print_date($search_dateorder_end, '%m') . '&search_dateorder_end_year=' . dol_print_date($search_dateorder_end, '%Y'); - if ($search_datedelivery_start) $param .= '&search_datedelivery_start_day=' . dol_print_date($search_datedelivery_start, '%d') . '&search_datedelivery_start_month=' . dol_print_date($search_datedelivery_start, '%m') . '&search_datedelivery_start_year=' . dol_print_date($search_datedelivery_start, '%Y'); - if ($search_datedelivery_end) $param .= '&search_datedelivery_end_day=' . dol_print_date($search_datedelivery_end, '%d') . '&search_datedelivery_end_month=' . dol_print_date($search_datedelivery_end, '%m') . '&search_datedelivery_end_year=' . dol_print_date($search_datedelivery_end, '%Y'); + if ($search_dateorder_start) $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y'); + if ($search_dateorder_end) $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y'); + if ($search_datedelivery_start) $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y'); + if ($search_datedelivery_end) $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_company) $param .= '&search_company='.urlencode($search_company); if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); @@ -831,27 +831,12 @@ if ($resql) print ''; } - // Status - if (!empty($arrayfields['c.fk_statut']['checked'])) - { - print ''; - } // Shippable if (!empty($arrayfields['shippable']['checked'])) { print ''; } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) + { + print ''; + } // Action column print ''; if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); @@ -909,9 +909,9 @@ if ($resql) if (!empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (!empty($arrayfields['c.note_public']['checked'])) print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.note_private']['checked'])) print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['shippable']['checked'])) print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print ''."\n"; @@ -950,7 +950,7 @@ if ($resql) $generic_commande->statut = $obj->fk_statut; $generic_commande->billed = $obj->billed; $generic_commande->date = $db->jdate($obj->date_commande); - $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated $generic_commande->delivery_date = $db->jdate($obj->date_delivery); $generic_commande->ref_client = $obj->ref_client; $generic_commande->total_ht = $obj->total_ht; @@ -1218,13 +1218,6 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } - // Status - if (!empty($arrayfields['c.fk_statut']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Show shippable Icon (this creates subloops, so may be slow) if (!empty($arrayfields['shippable']['checked'])) { @@ -1242,7 +1235,7 @@ if ($resql) // Get local and virtual stock and store it into cache if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { - $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() + $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } else { @@ -1252,9 +1245,9 @@ if ($resql) if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default should be this case. { - $text_info .= $generic_commande->lines[$lig]->qty . ' X ' . $generic_commande->lines[$lig]->product_ref . ' ' . dol_trunc($generic_commande->lines[$lig]->product_label, 25); - $text_info .= ' - ' . $langs->trans("Stock") . ': ' . $generic_product->stock_reel . ''; - $text_info .= ' - ' . $langs->trans("VirtualStock") . ': ' . $generic_product->stock_theorique . ''; + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; $text_info .= '
'; if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) { @@ -1288,20 +1281,20 @@ if ($resql) $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; } } - $text_info .= $generic_commande->lines[$lig]->qty . ' X ' . $generic_commande->lines[$lig]->ref . ' ' . dol_trunc($generic_commande->lines[$lig]->product_label, 25); - $text_stock_reel = $generic_product->stock_reel . '/' . $stock_order; + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { $warning++; - $text_warning .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) { $notshippable++; - $text_info .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } else { - $text_info .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if (!empty($conf->fournisseur->enabled)) { - $text_info .= ' ' . $langs->trans('SupplierOrder') . ' : ' . $stock_order_supplier . '
'; + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'
'; } else { $text_info .= '
'; } @@ -1310,10 +1303,10 @@ if ($resql) } if ($notshippable == 0) { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); - $text_info = $langs->trans('Shippable') . '
' . $text_info; + $text_info = $langs->trans('Shippable').'
'.$text_info; } else { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); - $text_info = $langs->trans('NonShippable') . '
' . $text_info; + $text_info = $langs->trans('NonShippable').'
'.$text_info; } } @@ -1321,7 +1314,7 @@ if ($resql) print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); } if ($warning) { // Always false in default mode - print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders') . '
' . $text_warning, 2, 1, img_picto('', 'error'), '', 2); + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); } } print ''; @@ -1334,6 +1327,13 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Action column print ''; // Year diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 02c89772e94..902a96ec16c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -225,17 +225,16 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if ($num_releve) { $bankline = new AccountLine($db); - if (isset($_POST['rowid']) && is_array($_POST['rowid'])) - { - foreach ($_POST['rowid'] as $row) - { - if ($row > 0) - { + + $rowids = GETPOST('rowid', 'array'); + + if (!empty($rowids) && is_array($rowids)) { + foreach ($rowids as $row) { + if ($row > 0) { $result = $bankline->fetch($row); $bankline->num_releve = $num_releve; //$_POST["num_releve"]; $result = $bankline->update_conciliation($user, GETPOST("cat"), GETPOST('confirm_reconcile', 'alpha') ? 1 : 0); // If we confirm_reconcile, we set flag 'rappro' to 1. - if ($result < 0) - { + if ($result < 0) { setEventMessages($bankline->error, $bankline->errors, 'errors'); $error++; break; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index a7841a72b22..30e483fdfa9 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -346,7 +346,7 @@ if ($action == 'create') // Type print ''; print ''; // Currency @@ -354,7 +354,7 @@ if ($action == 'create') print ''; @@ -367,9 +367,8 @@ if ($action == 'create') // Country $selectedcode = ''; - if (isset($_POST["account_country_id"])) - { - $selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code; + if (GETPOSTISSET("account_country_id")) { + $selectedcode = GETPOST("account_country_id") ? GETPOST("account_country_id") : $object->country_code; } elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules @@ -383,7 +382,7 @@ if ($action == 'create') print '"; } @@ -818,16 +817,16 @@ if ($action == 'create') // Ref print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Type print ''; print ''; // Currency @@ -837,7 +836,7 @@ if ($action == 'create') print ''; @@ -845,13 +844,13 @@ if ($action == 'create') // Status print ''; print ''; // Country $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id; $selectedcode = $object->country_code; - if (isset($_POST["account_country_id"])) $selectedcode = $_POST["account_country_id"]; + if (GETPOSTISSET("account_country_id")) $selectedcode = GETPOST("account_country_id"); elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules @@ -865,7 +864,7 @@ if ($action == 'create') print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Web print ''; - print ''; // Tags-Categories @@ -905,7 +904,7 @@ if ($action == 'create') $arrayselected[] = $cat->id; } } - print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 524877746f8..f4fa779fd7d 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -771,11 +771,11 @@ print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; $percent = -1; - if (isset($_GET['status']) || isset($_POST['status'])) $percent = GETPOST('status'); - elseif (isset($_GET['percentage']) || isset($_POST['percentage'])) $percent = GETPOST('percentage'); + if (GETPOSTISSET('status')) $percent = GETPOST('status'); + elseif (GETPOSTISSET('percentage')) $percent = GETPOST('percentage'); else { if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0'; elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100; @@ -1104,7 +1104,7 @@ if ($action == 'create') // Categories print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); - print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent', 0, 0); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'; print ''; - $liststatus = array( - Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), - Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), - Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), - -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), - Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") - ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); - print ''; //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1); - if (! empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { + if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { print ''; print $langs->trans('ShowShippableStatus'); } else { @@ -866,6 +851,21 @@ if ($resql) print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); print ''; + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") + ); + print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); + print ''; $searchpicto = $form->showFilterButtons(); @@ -878,8 +878,8 @@ if ($resql) print '
'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 54846a32852..6e5e022c651 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -38,11 +38,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; +$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; if ($mode == 'customer' && !$user->rights->commande->lire) accessforbidden(); if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) accessforbidden(); -$object_status = GETPOST('object_status'); +$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -302,11 +302,11 @@ if ($mode == 'customer') Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") ); - print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4); + print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4); } if ($mode == 'supplier') { - $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ?-1 : $object_status), 0, 'object_status'); + $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ? -1 : $object_status), 0, 'object_status'); } print '
'.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount(isset($_POST["type"]) ? $_POST["type"] : Account::TYPE_CURRENT, "type"); + $formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOST("type") : Account::TYPE_CURRENT, "type"); print '
'; $selectedcode = $object->currency_code; if (!$selectedcode) $selectedcode = $conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); + print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
'.$langs->trans('State').''; if ($selectedcode) { - $formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id'); + $formcompany->select_departement(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : '', $selectedcode, 'account_state_id'); } else { print $countrynotdefined; } @@ -408,7 +407,7 @@ if ($action == 'create') $arrayselected[] = $cat->id; } } - print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$langs->trans("Ref").'ref).'">
ref).'">
'.$langs->trans("Label").'label).'">
label).'">
'.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount((isset($_POST["type"]) ? $_POST["type"] : $object->type), "type"); + $formbank->selectTypeOfBankAccount((GETPOSTISSET("type") ? GETPOST("type") : $object->type), "type"); print '
'; $selectedcode = $object->currency_code; if (!$selectedcode) $selectedcode = $conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); + print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
'.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (isset($_POST["clos"]) ? $_POST["clos"] : $object->clos)); + print $form->selectarray("clos", $object->status, (GETPOSTISSET("clos") ? GETPOST("clos") : $object->clos)); print '
'.$langs->trans('State').''; if ($selectedcode) { - print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id'); + print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $object->state_id, $selectedcode, 'account_state_id'); } else { print $countrynotdefined; } @@ -882,14 +881,14 @@ if ($action == 'create') // Balance print '
'.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
min_allowed).'">
'.$langs->trans("BalanceMinimalDesired").'min_desired).'">
min_desired).'">
'.$langs->trans("Web").'url).'">'; + print 'url).'">'; print '
'; print ''; } else { print ''; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 1a1fd42d21b..75d2f71284c 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -43,12 +43,12 @@ class Deplacement extends CommonObject public $table_element = 'deplacement'; /** - * @var int Name of subtable line + * @var string Name of subtable line */ public $table_element_line = ''; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Fieldname with ID of parent key if this field has a parent */ public $fk_element = ''; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index c191c87f219..11dec142a17 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -117,6 +117,8 @@ $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer; $now = dol_now(); +$error = 0; + /* * Actions @@ -287,13 +289,21 @@ if (empty($reshook)) elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; - $result = $object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); + $result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($result > 0) { $object->titre = GETPOST('ref', 'alpha'); // deprecated $object->title = GETPOST('ref', 'alpha'); $object->ref = $object->title; - } else dol_print_error($db, $object->error, $object->errors); + } else { + $error++; + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorRefAlreadyExists', $ref), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { @@ -1233,7 +1243,7 @@ if ($action == 'create') print '
'; print '
'; - print '
'.$morehtml.'     '; if ($mode == 'showalltime') { - print ''; + print ''; print $langs->trans("GoBack"); print ''; } else { - print ''; + print ''; print $langs->trans("ShowAllTimeBalance"); print ''; } @@ -793,7 +793,7 @@ if ($mode == 'standard') if ($nextmonth > 12) { $nextmonth = 1; $nextyear++; } // For month - $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
'; print '
'; @@ -807,7 +807,7 @@ if ($mode == 'standard') // For year $prevyear = $year - 1; $nextyear = $year + 1; - $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
'; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 42bddce5d28..33f7f3a0352 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -139,17 +139,17 @@ if ($user->rights->banque->modifier && $action == "update") $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; $sql .= " SET "; // Always opened - if (isset($_POST['value'])) $sql .= " fk_type='".$db->escape(GETPOST('value'))."',"; - if (isset($_POST['num_chq'])) $sql .= " num_chq='".$db->escape(GETPOST("num_chq"))."',"; - if (isset($_POST['banque'])) $sql .= " banque='".$db->escape(GETPOST("banque"))."',"; - if (isset($_POST['emetteur'])) $sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',"; + if (GETPOSTISSET('value')) $sql .= " fk_type='".$db->escape(GETPOST('value'))."',"; + if (GETPOSTISSET('num_chq')) $sql .= " num_chq='".$db->escape(GETPOST("num_chq"))."',"; + if (GETPOSTISSET('banque')) $sql .= " banque='".$db->escape(GETPOST("banque"))."',"; + if (GETPOSTISSET('emetteur')) $sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',"; // Blocked when conciliated if (!$acline->rappro) { - if (isset($_POST['label'])) $sql .= " label = '".$db->escape(GETPOST("label"))."',"; - if (isset($_POST['amount'])) $sql .= " amount= '".$db->escape($amount)."',"; - if (isset($_POST['dateomonth'])) $sql .= " dateo = '".$db->idate($dateop)."',"; - if (isset($_POST['datevmonth'])) $sql .= " datev = '".$db->idate($dateval)."',"; + if (GETPOSTISSET('label')) $sql .= " label = '".$db->escape(GETPOST("label"))."',"; + if (GETPOSTISSET('amount')) $sql .= " amount= '".$db->escape($amount)."',"; + if (GETPOSTISSET('dateomonth')) $sql .= " dateo = '".$db->idate($dateop)."',"; + if (GETPOSTISSET('datevmonth')) $sql .= " datev = '".$db->idate($dateval)."',"; } $sql .= " fk_account = ".$actarget->id; $sql .= " WHERE rowid = ".$acline->id; @@ -613,7 +613,7 @@ if ($result) if ($user->rights->banque->consolidate) { print '
'; - print 'rappro ? ' checked="checked"' : '')).'">'; + print 'rappro ? ' checked="checked"' : '')).'">'; print ''.yn($objp->rappro).'
'; + print '
'; print '"; @@ -1262,7 +1272,7 @@ if ($action == 'create') // Payment term print '
'.$langs->trans("Author").''.$author->getFullName($langs)."
'; - print '
'; + print ''; if ($action != 'editconditions' && $user->rights->facture->creer) @@ -1452,7 +1462,7 @@ if ($action == 'create') $title = $langs->trans("Recurrence"); //print load_fiche_titre($title, '', 'calendar'); - print '
'; print $langs->trans('PaymentConditionsShort'); print '
'; + print '
'; print ''; @@ -1573,7 +1583,7 @@ if ($action == 'create') } print '
'; - print '
'.$title.'
'; + print '
'; // Nb of generation already done print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a4def0c0b9b..4451f13bd77 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -358,26 +358,23 @@ if (empty($reshook)) if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); - } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) - { + } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) - { + } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); - } elseif ($action == 'setinvoicedate' && $usercancreate) - { + } elseif ($action == 'setinvoicedate' && $usercancreate) { $object->fetch($id); $old_date_lim_reglement = $object->date_lim_reglement; $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); @@ -395,8 +392,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setdate_pointoftax' && $usercancreate) - { + } elseif ($action == 'setdate_pointoftax' && $usercancreate) { $object->fetch($id); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); $object->date_pointoftax = $date_pointoftax; @@ -2668,7 +2664,8 @@ if (empty($reshook)) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { @@ -3419,7 +3416,7 @@ if ($action == 'create') // Payment mode print ''; // Bank Account @@ -3554,7 +3551,7 @@ if ($action == 'create') print ''; } - // Lines from source (TODO Show them also when creating invoice from tempalte invoice) + // Lines from source (TODO Show them also when creating invoice from template invoice) if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { // TODO for compatibility @@ -3649,8 +3646,7 @@ if ($action == 'create') } print ''; -} elseif ($id > 0 || !empty($ref)) -{ +} elseif ($id > 0 || !empty($ref)) { /* * Show object in view mode */ @@ -3896,6 +3892,7 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 1); } if ($action == 'paid' && $resteapayer > 0) { + $close = array(); // Code $i = 0; $close[$i]['code'] = 'discount_vat'; // escompte @@ -3922,7 +3919,7 @@ if ($action == 'create') $i++; // arrayreasons[code]=reason foreach ($close as $key => $val) { - $arrayreasons[$close [$key]['code']] = $close[$key]['reason']; + $arrayreasons[$close[$key]['code']] = $close[$key]['reason']; } // Cree un tableau formulaire @@ -4073,24 +4070,26 @@ if ($action == 'create') // Type print ''; @@ -4132,13 +4132,11 @@ if ($action == 'create') // Relative and absolute discounts print ''."\n"; print ''; // Date invoice @@ -4154,7 +4152,7 @@ if ($action == 'create') if ($action == 'editinvoicedate') { $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date, 'invoicedate'); } else { - print dol_print_date($object->date, 'day'); + print ''.dol_print_date($object->date, 'day').''; } print ''; @@ -4173,7 +4171,7 @@ if ($action == 'create') if ($action == 'editdate_pointoftax') { $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_pointoftax, 'date_pointoftax'); } else { - print dol_print_date($object->date_pointoftax, 'day'); + print ''.dol_print_date($object->date_pointoftax, 'day').''; } print ''; } @@ -4213,7 +4211,7 @@ if ($action == 'create') if ($action == 'editpaymentterm') { $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_lim_reglement, 'paymentterm'); } else { - print dol_print_date($object->date_lim_reglement, 'day'); + print ''.dol_print_date($object->date_lim_reglement, 'day').''; if ($object->hasDelay()) { print img_warning($langs->trans('Late')); } @@ -4788,10 +4786,13 @@ if ($action == 'create') if ($object->type != Facture::TYPE_CREDIT_NOTE) { // Total already paid print ''; + } else { + print $langs->trans('AlreadyPaid'); + } + print ''; $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; @@ -4812,12 +4813,14 @@ if ($action == 'create') $obj = $db->fetch_object($resql); $invoice->fetch($obj->fk_facture_source); print ''; + print ''; + print ''; print ''; print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; @@ -4843,7 +4848,9 @@ if ($action == 'create') // Paye partiellement ou Abandon 'badcustomer' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'badcustomer') { print ''; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; @@ -4851,7 +4858,9 @@ if ($action == 'create') // Paye partiellement ou Abandon 'product_returned' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'product_returned') { print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; @@ -4862,20 +4871,27 @@ if ($action == 'create') $text = $langs->trans("HelpAbandonOther"); if ($object->close_note) $text .= '

'.$langs->trans("Reason").':'.$object->close_note; - print $form->textwithpicto($langs->trans("Abandoned").':', $text, - 1); + print ''; + print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); + print ''; print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Billed - print ''; + print ''; // Remainder to pay print ''; + print ''; + print ''; print ''; print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index e4187a4e906..48e2ad574ed 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -50,12 +50,12 @@ class FactureRec extends CommonInvoice public $table_element = 'facture_rec'; /** - * @var int Name of subtable line + * @var string Name of subtable line */ public $table_element_line = 'facturedet_rec'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Field with ID of parent key if this field has a parent */ public $fk_element = 'fk_facture'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 23b9ff7e316..77266718b75 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -64,17 +64,17 @@ class Facture extends CommonInvoice public $table_element = 'facture'; /** - * @var int Name of subtable line + * @var string Name of subtable line */ public $table_element_line = 'facturedet'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Fieldname with ID of parent key if this field has a parent */ public $fk_element = 'fk_facture'; /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + * @var string String with name of icon for myobject. */ public $picto = 'bill'; @@ -119,7 +119,7 @@ class Facture extends CommonInvoice * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) @@ -176,11 +176,6 @@ class Facture extends CommonInvoice */ public $fk_bank; - /** - * @deprecated - */ - public $products = array(); - /** * @var FactureLigne[] */ @@ -1077,7 +1072,6 @@ class Facture extends CommonInvoice $facture->origin_id = $this->origin_id; $facture->lines = $this->lines; // Array of lines of invoice - $facture->products = $this->lines; // Tant que products encore utilise $facture->situation_counter = $this->situation_counter; $facture->situation_cycle_ref = $this->situation_cycle_ref; $facture->situation_final = $this->situation_final; @@ -1179,7 +1173,6 @@ class Facture extends CommonInvoice $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; - $object->products = $object->lines; // For backward compatibility if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { $object->note_private = ''; $object->note_public = ''; @@ -1191,7 +1184,6 @@ class Facture extends CommonInvoice if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { unset($object->lines[$i]); - unset($object->products[$i]); // Tant que products encore utilise } // Bloc to update dates of service (month by month only if previously filled at 1d near start or end of month) // If it's a service with start and end dates @@ -1339,7 +1331,7 @@ class Facture extends CommonInvoice $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; $this->delivery_date = (empty($object->delivery_date) ? $object->date_livraison : $object->delivery_date); - $this->date_livraison = $object->delivery_date; // deprecated + $this->date_livraison = $object->delivery_date; // deprecated $this->fk_delivery_address = $object->fk_delivery_address; // deprecated $this->contact_id = $object->contact_id; $this->ref_client = $object->ref_client; @@ -1432,11 +1424,11 @@ class Facture extends CommonInvoice $label = ''; if ($user->rights->facture->lire) { - $label = img_picto('', $this->picto).' '.$langs->trans("Invoice").''; - if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ReplacementInvoice").''; - if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; - if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; - if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("InvoiceSituation").''; + $label = img_picto('', $picto).' '.$langs->trans("Invoice").''; + if ($this->type == self::TYPE_REPLACEMENT) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("ReplacementInvoice").''; + if ($this->type == self::TYPE_CREDIT_NOTE) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("CreditNote").''; + if ($this->type == self::TYPE_DEPOSIT) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("Deposit").''; + if ($this->type == self::TYPE_SITUATION) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("InvoiceSituation").''; if (isset($this->statut) && isset($this->alreadypaid)) { $label .= ' '.$this->getLibStatut(5, $this->alreadypaid); } @@ -3134,8 +3126,8 @@ class Facture extends CommonInvoice $this->line->tva_tx = $txtva; $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->localtax1_type = isset($localtaxes_type[0]) ? $localtaxes_type[0] : ''; + $this->line->localtax2_type = isset($localtaxes_type[2]) ? $localtaxes_type[2] : ''; $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 57532174db7..6b8758bc472 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -62,7 +62,8 @@ if ($action == 'addcontact' && $user->rights->facture->creer) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index eb73132c69f..e96371ad4f4 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -192,10 +192,10 @@ function getPieChart($socid = 0) { $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(['pie']); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphthirdparties'); $result .= ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b693238924f..c61bfdf6819 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -128,7 +128,7 @@ $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 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; if (!$sortorder) $sortorder = 'DESC'; @@ -223,7 +223,7 @@ if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_ } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 792ff73bcd3..7e852846d5c 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -632,10 +632,10 @@ if ($object->id > 0) print "\n
\n"; $buttonlabel = $langs->trans("MakeWithdrawRequest"); - $user_perms=$user->rights->prelevement->bons->creer; + $user_perms = $user->rights->prelevement->bons->creer; if ($type == 'bank-transfer') { $buttonlabel = $langs->trans("MakeBankTransferOrder"); - $user_perms=$user->rights->paymentbybanktransfer->create; + $user_perms = $user->rights->paymentbybanktransfer->create; } // Add a transfer request diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 9cbd826b4a1..13378979932 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -44,7 +44,7 @@ $mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; if ($mode == 'customer' && !$user->rights->facture->lire) accessforbidden(); if ($mode == 'supplier' && !$user->rights->fournisseur->facture->lire) accessforbidden(); -$object_status = GETPOST('object_status'); +$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -59,7 +59,7 @@ if ($user->socid > 0) } $nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear = $year - 2; else $startyear = $year - 1; $endyear = $year; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index b9aa625c06d..299cdf9a6c3 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -222,21 +222,21 @@ if ($action == 'create') print '
';*/ print '"; print ''; print '\n"; print ''; print ''; print ''; print ''; // Number diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 21bf795079a..fb2f114b579 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -164,12 +164,12 @@ class BonPrelevement extends CommonObject $result = 0; } else { $result = -1; - $this->errors[] = get_class($this)."::AddFacture " . $this->db->lasterror; + $this->errors[] = get_class($this)."::AddFacture ".$this->db->lasterror; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { $result = -2; - $this->errors[]=get_class($this)."::AddFacture linedid Empty"; + $this->errors[] = get_class($this)."::AddFacture linedid Empty"; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { @@ -247,7 +247,7 @@ class BonPrelevement extends CommonObject $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); $result = 0; } else { - $this->errors[]=get_class($this)."::addline Error -2 " .$this->db->lasterror; + $this->errors[] = get_class($this)."::addline Error -2 ".$this->db->lasterror; dol_syslog(get_class($this)."::addline Error -2"); $result = -2; } @@ -1124,7 +1124,7 @@ class BonPrelevement extends CommonObject if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); dol_syslog(__METHOD__."::Update Error=".$this->db->lasterror(), LOG_ERR); } } diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 1a1de43709d..93f91b25449 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2017 Olivier Geffroy - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -122,7 +122,9 @@ if ($modecompta == "CREANCES-DETTES") $name = $langs->trans("Turnover"); $calcmode = $langs->trans("CalcModeDebt"); //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $calcmode .= '
('.$langs->trans("SeeReportInBookkeepingMode", '', '').')'; + $calcmode .= '
('.$langs->trans("SeeReportInBookkeepingMode", '{links1}', '{link2}').')'; + $calcmode = str_replace('{link1}', '', $calcmode); + $calcmode = str_replace('{link2}', '', $calcmode); $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesCADue"); @@ -146,7 +148,9 @@ if ($modecompta == "CREANCES-DETTES") { $name = $langs->trans("Turnover"); $calcmode = $langs->trans("CalcModeBookkeeping"); - $calcmode .= '
('.$langs->trans("SeeReportInDueDebtMode", '', '').')'; + $calcmode .= '
('.$langs->trans("SeeReportInDueDebtMode", '{link1}', '{link2}').')'; + $calcmode = str_replace('{link1}', '', $calcmode); + $calcmode = str_replace('{link2}', '', $calcmode); //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index bd97f88ff65..752bdc4d642 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -893,7 +893,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) */ // We set country_id, and country_code label of the chosen country - if (isset($_POST["country_id"]) || $object->country_id) + if (GETPOSTISSET("country_id") || $object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 59423ec2b42..367a2e7cd62 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -805,19 +805,16 @@ class Contact extends CommonObject } // Mis a jour alerte birthday - if ($this->birthday_alert) - { + if (!empty($this->birthday_alert)) { //check existing $sql_check = "SELECT rowid FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $result_check = $this->db->query($sql_check); - if (!$result_check || ($this->db->num_rows($result_check) < 1)) - { + if (!$result_check || ($this->db->num_rows($result_check) < 1)) { //insert $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_alert(type,fk_contact,fk_user) "; $sql .= "VALUES (1,".$this->db->escape($id).",".$user->id.")"; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->lasterror(); } @@ -828,23 +825,20 @@ class Contact extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert "; $sql .= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTACT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -1342,9 +1336,10 @@ class Contact extends CommonObject if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste; $label .= '
'.$langs->trans("EMail").': '.$this->email; $phonelist = array(); - if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); - if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); - if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); + $country_code = empty($this->country_code) ? '': $this->country_code; + if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile'); + if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone'); $label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 16f7ea82f36..5b8c708b1b2 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -203,7 +203,7 @@ if (!empty($conf->socialnetworks->enabled)) { } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 68582d2fb33..a92ac8a1e73 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -946,7 +946,8 @@ if (empty($reshook)) if ($action == 'addcontact') { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); if ($result >= 0) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9e277fd706b..a3d0b82d2b7 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -53,12 +53,12 @@ class Contrat extends CommonObject public $table_element = 'contrat'; /** - * @var int Name of subtable line + * @var string Name of subtable line */ public $table_element_line = 'contratdet'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Fieldname with ID of parent key if this field has a parent */ public $fk_element = 'fk_contrat'; @@ -1032,21 +1032,19 @@ class Contrat extends CommonObject } // Insert business contacts ('SALESREPFOLL','contrat') - if (!$error) - { + if (!$error) { $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); if ($result < 0) $error++; } - if (!$error) - { + if (!$error) { if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { foreach ($this->linked_objects as $origin => $tmp_origin_id) { @@ -1144,10 +1142,10 @@ class Contrat extends CommonObject /** - * Supprime l'objet de la base + * Delete object * - * @param User $user Utilisateur qui supprime - * @return int < 0 si erreur, > 0 si ok + * @param User $user User that deletes + * @return int < 0 if KO, > 0 if OK */ public function delete($user) { diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 24b0ff54bf6..c837769819a 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -63,7 +63,8 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ad36a6e5ee7..80f16cb037d 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -62,7 +62,7 @@ if ($action == 'add' && !empty($permissiontoadd)) // Ignore special fields if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create + if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create } // Set value to insert @@ -146,7 +146,7 @@ if ($action == 'update' && !empty($permissiontoadd)) // Ignore special fields if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update + if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update } // Set value to update diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 9ad3ce1e92e..2b5b38441e0 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2020 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ if ($type == 'select') $extrasize = ''; // Add attribute if ($action == 'add') { - if ($_POST["button"] != $langs->trans("Cancel")) + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values if (!$type) @@ -132,11 +132,28 @@ if ($action == 'add') } } - if (!$error) - { + if (!$error) { + if (strlen(GETPOST('attrname', 'aZ09')) < 3) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $action = 'create'; + } + } + + // Check reserved keyword with more than 3 characters + if (!$error) { + if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'integer', 'float', 'double', 'position'))) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $action = 'create'; + } + } + + if (!$error) { // attrname must be alphabetical and lower case only - if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) - { + if (GETPOSTISSET("attrname") && preg_match("/^[a-z0-9-_]+$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) { // Construct array for parameter (value of select list) $default_value = GETPOST('default_value', 'alpha'); $parameters = $param; @@ -148,7 +165,7 @@ if ($action == 'add') $params['options'] = array($parameters=>null); } } else { - //Esle it's separated key/value and coma list + // Else it's separated key/value and coma list foreach ($parameters_array as $param_ligne) { list($key, $value) = explode(',', $param_ligne); @@ -161,7 +178,7 @@ if ($action == 'add') if ($type == 'separate') $visibility = 3; $result = $extrafields->addExtraField( - GETPOST('attrname', 'alpha'), + GETPOST('attrname', 'aZ09'), GETPOST('label', 'alpha'), $type, GETPOST('pos', 'int'), @@ -208,7 +225,7 @@ if ($action == 'add') // Rename field if ($action == 'update') { - if ($_POST["button"] != $langs->trans("Cancel")) + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values if (!$type) @@ -293,9 +310,28 @@ if ($action == 'update') } } + if (!$error) { + if (strlen(GETPOST('attrname', 'aZ09')) < 3 && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $action = 'edit'; + } + } + + // Check reserved keyword with more than 3 characters + if (!$error) { + if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'integer', 'float', 'double', 'position')) && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $action = 'edit'; + } + } + if (!$error) { - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) + if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) { $pos = GETPOST('pos', 'int'); // Construct array for parameter (value of select list) @@ -320,8 +356,11 @@ if ($action == 'update') $visibility = GETPOST('list', 'alpha'); if ($type == 'separate') $visibility = 3; + // Example: is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : 'objnotdefined' + $computedvalue = GETPOST('computed_value', 'nohtml'); + $result = $extrafields->update( - GETPOST('attrname', 'alpha'), + GETPOST('attrname', 'aZ09'), GETPOST('label', 'alpha'), $type, $extrasize, @@ -335,15 +374,14 @@ if ($action == 'update') $visibility, GETPOST('help', 'alpha'), GETPOST('default_value', 'alpha'), - GETPOST('computed_value', 'alpha'), + $computedvalue, (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), - GETPOST('enabled', 'alpha'), + GETPOST('enabled', 'alpha'), (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -365,13 +403,10 @@ if ($action == 'update') } // Delete attribute -if ($action == 'delete') -{ - if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) - { - $result = $extrafields->delete($_GET["attrname"], $elementtype); - if ($result >= 0) - { +if ($action == 'delete') { + if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST("attrname", 'aZ09'))) { + $result = $extrafields->delete(GETPOST("attrname", 'aZ09'), $elementtype); + if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else $mesg = $extrafields->error; diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 7c33ace20ab..dcb3fefe13a 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -89,7 +89,7 @@ class box_birthdays extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; - $sql.= " AND u.statut = 1"; + $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php new file mode 100644 index 00000000000..f4f4d5015cc --- /dev/null +++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php @@ -0,0 +1,193 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_clients.php + * \ingroup Facture + * \brief Module d'affichage pour les encours dépassés + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last thirdparties + */ +class box_customers_outstanding_bill_reached extends ModeleBoxes +{ + public $boxcode = "customersoutstandingbillreached"; + public $boximg = "object_company"; + public $boxlabel = "BoxCustomersOutstandingBillReached"; + public $depends = array("facture","societe"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable box for such cases + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option + + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastOutstandingBillReached", $max)); + + if ($user->rights->societe->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.client"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.code_compta"; + $sql .= ", s.code_compta_fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.email"; + $sql .= ", s.outstanding_limit"; + $sql .= ", s.datec, s.tms, s.status, s.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.client IN (1, 3)"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = $user->socid"; + $sql .= " AND s.outstanding_limit > 0"; + $sql .= " AND s.rowid IN (SELECT fk_soc from ".MAIN_DB_PREFIX."facture as f WHERE f.fk_statut = 1 and f.fk_soc = s.rowid)"; + $sql .= " ORDER BY s.tms DESC"; + //$sql .= $this->db->plimit($max, 0); + + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + + $nboutstandingbillreachedcustomers = 0; + + $line = 0; + while ($line < $num) + { + $objp = $this->db->fetch_object($result); + + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta = $objp->code_compta; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->entity = $objp->entity; + $thirdpartystatic->outstanding_limit = $objp->outstanding_limit; + + $outstandingtotal = $thirdpartystatic->getOutstandingBills()['opened']; + $outstandinglimit = $thirdpartystatic->outstanding_limit; + + if ($outstandingtotal >= $outstandinglimit) + { + $this->info_box_contents[$nboutstandingbillreachedcustomers][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1, 'customer'), + 'asis' => 1, + ); + + $this->info_box_contents[$nboutstandingbillreachedcustomers][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + ); + $nboutstandingbillreachedcustomers++; + } + + $line++; + } + + if ($num == 0 || $nboutstandingbillreachedcustomers == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedCustomers") + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php new file mode 100644 index 00000000000..c4cebfcf68a --- /dev/null +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -0,0 +1,268 @@ + + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juan José Menent + * Copyright (C) 2020 Pierre Ardoin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_funnel_of_prospection.php + * \ingroup projet + * \brief Module to show the funnel of prospection + */ +include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; + +/** + * Class to manage the box to show last projet + */ +class box_funnel_of_prospection extends ModeleBoxes +{ + public $boxcode = "FunnelOfProspection"; + public $boximg = "object_projectpub"; + public $boxlabel = "BoxTitleFunnelOfProspection"; + public $depends = array("projet"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs, $conf; + + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); + + $this->db = $db; + + $this->hidden = !($user->rights->projet->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf; + include DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; + $listofoppstatus = array(); + $listofopplabel = array(); + $listofoppcode = array(); + $colorseriesstat = array(); + $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls"; + $sql .= " WHERE active=1"; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + $listofoppstatus[$objp->rowid] = $objp->percent; + $listofopplabel[$objp->rowid] = $objp->label; + $listofoppcode[$objp->rowid] = $objp->code; + switch ($objp->code) { + case 'PROSP': + $colorseriesstat[$objp->rowid] = "-" . $badgeStatus0; + break; + case 'QUAL': + $colorseriesstat[$objp->rowid] = "-" . $badgeStatus1; + break; + case 'PROPO': + $colorseriesstat[$objp->rowid] = $badgeStatus1; + break; + case 'NEGO': + $colorseriesstat[$objp->rowid] = $badgeStatus4; + break; + case 'WON': + $colorseriesstat[$objp->rowid] = $badgeStatus6; + break; + default: + $colorseriesstat[$objp->rowid] = $badgeStatus2; + break; + } + $i++; + } + } else dol_print_error($this->db); + + global $conf, $user, $langs; + + $this->max = $max; + + $this->info_box_head = array( + 'text' => $langs->trans("Statistics") . ' - ' . $langs->trans("OpportunitiesStatusForOpenedProjects"), + $max + ); + + if ($user->rights->projet->lire || !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p, " . MAIN_DB_PREFIX . "c_lead_status as cls"; + $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; + $sql .= " AND p.fk_opp_status = cls.rowid"; + $sql .= " AND p.fk_statut = 1"; // Opend projects only + $sql .= " AND cls.code NOT IN ('LOST')"; + $sql .= " GROUP BY p.fk_opp_status, cls.code"; + $resql = $this->db->query($sql); + + $form = new Form($ths->db); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + $totalnb = 0; + $totaloppnb = 0; + $totalamount = 0; + $ponderated_opp_amount = 0; + $valsnb = array(); + $valsamount = array(); + $dataseries = array(); + + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $valsnb[$obj->opp_status] = $obj->nb; + $valsamount[$obj->opp_status] = $obj->opp_amount; + $totalnb += $obj->nb; + if ($obj->opp_status) $totaloppnb += $obj->nb; + if (!in_array($obj->code, array('WON', 'LOST'))) { + $totalamount += $obj->opp_amount; + $ponderated_opp_amount += $obj->ponderated_opp_amount; + } + } + $i++; + } + $this->db->free($resql); + $ponderated_opp_amount = $ponderated_opp_amount / 100; + + $stringtoprint = ''; + $stringtoprint .= '
'; + $listofstatus = array_keys($listofoppstatus); + foreach ($listofstatus as $status) { + $labelStatus = ''; + if ($status != 7) { + $code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code'); + if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code); + if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; + + $dataseries[] = array($labelStatus,(isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); + if (!$conf->use_javascript_ajax) { + $stringtoprint .= '
'; + $stringtoprint .= ''; + $stringtoprint .= ''; + $stringtoprint .= "\n"; + } + } + } + if ($conf->use_javascript_ajax) { + include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseriesstat)); + //$dolgraph->SetLegend(array('PROSP',$dataseries['PROSP'])); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->SetHeight('200'); + $dolgraph->draw('idgraphstatus'); + $stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1); + } + $stringtoprint .= ''; + + $line = 0; + $this->info_box_contents[$line][] = array( + 'tr' => 'class="nohover left "', + 'text' => '' + ); + $this->info_box_contents[$line][] = array( + 'tr' => 'class="nohover left "', + 'text' => '' + ); + $line++; + $this->info_box_contents[$line][] = array( + 'tr' => '', + 'td' => 'class="center nopaddingleftimp nopaddingrightimp" colspan="2"', + 'text' => $stringtoprint + ); + $line++; + $this->info_box_contents[$line][] = array( + 'tr' => 'class="oddeven"', + 'td' => 'class="left "', + 'maxlength' => 500, + 'text' => $langs->trans("OpportunityTotalAmount") . ' (' . $langs->trans("WonLostExcluded") . ')' + ); + $this->info_box_contents[$line][] = array( + 'tr' => 'class="oddeven"', + 'td' => 'class="right "', + 'maxlength' => 500, + 'text' => price($totalamount, 0, '', 1, -1, -1, $conf->currency) + ); + $line++; + $this->info_box_contents[$line][] = array( + 'tr' => 'class="oddeven"', + 'td' => 'class="left "', + 'maxlength' => 500, + 'text' => $form->textwithpicto($langs->trans("OpportunityPonderatedAmount") . ' (' . $langs->trans("WonLostExcluded") . ')', $langs->trans("OpportunityPonderatedAmountDesc"), 1) + + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right "', + 'maxlength' => 500, + 'text' => price(price2num($ponderated_opp_amount, 'MT'), 0, '', 1, -1, -1, $conf->currency) + ); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="center opacitymedium"', + 'text' => $langs->trans("NoRecordedCustomers") + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No $stringtoprint .=, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 2950eb9cfd8..94734894ad7 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -204,6 +204,6 @@ class box_last_modified_ticket extends ModeleBoxes */ public function showBox($head = null, $contents = null, $nooutput = 0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 9ada300901c..268a6861524 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -202,6 +202,6 @@ class box_last_ticket extends ModeleBoxes */ public function showBox($head = null, $contents = null, $nooutput = 0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index b45986387a8..aa7b5ca2ea5 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2017 Laurent Destailleur - * Copyright (C) 2014-2015 Frederic France + * Copyright (C) 2014-2020 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -107,10 +107,10 @@ class box_lastlogin extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 06808ab2518..f36b0500655 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -84,16 +84,25 @@ class box_produits extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); - if ($user->rights->produit->lire || $user->rights->service->lire) - { + if ($user->rights->produit->lire || $user->rights->service->lire) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; + $sql .= ", p.accountancy_code_sell"; + $sql .= ", p.accountancy_code_sell_intra"; + $sql .= ", p.accountancy_code_sell_export"; + $sql .= ", p.accountancy_code_buy"; + $sql .= ", p.accountancy_code_buy_intra"; + $sql .= ", p.accountancy_code_buy_export"; + $sql .= ', p.barcode'; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; - if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; + if (empty($user->rights->produit->lire)) { + $sql .= ' AND p.fk_product_type != 0'; + } + if (empty($user->rights->service->lire)) { + $sql .= ' AND p.fk_product_type != 1'; + } // Add where from hooks - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('boxproductlist'=>1); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -102,18 +111,15 @@ class box_produits extends ModeleBoxes $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) - { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datem = $this->db->jdate($objp->tms); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { + if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active $sqld = "SELECT label"; $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sqld .= " WHERE fk_product=".$objp->rowid; @@ -121,11 +127,11 @@ class box_produits extends ModeleBoxes $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); - if ($resultd) - { + if ($resultd) { $objtp = $this->db->fetch_object($resultd); - if (isset($objtp->label) && $objtp->label != '') + if (isset($objtp->label) && $objtp->label != '') { $objp->label = $objtp->label; + } } } $productstatic->id = $objp->rowid; @@ -133,6 +139,15 @@ class box_produits extends ModeleBoxes $productstatic->type = $objp->fk_product_type; $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; + $productstatic->status = $objp->tosell; + $productstatic->status_buy = $objp->tobuy; + $productstatic->barcode = $objp->barcode; + $productstatic->accountancy_code_sell = $objp->accountancy_code_sell; + $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra; + $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export; + $productstatic->accountancy_code_buy = $objp->accountancy_code_buy; + $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; + $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', @@ -149,14 +164,13 @@ class box_produits extends ModeleBoxes if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { $price_base_type = $langs->trans($objp->price_base_type); $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + } else { + //Parse the dynamic price $productstatic->fetch($objp->rowid, '', '', 1); $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProduct($productstatic); if ($price_result >= 0) { - if ($objp->price_base_type == 'HT') - { + if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); } else { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); @@ -164,7 +178,7 @@ class box_produits extends ModeleBoxes } $price = price($price_result); } - } + } $this->info_box_contents[$line][] = array( 'td' => 'class="right"', 'text' => $price, @@ -194,11 +208,12 @@ class box_produits extends ModeleBoxes $line++; } - if ($num == 0) + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProducts"), ); + } $this->db->free($result); } else { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 65c017e3dad..faf0a294dfe 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -58,6 +58,8 @@ class CMailFile public $alternative_boundary; public $deliveryreceipt; + public $atleastonefile; + public $eol; public $eol2; @@ -171,7 +173,7 @@ class CMailFile if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; - $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + $smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { $this->sendmode = $smtpContextSendMode; } @@ -240,6 +242,7 @@ class CMailFile { $this->html = $msg; + $findimg = 0; if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS)) { $findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias'); @@ -298,7 +301,7 @@ class CMailFile if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; - $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + $smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } @@ -338,8 +341,7 @@ class CMailFile $text_body = $this->write_body($msg); // Add attachments to text_encoded - if ($this->atleastonefile) - { + if (!empty($this->atleastonefile)) { $files_encoded = $this->write_files($filename_list, $mimetype_list, $mimefilename_list); } @@ -401,7 +403,7 @@ class CMailFile } } - if ($this->atleastonefile) + if (!empty($this->atleastonefile)) { foreach ($filename_list as $i => $val) { @@ -530,7 +532,7 @@ class CMailFile $this->message->addPart(dol_nl2br($msg), 'text/html'); } - if ($this->atleastonefile) + if (!empty($this->atleastonefile)) { foreach ($filename_list as $i => $val) { @@ -657,7 +659,7 @@ class CMailFile if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; - $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + $smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey; $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index d2c6221a598..3f9ca42e136 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -32,10 +32,13 @@ class Comment extends CommonObject public $table_element = 'comment'; /** - * @var int Field with ID of parent key if this field has a parent + * @var int ID of parent key (it's not the name of a field) */ - public $fk_element = ''; + public $fk_element; + /** + * @var string element type + */ public $element_type; /** @@ -72,10 +75,16 @@ class Comment extends CommonObject */ public $entity; + /** + * @var string import key + */ public $import_key; public $comments = array(); + /** + * @var Comment Object oldcopy + */ public $oldcopy; @@ -131,26 +140,26 @@ class Comment extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error) - { + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_COMMENT_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -190,12 +199,10 @@ class Comment extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - if ($num_rows) - { + if ($num_rows) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -212,8 +219,11 @@ class Comment extends CommonObject $this->db->free($resql); - if ($num_rows) return 1; - else return 0; + if ($num_rows) { + return 1; + } else { + return 0; + } } else { $this->error = "Error ".$this->db->lasterror(); return -1; @@ -234,8 +244,12 @@ class Comment extends CommonObject $error = 0; // Clean parameters - if (isset($this->fk_element)) $this->fk_project = (int) trim($this->fk_element); - if (isset($this->description)) $this->description = trim($this->description); + if (isset($this->fk_element)) { + $this->fk_project = (int) trim($this->fk_element); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } // Update request @@ -253,24 +267,24 @@ class Comment extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_COMMENT_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -303,24 +317,24 @@ class Comment extends CommonObject $sql .= " WHERE rowid=".$this->id; $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error) - { - if (!$notrigger) - { + if (!$error) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_COMMENT_DELETE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -355,13 +369,10 @@ class Comment extends CommonObject dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - if ($num_rows > 0) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($num_rows > 0) { + while ($obj = $this->db->fetch_object($resql)) { $comment = new self($db); $comment->fetch($obj->rowid); $this->comments[] = $comment; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 8327a26ae41..03a5154f23f 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -123,7 +123,7 @@ abstract class CommonDocGenerator if ($member->photo) { $logotouse = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $member, 'user').'/photos/'.$member->photo; } else { - $logotouse = DOL_DOCUMENT_ROOT . '/public/theme/common/nophoto.png'; + $logotouse = DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.png'; } $array_member = array( @@ -585,7 +585,7 @@ abstract class CommonDocGenerator 'line_product_ref'=>(empty($line->product_ref) ? '' : $line->product_ref), 'line_product_ref_fourn'=>(empty($line->ref_fourn) ? '' : $line->ref_fourn), // for supplier doc lines - 'line_product_label'=>(empty($line->product_label) ? '' :$line->product_label), + 'line_product_label'=>(empty($line->product_label) ? '' : $line->product_label), 'line_product_type'=>(empty($line->product_type) ? '' : $line->product_type), 'line_product_barcode'=>(empty($line->product_barcode) ? '' : $line->product_barcode), @@ -652,7 +652,7 @@ abstract class CommonDocGenerator { $columns = ""; - foreach ($extralabels as $key) + foreach ($extralabels as $key => $label) { $columns .= "$key, "; } @@ -666,7 +666,7 @@ abstract class CommonDocGenerator { $resql = $this->db->fetch_object($resql); - foreach ($extralabels as $key) + foreach ($extralabels as $key => $label) { $resarray['line_product_supplier_'.$key] = $resql->{$key}; } @@ -743,6 +743,12 @@ abstract class CommonDocGenerator $array_shipment = $this->fill_substitutionarray_with_extrafields($object, $array_shipment, $extrafields, $array_key, $outputlangs); } + // Add infor from $object->xxx where xxx has been loaded by fetch_origin() of shipment + if (!empty($object->commande) && is_object($object->commande)) { + $array_shipment['order_ref'] = $object->commande->ref; + $array_shipment['order_ref_customer'] = $object->commande->ref_customer; + } + return $array_shipment; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bc1c17d417f..6ecdfb93bb5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -936,11 +936,11 @@ abstract class CommonObject /** * Add a link between element $this->element and a contact * - * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link - * @param int $type_contact Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL - * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) - * @param int $notrigger Disable all triggers - * @return int <0 if KO, >0 if OK + * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link + * @param int|string $type_contact Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL + * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) + * @param int $notrigger Disable all triggers + * @return int <0 if KO, >0 if OK */ public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { @@ -1817,7 +1817,11 @@ abstract class CommonObject return -2; } } else { - $this->error = $this->db->lasterror(); + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->error = 'DB_ERROR_RECORD_ALREADY_EXISTS'; + } else { + $this->error = $this->db->lasterror(); + } $this->db->rollback(); return -1; } @@ -3157,7 +3161,7 @@ abstract class CommonObject $this->multicurrency_total_ttc += isset($this->revenuestamp) ? ($this->revenuestamp * $multicurrency_tx) : 0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE) + if (!empty($this->situation_cycle_ref) && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE) { $prev_sits = $this->get_prev_sits(); @@ -5092,7 +5096,7 @@ abstract class CommonObject global $conf, $extrafields; if (empty($rowid)) $rowid = $this->id; - if (empty($rowid) && isset($this->rowid)) $rowid = $this->rowid; // deprecated + if (empty($rowid) && isset($this->rowid)) $rowid = $this->rowid; // deprecated // To avoid SQL errors. Probably not the better solution though if (!$this->table_element) { @@ -5417,26 +5421,20 @@ abstract class CommonObject $sql .= ",".$attributeKey; } // 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 (!empty($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']) && 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; } } } $sql .= ") VALUES (".$this->id; - foreach ($new_array_options as $key => $value) - { + foreach ($new_array_options as $key => $value) { $attributeKey = substr($key, 8); // Remove 'options_' prefix // Add field of attribute - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) - { - if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') - { + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { // Only for other type than separator) + if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') { $sql .= ",'".$this->db->escape($new_array_options[$key])."'"; } else { $sql .= ",null"; @@ -5444,12 +5442,9 @@ 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 (!empty($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']) && 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 .= ", ''"; } @@ -5939,7 +5934,7 @@ abstract class CommonObject $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } elseif (in_array($type, array('duration'))) { $out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1); - } elseif (in_array($type, array('int', 'integer'))) { + } elseif (in_array($type, array('int', 'integer'))) { $tmp = explode(',', $size); $newsize = $tmp[0]; $out = ''; @@ -5949,7 +5944,7 @@ abstract class CommonObject $out = ''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { $out = ''; - } elseif (preg_match('/^text/', $type)) { + } elseif (preg_match('/^text/', $type)) { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -6728,7 +6723,7 @@ abstract class CommonObject * @param array $params Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan) * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) - * @param string $onetrtd All fields in same tr td (TODO field not used ?) + * @param string $onetrtd All fields in same tr td. Used by objectline_create.tpl.php for example. * @return string */ public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) @@ -6894,6 +6889,9 @@ abstract class CommonObject $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); $out .= ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && $action == 'view') { + $out .= ''; + } $out .= ''; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index c6ffe090c52..cba0b0b3e53 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -73,7 +73,7 @@ $coldisplay = 0; > global->MAIN_VIEW_LINE_NUMBER)) { ?> - + '; // Country @@ -560,9 +560,9 @@ if (!empty($id) && $action == 'edit') // Zip / Town print ''; // Country diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 042b22b3a1c..be9426415fe 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -47,7 +47,7 @@ class Don extends CommonObject public $table_element = 'don'; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Field with ID of parent key if this field has a parent */ public $fk_element = 'fk_donation'; diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index f2b87382c76..ca2b9fec473 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -62,8 +62,19 @@ class EcmDirectory extends CommonObject */ public $description; + /** + * @var int cache nb of doc + */ public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated' + + /** + * @var int date_c + */ public $date_c; + + /** + * @var int date_m + */ public $date_m; /** @@ -81,25 +92,31 @@ class EcmDirectory extends CommonObject */ public $ref; + /** + * @var array array of categories + */ public $cats = array(); + + /** + * @var array array of children categories + */ public $motherof = array(); + /** + * @var array array of forbidden chars + */ public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"'); + + /** + * @var array array of forbidden chars for dir + */ public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"'); + /** + * @var int 1 if full arbo loaded + */ public $full_arbo_loaded; - /** - * @var string Error code (or message) - */ - public $error; - - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); - - /** * Constructor * @@ -131,13 +148,14 @@ class EcmDirectory extends CommonObject $this->description = trim($this->description); $this->date_c = $now; $this->fk_user_c = $user->id; - if ($this->fk_parent <= 0) $this->fk_parent = 0; + if ($this->fk_parent <= 0) { + $this->fk_parent = 0; + } // Check if same directory does not exists with this name $relativepath = $this->label; - if ($this->fk_parent) - { + if ($this->fk_parent) { $parent = new EcmDirectory($this->db); $parent->fetch($this->fk_parent); $relativepath = $parent->getRelativePath().$relativepath; @@ -148,19 +166,16 @@ class EcmDirectory extends CommonObject $cat = new EcmDirectory($this->db); $cate_arbo = $cat->get_full_arbo(1); $pathfound = 0; - foreach ($cate_arbo as $key => $categ) - { + foreach ($cate_arbo as $key => $categ) { $path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']); //print $relativepath.' - '.$path.'
'; - if ($path == $relativepath) - { + if ($path == $relativepath) { $pathfound = 1; break; } } - if ($pathfound) - { + if ($pathfound) { $this->error = "ErrorDirAlreadyExists"; dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); return -1; @@ -188,21 +203,23 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories"); $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath(); $result = dol_mkdir($dir); - if ($result < 0) { $error++; $this->error = "ErrorFailedToCreateDir"; } + if ($result < 0) { + $error++; $this->error = "ErrorFailedToCreateDir"; + } // Call trigger $result = $this->call_trigger('MYECMDIR_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -249,22 +266,21 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = "Error ".$this->db->lasterror(); } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MYECMDIR_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -284,20 +300,26 @@ class EcmDirectory extends CommonObject { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - if (preg_match('/[0-9]+/', $value)) $sql .= " cachenbofdoc = ".(int) $value; - else $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1"; + if (preg_match('/[0-9]+/', $value)) { + $sql .= " cachenbofdoc = ".(int) $value; + } else { + $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1"; + } $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); return -1; } else { - if (preg_match('/[0-9]+/', $value)) $this->cachenbofdoc = (int) $value; - elseif ($value == '+') $this->cachenbofdoc++; - elseif ($value == '-') $this->cachenbofdoc--; + if (preg_match('/[0-9]+/', $value)) { + $this->cachenbofdoc = (int) $value; + } elseif ($value == '+') { + $this->cachenbofdoc++; + } elseif ($value == '-') { + $this->cachenbofdoc--; + } } return 1; @@ -327,11 +349,9 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->ref = $obj->rowid; @@ -374,7 +394,9 @@ class EcmDirectory extends CommonObject $error = 0; - if ($mode != 'databaseonly') $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3 + if ($mode != 'databaseonly') { + $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3 + } dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath)); @@ -385,35 +407,30 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->db->rollback(); $this->error = "Error ".$this->db->lasterror(); return -2; } else { // Call trigger $result = $this->call_trigger('MYECMDIR_DELETE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -2; } // End call triggers } - if ($mode != 'databaseonly') - { + if ($mode != 'databaseonly') { $file = $conf->ecm->dir_output."/".$relativepath; - if ($deletedirrecursive) - { + if ($deletedirrecursive) { $result = @dol_delete_dir_recursive($file, 0, 0); } else { $result = @dol_delete_dir($file, 0); } } - if ($result || !@is_dir(dol_osencode($file))) - { + if ($result || !@is_dir(dol_osencode($file))) { $this->db->commit(); } else { $this->error = 'ErrorFailToDeleteDir'; @@ -422,8 +439,11 @@ class EcmDirectory extends CommonObject $error++; } - if (!$error) return 1; - else return -1; + if (!$error) { + return 1; + } else { + return -1; + } } @@ -465,17 +485,27 @@ class EcmDirectory extends CommonObject $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = 'picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref); + } $result .= $linkend; return $result; @@ -497,18 +527,15 @@ class EcmDirectory extends CommonObject do { // Get index cursor in this->cats for id_mere $cursorindex = -1; - foreach ($this->cats as $key => $val) - { - if ($this->cats[$key]['id'] == $idtosearch) - { + foreach ($this->cats as $key => $val) { + if ($this->cats[$key]['id'] == $idtosearch) { $cursorindex = $key; break; } } //print "c=".$idtosearch."-".$cursorindex; - if ($cursorindex >= 0) - { + if ($cursorindex >= 0) { // Path is label sanitized (no space and no special char) and concatenated $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret; @@ -541,11 +568,9 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; @@ -608,8 +633,7 @@ class EcmDirectory extends CommonObject // phpcs:enable global $conf; - if (empty($force) && !empty($this->full_arbo_loaded)) - { + if (empty($force) && !empty($this->full_arbo_loaded)) { return $this->cats; } @@ -632,13 +656,11 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->cats = array(); $i = 0; // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : ''); $this->cats[$obj->rowid]['label'] = $obj->label; @@ -648,10 +670,8 @@ class EcmDirectory extends CommonObject $this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c; $this->cats[$obj->rowid]['login_c'] = $obj->login_c; - if (!empty($obj->rowid_fille)) - { - if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) - { + if (!empty($obj->rowid_fille)) { + if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) { $newelempos = count($this->cats[$obj->rowid]['id_children']); //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements
"; $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille; @@ -668,9 +688,10 @@ class EcmDirectory extends CommonObject } // We add properties fullxxx to all elements - foreach ($this->cats as $key => $val) - { - if (isset($motherof[$key])) continue; + foreach ($this->cats as $key => $val) { + if (isset($motherof[$key])) { + continue; + } $this->build_path_from_id_categ($key, 0); } @@ -693,8 +714,7 @@ class EcmDirectory extends CommonObject { // phpcs:enable // Define fullpath - if (!empty($this->cats[$id_categ]['id_mere'])) - { + if (!empty($this->cats[$id_categ]['id_mere'])) { $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ; $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename']; @@ -711,11 +731,11 @@ class EcmDirectory extends CommonObject // Traite ces enfants $protection++; - if ($protection > 20) return; // On ne traite pas plus de 20 niveaux - if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) - { - foreach ($this->cats[$id_categ]['id_children'] as $key => $val) - { + if ($protection > 20) { + return; // On ne traite pas plus de 20 niveaux + } + if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) { + foreach ($this->cats[$id_categ]['id_children'] as $key => $val) { $this->build_path_from_id_categ($val, $protection); } } @@ -741,8 +761,7 @@ class EcmDirectory extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; $sql .= " cachenbofdoc = '".count($filelist)."'"; - if (empty($all)) // By default - { + if (empty($all)) { // By default $sql .= " WHERE rowid = ".$this->id; } else { $sql .= " WHERE entity = ".$conf->entity; @@ -750,8 +769,7 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->cachenbofdoc = count($filelist); return $this->cachenbofdoc; } else { @@ -782,8 +800,7 @@ class EcmDirectory extends CommonObject $interface = new Interfaces($this->db); $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf); if ($result < 0) { - if (!empty($this->errors)) - { + if (!empty($this->errors)) { $this->errors = array_merge($this->errors, $interface->errors); } else { $this->errors = $interface->errors; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 978b6e46d9e..c096bc27869 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -94,7 +94,15 @@ class EcmFiles extends CommonObject * @var string keywords */ public $keywords; + + /** + * @var string cover + */ public $cover; + + /** + * @var int position + */ public $position; /** @@ -131,7 +139,15 @@ class EcmFiles extends CommonObject * @var string acl */ public $acl; + + /** + * @var string src object type + */ public $src_object_type; + + /** + * @var int src object id + */ public $src_object_id; @@ -233,8 +249,7 @@ class EcmFiles extends CommonObject $sql .= " WHERE filepath ='".$this->db->escape($this->filepath)."'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $maxposition = (int) $obj->maxposition; } else { @@ -247,13 +262,11 @@ class EcmFiles extends CommonObject } // Check parameters - if (empty($this->filename) || empty($this->filepath)) - { + if (empty($this->filename) || empty($this->filepath)) { $this->errors[] = 'Bad property filename or filepath'; return --$error; } - if (!isset($this->entity)) - { + if (!isset($this->entity)) { $this->entity = $conf->entity; } // Put here code to add control on parameters values @@ -317,11 +330,12 @@ class EcmFiles extends CommonObject $this->position = $maxposition; // Triggers - if (!$notrigger) - { + if (!$notrigger) { // Call triggers $result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } @@ -401,8 +415,7 @@ class EcmFiles extends CommonObject } elseif (!empty($hashforshare)) { $sql .= " AND t.share = '".$this->db->escape($hashforshare)."'"; //$sql .= " AND t.entity = ".$conf->entity; // hashforshare already unique - } elseif ($src_object_type && $src_object_id) - { + } elseif ($src_object_type && $src_object_id) { // Warning: May return several record, and only first one is returned ! $sql .= " AND t.src_object_type ='".$this->db->escape($src_object_type)."' AND t.src_object_id = ".$this->db->escape($src_object_id); $sql .= " AND t.entity = ".$conf->entity; @@ -668,11 +681,12 @@ class EcmFiles extends CommonObject } // Triggers - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + if ($result < 0) { + $error++; + } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -705,11 +719,12 @@ class EcmFiles extends CommonObject $this->db->begin(); // Triggers - if (!$notrigger) - { + if (!$notrigger) { // Call triggers $result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + if ($result < 0) { + $error++; + } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -804,7 +819,9 @@ class EcmFiles extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; @@ -815,25 +832,26 @@ class EcmFiles extends CommonObject $url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id; $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowProject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = '
'; $linkend = ''; - if ($withpicto) - { + if ($withpicto) { $result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result .= ' '; + if ($withpicto != 2) { + $result .= ' '; + } } $result .= $linkstart.$this->ref.$linkend; return $result; @@ -877,16 +895,16 @@ class EcmFiles extends CommonObject global $conf, $user; $this->id = 0; - + $this->specimen = 1; $this->label = '0a1b2c3e4f59999999'; - $this->entity = '1'; + $this->entity = 1; $this->filename = 'myspecimenfilefile.pdf'; $this->filepath = '/aaa/bbb'; $this->fullpath_orig = 'c:/file on my disk.pdf'; $this->description = 'This is a long description of file'; $this->keywords = 'key1,key2'; $this->cover = '1'; - $this->position = '5'; + $this->position = 5; $this->gen_or_uploaded = 'uploaded'; $this->extraparams = ''; $this->date_c = (dol_now() - 3600 * 24 * 10); diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index a2726a1ba75..8c13c377bd6 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -41,20 +41,22 @@ $confirm = GETPOST('confirm', 'alpha'); $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) $module = 'ecm'; +if (empty($module)) { + $module = 'ecm'; +} // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } $section = $urlsection = GETPOST('section', 'alpha'); -if (empty($urlsection)) $urlsection = 'misc'; +if (empty($urlsection)) { + $urlsection = 'misc'; +} -if ($module == 'ecm') -{ +if ($module == 'ecm') { $upload_dir = $conf->ecm->dir_output.'/'.$urlsection; } else // For example $module == 'medias' { @@ -65,19 +67,23 @@ $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 +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 = "label"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "label"; +} $ecmdir = new EcmDirectory($db); -if (!empty($section)) -{ +if (!empty($section)) { $result = $ecmdir->fetch($section); - if (!$result > 0) - { + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } @@ -86,18 +92,18 @@ if (!empty($section)) // Permissions $permtoadd = 0; $permtoupload = 0; -if ($module == 'ecm') -{ +if ($module == 'ecm') { $permtoadd = $user->rights->ecm->setup; $permtoupload = $user->rights->ecm->upload; } -if ($module == 'medias') -{ +if ($module == 'medias') { $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); } -if (!$permtoadd) accessforbidden(); +if (!$permtoadd) { + accessforbidden(); +} @@ -106,12 +112,9 @@ if (!$permtoadd) accessforbidden(); */ // Action ajout d'un produit ou service -if ($action == 'add' && $permtoadd) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if ($action == 'add' && $permtoadd) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { @@ -120,33 +123,31 @@ if ($action == 'add' && $permtoadd) } } - $ref = GETPOST("ref", 'alpha'); - $label = GETPOST("label", 'alpha'); - $desc = GETPOST("desc", 'alpha'); + $ref = (string) GETPOST("ref", 'alpha'); + $label = (string) GETPOST("label", 'alpha'); + $desc = (string) GETPOST("desc", 'alpha'); $catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager) - if ($catParent == '-1') $catParent = 0; + if ($catParent == '-1') { + $catParent = 0; + } $error = 0; - if (empty($label)) - { + if (empty($label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $action = 'create'; $error++; } - if (!$error) - { - if ($module == 'ecm') - { + if (!$error) { + if ($module == 'ecm') { $ecmdir->ref = $ref; $ecmdir->label = $label; $ecmdir->description = $desc; $ecmdir->fk_parent = (int) $catParent; $id = $ecmdir->create($user); - if ($id <= 0) - { + if ($id <= 0) { $error++; $langs->load("errors"); setEventMessages($ecmdir->error, $ecmdir->errors, 'errors'); @@ -155,22 +156,18 @@ if ($action == 'add' && $permtoadd) } else // For example $module == 'medias' { $dirfornewdir = ''; - if ($module == 'medias') - { + if ($module == 'medias') { $dirfornewdir = $conf->medias->multidir_output[$conf->entity]; } - if (empty($dirfornewdir)) - { + if (empty($dirfornewdir)) { $error++; dol_print_error('', 'Bad value for module. Not supported.'); } - if (!$error) - { + if (!$error) { $fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label; $result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT); - if ($result < 0) - { + if ($result < 0) { setEventMessages($langs->trans('ErrorFailToCreateDir', $label), null, 'errors'); $error++; } else { @@ -180,10 +177,8 @@ if ($action == 'add' && $permtoadd) } } - if (!$error) - { - if (!empty($backtopage)) - { + if (!$error) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { @@ -194,8 +189,7 @@ if ($action == 'add' && $permtoadd) } // Deleting file -elseif ($action == 'confirm_deletesection' && $confirm == 'yes') -{ +elseif ($action == 'confirm_deletesection' && $confirm == 'yes') { $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); } @@ -212,8 +206,7 @@ llxHeader('', $langs->trans("ECMNewSection")); $form = new Form($db); $formecm = new FormEcm($db); -if ($action == 'create') -{ +if ($action == 'create') { //*********************** // Create //*********************** @@ -222,8 +215,12 @@ if ($action == 'create') print ''; print ''; print ''; - if ($website) print ''; - if ($pageid) print ''; + if ($website) { + print ''; + } + if ($pageid) { + print ''; + } $title = $langs->trans("ECMNewSection"); print load_fiche_titre($title); @@ -240,8 +237,7 @@ if ($action == 'create') print ''."\n"; // Description - if ($module == 'ecm') - { + if ($module == 'ecm') { print '
'.$langs->trans("NbOfGenerationDone").'
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT'); + $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id', 'CRDT'); print '
'.$langs->trans('Type').''; + print ''; print $object->getLibType(); + print ''; if ($object->module_source) { - print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; + print ' ('.$langs->trans("POS").' '.ucfirst($object->module_source).' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; } if ($object->type == Facture::TYPE_REPLACEMENT) { $facreplaced = new Facture($db); $facreplaced->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; + print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { $facusing = new Facture($db); $facusing->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; + print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { - print ' ('.$langs->transnoentities("InvoiceHasAvoir"); + print ' ('.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; foreach ($facidavoir as $id) { if ($i == 0) @@ -4105,14 +4104,16 @@ if ($action == 'create') if ($objectidnext > 0) { $facthatreplace = new Facture($db); $facthatreplace->fetch($objectidnext); - print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; + print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, $object->id); if ($result > 0) { - print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
'; + print ' '; + print $langs->transnoentities("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')); + print '
'; } } @@ -4121,10 +4122,9 @@ if ($action == 'create') $tmptemplate = new FactureRec($db); $result = $tmptemplate->fetch($object->fk_fac_rec_source); if ($result > 0) { - print '. '.$langs->trans( - "GeneratedFromTemplate", - ''.$tmptemplate->ref.'' - ).''; + print ' '; + print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).''); + print ''; } } print '
'.$langs->trans('Discounts'); - print ''; $thirdparty = $soc; $discount_type = 0; $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - print '
'; - if ($object->type != Facture::TYPE_DEPOSIT) + print ''; + if ($object->type != Facture::TYPE_DEPOSIT) { print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); - else print $langs->trans('AlreadyPaid'); - print ' :'.price($totalpaye).' 
'.price($totalpaye).' 
'; + print ''; if ($invoice->type == Facture::TYPE_CREDIT_NOTE) print $langs->trans("CreditNote").' '; if ($invoice->type == Facture::TYPE_DEPOSIT) print $langs->trans("Deposit").' '; print $invoice->getNomUrl(0); - print ' :'.price($obj->amount_ttc).''; print 'rowid.'">'.img_delete().''; @@ -4835,7 +4838,9 @@ if ($action == 'create') // Paye partiellement 'escompte' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { print '
'; - print $form->textwithpicto($langs->trans("Discount").':', $langs->trans("HelpEscompte"), - 1); + print ''; + print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); + print ''; print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'; - print $form->textwithpicto($langs->trans("Abandoned").':', $langs->trans("HelpAbandonBadCustomer"), - 1); + print ''; + print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1); + print ''; print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'; - print $form->textwithpicto($langs->trans("ProductReturned").':', $langs->trans("HelpAbandonProductReturned"), - 1); + print ''; + print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); + print ''; print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.$langs->trans("Billed").' :'.price($object->total_ttc).' 
'; + print ''; + print $langs->trans("Billed"); + print ''.price($object->total_ttc).' 
'; + print ''; print $langs->trans('RemainderToPay'); if ($resteapayeraffiche < 0) print ' ('.$langs->trans('ExcessReceived').')'; - print ' :'.price($resteapayeraffiche).' 
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Date").''; - $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; + $datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int')); + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (GETPOSTISSET("remonth") ? $datepaye : -1) : 0; print $form->selectDate($datepayment, '', '', '', 0, "add_payment", 1, 1, 0, '', '', $charge->date_ech, '', 1, $langs->trans("DateOfSocialContribution")); print "
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $charge->paiementtype, "paiementtype"); + $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype") : $charge->paiementtype, "paiementtype"); print "
'.$langs->trans('AccountToDebit').''; - $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $charge->accountid, "accountid", 0, '', 2); // Show opend bank account list + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid") : $charge->accountid, "accountid", 0, '', 2); // Show opend bank account list print '
' . $labelStatus . '' . price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency) . '
deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } @@ -8489,7 +8487,7 @@ abstract class CommonObject // Delete ecm_files extrafields $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files_extrafields WHERE fk_object IN ("; $sql .= " SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here $sql .= ")"; if (!$this->db->query($sql)) { @@ -8501,7 +8499,7 @@ abstract class CommonObject // Delete ecm_files $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 5bb441ceb0a..09f2b0a44ae 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -537,6 +537,8 @@ class Conf if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1; + if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) $this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1; + // Format for date (used by default when not found or not searched in lang) $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 215a1710b82..98fbe62e4c5 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -98,7 +98,7 @@ class DolGeoIP //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); //print geoip_database_info(); } else { - $this->gi = ''; // For avoid error + $this->gi = ''; // For avoid error } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 0ff627ba20c..80314bcf9ed 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -39,9 +39,9 @@ */ class DolGraph { - public $type = array(); // Array with type of each series. Example: array('bars', 'lines', ...) + public $type = array(); // Array with type of each series. Example: array('bars', 'horizontalbars', 'lines', 'pies', 'piesemicircle', 'polar'...) public $mode = 'side'; // Mode bars graph: side, depth - private $_library = 'jflot'; // Graphic library to use (jflot, artichow) + private $_library = 'chart'; // Graphic library to use (jflot, chart, artichow) //! Array of data public $data; // Data of graph: array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) @@ -115,7 +115,7 @@ class DolGraph $this->_library = $library; if ($this->_library == 'auto') { - $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ? 'jflot' : $conf->global->MAIN_JS_GRAPH); + $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ? 'chart' : $conf->global->MAIN_JS_GRAPH); } } @@ -261,7 +261,7 @@ class DolGraph * Set type * * @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be: - * 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', ... + * 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horirontalbars'... * @return void */ public function SetType($type) @@ -1156,6 +1156,7 @@ class DolGraph else { $type = 'bar'; if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar'; + if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar'; if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line'; $this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, '; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index ec8d9fa15bd..e075005b437 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -631,11 +631,18 @@ class dolReceiptPrinter extends Printer break; case 'DOL_PRINT_OBJECT_LINES': foreach ($object->lines as $line) { - //var_dump($line); - $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); + if ($line->fk_product) + { + $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); + } + else { + $spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - 10 - 1; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + } } break; case 'DOL_PRINT_OBJECT_TAX': diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index efb2e554da9..0d9ddd72e24 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -125,7 +125,6 @@ class EmailSenderProfile extends CommonObject */ public $date_creation; - public $tms; public $private; public $signature; @@ -134,32 +133,6 @@ class EmailSenderProfile extends CommonObject // END MODULEBUILDER PROPERTIES - - // If this object has a subtable with lines - - /** - * @var int Name of subtable line - */ - //public $table_element_line = 'emailsenderprofiledet'; - /** - * @var int Field with ID of parent key if this field has a parent - */ - //public $fk_element = 'fk_emailsenderprofile'; - /** - * @var int Name of subtable class that manage subtable lines - */ - //public $class_element_line = 'EmailSenderProfileline'; - /** - * @var array List of child tables. To test if we can delete object. - */ - //protected $childtables=array(); - /** - * @var EmailSenderProfileLine[] Array of subtable lines - */ - //public $lines = array(); - - - /** * Constructor * diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 1b8a9eb3291..16c133f9dab 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -141,7 +141,7 @@ class Events // extends CommonObject // Clean parameters $this->description = trim($this->description); - if (empty($this->user_agent)) $this->user_agent = (empty($_SERVER['HTTP_USER_AGENT'])?'':$_SERVER['HTTP_USER_AGENT']); + if (empty($this->user_agent)) $this->user_agent = (empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']); // Check parameters if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 87cee951170..d041aba45f4 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1937,10 +1937,10 @@ class ExtraFields $out .= ''; print ''; } print '
select_resource_list('', 'fk_resource', '', 1, 1, 0, $events, '', 2, null); $out .= ''; -$out .= '
'.$form->selectyesno('busy', (isset($_POST['busy']) ? $_POST['busy'] : 1), 1).'
'; -$out .= '
'.$form->selectyesno('mandatory', (isset($_POST['mandatory']) ? $_POST['mandatory'] : 0), 1).'
'; +$out .= '
'.$form->selectyesno('busy', (GETPOSTISSET('busy') ? GETPOST('busy') : 1), 1).'
'; +$out .= '
'.$form->selectyesno('mandatory', (GETPOSTISSET('mandatory') ? GETPOST('mandatory') : 0), 1).'
'; $out .= '
'; $out .= ''; diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index e1bcaf85034..48c9614dea6 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -174,7 +174,7 @@ class InterfaceLogevents extends DolibarrTriggers $event->dateevent = $date; $event->label = $text; $event->description = $desc; - $event->user_agent = (empty($_SERVER["HTTP_USER_AGENT"])?'':$_SERVER["HTTP_USER_AGENT"]); + $event->user_agent = (empty($_SERVER["HTTP_USER_AGENT"]) ? '' : $_SERVER["HTTP_USER_AGENT"]); $result = $event->create($user); if ($result > 0) { diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index fd082884ce2..3d4c4ed63b7 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -717,20 +717,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page if (empty($object->actionmsg2)) { $langs->loadLangs(array("agenda", "other")); - if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key - $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key + $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)); } else { // generic translation key $tmp = explode('_', $action); - $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)); } } if (empty($object->actionmsg)) { $langs->loadLangs(array("agenda", "other")); - if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key - $object->actionmsg = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key + $object->actionmsg = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)); } else { // generic translation key $tmp = explode('_', $action); - $object->actionmsg = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)); } } @@ -787,8 +787,8 @@ class InterfaceActionsAuto extends DolibarrTriggers if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid); } // Set societeforaction. - if ($object->socid > 0) $societeforaction->fetch($object->socid); - elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); + if (isset($object->socid) && $object->socid > 0) $societeforaction->fetch($object->socid); + elseif (isset($object->fk_soc) && $object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); $projectid = isset($object->fk_project) ? $object->fk_project : 0; if ($object->element == 'project') $projectid = $object->id; diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 3743d044e44..7bb8988e18e 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -132,8 +132,9 @@ class InterfaceTicketEmail extends DolibarrTriggers $langs->load('ticket'); // Send email to notification email - $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) { + $sendto = empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? '' : $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + if ($sendto) { // Init to avoid errors $filepath = array(); @@ -246,7 +247,7 @@ class InterfaceTicketEmail extends DolibarrTriggers $message_customer .= '

'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : '.$url_public_ticket.'

'; $message_customer .= '

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

'; - $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; + $from = (empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOM.' ').'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; $replyto = $from; $trackid = 'tic'.$object->id; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 3c4d53f53e7..9c1e9682a10 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -48,7 +48,7 @@ class Delivery extends CommonObject public $element = "delivery"; /** - * @var int Field with ID of parent key if this field has a parent + * @var string Field with ID of parent key if this field has a parent */ public $fk_element = "fk_delivery"; @@ -58,7 +58,7 @@ class Delivery extends CommonObject public $table_element = "delivery"; /** - * @var int Name of subtable line + * @var string Name of subtable line */ public $table_element_line = "deliverydet"; @@ -102,6 +102,8 @@ class Delivery extends CommonObject */ public $model_pdf; + public $lines = array(); + /** * Constructor @@ -111,8 +113,6 @@ class Delivery extends CommonObject public function __construct($db) { $this->db = $db; - $this->lines = array(); - $this->products = array(); // List of short language codes for status $this->statuts[-1] = 'StatusDeliveryCanceled'; diff --git a/htdocs/document.php b/htdocs/document.php index c48a0363f78..060722e8d5b 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -245,7 +245,7 @@ if (!file_exists($fullpath_original_file_osencoded)) // Hooks if (!is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('document')); @@ -254,9 +254,9 @@ $parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'origina 'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded); $reshook = $hookmanager->executeHooks('downloadDocument', $parameters); // Note that $action and $object may have been if ($reshook < 0) { - $errors = $hookmanager->error . (is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '') . join($separator, $hookmanager->errors) : ''); - dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : " . $errors); - print "ErrorDownloadDocumentHooks: " . $errors; + $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join($separator, $hookmanager->errors) : ''); + dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : ".$errors); + print "ErrorDownloadDocumentHooks: ".$errors; exit; } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 0f4b2054619..c55751e913f 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -418,9 +418,9 @@ if ($action == 'create') // Zip / Town print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"]) ? $_POST["zipcode"] : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"]) ? $_POST["town"] : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"]) ? $_POST["zipcode"] : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOSTISSET("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"]) ? $_POST["town"] : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
'.$langs->trans("Description").''; print '