Merge branch 'develop' into 12.0

This commit is contained in:
Laurent Destailleur 2020-10-12 12:14:39 +02:00 committed by GitHub
commit bf458215c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3708 changed files with 164789 additions and 130076 deletions

17
.github/workflows/exakat.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: "Exakat analysis"
on:
schedule:
- cron: "0 20 * * *"
jobs:
exakat:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Exakat
uses: docker://exakat/exakat-ga
with:
ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/WrongNumberOfArguments,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/UselessParenthesis,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UseConstant'
ignore_dirs: '/htdocs/includes,/htdocs/build,/htdocs/dev,/htdocs/doc,/htdocs/scripts,/htdocs/test'

View File

@ -14,11 +14,11 @@ jobs:
- uses: Dolibarr/stale@staleunstale - uses: Dolibarr/stale@staleunstale
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 15 days (you should still be able to re-open it if required).' stale-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 10 days (you should still be able to re-open it if required).'
stale-label: 'Issue Stale (automatic label)' stale-label: 'Issue Stale (automatic label)'
exempt-labels: 'Priority High / Blocking,Priority Top Strategic,Priority Medium,Hacktoberfest,good first issue,Bug Security (CVE),Analysis of PR in progres' exempt-labels: 'Priority High / Blocking,Priority Top Strategic,Priority Medium,Hacktoberfest,good first issue,Bug Security (CVE),Analysis of PR in progres'
days-before-stale: 365 days-before-stale: 365
days-before-close: 15 days-before-close: 10
operations-per-run: 100 operations-per-run: 100
dry-run: false dry-run: false

15
.gitignore vendored
View File

@ -36,8 +36,21 @@ htdocs/includes/jakub-onderka/
htdocs/includes/phpdocumentor/ htdocs/includes/phpdocumentor/
htdocs/includes/phpspec/ htdocs/includes/phpspec/
htdocs/includes/phpunit/ htdocs/includes/phpunit/
htdocs/includes/php-parallel-lint/
htdocs/includes/sebastian/ htdocs/includes/sebastian/
htdocs/includes/squizlabs/ htdocs/includes/squizlabs/
htdocs/includes/symfony/
htdocs/includes/webmozart/ htdocs/includes/webmozart/
htdocs/.well-known/apple-developer-merchantid-domain-association htdocs/.well-known/apple-developer-merchantid-domain-association
# Node Modules
build/yarn-error.log
build/node_modules/
node_modules/
#yarn
yarn.lock
#package-lock
package-lock.json
doc/install.lock

View File

@ -5,7 +5,9 @@
# We use dist: xenial to have php 5.6+ available # We use dist: xenial to have php 5.6+ available
os: linux os: linux
dist: xenial dist: xenial
sudo: required #dist: bionic
# Deprecated: The key sudo has no effect anymore.
#sudo: required
language: php language: php
@ -118,24 +120,18 @@ install:
echo echo
- | - |
echo "Installing Composer dependencies (PHP Unit, Parallel Lint & PHP CodeSniffer" echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION"
if [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then
composer -n require phpunit/phpunit ^4 \
jakub-onderka/php-parallel-lint ^0 \
jakub-onderka/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3
fi
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \
[ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then
composer -n require phpunit/phpunit ^5 \ composer -n require phpunit/phpunit ^5 \
jakub-onderka/php-parallel-lint ^0 \ php-parallel-lint/php-parallel-lint ^0 \
jakub-onderka/php-console-highlighter ^0 \ php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3 squizlabs/php_codesniffer ^3
fi fi
if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \
jakub-onderka/php-parallel-lint ^0 \ php-parallel-lint/php-parallel-lint ^1 \
jakub-onderka/php-console-highlighter ^0 \ php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3 squizlabs/php_codesniffer ^3
fi fi
echo echo
@ -282,7 +278,11 @@ script:
# Ensure we catch errors # Ensure we catch errors
set -e set -e
#parallel-lint --exclude htdocs/includes --blame . #parallel-lint --exclude htdocs/includes --blame .
parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \
--exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \
--exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \
--exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \
--exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame .
set +e set +e
echo echo
@ -291,7 +291,7 @@ script:
# Ensure we catch errors # Ensure we catch errors
set -e set -e
# Exclusions are defined in the ruleset.xml file # Exclusions are defined in the ruleset.xml file
#phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . #phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi
set +e set +e
echo echo
@ -404,6 +404,10 @@ script:
php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log
php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log
php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log
php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log
php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
# Enable modules not enabled into original dump # Enable modules not enabled into original dump
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log
echo $? echo $?

View File

@ -326,6 +326,12 @@ source_file = htdocs/langs/en_US/receptions.lang
source_lang = en_US source_lang = en_US
type = MOZILLAPROPERTIES type = MOZILLAPROPERTIES
[dolibarr.recruitment]
file_filter = htdocs/langs/<lang>/recruitment.lang
source_file = htdocs/langs/en_US/recruitment.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.resource] [dolibarr.resource]
file_filter = htdocs/langs/<lang>/resource.lang file_filter = htdocs/langs/<lang>/resource.lang
source_file = htdocs/langs/en_US/resource.lang source_file = htdocs/langs/en_US/resource.lang

View File

@ -21,7 +21,7 @@ Mobiledetect 2.8.34 MIT License Yes
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
ParseDown 1.6 MIT License Yes Markdown parser ParseDown 1.6 MIT License Yes Markdown parser
PHPDebugBar 1.15.0 MIT License Yes Used only by the module "debugbar" for developers PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers
PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files
php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP
@ -39,7 +39,7 @@ TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes
JS libraries: JS libraries:
Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea. 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.3 MIT License Yes JS library for graph
jQuery 3.4.1 MIT License Yes JS library jQuery 3.5.1 MIT License Yes JS library
jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI 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 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
jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups)

View File

@ -2,6 +2,31 @@
English Dolibarr ChangeLog English Dolibarr ChangeLog
-------------------------------------------------------------- --------------------------------------------------------------
***** ChangeLog for 13.0.0 compared to 12.0.0 *****
For users:
NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files.
NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable.
WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Properties ->contactid have been renamed into ->contact_id
* Properties ->titre have been renamed into ->title
* Property $paiementid in API 'api_supplier_invoices.php' has been renamed into into $payment_mode_id (english)
* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you used the old syntax in
your email templates.
* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom
days of holiday.
* Property 'num_paiement' has been renamed 'num_payment' everywhere for better code consistency.
* If you build a class that implement CommonObject to use the incoterm properties or methods (->fk_incoterm, ->label_incoterm, ->location_incoterm),
you must now also include declaration of the Trait 'CommonIncoterm' in your class. All incoterm functions were moved into this Trait.
* The GETPOST(..., 'alpha') has now the same behaviour than GETPOST(..., 'alphanohtml') so no html will be allowed. Use GETPOST(..., 'restricthtml') to accept HTML.
* If you have links in your code with '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors.
* 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 amount.
* The method select_thirdparty(), deprecated since 3.8, into html.form.class.php has been removed.
***** ChangeLog for 12.0.3 compared to 12.0.2 ***** ***** ChangeLog for 12.0.3 compared to 12.0.2 *****
FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename
FIX: 11.0 - expenses lines overlapping the total amounts frame FIX: 11.0 - expenses lines overlapping the total amounts frame
@ -373,14 +398,14 @@ Following changes may create regressions for some external modules, but were nec
WARNING FOR DOLIWAMP USERS ONLY: WARNING FOR DOLIWAMP USERS ONLY:
Only people that installed Dolibarr using the all-in-one autoinstaller for Windows called "DoliWAMP" are concerned by the following warnings: Only people that installed Dolibarr using the all-in-one auto-installer for Windows called "DoliWAMP" are concerned by the following warnings:
* DoliWAMP autoinstaller for Windows is not more available on 32bits systems. Use standard package if you need to use such architecture. * DoliWAMP auto-installer for Windows is no more available on 32 bits systems. Use standard package if you need to use such architecture.
* It is not possible to migrate from an installation done with the old DoliWAMP autoinstaller for Windows by using this new one. You must make a backup * It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one.
of your database, make a fresh installation using the new installer and reload. You must make a backup of your database, make a fresh installation using the new installer and reload your backup.
* Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but was never recommanded as a production Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production
solution on a local desktop since a desktop computer has not a backup and security policy as good as on a server (when there is one). solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one).
DoliWAMP remains a solution for fast test or demo purposes. DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard packages for production.
***** ChangeLog for 11.0.5 compared to 11.0.4 ***** ***** ChangeLog for 11.0.5 compared to 11.0.4 *****

View File

@ -3,13 +3,15 @@
![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg) ![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg)
![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg)
Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…). Dolibarr ERP & CRM is a modern software package that helps manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…).
It's an Open Source Software (written in PHP language) designed for small, medium or large companies, foundations and freelancers. It's an Open Source Software suite (written in PHP with optional JavaScript enhancements) designed for small, medium or large companies, foundations and freelancers.
You can freely use, study, modify or distribute it according to its Free Software licence. You can freely use, study, modify or distribute it according to its licence.
You can use it as a standalone application or as a web application to be able to access it from the Internet or a LAN. You can use it as a standalone application or as a web application to access it from the Internet or a LAN.
Dolibarr has a large community ready to help you, free forums and [oficially preferred partners ready to offer commercial support should you need it](https://partners.dolibarr.org)
![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg) ![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg)
@ -27,19 +29,23 @@ Other licenses apply for some included dependencies. See [COPYRIGHT](https://git
If you have low technical skills and you're looking to install Dolibarr ERP/CRM in just a few clicks, you can use one of the packaged versions: If you have low technical skills and you're looking to install Dolibarr ERP/CRM in just a few clicks, you can use one of the packaged versions:
- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_(DoliWamp) - [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_DoliWamp)
- [DoliDeb for Debian](https://wiki.dolibarr.org/index.php/Dolibarr_for_Ubuntu_or_Debian - [DoliDeb for Debian](https://wiki.dolibarr.org/index.php/Dolibarr_for_Ubuntu_or_Debian)
- DoliRpm for Redhat, Fedora, OpenSuse, Mandriva or Mageia - DoliRpm for Redhat, Fedora, OpenSuse, Mandriva or Mageia
Releases can be downloaded from [official website](https://www.dolibarr.org/). Releases can be downloaded from [official website](https://www.dolibarr.org/).
### Advanced setup ### Advanced setup
You can use a Web server and a supported database (MariaDB, MySQL or PostgreSQL) to install the standard version. You can use a web server and a supported database (MariaDB, MySQL or PostgreSQL) to install the standard version.
On GNU/Linux, first check if your distribution has already packaged Dolibarr.
#### Generic install steps:
- Check that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Versions). - Check that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Versions).
- Uncompress the downloaded .zip archive to copy the "dolibarr/htdocs" directory and all its files inside your web server root or get the files directly from GitHub (recommanded if you known git): - Uncompress the downloaded .zip archive to copy the "dolibarr/htdocs" directory and all its files inside your web server root or get the files directly from GitHub (recommanded if you know git as it makes it easier if you want to upgrade later):
`git clone https://github.com/dolibarr/dolibarr -b x.y` (where x.y is main version like 3.6, 9.0, ...) `git clone https://github.com/dolibarr/dolibarr -b x.y` (where x.y is main version like 3.6, 9.0, ...)
@ -70,13 +76,13 @@ If you don't have time to install it yourself, you can try some commercial 'read
## UPGRADING ## UPGRADING
- At first make a backup of your Dolibarr files & than see https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr Dolibarr supports upgrading usually wihtout the need for any (commercial) support (depending on if you use any commercial extensions) and supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate!
- At first make a backup of your Dolibarr files & than [see](https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr)
- Check that your installed PHP version is supported by the new version [see PHP support](./doc/phpmatrix.md). - Check that your installed PHP version is supported by the new version [see PHP support](./doc/phpmatrix.md).
- Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package.
- At first next access, Dolibarr will redirect your to the "install/" page to follow the upgrade process. - At first next access, Dolibarr will redirect you to the "install/" page to follow the upgrade process.
 If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file into the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*").  If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file in the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*").
*Note: migration process can be safely done multiple times by calling the `/install/index.php` page*
## WHAT'S NEW ## WHAT'S NEW
@ -139,7 +145,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- 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) - 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
- An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture) - 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: - Support a lot of country specific features:
- Spanish Tax RE and ISPF - Spanish Tax RE and ISPF
- French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM)
@ -149,7 +155,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE)
- Compatible with European GDPR rules - Compatible with European GDPR rules
- ... - ...
- PDF or ODT generation for invoice, proposals, orders... - Flexible PDF & ODT generation for invoices, proposals, orders...
- … - …
### System Environment / Requirements ### System Environment / Requirements
@ -167,12 +173,12 @@ These are features that Dolibarr does **not** yet fully support:
- Tasks dependencies in projects - Tasks dependencies in projects
- Payroll module - Payroll module
- No native embedded Webmail - No native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc.
- Dolibarr can't do coffee (yet) - Dolibarr can't do coffee (yet)
## DOCUMENTATION ## DOCUMENTATION
Administrator, user, developer and translator's documentations are available along with other community resources on the [Wiki](https://wiki.dolibarr.org). Administrator, user, developer and translator's documentations are available along with other community resources in the [Wiki](https://wiki.dolibarr.org).
## CONTRIBUTING ## CONTRIBUTING
@ -182,7 +188,7 @@ This project exists thanks to all the people who contribute. [[Contribute](https
## CREDITS ## CREDITS
Dolibarr is the work of many contributors over the years and uses some fine libraries. Dolibarr is the work of many contributors over the years and uses some fine PHP libraries.
See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file.

View File

@ -1,13 +1,115 @@
# Security Policy # Security Policy
## Supported Versions This file contains some policies about the security reports on Dolibarr ERP CRM project, one of the most popular Open Source ERP and CRM in the world.
## Supported Versions for security reports
| Version | Supported |
| --------- | ------------------ |
| <= 9.0.* | :x: |
| >= 10.0.* | :white_check_mark: |
| Version | Supported |
| -------- | ------------------ |
| <= 8.0.* | :x: |
| >= 9.0.* | :white_check_mark: |
## Reporting a Vulnerability ## Reporting a Vulnerability
To report a vulnerability, please send an email to security@dolibarr.org 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. In most cases, after fixing the security, we make an answer by email to say the issue has been fixed.
## Hunting vulnerabilities on Dolibarr
We believe that future of software is online SaaS. This means software are more and more critical and no technology is perfect. Working with skilled security researchers is crucial in identifying weaknesses in our technology.
If you believe you've found a security bug in our service, we are happy to work with you to resolve the issue promptly and ensure you are fairly rewarded for your discovery.
Any type of denial of service attacks is strictly forbidden, as well as any interference with network equipment and Dolibarr infrastructure.
We recommand to install Dolibarr ERP CRM on you own server (as most Open Source software, download and use is free: https://www.dolibarr.org/download) to get access on every side of application.
### User Agent
If you try to find bug on Dolibarr, we recommend to append to your user-agent header the following value: '-BugHunting-dolibarr'.
### Account access
You can install the web application yourself on your own platform/server so you get full access to application and sources. Download the zip of the files to put into your own web server virtual host from https://www.dolibarr.org/download
## Eligibility and Responsible Disclosure
We are happy to thank everyone who submits valid reports which help us improve the security of Dolibarr however, only those that meet the following eligibility requirements may receive a monetary reward:
You must be the first reporter of a vulnerability.
The vulnerability must be a qualifying vulnerability (see below)
Any vulnerability found must be reported no later than 24 hours after discovery
You must send a clear textual description of the report along with steps to reproduce the issue, include attachments such as screenshots or proof of concept code as necessary.
You must avoid tests that could cause degradation or interruption of our service (refrain from using automated tools, and limit yourself about requests per second), that's why we recommand to install softwate on your own platform.
You must not leak, manipulate, or destroy any user data.
You must not be a former or current employee of Dolibarr or one of its contractor.
Reports about vulnerabilities are examined by our security analysts.
Our analysis is always based on worst case exploitation of the vulnerability, as is the reward we pay.
No vulnerability disclosure, including partial is allowed for the moment.
## Scope for qualified vulnerabilities
ONLY vulnerabilities discovered, when the following setup on test platform is used, are accepted:
* $dolibarr_main_prod must be set to 1 into conf.php
* $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value)
* $dolibarr_main_force_https must be set to something else than 0.
* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be enabled soon by default)
* The module DebugBar must NOT be enabled (by default, this module is not enabled. This is a developer tool)
* The module ModuleBuilder must NOT be enabled (by default, this module is not enabled. This is a developer tool)
* ONLY security reports on modules provided by default and with the "stable" status are allowed (troubles into "experimental", "developement" or external modules are not accepted).
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
* The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly.
* CSRF attacks are accepted for all when using a POST URL, but are accepted only for creating or updating data resctricted to the admin user when using GET URL.
* Ability for a high level user to edit web site pages in the CMS by including javascript is an expected feature.
Scope is the web application (back office) and the APIs.
## Qualifying vulnerabilities for Bug bounty programs
* Remote code execution (RCE)
* Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA)
* Code injections (HTML, JS, SQL, PHP, ...)
* Cross-Site Scripting (XSS)
* Cross-Site Requests Forgery (CSRF) with real security impact
* Open redirect
* Broken authentication & session management
* Insecure direct object references
* CORS with real security impact
* Horizontal and vertical privilege escalation
* "HTTP Host Header" XSS
* Software version disclosure (for non admin users only)
* Stack traces or path disclosure (for non admin users only)
## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting
* "Self" XSS
* SSL/TLS best practices
* Denial of Service attacks
* Clickjacking/UI redressing
* Physical or social engineering attempts or issues that require physical access to a victim’s computer/device
* Presence of autocomplete attribute on web forms
* Vulnerabilities affecting outdated browsers or platforms
* Logout and other instances of low-severity Cross-Site Request Forgery
* Missing cookie flags
* Missing security-related HTTP headers which do not lead directly to a vulnerability
* Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated
* Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC)
* Reports on features flagged as "experimental" or "development"
* Software version or private IP disclosure when logged user is admin
* Stack traces or path disclosure when logged user is admin
* Any vulnerabilities due to a configuration different than the one defined into chapter "Scope for qualified vulnerabilities".

View File

@ -19,30 +19,34 @@ Note: Prerequisites to build autoexe DoliWamp package:
> Launch "wine cmd" to check a drive Z: pointing to / exists. > Launch "wine cmd" to check a drive Z: pointing to / exists.
> Install InnoSetup > Install InnoSetup
For example by running isetup-5.3.9.exe (http://www.jrsoftware.org) For example by running isetup-5.3.9.exe (http://www.jrsoftware.org)
> Install WampServer into "C:\Program Files\Wamp" > Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB
For example by running wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe (http://www.wampserver.com) 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.
> Install WampServer addon to have versions: Mysql5.0.45
For example by running WampServer2-MYSQL5045.exe (http://www.wampserver.com)
> To build 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.
> Add path to ISCC into PATH windows var: > 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 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 - To build a theme package, launch the script
> perl makepack-dolibarrtheme.pl > perl makepack-dolibarrtheme.pl
- To build a package for a module, launch the script - To build a package for a module, launch the script
> perl makepack-dolibarrmodule.pl > perl makepack-dolibarrmodule.pl
- To build developper documentation, launch the script - To build developper documentation, launch the script
> perl dolibarr-doxygen-build.pl > perl dolibarr-doxygen-build.pl
Note: Note:
The build directory and all its contents is absolutely not required to make The build directory and all its contents is absolutely not required to make Dolibarr working.
Dolibarr working. It is here only to build Dolibarr packages, and those It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory.
generated packages will not contains this "build" directory.
You can find in "build", following sub-directories: You can find in "build", following sub-directories:
@ -59,6 +63,9 @@ To build Mac OS package (not ready yet).
* doap: * doap:
To build Doap descriptor to promote/describe Dolibarr releases. To build Doap descriptor to promote/describe Dolibarr releases.
* docker:
To deploy Dolibarr with docker.
* doxygen: * doxygen:
Dir with config file to build doxygen documentation. Dir with config file to build doxygen documentation.
@ -66,12 +73,12 @@ Dir with config file to build doxygen documentation.
To build exe package for Windows that distribute Dolibarr sources or To build exe package for Windows that distribute Dolibarr sources or
to build the complete DoliWamp package. to build the complete DoliWamp package.
* gource:
To build the video of history of git changes.
* launchpad: * launchpad:
Doc file to explain how to use launchpad. Doc file to explain how to use launchpad.
* live:
Doc file to explain how to create a demo live CD.
* obs: * obs:
Doc file to explain how to push release onto OBS. Doc file to explain how to push release onto OBS.
@ -90,5 +97,8 @@ To build Redhat, Opensuse or Mandriva package.
* tgz: * tgz:
To build a tgz package. To build a tgz package.
* travis-ci:
Used by travis to make CI.
* zip: * zip:
To build a zip package. To build a zip package.

View File

@ -1,38 +1,50 @@
FROM php:7.2-apache FROM php:7.3-apache
ENV HOST_USER_ID 33
ENV PHP_INI_DATE_TIMEZONE 'UTC' ENV PHP_INI_DATE_TIMEZONE 'UTC'
ENV PHP_INI_MEMORY_LIMIT 256M
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libldap2-dev libzip-dev zlib1g-dev libicu-dev g++\ RUN apt-get update -y \
&& rm -rf /var/lib/apt/lists/* \ && apt-get install -y --no-install-recommends \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ libfreetype6-dev \
&& docker-php-ext-install gd \ libjpeg62-turbo-dev \
&& docker-php-ext-install zip \ libjpeg62-turbo \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ libpng-dev \
&& docker-php-ext-install ldap \ libpng16-16 \
&& docker-php-ext-install mysqli \ libldap2-dev \
&& docker-php-ext-install calendar \ libxml2-dev \
&& docker-php-ext-configure intl \ libzip-dev \
&& docker-php-ext-install intl \ zlib1g-dev \
&& apt-get autoremove --purge -y libjpeg-dev libldap2-dev zlib1g-dev libicu-dev g++ libicu-dev \
g++ \
default-mysql-client \
unzip \
curl \
apt-utils \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install -j$(nproc) ldap && \
mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini
RUN mkdir /var/documents RUN mkdir /var/documents
RUN chown www-data /var/documents RUN chown www-data:www-data /var/documents
COPY docker-run.sh /usr/local/bin/ COPY docker-run.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-run.sh RUN chmod +x /usr/local/bin/docker-run.sh
RUN pecl install xdebug && docker-php-ext-enable xdebug RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"' >> /usr/local/etc/php/php.ini RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_autostart=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_autostart=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_enable=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.default_enable=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.default_enable=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_host=docker.host' >> /usr/local/etc/php/php.ini #RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_port=9000' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_connect_back=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.profiler_enable=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini
RUN echo '172.17.0.1 docker.host' >> /etc/hosts #RUN echo '172.17.0.1 docker.host' >> /etc/hosts
EXPOSE 80 EXPOSE 80

View File

@ -1,6 +1,8 @@
# How to use it ? # How to use it ?
The docker-compose.yml file is used to build and run Dolibarr in the current workspace. The docker-compose.yml file is used to build and run Dolibarr in the current workspace.
This docker image intended for developpement usage.
For production usage you should consider other contributor reference like https://hub.docker.com/r/tuxgasy/dolibarr
Before build/run, define the variable HOST_USER_ID as following: Before build/run, define the variable HOST_USER_ID as following:
@ -26,3 +28,4 @@ The URL to go to PhpMyAdmin is (login/password is root/root) :
Setup the database connection during the installation process, please use mariad Setup the database connection during the installation process, please use mariad
b (name of the database container) as database host. b (name of the database container) as database host.
Setup documents folder, during the installation process, to /var/documents

View File

@ -1,25 +1,54 @@
mariadb: version: '3'
build: mariadb
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: dolibarr
phpmyadmin: networks:
image: phpmyadmin/phpmyadmin internal-pod:
environment: internal: true
PMA_HOST: mariadb external-pod:
links: internal: false
- mariadb
ports:
- "8080:80"
web: services:
build: . mariadb:
environment: image: mariadb:latest
HOST_USER_ID: $HOST_USER_ID environment:
volumes: MYSQL_ROOT_PASSWORD: root
- ../../htdocs:/var/www/html MYSQL_DATABASE: dolibarr
links: ports:
- mariadb - "3306:3306"
ports: networks:
- "80:80" - internal-pod
- external-pod
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
PMA_HOST: mariadb
depends_on:
- mariadb
ports:
- "8080:80"
networks:
- internal-pod
- external-pod
web:
build: .
environment:
HOST_USER_ID: $HOST_USER_ID
volumes:
- ../../htdocs:/var/www/html/
- ../../documents:/var/documents
ports:
- "80:80"
- "9000:9000"
depends_on:
- mariadb
- mail
networks:
- internal-pod
- external-pod
mail:
image: maildev/maildev
ports:
- "8081:80"
- "25:25"

View File

@ -1,15 +1,21 @@
#!/bin/bash #!/bin/bash
usermod -u $HOST_USER_ID www-data usermod -u ${HOST_USER_ID} www-data
groupmod -g $HOST_USER_ID www-data groupmod -g ${HOST_USER_ID} www-data
chgrp -hR www-data /var/www/html chgrp -hR www-data /var/www/html
chmod g+rwx /var/www/html/conf chmod g+rwx /var/www/html/conf
if [ ! -d /var/documents ]; then
echo "[docker-run] => create volume directory /var/documents ..."
mkdir -p /var/documents
fi
echo "[docker-run] => Set Permission to www-data for /var/documents"
chown -R www-data:www-data /var/documents
if [ ! -f /usr/local/etc/php/php.ini ]; then if [ ! -f /usr/local/etc/php/php.ini ]; then
cat <<EOF > /usr/local/etc/php/php.ini cat <<EOF > /usr/local/etc/php/php.ini
date.timezone = $PHP_INI_DATE_TIMEZONE date.timezone = $PHP_INI_DATE_TIMEZONE
display_errors = On
EOF EOF
fi fi

View File

@ -5,6 +5,7 @@ It's a dedicated Dolibarr version for Windows newbies with no technical knowledg
This directory contains files used by *makepack-dolibarr.pl* script to build the all-in-on .EXE package DoliWamp, ready This directory contains files used by *makepack-dolibarr.pl* script to build the all-in-on .EXE package DoliWamp, ready
to be distributed (for Windows). to be distributed (for Windows).
The build of .exe files need to have some windows executable files already installed (Apache, MariaDb). The package to install to get this files are defined into the file *doliwamp.iss* (searhc line starting with "; Value OK:")
If you have technical knowledge in web administration and plan to share your server instance (Apache, Mysql or PHP) with other projects than Dolibarr or want to use Dolibarr other components (PostgreSQL), you should not use this assistant and make a manual installation of Dolibarr on your existing server by downloading the standard package (.tgz or .zip file). If you have technical knowledge in web administration and plan to share your server instance (Apache, Mysql or PHP) with other projects than Dolibarr or want to use Dolibarr other components (PostgreSQL), you should not use this assistant and make a manual installation of Dolibarr on your existing server by downloading the standard package (.tgz or .zip file).

View File

@ -110,7 +110,7 @@ print "Working on files into : ".DOL_DOCUMENT_ROOT."\n";
print "Include custom in signature : ".$includecustom."\n"; print "Include custom in signature : ".$includecustom."\n";
print "Include constants in signature : "; print "Include constants in signature : ";
foreach ($includeconstants as $countrycode => $tmp) { foreach ($includeconstants as $countrycode => $tmp) {
foreach($tmp as $constname => $constvalue) { foreach ($tmp as $constname => $constvalue) {
print $constname.'='.$constvalue." "; print $constname.'='.$constvalue." ";
} }
} }
@ -130,7 +130,7 @@ fputs($fp, '<checksum_list version="'.$release.'" date="'.dol_print_date(dol_now
foreach ($includeconstants as $countrycode => $tmp) { foreach ($includeconstants as $countrycode => $tmp) {
fputs($fp, '<dolibarr_constants country="'.$countrycode.'">'."\n"); fputs($fp, '<dolibarr_constants country="'.$countrycode.'">'."\n");
foreach($tmp as $constname => $constvalue) { foreach ($tmp as $constname => $constvalue) {
$valueforchecksum=(empty($constvalue)?'0':$constvalue); $valueforchecksum=(empty($constvalue)?'0':$constvalue);
$checksumconcat[]=$valueforchecksum; $checksumconcat[]=$valueforchecksum;
fputs($fp, ' <constant name="'.$constname.'">'.$valueforchecksum.'</constant>'."\n"); fputs($fp, ' <constant name="'.$constname.'">'.$valueforchecksum.'</constant>'."\n");

View File

@ -620,6 +620,9 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $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/LICENSE.TXT`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/autoload.php`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`;
} }

View File

@ -1,9 +1,10 @@
To make htmldoc working from wiki.dolibarr.org, them must be modified to have To make htmldoc working from wiki.dolibarr.org, the wiki must be modified to have
$_SERVER["HTTP_USER_AGENT"] is "HTMLDOC/x.y.z" To disable part of content, add:
$_COOKIE["htmldoc"] may also be defined if set on command line. class="htmldoc-ignore"
with css
To disable part, add
class="htmldoc-ignore" with css
.htmldoc-ignore { display: none; } .htmldoc-ignore { display: none; }
Note:
$_SERVER["HTTP_USER_AGENT"] is "HTMLDOC/x.y.z"
$_COOKIE["htmldoc"] may also be defined if set on command line.

View File

@ -1 +1 @@
http://wiki.dolibarr.org/ https://wiki.dolibarr.org/

View File

@ -24,7 +24,7 @@
"vendor-dir" : "htdocs/includes" "vendor-dir" : "htdocs/includes"
}, },
"require" : { "require" : {
"php" : ">=5.5.0", "php" : ">=5.6.0",
"ext-curl" : "*", "ext-curl" : "*",
"ckeditor/ckeditor" : "4.12.1", "ckeditor/ckeditor" : "4.12.1",
"mike42/escpos-php" : "2.2", "mike42/escpos-php" : "2.2",
@ -33,11 +33,13 @@
"restler/framework" : "3.0.0-RC6", "restler/framework" : "3.0.0-RC6",
"tecnickcom/tcpdf" : "6.3.2", "tecnickcom/tcpdf" : "6.3.2",
"nnnick/chartjs" : "^2.9", "nnnick/chartjs" : "^2.9",
"stripe/stripe-php" : "6.43.1" "stripe/stripe-php" : "6.43.1",
"maximebf/debugbar" : "1.15.1",
"symfony/var-dumper": "3"
}, },
"require-dev" : { "require-dev" : {
"jakub-onderka/php-parallel-lint" : "^0", "php-parallel-lint/php-parallel-lint" : "^0",
"jakub-onderka/php-console-highlighter" : "^0", "php-parallel-lint/php-console-highlighter" : "^0",
"phpunit/phpunit" : "^4", "phpunit/phpunit" : "^4",
"squizlabs/php_codesniffer" : "^2", "squizlabs/php_codesniffer" : "^2",
"phpunit/phpunit-selenium" : "^2" "phpunit/phpunit-selenium" : "^2"

458
composer.lock generated
View File

@ -1,10 +1,10 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "17e906996157e8a94564f686a6096dc5", "content-hash": "1dbd2d05cc0836acfca5988f29005cf2",
"packages": [ "packages": [
{ {
"name": "ckeditor/ckeditor", "name": "ckeditor/ckeditor",
@ -47,6 +47,67 @@
], ],
"time": "2019-06-28T10:41:23+00:00" "time": "2019-06-28T10:41:23+00:00"
}, },
{
"name": "maximebf/debugbar",
"version": "v1.15.1",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6c4277f6117e4864966c9cb58fb835cee8c74a1e",
"reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e",
"shasum": ""
},
"require": {
"php": ">=5.6",
"psr/log": "^1.0",
"symfony/var-dumper": "^2.6|^3|^4"
},
"require-dev": {
"phpunit/phpunit": "^5"
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
"monolog/monolog": "Log using Monolog",
"predis/predis": "Redis storage"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.15-dev"
}
},
"autoload": {
"psr-4": {
"DebugBar\\": "src/DebugBar/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "maxime.bouroumeau@gmail.com",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Debug bar in the browser for php application",
"homepage": "https://github.com/maximebf/php-debugbar",
"keywords": [
"debug",
"debugbar"
],
"time": "2019-09-24T14:55:42+00:00"
},
{ {
"name": "mike42/escpos-php", "name": "mike42/escpos-php",
"version": "v2.2", "version": "v2.2",
@ -253,6 +314,53 @@
"abandoned": "phpoffice/phpspreadsheet", "abandoned": "phpoffice/phpspreadsheet",
"time": "2015-05-01T07:00:55+00:00" "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", "name": "restler/framework",
"version": "3.0.0-RC6", "version": "3.0.0-RC6",
@ -260,12 +368,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Luracast/Restler-Framework.git", "url": "https://github.com/Luracast/Restler-Framework.git",
"reference": "0f6b0f26152f83e43a2a86820206c455095fb2b0" "reference": "d52e61600d153bca60a287c35141c5c01863127b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/0f6b0f26152f83e43a2a86820206c455095fb2b0", "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/d52e61600d153bca60a287c35141c5c01863127b",
"reference": "0f6b0f26152f83e43a2a86820206c455095fb2b0", "reference": "d52e61600d153bca60a287c35141c5c01863127b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -312,7 +420,7 @@
"rest", "rest",
"server" "server"
], ],
"time": "2019-05-12T15:15:11+00:00" "time": "2020-02-13T16:05:12+00:00"
}, },
{ {
"name": "stripe/stripe-php", "name": "stripe/stripe-php",
@ -370,6 +478,146 @@
], ],
"time": "2019-08-29T16:56:12+00:00" "time": "2019-08-29T16:56:12+00:00"
}, },
{
"name": "symfony/polyfill-mbstring",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a",
"reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.18-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-07-14T12:35:20+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "737e07704cca83f9dd0af926d45ce27eedc25657"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/737e07704cca83f9dd0af926d45ce27eedc25657",
"reference": "737e07704cca83f9dd0af926d45ce27eedc25657",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
"twig/twig": "~1.20|~2.0"
},
"suggest": {
"ext-symfony_debug": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"files": [
"Resources/functions/dump.php"
],
"psr-4": {
"Symfony\\Component\\VarDumper\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony mechanism for exploring and dumping PHP variables",
"homepage": "https://symfony.com",
"keywords": [
"debug",
"dump"
],
"time": "2015-11-18T13:48:51+00:00"
},
{ {
"name": "tecnickcom/tcpdf", "name": "tecnickcom/tcpdf",
"version": "6.3.2", "version": "6.3.2",
@ -489,16 +737,16 @@
"time": "2015-06-14T21:17:01+00:00" "time": "2015-06-14T21:17:01+00:00"
}, },
{ {
"name": "jakub-onderka/php-console-color", "name": "php-parallel-lint/php-console-color",
"version": "v0.2", "version": "v0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/JakubOnderka/PHP-Console-Color.git", "url": "https://github.com/php-parallel-lint/PHP-Console-Color.git",
"reference": "d5deaecff52a0d61ccb613bb3804088da0307191" "reference": "d5deaecff52a0d61ccb613bb3804088da0307191"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/d5deaecff52a0d61ccb613bb3804088da0307191", "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Color/zipball/d5deaecff52a0d61ccb613bb3804088da0307191",
"reference": "d5deaecff52a0d61ccb613bb3804088da0307191", "reference": "d5deaecff52a0d61ccb613bb3804088da0307191",
"shasum": "" "shasum": ""
}, },
@ -531,28 +779,31 @@
"time": "2018-09-29T17:23:10+00:00" "time": "2018-09-29T17:23:10+00:00"
}, },
{ {
"name": "jakub-onderka/php-console-highlighter", "name": "php-parallel-lint/php-console-highlighter",
"version": "v0.4", "version": "v0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/JakubOnderka/PHP-Console-Highlighter.git", "url": "https://github.com/php-parallel-lint/PHP-Console-Highlighter.git",
"reference": "9f7a229a69d52506914b4bc61bfdb199d90c5547" "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/9f7a229a69d52506914b4bc61bfdb199d90c5547", "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Highlighter/zipball/21bf002f077b177f056d8cb455c5ed573adfdbb8",
"reference": "9f7a229a69d52506914b4bc61bfdb199d90c5547", "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-tokenizer": "*", "ext-tokenizer": "*",
"jakub-onderka/php-console-color": "~0.2", "php": ">=5.4.0",
"php": ">=5.4.0" "php-parallel-lint/php-console-color": "~0.2"
},
"replace": {
"jakub-onderka/php-console-highlighter": "*"
}, },
"require-dev": { "require-dev": {
"jakub-onderka/php-code-style": "~1.0", "php-parallel-lint/php-code-style": "~1.0",
"jakub-onderka/php-parallel-lint": "~1.0", "php-parallel-lint/php-parallel-lint": "~1.0",
"jakub-onderka/php-var-dump-check": "~0.1", "php-parallel-lint/php-var-dump-check": "~0.1",
"phpunit/phpunit": "~4.0", "phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~1.5" "squizlabs/php_codesniffer": "~1.5"
}, },
@ -574,19 +825,19 @@
} }
], ],
"description": "Highlight PHP code in terminal", "description": "Highlight PHP code in terminal",
"time": "2018-09-29T18:48:56+00:00" "time": "2020-05-13T07:37:49+00:00"
}, },
{ {
"name": "jakub-onderka/php-parallel-lint", "name": "php-parallel-lint/php-parallel-lint",
"version": "v0.9.2", "version": "v0.9.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git", "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git",
"reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa" "reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/2ead2e4043ab125bee9554f356e0a86742c2d4fa", "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/2ead2e4043ab125bee9554f356e0a86742c2d4fa",
"reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa", "reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa",
"shasum": "" "shasum": ""
}, },
@ -1082,6 +1333,7 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"abandoned": true,
"time": "2017-12-04T08:55:13+00:00" "time": "2017-12-04T08:55:13+00:00"
}, },
{ {
@ -1785,6 +2037,159 @@
], ],
"time": "2019-08-06T08:03:45+00:00" "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", "name": "symfony/yaml",
"version": "v3.4.32", "version": "v3.4.32",
@ -1903,8 +2308,9 @@
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=5.5.0", "php": ">=5.6.0",
"ext-curl": "*" "ext-curl": "*"
}, },
"platform-dev": [] "platform-dev": [],
"plugin-api-version": "1.1.0"
} }

View File

@ -28,19 +28,6 @@ With
DEBUGBAR:
---------
Move
this.options = {
bodyMarginBottom: true,
bodyMarginBottomHeight: parseInt($('body').css('margin-bottom')),
};
few line lower in the
initialize: function() {
ESCPOS: ESCPOS:
------- -------
Replace Replace
@ -181,6 +168,7 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php
TCPDI: TCPDI:
------ ------
Add fpdf_tpl.php 1.2 Add fpdf_tpl.php 1.2
Add tcpdi.php Add tcpdi.php
Add tcpdi_parser.php and replace: Add tcpdi_parser.php and replace:
@ -219,8 +207,6 @@ with
JCROP: JCROP:
------ ------
* Remove analytics tag into file index.html * Remove analytics tag into file index.html

View File

@ -87,14 +87,11 @@ if ($idobject > 0)
// Change status to validated // Change status to validated
$result=$obj->validate($user); $result=$obj->validate($user);
if ($result > 0) print "OK Object created with id ".$idobject."\n"; if ($result > 0) print "OK Object created with id ".$idobject."\n";
else else {
{
$error++; $error++;
dol_print_error($db, $obj->error); dol_print_error($db, $obj->error);
} }
} } else {
else
{
$error++; $error++;
dol_print_error($db, $obj->error); dol_print_error($db, $obj->error);
} }
@ -106,9 +103,7 @@ if (! $error)
{ {
$db->commit(); $db->commit();
print '--- end ok'."\n"; print '--- end ok'."\n";
} } else {
else
{
print '--- end error code='.$error."\n"; print '--- end error code='.$error."\n";
$db->rollback(); $db->rollback();
} }

View File

@ -85,14 +85,11 @@ if ($idobject > 0)
// Change status to validated // Change status to validated
$result=$com->valid($user); $result=$com->valid($user);
if ($result > 0) print "OK Object created with id ".$idobject."\n"; if ($result > 0) print "OK Object created with id ".$idobject."\n";
else else {
{
$error++; $error++;
dol_print_error($db, $com->error); dol_print_error($db, $com->error);
} }
} } else {
else
{
$error++; $error++;
dol_print_error($db, $com->error); dol_print_error($db, $com->error);
} }
@ -104,9 +101,7 @@ if (! $error)
{ {
$db->commit(); $db->commit();
print '--- end ok'."\n"; print '--- end ok'."\n";
} } else {
else
{
print '--- end error code='.$error."\n"; print '--- end error code='.$error."\n";
$db->rollback(); $db->rollback();
} }

View File

@ -82,9 +82,7 @@ $idobject = $myproduct->create($user);
if ($idobject > 0) if ($idobject > 0)
{ {
print "OK Object created with id ".$idobject."\n"; print "OK Object created with id ".$idobject."\n";
} } else {
else
{
$error++; $error++;
dol_print_error($db, $myproduct->error); dol_print_error($db, $myproduct->error);
} }
@ -95,9 +93,7 @@ if (! $error)
{ {
$db->commit(); $db->commit();
print '--- end ok'."\n"; print '--- end ok'."\n";
} } else {
else
{
print '--- end error code='.$error."\n"; print '--- end error code='.$error."\n";
$db->rollback(); $db->rollback();
} }

View File

@ -74,18 +74,14 @@ if ($idobject > 0)
// Change status to validated // Change status to validated
$result=$obj->setStatut(1); $result=$obj->setStatut(1);
if ($result > 0) print "OK Object created with id ".$idobject."\n"; if ($result > 0) print "OK Object created with id ".$idobject."\n";
else else {
{
$error++; $error++;
dol_print_error($db, $obj->error); dol_print_error($db, $obj->error);
} }
} } elseif ($obj->error == 'ErrorLoginAlreadyExists')
elseif ($obj->error == 'ErrorLoginAlreadyExists')
{ {
print "User with login ".$obj->login." already exists\n"; print "User with login ".$obj->login." already exists\n";
} } else {
else
{
$error++; $error++;
dol_print_error($db, $obj->error); dol_print_error($db, $obj->error);
} }
@ -97,9 +93,7 @@ if (! $error)
{ {
$db->commit(); $db->commit();
print '--- end ok'."\n"; print '--- end ok'."\n";
} } else {
else
{
print '--- end error code='.$error."\n"; print '--- end error code='.$error."\n";
$db->rollback(); $db->rollback();
} }

View File

@ -0,0 +1,89 @@
Delivered-To: testldrdev@gmail.com
Received: by 2002:a2e:9b9a:0:0:0:0:0 with SMTP id z26csp1425223lji;
Thu, 20 Aug 2020 08:29:02 -0700 (PDT)
X-Received: by 2002:a05:620a:1292:: with SMTP id w18mr2938234qki.158.1597937342304;
Thu, 20 Aug 2020 08:29:02 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1597937342; cv=none;
d=google.com; s=arc-20160816;
b=FhT/+rJ/zNYgVQ5Nt/rLZJycGd/Ntkhm6LwI16YUfmEmxeGrP/cXXQULrqQ1LhBr9B
oRKweltTdnpyA14gm0kzbs1vUkf5HxLUuGk8IqqJWAPMUZoN8oUPkzq2BuKNQGxPiE+y
Hsg/fnYp8WzcAlZOLsEP2kcFIdA95Dyy5LkM8HgphI1jSS1d6gkx6nDGIMIpDD9D+w4X
ISxRUXp5JlDwFCUMOPoAvHIBUdJ3jpLsjesbMEnU4ssFqhxU21pBq+Fc+csSPeY5DL0M
HR1o+ChEAXIdDOrDqa0ohHfqR216juGCzH8YuEQ88LT0Qbst9IkOYWiAQv4TIh7vHtvQ
TMvA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
h=to:subject:message-id:date:from:mime-version:dkim-signature;
bh=sojOjnIKAXmsZ9zvMk5MGvY3qyOaFgnpRe6YPMYutOI=;
b=CRlrRPfoGkfmz6iXKy4HdxKQ4SeJTiIxjC2jNkgQPSnIDFJgDkJcwASJVpcjTmlVmH
Z9WnHKVUPRIHGDEoMRlx6eUx9QfelWqPYu3BBQGFry9sgth0BR/1s6tmQ+P+bAj23ryo
aL3UkF6KCSx4GhEk3MfHA5Ex81YDFHvHL3BZ2kb3XCVSlPiBq2szw1ETmRAsDdS5Gbu+
ZlzBbl4pRtUWgi1fB5H4Wcv7e90F4Et1SBP8IKSCa23qu2nV9xefgjfMw2ndxCj1zgCL
c3l7Ul6pw32nqf6+vxfZTstwIwgu6dXZXCHDqJqesI2g8RGxeba+LfKZEDpBuSeINS9r
GMvw==
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@destailleur.fr header.s=google header.b=IPMz90Yj;
spf=pass (google.com: domain of contact@destailleur.fr designates 209.85.220.41 as permitted sender) smtp.mailfrom=contact@destailleur.fr;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=destailleur.fr
Return-Path: <contact@destailleur.fr>
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
by mx.google.com with SMTPS id w14sor2138230qtb.9.2020.08.20.08.29.00
for <testldrdev@gmail.com>
(Google Transport Security);
Thu, 20 Aug 2020 08:29:01 -0700 (PDT)
Received-SPF: pass (google.com: domain of contact@destailleur.fr designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
Authentication-Results: mx.google.com;
dkim=pass header.i=@destailleur.fr header.s=google header.b=IPMz90Yj;
spf=pass (google.com: domain of contact@destailleur.fr designates 209.85.220.41 as permitted sender) smtp.mailfrom=contact@destailleur.fr;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=destailleur.fr
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=destailleur.fr; s=google;
h=mime-version:from:date:message-id:subject:to;
bh=sojOjnIKAXmsZ9zvMk5MGvY3qyOaFgnpRe6YPMYutOI=;
b=IPMz90Yjw1Mf57/rYWUYGtpc+IazEWcy6/bqxf1j0h6rxDH/wjhxsCWzfARgqqlfVj
ACg4IbPpZZlKFIYDSCbfMlWF65rbKfNre56HldfQgy0Tq3LC434zHz2ZZMOVCM52w3J9
VGBpASUlSL1o+YRmzOpRtHVu7I9aNwGxHuA070Yka8XLV76vV3P0vdL8PcoHq0jUUEoi
+dCZ9NCPuAFtGK2IavNoM2qQrLdfYIi+RwgWBtqjTwzyvDEJR+p5fIPK142ynMbHgWYO
RVtMqAgxjvL4sfyKZ5KuzKXkQNM3zyzMinWK89scBl+QLFCcWA4Qqc0dJjqLCBhh8lmq
n67g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=sojOjnIKAXmsZ9zvMk5MGvY3qyOaFgnpRe6YPMYutOI=;
b=H0GsrFAi9JmRTKQ2budtDeLBqCaTisHKYCVVziyxmv+/tIcrSZBA4tdKwm+wR80r50
zMJXmyVS2DMDWfnIlOv39wcwQjYN3WK1aRJfV0bVuEWrQuzt5MMWbskf6xbzo201nhr9
ZlqATsEV7v1u5EHmfYwRhR8+AOmENdnm0g9RXPJVrFS58WNEJUSotS5Y5rZPjnT943y0
62Kf4Bd6uWvXhPFXWQoZLtWrPpkbcYPWIBmpftKhD0PD9c6rKaVduV0WhbigYsDoxb3F
iIafGPOyq91hiHR2gTLHiMmTDm+IDQ4n6gSkS7HKpZlLQhHoBMnpqJZYoxMJTxdpAbSy
mY+A==
X-Gm-Message-State: AOAM5325RcN4/ThWbYCO3vWRMFFBrfzJUHC1bd1Z9VB3/2Q3RuF9lmIJ +SjshEErhK68Of2pHDZQ3aPU4rzDfV8ozbvRsgChdfZg8aA=
X-Google-Smtp-Source: ABdhPJxUOUdurKEQfLldtiQGRkgC/h8gKQG1zhS+8k93p6N1SsOn517+GeRyT3E+/Uw536pmReO29la3EIAS6VT33SE=
X-Received: by 2002:aed:3e8e:: with SMTP id n14mr3191190qtf.67.1597937340509; Thu, 20 Aug 2020 08:29:00 -0700 (PDT)
MIME-Version: 1.0
From: John Tester <customer@customercompany.fr>
Date: Thu, 20 Aug 2020 17:28:34 +0200
Message-ID: <CALeEO_kij-ogXKzrjV_pTgqVbUB9j=287VkX34iVSWgDHFA8eg@mail.gmail.com>
Subject: Support besoin
To: testldrdev@gmail.com
Content-Type: multipart/alternative; boundary="0000000000008e099705ad50c772"
--0000000000008e099705ad50c772
Content-Type: text/plain; charset="UTF-8"
adfsdfsdfds
--
Laurent.
------------------------------------------------------------------------------------
Twitter: https://www.twitter.com/eldy10
--0000000000008e099705ad50c772
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">adfsdfsdfds<br clear=3D"all"><div><br></div>-- <br><div di=
r=3D"ltr" class=3D"gmail_signature" data-smartmail=3D"gmail_signature">Laur=
ent.<br>-------------------------------------------------------------------=
-----------------<br>Twitter: <a href=3D"https://www.twitter.com/eldy10" ta=
rget=3D"_blank">https://www.twitter.com/eldy10</a></div></div>
--0000000000008e099705ad50c772--

View File

@ -0,0 +1,57 @@
Return-Path: <testldrdev@gmail.com>
Received: from smtp.gmail.com ([2a01:e0a:7e:4ae0:329c:23ff:feb8:dc8d])
by smtp.gmail.com with ESMTPSA id 32sm5811196wrh.18.2020.08.20.09.31.37
for <customer@customercompany.fr>
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 20 Aug 2020 09:31:37 -0700 (PDT)
From: testldrdev@gmail.com
X-Google-Original-From: <aa@aa.comg>
To: customer@customercompany.fr
Subject: [MyBigCompany - Ticket #TS2008-0040] Nouveau message
Date: Thu, 20 Aug 2020 18:31:37 +0200
Message-ID: <1597941097.SMTPs-dolibarr-tic58@83b5bc91f83a56e458db71e0adac2b62>
References: <1597941097.SMTPs-dolibarr-tic58@83b5bc91f83a56e458db71e0adac2b62>
X-Dolibarr-TRACKID: tic58@83b5bc91f83a56e458db71e0adac2b62
X-RemoteAddr: 127.0.0.1
X-Mailer: Dolibarr version 13.0.0-alpha (using SMTPs Mailer)
X-Dolibarr-Option: MAIN_MAIL_USE_MULTI_PART
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="multipart_x.1597941097.x_boundary"
Content-Transfer-Encoding: 8bit
--multipart_x.1597941097.x_boundary
Content-Type: multipart/alternative; boundary="mul_872cdd6a64216735955664484832b075"
--mul_872cdd6a64216735955664484832b075
Content-Type: text/plain; charset=UTF-8
Bonjour
Une nouvelle réponse a été ajoutée à un ticket que vous suivez. Voici
le message :PredefinedMailContentTicket_send
Vous pouvez voir la progression du ticket en cliquant sur le lien
ci-dessus. : fr5uw2yospypn2rz
Cordialement,
--
--mul_872cdd6a64216735955664484832b075
Content-Type: text/html; charset=UTF-8
<html><head><title></title></head><body>Bonjour<br>
<br>
Une nouvelle réponse a été ajoutée à un ticket que vous suivez. Voici
le message :PredefinedMailContentTicket_send<br>
<br>
<br>
Vous pouvez voir la progression du ticket en cliquant sur le lien
ci-dessus. : <a
href="http://localhostgit/dolibarr_dev/htdocs/public/ticket/view.php?track_id=fr5uw2yospypn2rz">fr5uw2yospypn2rz</a><br>
<br>Cordialement,<br>
<br>
--</body></html>
--mul_872cdd6a64216735955664484832b075--
--multipart_x.1597941097.x_boundary--

View File

@ -0,0 +1,48 @@
MIME-Version: 1.0
Date: Thu, 20 Aug 2020 18:34:01 +0200
References: <CALeEO_kij-ogXKzrjV_pTgqVbUB9j=287VkX34iVSWgDHFA8eg@mail.gmail.com>
In-Reply-To: <CALeEO_kij-ogXKzrjV_pTgqVbUB9j=287VkX34iVSWgDHFA8eg@mail.gmail.com>
Message-ID: <CAC8+=32ccpEo12RR-juT=FW6+gNV-DcvNjxs_0s6Wn40xmfhug@mail.gmail.com>
Subject: Re: Support besoin
From: John Tester <testldrdev@gmail.com>
To: John Tester <customer@customercompany.fr>
Content-Type: multipart/alternative; boundary="0000000000001620dd05ad51b075"
--0000000000001620dd05ad51b075
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Merci pour votre question.
Voici la rep.
Le jeu. 20 ao=C3=BBt 2020 =C3=A0 17:29, John Tester <laurent@destai=
lleur.fr>
a =C3=A9crit :
> adfsdfsdfds
>
> --
> Laurent.
>
> -------------------------------------------------------------------------=
-----------
> Twitter: https://www.twitter.com/eldy10
>
--0000000000001620dd05ad51b075
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Merci pour votre question.<div>Voici la rep.</div></div><b=
r><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">Le=C2=A0=
jeu. 20 ao=C3=BBt 2020 =C3=A0=C2=A017:29, John Tester &lt;<a href=
=3D"mailto:customer@customercompany.fr">customer@customercompany.fr</a>&gt; a =C3=A9c=
rit=C2=A0:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div =
dir=3D"ltr">adfsdfsdfds<br clear=3D"all"><div><br></div>-- <br><div dir=3D"=
ltr">Laurent.<br>----------------------------------------------------------=
--------------------------<br>Twitter: <a href=3D"https://www.twitter.com/e=
ldy10" target=3D"_blank">https://www.twitter.com/eldy10</a></div></div>
</blockquote></div>
--0000000000001620dd05ad51b075--

View File

@ -0,0 +1,134 @@
Delivered-To: testldrdev@gmail.com
Received: by 2002:a2e:9b9a:0:0:0:0:0 with SMTP id z26csp1483607lji;
Thu, 20 Aug 2020 09:56:03 -0700 (PDT)
X-Received: by 2002:ac8:3868:: with SMTP id r37mr3301993qtb.95.1597942563252;
Thu, 20 Aug 2020 09:56:03 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1597942563; cv=none;
d=google.com; s=arc-20160816;
b=skUGL+keim3FdNXfKGgQokCfj85gnhYhuLbMM61qY5W6ixSH9s8I6uoNh3gzVy89XM
NGbZiajjDiPMBryl87PhD+ACBjv8WoZAQiojAga0ELPPmVDnhrtWKANLbRrkUI3Xtfoj
b1o2iHP2Q12Vqs6xiAy86yxURlIKGM3tw91WryWiIPiAL7bRZPn49N3XbO2ULE0QKTBq
BI5YnOxt9NfTj0xhKaLLIJ9M1qa4e1QyOHl56WuEv3Gx6uHDAQDYz+C5G0VgdjBvwRzH
pJaiAulc1uW/V9TcRMwvwIWtI7eWygvU2PiuI/c05G1KVKibAubHE55IjOJCn2O2UaH4
WMNQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:dkim-signature;
bh=j6+rsx5MBsg1/s7LIIfByV7u0jGK09n72bnK4XcN6ZQ=;
b=Ps5kk+tBGQzMP6ugDCwKf4hzn8fn3DU4AFz1dJvkHdDestLZWN99Qtr6iNMdslsHJm
ov378c+8oCfcV7shyBYjlAFfikFi7o4RM/evh3yqqjAnhyVfcYH7c9cexVvDo/AXUAZ7
N7Mh7EOvyDXXsaHK2l89XiAxZx/hZh/O+/HR2EoVEGre1eYRYwI/aEfPN8d4/fL2VtCD
0wzAwnUrINuXmcaUDT30Twjk9kwGjjTsM6Z531vKM6L3y48a7f3GTE7V+vo2QxHdUT54
fQVue9OO7b4VKTEj/x/dmNr+92sHRAMMS7dj/VXMmzM+WttUCAPNxZ27/bvt4bBc5oBp
QPEA==
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@destailleur.fr header.s=google header.b=SEYSmxbT;
spf=pass (google.com: domain of contact@destailleur.fr designates 209.85.220.41 as permitted sender) smtp.mailfrom=contact@destailleur.fr;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=destailleur.fr
Return-Path: <contact@destailleur.fr>
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
by mx.google.com with SMTPS id q3sor2285165qtn.34.2020.08.20.09.56.02
for <testldrdev@gmail.com>
(Google Transport Security);
Thu, 20 Aug 2020 09:56:03 -0700 (PDT)
Received-SPF: pass (google.com: domain of contact@destailleur.fr designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
Authentication-Results: mx.google.com;
dkim=pass header.i=@destailleur.fr header.s=google header.b=SEYSmxbT;
spf=pass (google.com: domain of contact@destailleur.fr designates 209.85.220.41 as permitted sender) smtp.mailfrom=contact@destailleur.fr;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=destailleur.fr
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=destailleur.fr; s=google;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=j6+rsx5MBsg1/s7LIIfByV7u0jGK09n72bnK4XcN6ZQ=;
b=SEYSmxbTKCuc1baQZzjIJwm7WXvgjt/nEGhMLqWxQCU3beM3qhH8wYlSeMyB8Z/9pi
tszZFZhZ3cjnIbbJnjzsMYJgBnYbkf6hz14+BsFwyPU030EkDjJy2i3DSXzYK7A+GbBn
G9I9foG/4+pcx0LnFsjchGsRhLFkTKJIsP2SVfOx0wlim3WHMIqIXvKsxY05PoPyf8Tp
IwQi7iNl/+nTyjNHl2DQh+ty3CRTmUw9uEbY+jRRvIg5i/7cfREekK98d7qi/5HQycr6
aptRDdCVHXpe47q+c7OPiMEEQWs+mFJhBqPXIlU54fwFApEEnLn/jwGbrPsrPYJaswgI
vd/g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=j6+rsx5MBsg1/s7LIIfByV7u0jGK09n72bnK4XcN6ZQ=;
b=M6a4k1gKc4e7TwKncuNPy0b3KxutR1FLFJGWxd4NyW84b7f3LfIR94IeInLQIWmY8C
Ddus0upZJI4+NN9XBGvXCdsiiYlwFGBJRWwjv82XFKVAKL5DD94RJNQZJUiE39hgJ2aa
6V9gasiP+nUAX4ZV9bZmw21CgKEZrZVXh5unmW2ABrfcx8lHjp/DUw5XEkym1J92Wo1l
g0H3XrC2FL+aQuj+WpCynMNkY9ljw71oqyv3SP9pjnVNHArAdZiPMHkNxiuPdq7q41fg
eIbdRCQXYZL5O48QsjDdiXwaQzx+NcYtrKAH0RIVD1lG6zc9pxqDJsbGxP9VLs8jGDTT
mSdQ==
X-Gm-Message-State: AOAM532LuATWDKbo1HImMWshHVqb0kC0isehf3owfYUKq5J68o3juKbm kCgUMt25A2C7QoNMDXcjfJyteBNQD7ZhSh3yeYTGoLSvsD4=
X-Google-Smtp-Source: ABdhPJyQYCpCHSwA87x030i8YChySZqcNXxT1qVlZyEA+XM6DTyPZusa8gtbDUVcMyx7Jma/7toh+4EEE2bWg0bG+2E=
X-Received: by 2002:aed:3e8e:: with SMTP id n14mr3547383qtf.67.1597942562373; Thu, 20 Aug 2020 09:56:02 -0700 (PDT)
MIME-Version: 1.0
References: <CALeEO_kij-ogXKzrjV_pTgqVbUB9j=287VkX34iVSWgDHFA8eg@mail.gmail.com> <CAC8+=32ccpEo12RR-juT=FW6+gNV-DcvNjxs_0s6Wn40xmfhug@mail.gmail.com>
In-Reply-To: <CAC8+=32ccpEo12RR-juT=FW6+gNV-DcvNjxs_0s6Wn40xmfhug@mail.gmail.com>
From: John Tester <customer@customercompany.fr>
Date: Thu, 20 Aug 2020 18:55:36 +0200
Message-ID: <CALeEO_nLUY8Tk+o7WoaHtBkxvOy0dhvt+fL0MwPrApGty_AG_g@mail.gmail.com>
Subject: Re: Support besoin
To: John Tester <testldrdev@gmail.com>
Content-Type: multipart/alternative; boundary="000000000000cd54be05ad51fe67"
--000000000000cd54be05ad51fe67
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Merci
Le jeu. 20 ao=C3=BBt 2020 =C3=A0 18:34, John Tester <testldrdev@gma=
il.com> a
=C3=A9crit :
> Merci pour votre question.
> Voici la rep.
>
> Le jeu. 20 ao=C3=BBt 2020 =C3=A0 17:29, John Tester <laurent@dest=
ailleur.fr>
> a =C3=A9crit :
>
>> adfsdfsdfds
>>
>> --
>> Laurent.
>>
>> ------------------------------------------------------------------------=
------------
>> Twitter: https://www.twitter.com/eldy10
>>
>
--=20
Laurent.
---------------------------------------------------------------------------=
---------
Twitter: https://www.twitter.com/eldy10
--000000000000cd54be05ad51fe67
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Merci</div><br><div class=3D"gmail_quote"><div dir=3D"ltr"=
class=3D"gmail_attr">Le=C2=A0jeu. 20 ao=C3=BBt 2020 =C3=A0=C2=A018:34, Lau=
rent Destailleur &lt;<a href=3D"mailto:testldrdev@gmail.com">testldrdev@gma=
il.com</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)=
;padding-left:1ex"><div dir=3D"ltr">Merci pour votre question.<div>Voici la=
rep.</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"g=
mail_attr">Le=C2=A0jeu. 20 ao=C3=BBt 2020 =C3=A0=C2=A017:29, Laurent Destai=
lleur &lt;<a href=3D"mailto:customer@customercompany.fr" target=3D"_blank">laure=
nt@destailleur.fr</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(2=
04,204,204);padding-left:1ex"><div dir=3D"ltr">adfsdfsdfds<br clear=3D"all"=
><div><br></div>-- <br><div dir=3D"ltr">Laurent.<br>-----------------------=
-------------------------------------------------------------<br>Twitter: <=
a href=3D"https://www.twitter.com/eldy10" target=3D"_blank">https://www.twi=
tter.com/eldy10</a></div></div>
</blockquote></div>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
class=3D"gmail_signature">Laurent.<br>------------------------------------=
------------------------------------------------<br>Twitter: <a href=3D"htt=
ps://www.twitter.com/eldy10" target=3D"_blank">https://www.twitter.com/eldy=
10</a></div>
--000000000000cd54be05ad51fe67--

View File

@ -227,8 +227,7 @@ while ($fields = $db->fetch_array($resql)) {
$error++; // $errorrecord will be reset $error++; // $errorrecord will be reset
} }
$j++; $j++;
} else } else die("error : $sql");
die("error : $sql");

View File

@ -179,8 +179,7 @@ while ($fields = $db->fetch_array($resql)) {
$object->town = trim($fields['FVILLE']); $object->town = trim($fields['FVILLE']);
if ($fields['FPAYS']) if ($fields['FPAYS'])
$object->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['FPAYS']))), 'c_country', 'label', 'rowid'); $object->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['FPAYS']))), 'c_country', 'label', 'rowid');
else else $object->country_id = 1;
$object->country_id = 1;
$object->phone = trim($fields['FTEL']) ? trim($fields['FTEL']) : trim($fields['FCONTACT']); $object->phone = trim($fields['FTEL']) ? trim($fields['FTEL']) : trim($fields['FCONTACT']);
$object->phone = substr($object->phone, 0, 20); $object->phone = substr($object->phone, 0, 20);
$object->fax = trim($fields['FFAX']) ? trim($fields['FFAX']) : trim($fields['FCONTACT']); $object->fax = trim($fields['FFAX']) ? trim($fields['FFAX']) : trim($fields['FCONTACT']);
@ -299,8 +298,7 @@ while ($fields = $db->fetch_array($resql)) {
$contact->town = trim($fields['LVILLE']); $contact->town = trim($fields['LVILLE']);
if ($fields['FPAYS']) if ($fields['FPAYS'])
$contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid'); $contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid');
else else $contact->country_id = 1;
$contact->country_id = 1;
$contact->email = $fields['LMAIL']; $contact->email = $fields['LMAIL'];
$contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']); $contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']);
$contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']); $contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']);
@ -340,8 +338,7 @@ while ($fields = $db->fetch_array($resql)) {
$error++; // $errorrecord will be reset $error++; // $errorrecord will be reset
} }
$j++; $j++;
} else } else die("error : $sql");
die("error : $sql");
$db->commit(); $db->commit();

View File

@ -207,8 +207,7 @@ class DBase
$value = true; $value = true;
elseif ($value == 'f' || $value == 'n') elseif ($value == 'f' || $value == 'n')
$value = false; $value = false;
else else $value = null;
$value = null;
} }
$record[$i] = $value; $record[$i] = $value;
} }
@ -295,8 +294,7 @@ class DBase
$i = unpack("S$n", $data); $i = unpack("S$n", $data);
if ($n == 1) if ($n == 1)
return (int) $i[1]; return (int) $i[1];
else else return array_merge($i);
return array_merge($i);
} }
private static function putInt16($fd, $value) private static function putInt16($fd, $value)
@ -310,8 +308,7 @@ class DBase
$i = unpack("L$n", $data); $i = unpack("L$n", $data);
if ($n == 1) if ($n == 1)
return (int) $i[1]; return (int) $i[1];
else else return array_merge($i);
return array_merge($i);
} }
private static function putInt32($fd, $value) private static function putInt32($fd, $value)

View File

@ -179,14 +179,10 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0)
if ($result) if ($result)
{ {
print " OK with ref ".$object->ref."\n";; print " OK with ref ".$object->ref."\n";;
} } else {
else
{
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
} } else {
else
{
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
} }

View File

@ -124,8 +124,7 @@ if ($resql) {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$societesid[$i] = $row[0]; $societesid[$i] = $row[0];
} }
} } else { print "err"; }
else { print "err"; }
$commandesid = array(); $commandesid = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
@ -138,8 +137,7 @@ if ($resql) {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$commandesid[$i] = $row[0]; $commandesid[$i] = $row[0];
} }
} } else { print "err"; }
else { print "err"; }
$prodids = array(); $prodids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
@ -206,16 +204,12 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
{ {
$db->commit(); $db->commit();
print " OK with ref ".$object->ref."\n"; print " OK with ref ".$object->ref."\n";
} } else {
else
{
print " KO\n"; print " KO\n";
$db->rollback(); $db->rollback();
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
} } else {
else
{
print " KO\n"; print " KO\n";
$db->rollback(); $db->rollback();
dol_print_error($db, $object->error); dol_print_error($db, $object->error);

View File

@ -210,16 +210,12 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
{ {
$db->commit(); $db->commit();
print " OK with ref ".$object->ref."\n"; print " OK with ref ".$object->ref."\n";
} } else {
else
{
print " KO\n"; print " KO\n";
$db->rollback(); $db->rollback();
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
} } else {
else
{
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
} }

View File

@ -136,9 +136,7 @@ for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++)
} }
print "Company ".$s." created nom=".$soc->name."\n"; print "Company ".$s." created nom=".$soc->name."\n";
} } else {
else
{
print "Error: ".$soc->error."\n"; print "Error: ".$soc->error."\n";
} }
} }

View File

@ -163,9 +163,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in create result code = ".$ret." - ".$produit->errorsToString(); print " - Error in create result code = ".$ret." - ".$produit->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - Creation OK with ref ".$produit->ref." - id = ".$ret; print " - Creation OK with ref ".$produit->ref." - id = ".$ret;
} }
@ -180,9 +178,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString(); print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - updatePrice OK"; print " - updatePrice OK";
} }
} }
@ -200,9 +196,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString(); print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - setMultiLangs OK"; print " - setMultiLangs OK";
} }
} }
@ -227,9 +221,7 @@ if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
{ {
print "Rollback any changes.\n"; print "Rollback any changes.\n";
$db->rollback(); $db->rollback();
} } else {
else
{
print "Commit all changes.\n"; print "Commit all changes.\n";
$db->commit(); $db->commit();
} }

View File

@ -181,9 +181,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in create result code = ".$ret." - ".$object->errorsToString(); print " - Error in create result code = ".$ret." - ".$object->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - Creation OK with name ".$object->name." - id = ".$ret; print " - Creation OK with name ".$object->name." - id = ".$ret;
} }
} }
@ -212,9 +210,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString(); print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - create link sale representative OK"; print " - create link sale representative OK";
} }
} }
@ -243,9 +239,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - create contact OK"; print " - create contact OK";
} }
} }
@ -277,9 +271,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString(); print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - create contact OK"; print " - create contact OK";
} }
} }
@ -305,9 +297,7 @@ if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
{ {
print "Rollback any changes.\n"; print "Rollback any changes.\n";
$db->rollback(); $db->rollback();
} } else {
else
{
print "Commit all changes.\n"; print "Commit all changes.\n";
$db->commit(); $db->commit();
} }

View File

@ -142,9 +142,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
{ {
print " - Error in create result code = ".$ret." - ".$object->errorsToString(); print " - Error in create result code = ".$ret." - ".$object->errorsToString();
$errorrecord++; $errorrecord++;
} } else {
else
{
print " - Creation OK with login ".$object->login." - id = ".$ret; print " - Creation OK with login ".$object->login." - id = ".$ret;
} }
@ -168,9 +166,7 @@ if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
{ {
print "Rollback any changes.\n"; print "Rollback any changes.\n";
$db->rollback(); $db->rollback();
} } else {
else
{
print "Commit all changes.\n"; print "Commit all changes.\n";
$db->commit(); $db->commit();
} }

View File

@ -26,7 +26,7 @@
$sapi_type = php_sapi_name(); $sapi_type = php_sapi_name();
$script_file = basename(__FILE__); $script_file = basename(__FILE__);
$path=dirname(__FILE__).'/'; $path=__DIR__.'/';
// Test si mode batch // Test si mode batch
if (substr($sapi_type, 0, 3) == 'cgi') { if (substr($sapi_type, 0, 3) == 'cgi') {
@ -198,7 +198,7 @@ if (empty($option))
if ($option != 'all') if ($option != 'all')
{ {
$listofoptions=explode(',', $option); $listofoptions=explode(',', $option);
foreach($listofoptions as $cursoroption) foreach ($listofoptions as $cursoroption)
{ {
if (! in_array($cursoroption, array_keys($sqls))) { if (! in_array($cursoroption, array_keys($sqls))) {
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n"; print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
@ -264,7 +264,7 @@ function processfamily($family, $date)
global $db, $sqls; global $db, $sqls;
$error=0; $error=0;
foreach($sqls[$family] as $sql) foreach ($sqls[$family] as $sql)
{ {
if (preg_match('/^@/', $sql)) if (preg_match('/^@/', $sql))
{ {
@ -302,10 +302,10 @@ function processfamily($family, $date)
$db->begin(); $db->begin();
$listofoptions=explode(',', $option); $listofoptions=explode(',', $option);
foreach($listofoptions as $cursoroption) foreach ($listofoptions as $cursoroption)
{ {
$oldfamily=''; $oldfamily='';
foreach($sqls as $family => $familysql) foreach ($sqls as $family => $familysql)
{ {
if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) continue; if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) continue;
@ -325,9 +325,7 @@ if ($error || $mode != 'confirm')
{ {
print "\nRollback any changes.\n"; print "\nRollback any changes.\n";
$db->rollback(); $db->rollback();
} } else {
else
{
print "Commit all changes.\n"; print "Commit all changes.\n";
$db->commit(); $db->commit();
} }

View File

@ -69,6 +69,7 @@ then
255) 255)
exit;; exit;;
esac esac
rm $fichtemp
# ----------------------------- database name # ----------------------------- database name
DIALOG=${DIALOG=dialog} DIALOG=${DIALOG=dialog}
@ -86,6 +87,7 @@ then
255) 255)
exit;; exit;;
esac esac
rm $fichtemp
# ---------------------------- database port # ---------------------------- database port
DIALOG=${DIALOG=dialog} DIALOG=${DIALOG=dialog}
@ -104,6 +106,7 @@ then
255) 255)
exit;; exit;;
esac esac
rm $fichtemp
# ---------------------------- compte admin mysql # ---------------------------- compte admin mysql
DIALOG=${DIALOG=dialog} DIALOG=${DIALOG=dialog}
@ -122,6 +125,7 @@ then
255) 255)
exit;; exit;;
esac esac
rm $fichtemp
# ---------------------------- mot de passe admin mysql # ---------------------------- mot de passe admin mysql
DIALOG=${DIALOG=dialog} DIALOG=${DIALOG=dialog}
@ -140,6 +144,7 @@ then
255) 255)
exit;; exit;;
esac esac
rm $fichtemp
export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g' ` export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g' `

166
dev/initdemo/initdemopassword.sh Executable file
View File

@ -0,0 +1,166 @@
#!/bin/sh
#------------------------------------------------------
# Script to reinit admin password.
# Note: "dialog" tool need to be available if no parameter provided.
#
# Laurent Destailleur - eldy@users.sourceforge.net
#------------------------------------------------------
# Usage: initdemopassword.sh confirm
# usage: initdemopassword.sh confirm base port login pass
#------------------------------------------------------
export mydir=`echo "$0" | sed -e 's/initdemopassword.sh//'`;
if [ "x$mydir" = 'x' -o "x$mydir" = 'x./' ]
then
export mydir="."
fi
export id=`id -u`;
# ----------------------------- check if root
if [ "x$id" != "x0" -a "x$id" != "x1001" ]
then
echo "Script must be ran as root"
exit
fi
# ----------------------------- command line params
confirm=$1;
base=$2;
port=$3;
demologin=$4;
demopass=$5;
# ----------------------------- check params
if [ "x$confirm" != "xconfirm" ]
then
echo "----- $0 -----"
echo "Usage: initdemopassword.sh confirm [base port login pass]"
exit
fi
# ----------------------------- if no params on command line
if [ "x$demopass" = "x" ]
then
export dumpfile=`ls -v $mydir/mysqldump_dolibarr_*.sql | tail -n 1`
export dumpfile=`basename $dumpfile`
# ----------------------------- database name
DIALOG=${DIALOG=dialog}
DIALOG="$DIALOG --ascii-lines"
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
trap "rm -f $fichtemp" 0 1 2 5 15
$DIALOG --title "Init Dolibarr with demo values" --clear \
--inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp
valret=$?
case $valret in
0)
base=`cat $fichtemp`;;
1)
exit;;
255)
exit;;
esac
rm $fichtemp
# ---------------------------- database port
DIALOG=${DIALOG=dialog}
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
trap "rm -f $fichtemp" 0 1 2 5 15
$DIALOG --title "Init Dolibarr with demo values" --clear \
--inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp
valret=$?
case $valret in
0)
port=`cat $fichtemp`;;
1)
exit;;
255)
exit;;
esac
rm $fichtemp
# ----------------------------- demo login
DIALOG=${DIALOG=dialog}
DIALOG="$DIALOG --ascii-lines"
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
trap "rm -f $fichtemp" 0 1 2 5 15
$DIALOG --title "Reset login password" --clear \
--inputbox "Login to reset :" 16 55 dolibarrdemologin 2> $fichtemp
valret=$?
case $valret in
0)
demologin=`cat $fichtemp`;;
1)
exit;;
255)
exit;;
esac
rm fichtemp
# ----------------------------- demo pass
DIALOG=${DIALOG=dialog}
DIALOG="$DIALOG --ascii-lines"
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
trap "rm -f $fichtemp" 0 1 2 5 15
$DIALOG --title "Reset login password" --clear \
--inputbox "Pass to set :" 16 55 dolibarrdemopass 2> $fichtemp
valret=$?
case $valret in
0)
demopass=`cat $fichtemp`;;
1)
exit;;
255)
exit;;
esac
rm fichtemp
export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g' `
# ---------------------------- confirmation
DIALOG=${DIALOG=dialog}
$DIALOG --title "Init demo login with demo values" --clear \
--yesno "Do you confirm ? \n Mysql database : '$base' \n Mysql port : '$port' \n Demo login: '$demologin' \n Demo password : '$demopass'" 15 55
case $? in
0) echo "Ok, start process...";;
1) exit;;
255) exit;;
esac
fi
# ---------------------------- run sql file
if [ "x$passwd" != "x" ]
then
export passwd="-p$passwd"
fi
#echo "mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile"
#mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
echo "echo \"UPDATE llx_user SET pass_crypted = MD5('$demopass') WHERE login = '$demologin';\" | mysql -P$port $base"
echo "UPDATE llx_user SET pass_crypted = MD5('$demopass') WHERE login = '$demologin';" | mysql -P$port $base
export res=$?
if [ $res -ne 0 ]; then
echo "Error to execute sql with mysql -P$port -u$admin -p***** $base"
exit
fi
if [ "x$res" = "x0" ]
then
echo "Success, file successfully loaded."
else
echo "Error, load failed."
fi
echo

View File

@ -95,8 +95,7 @@ if ($connection)
dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR); dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR);
exit(-5); exit(-5);
} }
else else {
{
//$stream = ssh2_exec($connection, '/usr/bin/php -i'); //$stream = ssh2_exec($connection, '/usr/bin/php -i');
/* /*
print "Generate dump ".$filesys1.'.bz2'."\n"; print "Generate dump ".$filesys1.'.bz2'."\n";
@ -125,14 +124,13 @@ if ($connection)
$return_var=0; $return_var=0;
print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n"; print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n";
exec($fullcommand, $output, $return_var); exec($fullcommand, $output, $return_var);
foreach($output as $line) print $line."\n"; foreach ($output as $line) print $line."\n";
//ssh2_sftp_unlink($sftp, $fileinstalllock); //ssh2_sftp_unlink($sftp, $fileinstalllock);
//print $output; //print $output;
} }
} }
else else {
{
print 'Failed to connect to ssh2 to '.$server; print 'Failed to connect to ssh2 to '.$server;
exit(-6); exit(-6);
} }

View File

@ -87,7 +87,7 @@ while ($year <= $currentyear)
if ($delta1) if ($delta1)
{ {
foreach($tables as $tablekey => $tableval) foreach ($tables as $tablekey => $tableval)
{ {
print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." "; print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." ";
$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)"; $sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)";
@ -105,7 +105,7 @@ while ($year <= $currentyear)
print "."; print ".";
$sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set "; $sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set ";
$j=0; $j=0;
foreach($tableval as $field) foreach ($tableval as $field)
{ {
if ($j) $sql2.=", "; if ($j) $sql2.=", ";
$sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)"); $sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)");

View File

@ -27,7 +27,7 @@
<!-- Rules from Generic Standard --> <!-- Rules from Generic Standard -->
<!-- We want to allow empty statement: It allows to put some code comments into the else for examples --> <!-- We want to allow empty statement: It allows to put some code comments into the else for examples -->
<rule ref="Generic.CodeAnalysis.EmptyStatement"> <rule ref="Generic.CodeAnalysis.EmptyStatement">
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIf"/> <exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIf"/>
@ -101,7 +101,7 @@
<property name="error" value="false"/> <property name="error" value="false"/>
</properties> </properties>
</rule> </rule>
--> -->
<!-- We want to allow 'if () { ...small code... }' on same line for better code compacity and readability --> <!-- We want to allow 'if () { ...small code... }' on same line for better code compacity and readability -->
<rule ref="Generic.Formatting.DisallowMultipleStatements"> <rule ref="Generic.Formatting.DisallowMultipleStatements">
<severity>0</severity> <severity>0</severity>
@ -117,7 +117,7 @@
</properties> </properties>
</rule> </rule>
--> -->
<rule ref="Generic.Formatting.SpaceAfterCast" /> <rule ref="Generic.Formatting.SpaceAfterCast" />
<rule ref="Generic.Functions.CallTimePassByReference" /> <rule ref="Generic.Functions.CallTimePassByReference" />
@ -188,8 +188,8 @@
</rule> </rule>
<!-- Check for duplicate class names --> <!-- Check for duplicate class names -->
<!-- Disabled: We need this for dependency injection. <!-- Disabled: We need this for dependency injection.
<rule ref="Generic.Classes.DuplicateClassName" /> <rule ref="Generic.Classes.DuplicateClassName" />
--> -->
@ -213,6 +213,10 @@
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" /> <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" /> <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
<!-- <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis" /> -->
<!-- <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" /> -->
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword" />
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen" /> <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen" />
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose" /> <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose" />
@ -309,16 +313,16 @@
<rule ref="PEAR.Files.IncludingFile.UseInclude"> <rule ref="PEAR.Files.IncludingFile.UseInclude">
<severity>0</severity> <severity>0</severity>
</rule> </rule>
<!-- We disable this. We must be allowed to use strict require instead of non strict include anywhere --> <!-- We disable this. We must be allowed to use strict require instead of non strict include anywhere -->
<rule ref="PEAR.Files.IncludingFile.UseIncludeOnce"> <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
<severity>0</severity> <severity>0</severity>
</rule> </rule>
<rule ref="PEAR.Files.IncludingFile.UseRequire"> <rule ref="PEAR.Files.IncludingFile.UseRequire">
<severity>0</severity> <severity>0</severity>
</rule> </rule>
<!-- We disable this: We want to allow include_once --> <!-- We disable this: We want to allow include_once -->
<rule ref="PEAR.Files.IncludingFile.UseRequireOnce"> <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
<severity>0</severity> <severity>0</severity>
@ -332,7 +336,7 @@
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine"> <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
<severity>0</severity> <severity>0</severity>
</rule> </rule>
<!-- We disable this: We want to allow small function on 1 line --> <!-- We disable this: We want to allow small function on 1 line -->
<rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"> <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
<severity>0</severity> <severity>0</severity>
@ -385,7 +389,7 @@
<!--<rule ref="PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"> <!--<rule ref="PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps">
<severity>0</severity> <severity>0</severity>
</rule>--> </rule>-->
<!-- We disable this: We don't want to have private methods prefixed with an underscore --> <!-- We disable this: We don't want to have private methods prefixed with an underscore -->
<rule ref="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"> <rule ref="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore">
<severity>0</severity> <severity>0</severity>
@ -426,5 +430,5 @@
<rule ref="PSR2.Classes.PropertyDeclaration.VarUsed" /> <rule ref="PSR2.Classes.PropertyDeclaration.VarUsed" />
<!-- The closing ?> tag MUST be omitted from files containing only PHP. --> <!-- The closing ?> tag MUST be omitted from files containing only PHP. -->
<rule ref="PSR2.Files.ClosingTag"/> <rule ref="PSR2.Files.ClosingTag"/>
</ruleset> </ruleset>

View File

@ -76,14 +76,12 @@ function getfieldname($l)
if (preg_match("/`(.*)`/", $l, $regs)) { if (preg_match("/`(.*)`/", $l, $regs)) {
if ($regs[1]) if ($regs[1])
return $regs[1]; return $regs[1];
else else return null;
return null;
} // if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space. } // if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space.
elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) { elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) {
if ($regs[1]) if ($regs[1])
return $regs[1]; return $regs[1];
else else return null;
return null;
} }
} }
@ -102,8 +100,7 @@ function formatsize($s)
return sprintf("%.1f", round($s / 1024, 1)) . "K"; return sprintf("%.1f", round($s / 1024, 1)) . "K";
elseif ($s < pow(2, 30)) elseif ($s < pow(2, 30))
return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M"; return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M";
else else return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G";
return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G";
} }
/** /**
@ -146,8 +143,7 @@ function pg2mysql_large($infilename, $outfilename)
if ($c % 2 != 0) { if ($c % 2 != 0) {
if ($inquotes) if ($inquotes)
$inquotes = false; $inquotes = false;
else else $inquotes = true;
$inquotes = true;
} }
if ($linenum % 10000 == 0) { if ($linenum % 10000 == 0) {
@ -329,8 +325,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
$num = $regs[1]; $num = $regs[1];
if ($num <= 255) if ($num <= 255)
$line = preg_replace("/ character varying\([0-9]*\)/", " varchar($num)", $line); $line = preg_replace("/ character varying\([0-9]*\)/", " varchar($num)", $line);
else else $line = preg_replace("/ character varying\([0-9]*\)/", " text", $line);
$line = preg_replace("/ character varying\([0-9]*\)/", " text", $line);
} }
// character varying with no size, we will default to varchar(255) // character varying with no size, we will default to varchar(255)
if (preg_match("/ character varying/", $line)) { if (preg_match("/ character varying/", $line)) {
@ -352,8 +347,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
$num = $regs[1]; $num = $regs[1];
if ($num <= 255) if ($num <= 255)
$line = preg_replace("/ character\([0-9]*\)/", " varchar($num)", $line); $line = preg_replace("/ character\([0-9]*\)/", " varchar($num)", $line);
else else $line = preg_replace("/ character\([0-9]*\)/", " text", $line);
$line = preg_replace("/ character\([0-9]*\)/", " text", $line);
} }
// timestamps // timestamps
$line = str_replace(" timestamp with time zone", " datetime", $line); $line = str_replace(" timestamp with time zone", " datetime", $line);
@ -363,8 +357,8 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
$line = str_replace(" time with time zone", " time", $line); $line = str_replace(" time with time zone", " time", $line);
$line = str_replace(" time without time zone", " time", $line); $line = str_replace(" time without time zone", " time", $line);
$line = str_replace(" timestamp DEFAULT now()", " timestamp DEFAULT CURRENT_TIMESTAMP", $line); $line = str_replace(" timestamp DEFAULT now()", " timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", $line);
$line = str_replace(" timestamp without time zone DEFAULT now()", " timestamp DEFAULT CURRENT_TIMESTAMP", $line); $line = str_replace(" timestamp without time zone DEFAULT now()", " timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", $line);
if (strstr($line, "auto_increment") || preg_match('/ rowid int/', $line) || preg_match('/ id int/', $line)) { if (strstr($line, "auto_increment") || preg_match('/ rowid int/', $line) || preg_match('/ id int/', $line)) {
$field = getfieldname($line); $field = getfieldname($line);
@ -465,8 +459,7 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
if ($c % 2 != 0) { if ($c % 2 != 0) {
if ($inquotes) if ($inquotes)
$inquotes = false; $inquotes = false;
else else $inquotes = true;
$inquotes = true;
// echo "inquotes=$inquotes\n"; // echo "inquotes=$inquotes\n";
} }
} while (substr($lines[$linenumber], - 3, - 1) != ");" || $inquotes); } while (substr($lines[$linenumber], - 3, - 1) != ");" || $inquotes);

21
dev/tools/test/testperf.php Executable file
View File

@ -0,0 +1,21 @@
<?php
$a = microtime(true);
$i = 0;
while ($i < 1000000)
{
$key = '1234567890111213141516171819'.$i;
if ($i == 1000) $key = 'MAIN_MODULE_AAAAAiiiiiiiiiiiiiiiiiiiiiiiiiiiii';
//if (preg_match('/^MAIN_MODULE_/', $key)) {
//if (substr($key, 0, 12) == 'MAIN_MODULE_') {
if (strpos($key, 'MAIN_MODULE_') === 0) {
print "Found\n";
}
$i++;
}
$b = microtime(true);
print $b - $a."\n";

View File

@ -77,7 +77,7 @@ class autoTranslator
$files = $this->getTranslationFilesArray($this->_refLang); $files = $this->getTranslationFilesArray($this->_refLang);
$counter = 1; $counter = 1;
foreach($files as $file) foreach ($files as $file)
{ {
if ($this->_limittofile && $this->_limittofile != $file) continue; if ($this->_limittofile && $this->_limittofile != $file) continue;
$counter++; $counter++;
@ -94,7 +94,7 @@ class autoTranslator
// If we must process all languages // If we must process all languages
$arraytmp=dol_dir_list($this->_langDir, 'directories', 0); $arraytmp=dol_dir_list($this->_langDir, 'directories', 0);
foreach($arraytmp as $dirtmp) foreach ($arraytmp as $dirtmp)
{ {
if ($dirtmp['name'] === $this->_refLang) continue; // We discard source language if ($dirtmp['name'] === $this->_refLang) continue; // We discard source language
$tmppart=explode('_', $dirtmp['name']); $tmppart=explode('_', $dirtmp['name']);
@ -112,7 +112,7 @@ class autoTranslator
} }
// Process translation of source file for each target languages // Process translation of source file for each target languages
foreach($targetlangs as $my_destlang) foreach ($targetlangs as $my_destlang)
{ {
$this->_translatedFiles = array(); $this->_translatedFiles = array();
@ -124,15 +124,14 @@ class autoTranslator
echo "File not found: " . $destPath . ". We generate it.<br>\n"; echo "File not found: " . $destPath . ". We generate it.<br>\n";
$this->createTranslationFile($destPath, $my_destlang); $this->createTranslationFile($destPath, $my_destlang);
} }
else else {
{
echo "Updating file: " . $destPath . "<br>\n"; echo "Updating file: " . $destPath . "<br>\n";
} }
// Translate lines // Translate lines
$fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
$newlines=0; $newlines=0;
foreach($fileContent as $line){ foreach ($fileContent as $line){
$key = $this->getLineKey($line); $key = $this->getLineKey($line);
$value = $this->getLineValue($line); $value = $this->getLineValue($line);
if ($key && $value) if ($key && $value)
@ -167,7 +166,7 @@ class autoTranslator
fwrite($fp, "\n"); fwrite($fp, "\n");
fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\n"); fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\n");
fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\n"); fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\n");
foreach($this->_translatedFiles[$file] as $line) { foreach ($this->_translatedFiles[$file] as $line) {
fwrite($fp, $line . "\n"); fwrite($fp, $line . "\n");
} }
fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\n"); fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\n");
@ -209,7 +208,7 @@ class autoTranslator
{ {
//print "key =".$key."\n"; //print "key =".$key."\n";
foreach($content as $line) { foreach ($content as $line) {
$destKey = $this->getLineKey($line); $destKey = $this->getLineKey($line);
$destValue = $this->getLineValue($line); $destValue = $this->getLineValue($line);
// If translated return // If translated return
@ -273,8 +272,8 @@ class autoTranslator
private function getTranslationFilesArray($lang) private function getTranslationFilesArray($lang)
{ {
$dir = new DirectoryIterator($this->_langDir.$lang); $dir = new DirectoryIterator($this->_langDir.$lang);
while($dir->valid()) { while ($dir->valid()) {
if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) {
$files[] = $dir->getFilename(); $files[] = $dir->getFilename();
} }
$dir->next(); $dir->next();

View File

@ -360,16 +360,14 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a
$unused[$value] = $line; $unused[$value] = $line;
echo $line; // $trad contains the \n echo $line; // $trad contains the \n
} }
else else {
{
unset($output); unset($output);
//print 'X'.$output.'Y'; //print 'X'.$output.'Y';
} }
} }
if (empty($unused)) print "No string not used found.\n"; if (empty($unused)) print "No string not used found.\n";
else else {
{
$filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang'; $filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
print "Strings in en_US that are never used are saved into file ".$filetosave.":\n"; print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
file_put_contents($filetosave, implode("", $unused)); file_put_contents($filetosave, implode("", $unused));

View File

@ -80,8 +80,8 @@ $aEnglish = array();
if ($filesToProcess == 'all') if ($filesToProcess == 'all')
{ {
$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary); $dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
while($dir->valid()) { while ($dir->valid()) {
if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) { if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) {
$files[] = $dir->getFilename(); $files[] = $dir->getFilename();
} }
$dir->next(); $dir->next();
@ -94,7 +94,7 @@ else $filesToProcess=explode(',', $filesToProcess);
// Loop on each file // Loop on each file
foreach($filesToProcess as $fileToProcess) foreach ($filesToProcess as $fileToProcess)
{ {
$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess; $lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess; $lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
@ -285,8 +285,7 @@ foreach($filesToProcess as $fileToProcess)
print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n"; print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
continue; continue;
} }
else else {
{
$fileFirstFound[$key] = $fileToProcess; $fileFirstFound[$key] = $fileToProcess;
$lineFirstFound[$key] = $cnt; $lineFirstFound[$key] = $cnt;
} }

BIN
doc/images/invoice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -54,8 +54,8 @@ if (!$user->rights->accounting->chartofaccount) accessforbidden();
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $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; $offset = $limit * $page;
@ -119,8 +119,7 @@ if (empty($reshook))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$country_code = $obj->code; $country_code = $obj->code;
} } else dol_print_error($db);
else dol_print_error($db);
// Try to load sql file // Try to load sql file
if ($country_code) if ($country_code)
@ -143,9 +142,7 @@ if (empty($reshook))
if ($result > 0) if ($result > 0)
{ {
setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs'); setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs');
} } else {
else
{
setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings'); setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings');
} }
} }
@ -233,10 +230,9 @@ if (strlen(trim($search_account))) {
$search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp); $search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp);
$search_account_clean = preg_replace('/^\^/', '', $search_account); $search_account_clean = preg_replace('/^\^/', '', $search_account);
} }
$sql .= " AND (aa.account_number LIKE '".$startchar.$search_account_tmp_clean."'"; $sql .= " AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean)."'";
$sql .= " OR aa.account_number LIKE '".$startchar.$search_account_clean."%')"; $sql .= " OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean)."%')";
} } else $sql .= natural_search("aa.account_number", $search_account_tmp);
else $sql .= natural_search("aa.account_number", $search_account_tmp);
} }
} }
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
@ -267,15 +263,15 @@ if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_account) $param .= '&search_account='.urlencode($search_account); if ($search_account) $param .= '&search_account='.urlencode($search_account);
if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort); if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort);
if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent); if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent);
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
if ($optioncss != '') $param .= '&optioncss='.$optioncss; if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax))
{ {
@ -298,13 +294,11 @@ if ($resql)
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
// Box to select active chart of account // Box to select active chart of account
print $langs->trans("Selectchartofaccounts")." : "; print $langs->trans("Selectchartofaccounts")." : ";
@ -328,8 +322,7 @@ if ($resql)
$i++; $i++;
} }
} } else dol_print_error($db);
else dol_print_error($db);
print "</select>"; print "</select>";
print ajax_combobox("chartofaccounts"); print ajax_combobox("chartofaccounts");
print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">'; print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
@ -348,15 +341,15 @@ if ($resql)
// Line for search fields // Line for search fields
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="'.$search_account.'"></td>'; if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.'"></td>';
if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>'; if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.'"></td>';
if (!empty($arrayfields['aa.labelshort']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_labelshort" value="'.$search_labelshort.'"></td>'; if (!empty($arrayfields['aa.labelshort']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.'"></td>';
if (!empty($arrayfields['aa.account_parent']['checked'])) { if (!empty($arrayfields['aa.account_parent']['checked'])) {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2); print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2);
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>'; if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; }
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
@ -395,7 +388,7 @@ if ($resql)
if (!empty($arrayfields['aa.account_number']['checked'])) if (!empty($arrayfields['aa.account_number']['checked']))
{ {
print "<td>"; print "<td>";
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1); print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard');
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
@ -421,20 +414,24 @@ if ($resql)
// Account parent // Account parent
if (!empty($arrayfields['aa.account_parent']['checked'])) if (!empty($arrayfields['aa.account_parent']['checked']))
{ {
if (!empty($obj->account_parent)) // Note: obj->account_parent is a foreign key to a rowid. It is field in child table and obj->rowid2 is same, but in parent table.
// So for orphans, obj->account_parent is set but not obj->rowid2
if (!empty($obj->account_parent) && !empty($obj->rowid2))
{ {
print "<td>";
print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->';
$accountparent->id = $obj->rowid2; $accountparent->id = $obj->rowid2;
$accountparent->label = $obj->label2; $accountparent->label = $obj->label2;
$accountparent->account_number = $obj->account_number2; $accountparent->account_number = $obj->account_number2; // Sotre an account number for output
print "<td>";
print $accountparent->getNomUrl(1); print $accountparent->getNomUrl(1);
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} } else {
else print '<td>';
{ if (!empty($obj->account_parent)) {
print '<td>&nbsp;</td>'; print '<!-- Bad value for obj->account_parent = '.$obj->account_parent.': is a rowid that does not exists -->';
}
print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
} }
@ -488,11 +485,11 @@ if ($resql)
// Action // Action
print '<td class="center">'; print '<td class="center">';
if ($user->rights->accounting->chartofaccount) { if ($user->rights->accounting->chartofaccount) {
print '<a class="editfielda" href="./card.php?action=update&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">'; print '<a class="editfielda" href="./card.php?action=update&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
print '&nbsp;'; print '&nbsp;';
print '<a class="marginleftonly" href="./card.php?action=delete&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">'; print '<a class="marginleftonly" href="./card.php?action=delete&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
} }

View File

@ -228,8 +228,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') { if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
} } elseif ($value == 'entity') {
elseif ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) $sql .= ",";
@ -245,13 +244,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id'=>$id); // Clean $_POST array, we keep only $_POST = array('id'=>$id); // Clean $_POST array, we keep only
} } else {
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
} } else {
else {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -260,8 +256,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha'))
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
@ -276,8 +271,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') { if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
} } elseif ($field == 'entity') {
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) $sql .= ",";
@ -286,7 +280,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = '".$rowid."'"; $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
@ -306,10 +300,9 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
@ -318,9 +311,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{ {
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} } else {
else
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -329,14 +320,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$db->escape($code)."'";
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -349,14 +338,12 @@ if ($action == $acts[0])
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$db->escape($code)."'";
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -369,14 +356,12 @@ if ($action == $acts[1])
// favorite // favorite
if ($action == 'activate_favorite') if ($action == 'activate_favorite')
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$db->escape($code)."'";
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -389,14 +374,12 @@ if ($action == 'activate_favorite')
// disable favorite // disable favorite
if ($action == 'disable_favorite') if ($action == 'disable_favorite')
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$db->escape($code)."'";
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -581,9 +564,7 @@ if ($id)
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>'; print '</td>';
} } else {
else
{
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
} }
@ -629,9 +610,7 @@ if ($id)
print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
} } else {
else
{
$tmpaction = 'view'; $tmpaction = 'view';
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@ -652,26 +631,20 @@ if ($id)
if ($value == 'element') if ($value == 'element')
{ {
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
} } elseif ($value == 'source')
elseif ($value == 'source')
{ {
$valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow; $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
} } elseif ($valuetoshow == 'all') {
elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All'); $valuetoshow = $langs->trans('All');
} } elseif ($fieldlist[$field] == 'country') {
elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code)) if (empty($obj->country_code))
{ {
$valuetoshow = '-'; $valuetoshow = '-';
} } else {
else
{
$key = $langs->trans("Country".strtoupper($obj->country_code)); $key = $langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
} }
} } elseif ($fieldlist[$field] == 'country_id') {
elseif ($fieldlist[$field] == 'country_id') {
$showfield = 0; $showfield = 0;
} }
@ -696,11 +669,11 @@ if ($id)
print "</td>"; print "</td>";
// Modify link // Modify link
if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit">'.img_edit().'</a></td>'; if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
else print '<td>&nbsp;</td>'; else print '<td>&nbsp;</td>';
// Delete link // Delete link
if ($iserasable) print '<td class="center"><a href="'.$url.'action=delete">'.img_delete().'</a></td>'; if ($iserasable) print '<td class="center"><a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>';
else print '<td>&nbsp;</td>'; else print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
@ -708,8 +681,7 @@ if ($id)
$i++; $i++;
} }
} }
} } else {
else {
dol_print_error($db); dol_print_error($db);
} }
@ -761,8 +733,7 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
$fieldname = 'country'; $fieldname = 'country';
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>'; print '</td>';
} } elseif ($fieldlist[$field] == 'country_id')
elseif ($fieldlist[$field] == 'country_id')
{ {
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{ {
@ -771,8 +742,7 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>'; print '</td>';
} }
} } elseif ($fieldlist[$field] == 'type_cdr') {
elseif ($fieldlist[$field] == 'type_cdr') {
if ($fieldlist[$field] == 'type_cdr') print '<td class="center">'; if ($fieldlist[$field] == 'type_cdr') print '<td class="center">';
else print '<td>'; else print '<td>';
if ($fieldlist[$field] == 'type_cdr') { if ($fieldlist[$field] == 'type_cdr') {
@ -781,12 +751,9 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
} }
print '</td>'; print '</td>';
} } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
} } else {
else
{
print '<td>'; print '<td>';
$size = ''; $class = ''; $size = ''; $class = '';
if ($fieldlist[$field] == 'code') $size = 'size="8" '; if ($fieldlist[$field] == 'code') $size = 'size="8" ';

View File

@ -44,6 +44,8 @@ $cancel = GETPOST('cancel', 'alpha');
$accountingaccount = GETPOST('accountingaccount', 'alpha'); $accountingaccount = GETPOST('accountingaccount', 'alpha');
// Security check // Security check
if ($user->socid > 0) accessforbidden();
if (!$user->rights->accounting->chartofaccount) accessforbidden();
$object = new AccountingAccount($db); $object = new AccountingAccount($db);
@ -75,18 +77,14 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{ {
$account_number = GETPOST('account_number', 'string'); $account_number = GETPOST('account_number', 'string');
} } else {
else
{
$account_number = clean_account(GETPOST('account_number', 'string')); $account_number = clean_account(GETPOST('account_number', 'string'));
} }
if (GETPOST('account_parent', 'int') <= 0) if (GETPOST('account_parent', 'int') <= 0)
{ {
$account_parent = 0; $account_parent = 0;
} } else {
else
{
$account_parent = GETPOST('account_parent', 'int'); $account_parent = GETPOST('account_parent', 'int');
} }
@ -104,13 +102,11 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$error = 1; $error = 1;
$action = "create"; $action = "create";
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} } elseif ($res == - 4) {
elseif ($res == - 4) {
$error = 2; $error = 2;
$action = "create"; $action = "create";
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} } elseif ($res < 0)
elseif ($res < 0)
{ {
$error++; $error++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -140,18 +136,14 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{ {
$account_number = GETPOST('account_number', 'string'); $account_number = GETPOST('account_number', 'string');
} } else {
else
{
$account_number = clean_account(GETPOST('account_number', 'string')); $account_number = clean_account(GETPOST('account_number', 'string'));
} }
if (GETPOST('account_parent', 'int') <= 0) if (GETPOST('account_parent', 'int') <= 0)
{ {
$account_parent = 0; $account_parent = 0;
} } else {
else
{
$account_parent = GETPOST('account_parent', 'int'); $account_parent = GETPOST('account_parent', 'int');
} }
@ -269,8 +261,7 @@ if ($action == 'create') {
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} } elseif ($id > 0 || $ref) {
elseif ($id > 0 || $ref) {
$result = $object->fetch($id, $ref, 1); $result = $object->fetch($id, $ref, 1);
if ($result > 0) { if ($result > 0) {
@ -381,13 +372,13 @@ elseif ($id > 0 || $ref) {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if (!empty($user->rights->accounting->chartofaccount)) { if (!empty($user->rights->accounting->chartofaccount)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=update&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
} }
if (!empty($user->rights->accounting->chartofaccount)) { if (!empty($user->rights->accounting->chartofaccount)) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$id.'">'.$langs->trans('Delete').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
} }

View File

@ -170,9 +170,9 @@ if ($action == 'display' || $action == 'delete') {
print '<td>'.length_accountg($cpt->account_number).'</td>'; print '<td>'.length_accountg($cpt->account_number).'</td>';
print '<td>'.$cpt->label.'</td>'; print '<td>'.$cpt->label.'</td>';
print '<td class="right">'; print '<td class="right">';
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=".$cat_id."&cptid=".$cpt->rowid."'>"; print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&account_category='.$cat_id.'&cptid='.$cpt->rowid.'">';
print $langs->trans("DeleteFromCat"); print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink'); print img_picto($langs->trans("DeleteFromCat"), 'unlink', 'class="paddingleft"');
print "</a>"; print "</a>";
print "</td>"; print "</td>";
print "</tr>\n"; print "</tr>\n";

View File

@ -235,13 +235,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id'=>$id); // Clean $_POST array, we keep only $_POST = array('id'=>$id); // Clean $_POST array, we keep only
} } else {
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
} } else {
else {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -250,8 +247,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha'))
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
@ -266,8 +262,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
if ($field == 'fk_country' && $_POST['country'] > 0) { if ($field == 'fk_country' && $_POST['country'] > 0) {
$_POST[$listfieldvalue[$i]] = $_POST['country']; $_POST[$listfieldvalue[$i]] = $_POST['country'];
} } elseif ($field == 'entity') {
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) $sql .= ",";
@ -276,7 +271,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = '".$rowid."'"; $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
@ -296,10 +291,9 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
@ -308,9 +302,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{ {
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} } else {
else
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -319,13 +311,11 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'";
} }
@ -339,13 +329,11 @@ if ($action == $acts[0])
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'";
} }
@ -359,13 +347,11 @@ if ($action == $acts[1])
// favorite // favorite
if ($action == 'activate_favorite') if ($action == 'activate_favorite')
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'";
} }
@ -379,13 +365,11 @@ if ($action == 'activate_favorite')
// disable favorite // disable favorite
if ($action == 'disable_favorite') if ($action == 'disable_favorite')
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'";
} }
@ -597,9 +581,7 @@ if ($id)
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>'; print '</td>';
$filterfound++; $filterfound++;
} } else {
else
{
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
} }
@ -726,10 +708,8 @@ if ($id)
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
} } else {
else $tmpaction = 'view';
{
$tmpaction = 'view';
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@ -745,35 +725,27 @@ if ($id)
if ($value == 'category_type') if ($value == 'category_type')
{ {
$valuetoshow = yn($valuetoshow); $valuetoshow = yn($valuetoshow);
} } elseif ($valuetoshow == 'all') {
elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All'); $valuetoshow = $langs->trans('All');
} } elseif ($fieldlist[$field] == 'country') {
elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code)) if (empty($obj->country_code))
{ {
$valuetoshow = '-'; $valuetoshow = '-';
} } else {
else
{
$key = $langs->trans("Country".strtoupper($obj->country_code)); $key = $langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
} }
} } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
$key = $langs->trans("Country".strtoupper($obj->code)); $key = $langs->trans("Country".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
} } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
$langs->loadLangs(array("propal")); $langs->loadLangs(array("propal"));
$key = $langs->trans("AvailabilityType".strtoupper($obj->code)); $key = $langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
} } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
$key = $langs->trans("Action".strtoupper($obj->code)); $key = $langs->trans("Action".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
} } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
$showfield = 0; $showfield = 0;
} }
@ -799,8 +771,7 @@ if ($id)
// Active // Active
print '<td class="center" class="nowrap">'; print '<td class="center" class="nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
else else {
{
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} }
print "</td>"; print "</td>";
@ -816,8 +787,7 @@ if ($id)
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>'; if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
print '</td>'; print '</td>';
} } else print '<td>&nbsp;</td>';
else print '<td>&nbsp;</td>';
// Link to setup the group // Link to setup the group
print '<td class="center">'; print '<td class="center">';
@ -833,8 +803,7 @@ if ($id)
$i++; $i++;
} }
} }
} } else {
else {
dol_print_error($db); dol_print_error($db);
} }
@ -882,14 +851,11 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
{ {
$fieldname = 'country_id'; $fieldname = 'country_id';
print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
} } else {
else
{
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
} }
print '</td>'; print '</td>';
} } elseif ($fieldlist[$field] == 'country_id')
elseif ($fieldlist[$field] == 'country_id')
{ {
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{ {
@ -898,17 +864,13 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>'; print '</td>';
} }
} } elseif ($fieldlist[$field] == 'category_type') {
elseif ($fieldlist[$field] == 'category_type') {
print '<td>'; print '<td>';
print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
print '</td>'; print '</td>';
} } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
} } else {
else
{
print '<td>'; print '<td>';
$size = ''; $class = ''; $size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; if ($fieldlist[$field] == 'code') $class = 'maxwidth100';

View File

@ -92,7 +92,7 @@ print '<span class="opacitymedium">'.$langs->trans("DefaultClosureDesc").'</span
print '<br>'; print '<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
// Define main accounts for closure // Define main accounts for closure

View File

@ -47,9 +47,9 @@ $action = GETPOST('action', 'aZ09');
$list_account_main = array( $list_account_main = array(
'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_CUSTOMER',
'ACCOUNTING_ACCOUNT_SUPPLIER', 'ACCOUNTING_ACCOUNT_SUPPLIER',
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
); );
$list_account = array(); $list_account = array();
@ -75,7 +75,7 @@ if ($mysoc->isInEEC()) {
$list_account[] = 'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'; $list_account[] = 'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT';
} }
$list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'; $list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT';
$list_account[] = '---Other---'; $list_account[] = '---Others---';
$list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT';
$list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT';
@ -94,26 +94,13 @@ if ($conf->loan->enabled) {
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST';
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE';
} }
if ($conf->societe->enabled) {
$list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT';
}
/* /*
* Actions * Actions
*/ */
$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
if (GETPOST('change_chart', 'alpha'))
{
$chartofaccounts = GETPOST('chartofaccounts', 'int');
if (!empty($chartofaccounts)) {
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
$error++;
}
}
if ($action == 'update') { if ($action == 'update') {
$error = 0; $error = 0;
@ -133,9 +120,9 @@ if ($action == 'update') {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
} }
if (!$error) { if (!$error) {
@ -172,20 +159,20 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("ThirdParties").' | '.$langs->trans("Users").'</td><td></td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("ThirdParties").' | '.$langs->trans("Users").'</td><td></td></tr>';
foreach ($list_account_main as $key) { foreach ($list_account_main as $key) {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
$label = $langs->trans($key); $label = $langs->trans($key);
$keydesc = $key.'_Desc'; $keydesc = $key.'_Desc';
$htmltext = $langs->trans($keydesc); $htmltext = $langs->trans($keydesc);
print '<td class="fieldrequired" width="50%">'; print '<td class="fieldrequired" width="50%">';
print $form->textwithpicto($label, $htmltext); print $form->textwithpicto($label, $htmltext);
print '</td>'; print '</td>';
// Value // Value
print '<td>'; // Do not force class=right, or it align also the content of the select box print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
@ -193,8 +180,7 @@ foreach ($list_account as $key) {
$reg = array(); $reg = array();
if (preg_match('/---(.*)---/', $key, $reg)) { if (preg_match('/---(.*)---/', $key, $reg)) {
print '<tr class="liste_titre"><td>'.$langs->trans($reg[1]).'</td><td></td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans($reg[1]).'</td><td></td></tr>';
} } else {
else {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
$label = $langs->trans($key); $label = $langs->trans($key);

View File

@ -29,8 +29,8 @@ $action = GETPOST('action', 'aZ09');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $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; $offset = $limit * $page;
@ -79,6 +79,7 @@ $object = new Fiscalyear($db);
$max = 100; $max = 100;
$form = new Form($db); $form = new Form($db);
$fiscalyearstatic = new Fiscalyear($db);
$title = $langs->trans('AccountingPeriods'); $title = $langs->trans('AccountingPeriods');
$helpurl = ""; $helpurl = "";
@ -132,13 +133,15 @@ if ($result)
print '</tr>'; print '</tr>';
if ($num) { if ($num) {
$fiscalyearstatic = new Fiscalyear($db);
while ($i < $num && $i < $max) { while ($i < $num && $i < $max) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$fiscalyearstatic->id = $obj->rowid; $fiscalyearstatic->id = $obj->rowid;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td><a href="fiscalyear_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowFiscalYear"), "technic").' '.$obj->rowid.'</a></td>'; print '<td>';
print $fiscalyearstatic->getNomUrl(1);
print '</td>';
print '<td class="left">'.$obj->label.'</td>'; print '<td class="left">'.$obj->label.'</td>';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>'; print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>'; print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';

View File

@ -71,9 +71,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} } elseif ($action == 'add') {
elseif ($action == 'add') {
if (!GETPOST('cancel', 'alpha')) { if (!GETPOST('cancel', 'alpha')) {
$error = 0; $error = 0;
@ -302,16 +300,16 @@ if ($action == 'create')
if (!empty($user->rights->accounting->fiscalyear->write)) if (!empty($user->rights->accounting->fiscalyear->write))
{ {
/* /*
* Barre d'actions * Barre d'actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>';
// print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>'; // print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&token='.newToken().'&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
print '</div>'; print '</div>';
} }
} }
} else { } else {

View File

@ -31,9 +31,10 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "admin", "accountancy")); $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other"));
// Security access // Security access
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))
@ -45,78 +46,95 @@ $action = GETPOST('action', 'aZ09');
// Parameters ACCOUNTING_* and others // Parameters ACCOUNTING_* and others
$list = array( $list = array(
'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT', 'ACCOUNTING_LENGTH_AACCOUNT',
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
); );
$list_binding = array(
'ACCOUNTING_DATE_START_BINDING',
'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER'
);
/* /*
* Actions * Actions
*/ */
$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
if ($action == 'update') { if ($action == 'update') {
$error = 0; $error = 0;
if (!$error) if (!$error)
{ {
foreach ($list as $constname) foreach ($list as $constname)
{ {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
} }
if ($error) { if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
foreach ($list_binding as $constname)
{
$constvalue = GETPOST($constname, 'alpha');
if ($constname == 'ACCOUNTING_DATE_START_BINDING') {
$constvalue = dol_mktime(12, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int'));
}
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} }
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
} }
if ($action == 'setlistsorttodo') { if ($action == 'setlistsorttodo') {
$setlistsorttodo = GETPOST('value', 'int'); $setlistsorttodo = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
} }
if ($action == 'setlistsortdone') { if ($action == 'setlistsortdone') {
$setlistsortdone = GETPOST('value', 'int'); $setlistsortdone = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
} }
if ($action == 'setmanagezero') { if ($action == 'setmanagezero') {
$setmanagezero = GETPOST('value', 'int'); $setmanagezero = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
} }
if ($action == 'setdisabledirectinput') { if ($action == 'setdisabledirectinput') {
@ -144,20 +162,57 @@ if ($action == 'setenabledraftexport') {
} }
if ($action == 'setenablesubsidiarylist') { if ($action == 'setenablesubsidiarylist') {
$setenablesubsidiarylist = GETPOST('value', 'int'); $setenablesubsidiarylist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
if (!$res > 0) if (!$res > 0)
$error++; $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'mesgs'); setEventMessages($langs->trans("Error"), null, 'mesgs');
} }
}
if ($action == 'setdisablebindingonsales') {
$setdisablebindingonsales = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity);
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
}
}
if ($action == 'setdisablebindingonpurchases') {
$setdisablebindingonpurchases = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity);
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
}
}
if ($action == 'setdisablebindingonexpensereports') {
$setdisablebindingonexpensereports = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity);
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
}
} }
/* /*
* View * View
*/ */
$form = new Form($db);
$title = $langs->trans('ConfigAccountingExpert'); $title = $langs->trans('ConfigAccountingExpert');
llxHeader('', $title); llxHeader('', $title);
@ -170,155 +225,187 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
// Default mode for calculating turnover (parameter ACCOUNTING_MODE) // Params
/*
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>'; print '<td colspan="2">'.$langs->trans('Options').'</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr ' . $bc[false] . '><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"' . ($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '') . '> ' . $langs->trans('OptionModeTrue') . '</td>';
print '<td colspan="2">' . nl2br($langs->trans('OptionModeTrueDesc'));
// Write info on way to count VAT
// if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
// {
// // print "<br>\n";
// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
// }
// else
// {
// // print "<br>\n";
// // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
// }
print "</td></tr>\n";
print '<tr ' . $bc[true] . '><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"' . ($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '') . '> ' . $langs->trans('OptionModeVirtual') . '</td>';
print '<td colspan="2">' . nl2br($langs->trans('OptionModeVirtualDesc')) . "</td></tr>\n";
print "</table>\n"; // TO DO Mutualize code for yes/no constants
/* Set this option as a hidden option but keep it for some needs.
print '<br>'; print '<tr>';
print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enabledraftexport&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enabledraftexport&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
*/ */
// Others params print '<tr class="oddeven">';
print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
print '<table class="noborder centpercent">'; if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
print '<tr class="liste_titre">'; print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disabledirectinput&value=0">';
print '<td colspan="2">'.$langs->trans('OtherOptions').'</td>'; print img_picto($langs->trans("Activated"), 'switch_on');
print "</tr>\n"; print '</a></td>';
} else {
if (!empty($user->admin)) print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disabledirectinput&value=1">';
{ print img_picto($langs->trans("Disabled"), 'switch_off');
// TO DO Mutualize code for yes/no constants print '</a></td>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
/* Set this option as a hidden option but keep it for some needs.
print '<tr>';
print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
*/
print '<tr>';
print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
} }
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&managezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&managezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
// Param a user $user->rights->accounting->chartofaccount can access // Param a user $user->rights->accounting->chartofaccount can access
foreach ($list as $key) foreach ($list as $key)
{ {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
// Param // Param
$label = $langs->trans($key); $label = $langs->trans($key);
print '<td>'.$label.'</td>'; print '<td>'.$label.'</td>';
// Value // Value
print '<td class="right">'; print '<td class="right">';
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">'; print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td>';
print '</tr>'; print '</td>';
print '</tr>';
}
print '</table>';
print '<br>';
// Binding params
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans('BindingOptions').'</td>';
print "</tr>\n";
// TO DO Mutualize code for yes/no constants
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsorttodo&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsorttodo&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsortdone&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsortdone&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
// Param a user $user->rights->accounting->chartofaccount can access
foreach ($list_binding as $key)
{
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
print '<td>'.$label.'</td>';
// Value
print '<td class="right">';
if ($key == 'ACCOUNTING_DATE_START_BINDING') {
print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1);
} elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
$array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear"));
print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0));
} else {
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
}
print '</td>';
print '</tr>';
} }
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").'</td>';
if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonsales&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonsales&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").'</td>';
if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonpurchases&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonpurchases&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").'</td>';
if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonexpensereports&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonexpensereports&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '</table>'; print '</table>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>'; print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
print '<br>';
print '<br>';
print '<br>';
print '</form>'; print '</form>';
// End of page // End of page

View File

@ -22,6 +22,8 @@
* \brief Setup page to configure journals * \brief Setup page to configure journals
*/ */
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 '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
@ -238,13 +240,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id'=>$id); // Clean $_POST array, we keep only $_POST = array('id'=>$id); // Clean $_POST array, we keep only
} } else {
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
} } else {
else {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -253,8 +252,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha'))
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
@ -269,8 +267,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') { if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
} } elseif ($field == 'entity') {
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) $sql .= ",";
@ -279,7 +276,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = '".$rowid."'"; $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
@ -300,10 +297,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
@ -313,9 +309,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{ {
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} } else {
else
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -324,14 +318,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$db->escape($code)."'";
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
} }
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
@ -345,14 +337,12 @@ if ($action == $acts[0])
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
} } elseif ($code) {
elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$db->escape($code)."'";
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
} }
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
@ -595,9 +585,7 @@ if ($id)
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>'; print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
print '</td>'; print '</td>';
} } else {
else
{
$tmpaction = 'view'; $tmpaction = 'view';
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
@ -614,12 +602,10 @@ if ($id)
$valuetoshow = $obj->{$fieldlist[$field]}; $valuetoshow = $obj->{$fieldlist[$field]};
if ($valuetoshow == 'all') { if ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All'); $valuetoshow = $langs->trans('All');
} } elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
$key = $langs->trans("AccountingJournalType".strtoupper($obj->nature)); $key = $langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]}); $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
} } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
$valuetoshow = $langs->trans($obj->label); $valuetoshow = $langs->trans($obj->label);
} }
@ -652,23 +638,22 @@ if ($id)
// Active // Active
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
else print $langs->trans("AlwaysActive"); else print $langs->trans("AlwaysActive");
print "</td>"; print "</td>";
// Modify link // Modify link
if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit">'.img_edit().'</a></td>'; if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
else print '<td>&nbsp;</td>'; else print '<td>&nbsp;</td>';
// Delete link // Delete link
if ($iserasable) if ($iserasable)
{ {
print '<td class="center">'; print '<td class="center">';
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>'; if ($user->admin) print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
print '</td>'; print '</td>';
} } else print '<td>&nbsp;</td>';
else print '<td>&nbsp;</td>';
print '<td></td>'; print '<td></td>';
@ -679,8 +664,7 @@ if ($id)
$i++; $i++;
} }
} }
} } else {
else {
dol_print_error($db); dol_print_error($db);
} }
@ -724,12 +708,9 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
print '<td>'; print '<td>';
print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
print '</td>'; print '</td>';
} } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
} } else {
else
{
print '<td>'; print '<td>';
$size = ''; $class = ''; $size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; if ($fieldlist[$field] == 'code') $class = 'maxwidth100';

View File

@ -57,6 +57,7 @@ $changeaccount_sell = GETPOST('changeaccount_sell', 'array');
$search_ref = GETPOST('search_ref', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_current_account = GETPOST('search_current_account', 'alpha'); $search_current_account = GETPOST('search_current_account', 'alpha');
$search_current_account_valid = GETPOST('search_current_account_valid', 'alpha'); $search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount'; if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount';
@ -102,6 +103,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_ref = ''; $search_ref = '';
$search_label = ''; $search_label = '';
$search_desc = ''; $search_desc = '';
$search_vat = '';
$search_onsell = ''; $search_onsell = '';
$search_onpurchase = ''; $search_onpurchase = '';
$search_current_account = ''; $search_current_account = '';
@ -136,7 +138,7 @@ if ($action == 'update') {
if (!empty($chk_prod)) { if (!empty($chk_prod)) {
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
//$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>'; //$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
$arrayofdifferentselectedvalues = array(); $arrayofdifferentselectedvalues = array();
$cpt = 0; $ok = 0; $ko = 0; $cpt = 0; $ok = 0; $ko = 0;
@ -152,7 +154,7 @@ if ($action == 'update') {
} }
if ($result <= 0) { if ($result <= 0) {
// setEventMessages(null, $accounting->errors, 'errors'); // setEventMessages(null, $accounting->errors, 'errors');
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br/> <pre>'.$sql.'</pre></font></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br/> <pre>'.$sql.'</pre></span></div>';
$ko++; $ko++;
} else { } else {
$db->begin(); $db->begin();
@ -176,7 +178,7 @@ if ($action == 'update') {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
} }
$sql .= " WHERE rowid = ".$productid; $sql .= " WHERE rowid = ".((int) $productid);
dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql)) if ($db->query($sql))
@ -243,7 +245,7 @@ $pcgverid = $conf->global->CHARTOFACCOUNTS;
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
if (empty($pcgvercode)) $pcgvercode = $pcgverid; if (empty($pcgvercode)) $pcgvercode = $pcgverid;
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,"; $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
$sql .= " p.tms, p.fk_product_type as product_type,"; $sql .= " p.tms, p.fk_product_type as product_type,";
@ -251,27 +253,21 @@ $sql .= " aa.rowid as aaid";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA')
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA')
{ {
$sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
{ {
$sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; $sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL')
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL')
{ {
$sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
{ {
$sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'"; $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} } else {
else $sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
{
$sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$pcgvercode."'";
} }
$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
@ -290,13 +286,11 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell", $search_current_account); $sql .= natural_search("p.accountancy_code_sell", $search_current_account);
} }
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account);
} }
} } else {
else {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account);
} }
@ -319,6 +313,9 @@ if (strlen(trim($search_label))) {
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= natural_search("p.description", $search_desc); $sql .= natural_search("p.description", $search_desc);
} }
if (strlen(trim($search_vat))) {
$sql .= natural_search("p.tva_tx", price2num($search_vat), 1);
}
if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1); if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1);
if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1); if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1);
@ -351,6 +348,7 @@ if ($result)
if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat);
if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid);
if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode);
@ -419,6 +417,8 @@ if ($result)
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" size="5" name="search_vat" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
// On sell // On sell
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
@ -445,7 +445,8 @@ if ($result)
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
// On sell / On purchase print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
// On sell / On purchase
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount = "p.accountancy_code_sell"; $fieldtosortaccount = "p.accountancy_code_sell";
@ -492,34 +493,27 @@ if ($result)
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell; $compta_prodsell_id = $aarowid_prodsell;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra; $compta_prodsell_id = $aarowid_prodsell_intra;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export; $compta_prodsell_id = $aarowid_prodsell_export;
} } else {
else {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell; $compta_prodsell_id = $aarowid_prodsell;
} }
} } else {
else {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell; $compta_prodsell_id = $aarowid_servsell;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell_intra; $compta_prodsell_id = $aarowid_servsell_intra;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell_export; $compta_prodsell_id = $aarowid_servsell_export;
} } else {
else {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell; $compta_prodsell_id = $aarowid_servsell;
} }
@ -530,34 +524,27 @@ if ($result)
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy; $compta_prodbuy_id = $aarowid_prodbuy;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy_intra; $compta_prodbuy_id = $aarowid_prodbuy_intra;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy_export; $compta_prodbuy_id = $aarowid_prodbuy_export;
} } else {
else {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy; $compta_prodbuy_id = $aarowid_prodbuy;
} }
} } else {
else {
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy; $compta_prodbuy_id = $aarowid_servbuy;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy_intra; $compta_prodbuy_id = $aarowid_servbuy_intra;
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy_export; $compta_prodbuy_id = $aarowid_servbuy_export;
} } else {
else {
$compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_servbuy; $compta_prodbuy_id = $aarowid_servbuy;
} }
@ -575,11 +562,16 @@ if ($result)
{ {
// TODO ADJUST DESCRIPTION SIZE // TODO ADJUST DESCRIPTION SIZE
// print '<td class="left">' . $obj->description . '</td>'; // print '<td class="left">' . $obj->description . '</td>';
// TODO: we shoul set a user defined value to adjust user square / wide screen size // TODO: we should set a user defined value to adjust user square / wide screen size
$trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print '<td>'.nl2br(dol_trunc($obj->description, $trunclengh)).'</td>'; print '<td>'.nl2br(dol_trunc($obj->description, $trunclength)).'</td>';
} }
// VAT
print '<td class="right">';
print vatrate($obj->tva_tx);
print '</td>';
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT')
print '<td class="center">'.$product_static->getLibStatut(3, 0).'</td>'; print '<td class="center">'.$product_static->getLibStatut(3, 0).'</td>';
@ -620,21 +612,21 @@ if ($result)
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1);
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
// Accounting account buy intra (In EEC) // Accounting account buy intra (In EEC)
print '<td class="left">'; print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_intra; if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy;
$codesell = length_accountg($obj->accountancy_code_buy_intra); $codesell = length_accountg($obj->accountancy_code_buy_intra);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1);
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
// Accounting account buy export (Out of EEC) // Accounting account buy export (Out of EEC)
print '<td class="left">'; print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy_export; if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy;
$codesell = length_accountg($obj->accountancy_code_buy_export); $codesell = length_accountg($obj->accountancy_code_buy_export);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid

View File

@ -0,0 +1,419 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/admin/subaccount.php
* \ingroup Accountancy (Double entries)
* \brief List of accounting sub-account (auxiliary accounts)
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "hrm", "errors"));
$mesg = '';
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
$massaction = GETPOST('massaction', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingsubaccountlist'; // To manage different context of search
$search_subaccount = GETPOST('search_subaccount', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_type = GETPOST('search_type', 'int');
// Security check
if ($user->socid > 0) accessforbidden();
if (!$user->rights->accounting->chartofaccount) accessforbidden();
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "label";
if (!$sortorder) $sortorder = "ASC";
$arrayfields = array(
'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
'label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1)
);
if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['reconcilable']);
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
$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 (empty($reshook))
{
if (!empty($cancel)) $action = '';
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{
$search_subaccount = "";
$search_label = "";
$search_type = "";
$search_array_options = array();
}
}
/*
* View
*/
$form = new Form($db);
$title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger');
llxHeader('', $title);
// Customer
$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '0' as type, sa.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."societe sa";
$sql .= " WHERE sa.entity IN (".getEntity('societe').")";
$sql .= " AND sa.code_compta <> ''";
//print $sql;
if (strlen(trim($search_subaccount))) {
$lengthpaddingaccount = 0;
if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
$lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
}
$search_subaccount_tmp = $search_subaccount;
$weremovedsomezero = 0;
if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
for ($i = 0; $i < $lengthpaddingaccount; $i++) {
if (preg_match('/0$/', $search_subaccount_tmp)) {
$weremovedsomezero++;
$search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
}
}
}
//var_dump($search_subaccount); exit;
if ($search_subaccount_tmp) {
if ($weremovedsomezero) {
$search_subaccount_tmp_clean = $search_subaccount_tmp;
$search_subaccount_clean = $search_subaccount;
$startchar = '%';
if (strpos($search_subaccount_tmp, '^') === 0)
{
$startchar = '';
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
}
$sql .= " AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
$sql .= " OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
} else $sql .= natural_search("sa.code_compta", $search_subaccount_tmp);
}
}
if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label);
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
// Supplier
$sql .= " UNION ";
$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '1' as type, sa.entity FROM ".MAIN_DB_PREFIX."societe sa";
$sql .= " WHERE sa.entity IN (".getEntity('societe').")";
$sql .= " AND sa.code_compta_fournisseur <> ''";
//print $sql;
if (strlen(trim($search_subaccount))) {
$lengthpaddingaccount = 0;
if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
$lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
}
$search_subaccount_tmp = $search_subaccount;
$weremovedsomezero = 0;
if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
for ($i = 0; $i < $lengthpaddingaccount; $i++) {
if (preg_match('/0$/', $search_subaccount_tmp)) {
$weremovedsomezero++;
$search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
}
}
}
//var_dump($search_subaccount); exit;
if ($search_subaccount_tmp) {
if ($weremovedsomezero) {
$search_subaccount_tmp_clean = $search_subaccount_tmp;
$search_subaccount_clean = $search_subaccount;
$startchar = '%';
if (strpos($search_subaccount_tmp, '^') === 0)
{
$startchar = '';
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
}
$sql .= " AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
$sql .= " OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
} else $sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp);
}
}
if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label);
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
// User
$sql .= " UNION ";
$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '2' as type, u.entity FROM ".MAIN_DB_PREFIX."user u";
$sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.accountancy_code <> ''";
//print $sql;
if (strlen(trim($search_subaccount))) {
$lengthpaddingaccount = 0;
if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
$lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT);
}
$search_subaccount_tmp = $search_subaccount;
$weremovedsomezero = 0;
if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
for ($i = 0; $i < $lengthpaddingaccount; $i++) {
if (preg_match('/0$/', $search_subaccount_tmp)) {
$weremovedsomezero++;
$search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
}
}
}
//var_dump($search_subaccount); exit;
if ($search_subaccount_tmp) {
if ($weremovedsomezero) {
$search_subaccount_tmp_clean = $search_subaccount_tmp;
$search_subaccount_clean = $search_subaccount;
$startchar = '%';
if (strpos($search_subaccount_tmp, '^') === 0)
{
$startchar = '';
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
}
$sql .= " AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
$sql .= " OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
} else $sql .= natural_search("u.accountancy_code", $search_subaccount_tmp);
}
}
if (strlen(trim($search_label))) $sql .= natural_search("u.lastname", $search_label);
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
}
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/admin/subaccount.php:: $sql='.$sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_subaccount) $param .= '&search_subaccount='.urlencode($search_subaccount);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
print '<div class="warning">'.$langs->trans("WarningCreateSubAccounts").'</div>';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$moreforfilter = '';
$massactionbutton = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Line for search fields
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['subaccount']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.'"></td>';
if (!empty($arrayfields['label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
if (!empty($arrayfields['type']['checked'])) print '<td class="liste_titre center">'.$form->selectarray('search_type', array('0'=>$langs->trans('Customer'), '1'=>$langs->trans('Supplier'), '2'=>$langs->trans('Employee')), $search_type, 1).'</td>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; }
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
if (!empty($arrayfields['subaccount']['checked'])) print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['label']['checked'])) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center '); }
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$totalarray = array();
$i = 0;
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
// Account number
if (!empty($arrayfields['subaccount']['checked']))
{
print "<td>";
print length_accounta($obj->subaccount);
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Subaccount label
if (!empty($arrayfields['label']['checked']))
{
print "<td>";
print $obj->label;
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Type
if (!empty($arrayfields['type']['checked']))
{
print '<td class="center">';
$s = '';
// Customer
if ($obj->type == 0)
{
$s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">'.$langs->trans("Customer").'</a>';
}
// Supplier
elseif ($obj->type == 1)
{
$s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>';
}
// User
elseif ($obj->type == 2)
{
$s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->id.'">'.$langs->trans("Employee").'</a>';
}
print $s;
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
// Activated or not reconciliation on accounting account
if (!empty($arrayfields['reconcilable']['checked'])) {
print '<td class="center">';
if (empty($obj->reconcilable)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
}
// Action
print '<td class="center">';
$e = '';
// Customer
if ($obj->type == 0)
{
$e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
}
// Supplier
elseif ($obj->type == 1)
{
$e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
}
// User
elseif ($obj->type == 2)
{
$e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
}
print $e;
print '</td>'."\n";
if (!$i) $totalarray['nbfield']++;
print '</tr>'."\n";
$i++;
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>";
print "</div>";
print '</form>';
} else {
dol_print_error($db);
}
// End of page
llxFooter();
$db->close();

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2016-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,6 +31,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@ -45,8 +46,8 @@ $action = GETPOST('action', 'aZ09');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page; $offset = $limit * $page;
@ -55,7 +56,7 @@ $pagenext = $page + 1;
//if (! $sortfield) $sortfield="p.date_fin"; //if (! $sortfield) $sortfield="p.date_fin";
//if (! $sortorder) $sortorder="DESC"; //if (! $sortorder) $sortorder="DESC";
$show_subgroup = GETPOST('show_subgroup', 'alpha');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
@ -130,10 +131,11 @@ if (!empty($search_accountancy_code_end)) {
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$search_accountancy_code_start = ''; $show_subgroup = '';
$search_accountancy_code_end = '';
$search_date_start = ''; $search_date_start = '';
$search_date_end = ''; $search_date_end = '';
$search_accountancy_code_start = '';
$search_accountancy_code_end = '';
$filter = array(); $filter = array();
} }
@ -223,6 +225,12 @@ if ($action != 'export_csv')
$moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0); $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateEnd').': '; $moreforfilter .= $langs->trans('DateEnd').': ';
$moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0); $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0);
$moreforfilter .= ' - ';
$moreforfilter .= $langs->trans('ShowSubtotalByGroup').': ';
$moreforfilter .= '<input type="checkbox" name="show_subgroup" value="show_subgroup"'.($show_subgroup == 'show_subgroup' ? ' checked' : '').'>';
$moreforfilter .= '</div>'; $moreforfilter .= '</div>';
if (!empty($moreforfilter)) { if (!empty($moreforfilter)) {
@ -237,15 +245,15 @@ if ($action != 'export_csv')
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">'; print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="6">'; print '<td class="liste_titre" colspan="5">';
print $langs->trans('From'); print $langs->trans('From');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
print ' '; print ' ';
print $langs->trans('to'); print $langs->trans('to');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
print '</td>'; print '</td>';
print '<td class="liste_titre right">'; print '<td class="liste_titre center">';
$searchpicto = $form->showFilterAndCheckAddButtons(0); $searchpicto = $form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
@ -253,7 +261,6 @@ if ($action != 'export_csv')
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
@ -267,6 +274,8 @@ if ($action != 'export_csv')
$sous_total_credit = 0; $sous_total_credit = 0;
$displayed_account = ""; $displayed_account = "";
$accountingaccountstatic = new AccountingAccount($db);
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
$sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features
@ -283,44 +292,54 @@ if ($action != 'export_csv')
foreach ($object->lines as $line) foreach ($object->lines as $line)
{ {
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
if (!empty($accountingaccountstatic->account_number)) {
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
} else {
$accounting_account = length_accountg($line->numero_compte);
}
$link = ''; $link = '';
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
$root_account_description = $object->get_compte_racine($line->numero_compte); $root_account_description = $object->get_compte_racine($line->numero_compte);
if (empty($description)) { if (empty($accountingaccountstatic->account_number)) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>'; $link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Display the accounting account if (!empty($show_subgroup))
if (empty($displayed_account) || $root_account_description != $displayed_account)
{ {
// Display a sub-total per account // Show accounting account
if ($displayed_account != "") { if (empty($displayed_account) || $root_account_description != $displayed_account) {
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_credit - $sous_total_debit)).'</td>'; // Show subtotal per accounting account
print "<td>&nbsp;</td>\n"; if ($displayed_account != "") {
print '<tr class="liste_total">';
print '<td class="right" colspan="2">'.$langs->trans("SubTotal").':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_credit - $sous_total_debit)).'</td>';
print "<td></td>\n";
print '</tr>';
}
// Show first line of a break
print '<tr class="trforbreak">';
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '</tr>'; print '</tr>';
$displayed_account = $root_account_description;
$sous_total_debit = 0;
$sous_total_credit = 0;
} }
// Show first line of a break
print '<tr class="trforbreak">';
print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '</tr>';
$displayed_account = $root_account_description;
$sous_total_debit = 0;
$sous_total_credit = 0;
} }
// $object->get_compte_racine($line->numero_compte); // $object->get_compte_racine($line->numero_compte);
print '<td>'.$accounting_account.'</td>';
print '<td>'.length_accountg($line->numero_compte).'</td>';
print '<td>'.$description.'</td>';
print '<td class="nowraponall right">'.price($opening_balances["'".$line->numero_compte."'"]).'</td>'; print '<td class="nowraponall right">'.price($opening_balances["'".$line->numero_compte."'"]).'</td>';
print '<td class="nowraponall right">'.price($line->debit).'</td>'; print '<td class="nowraponall right">'.price($line->debit).'</td>';
print '<td class="nowraponall right">'.price($line->credit).'</td>'; print '<td class="nowraponall right">'.price($line->credit).'</td>';
print '<td class="nowraponall right">'.price($line->debit - $line->credit).'</td>'; print '<td class="nowraponall right">'.price(price2num($line->debit - $line->credit, 'MT')).'</td>';
print '<td class="center">'.$link; print '<td class="center">'.$link;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -330,12 +349,15 @@ if ($action != 'export_csv')
$sous_total_credit += $line->credit; $sous_total_credit += $line->credit;
} }
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>'; if (!empty($show_subgroup))
print "<td>&nbsp;</td>\n"; {
print '</tr>'; print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
print "<td></td>\n";
print '</tr>';
}
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>'; print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
print "<td>&nbsp;</td>\n"; print "<td></td>\n";
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";

View File

@ -114,11 +114,13 @@ if ($action == "confirm_update") {
$object->credit = $credit; $object->credit = $credit;
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$object->montant = $debit; $object->montant = $debit; // deprecated
$object->amount = $debit;
$object->sens = 'D'; $object->sens = 'D';
} }
if (floatval($credit) != 0.0) { if (floatval($credit) != 0.0) {
$object->montant = $credit; $object->montant = $credit; // deprecated
$object->amount = $credit;
$object->sens = 'C'; $object->sens = 'C';
} }
@ -138,9 +140,7 @@ if ($action == "confirm_update") {
} }
} }
} }
} } elseif ($action == "add") {
elseif ($action == "add") {
$error = 0; $error = 0;
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0))
@ -175,12 +175,14 @@ elseif ($action == "add") {
$object->fk_docdet = (int) GETPOST('fk_docdet', 'int'); $object->fk_docdet = (int) GETPOST('fk_docdet', 'int');
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$object->montant = $debit; $object->montant = $debit; // deprecated
$object->amount = $debit;
$object->sens = 'D'; $object->sens = 'D';
} }
if (floatval($credit) != 0.0) { if (floatval($credit) != 0.0) {
$object->montant = $credit; $object->montant = $credit; // deprecated
$object->amount = $credit;
$object->sens = 'C'; $object->sens = 'C';
} }
@ -199,9 +201,7 @@ elseif ($action == "add") {
$action = ''; $action = '';
} }
} }
} } elseif ($action == "confirm_delete") {
elseif ($action == "confirm_delete") {
$object = new BookKeeping($db); $object = new BookKeeping($db);
$result = $object->fetch($id, null, $mode); $result = $object->fetch($id, null, $mode);
@ -216,9 +216,7 @@ elseif ($action == "confirm_delete") {
} }
} }
$action = ''; $action = '';
} } elseif ($action == "confirm_create") {
elseif ($action == "confirm_create") {
$error = 0; $error = 0;
$object = new BookKeeping($db); $object = new BookKeeping($db);
@ -247,7 +245,8 @@ elseif ($action == "confirm_create") {
$object->journal_label = $journal_label; $object->journal_label = $journal_label;
$object->fk_doc = 0; $object->fk_doc = 0;
$object->fk_docdet = 0; $object->fk_docdet = 0;
$object->montant = 0; $object->montant = 0; // deprecated
$object->amount = 0;
$result = $object->createStd($user, 0, $mode); $result = $object->createStd($user, 0, $mode);
if ($result < 0) { if ($result < 0) {
@ -293,7 +292,7 @@ if ($action == 'setjournal') {
} }
if ($action == 'setdocref') { if ($action == 'setdocref') {
$refdoc = trim(GETPOST('doc_ref', 'alpha')); $refdoc = GETPOST('doc_ref', 'alpha');
$result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode); $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -329,7 +328,7 @@ llxHeader('', $langs->trans("CreateMvts"));
// Confirmation to delete the command // Confirmation to delete the command
if ($action == 'delete') { if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'confirm_delete', '', 0, 1);
print $formconfirm; print $formconfirm;
} }
@ -628,9 +627,7 @@ if ($action == 'create')
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{ {
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1);
} } else {
else
{
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">'; print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
} }
print '</td>'; print '</td>';
@ -685,9 +682,7 @@ if ($action == 'create')
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{ {
print $formaccounting->select_auxaccount('', 'subledger_account', 1); print $formaccounting->select_auxaccount('', 'subledger_account', 1);
} } else {
else
{
print '<input type="text" class="maxwidth150" name="subledger_account" value="">'; print '<input type="text" class="maxwidth150" name="subledger_account" value="">';
} }
print '</td>'; print '</td>';
@ -707,9 +702,7 @@ if ($action == 'create')
if ($total_debit == $total_credit) if ($total_debit == $total_credit)
{ {
print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>'; print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>';
} } else {
else
{
print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">'; print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">';
} }

View File

@ -91,8 +91,8 @@ $search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page; $offset = $limit * $page;
@ -108,7 +108,7 @@ $hookmanager->initHooks(array('bookkeepinglist'));
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$form = new Form($db); $form = new Form($db);
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !isset($_POST['begin']) && !isset($_GET['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') && !isset($_POST['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')) if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values'))
{ {
@ -351,18 +351,14 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} } else {
else
{
setEventMessages("RecordDeleted", null, 'mesgs'); setEventMessages("RecordDeleted", null, 'mesgs');
} }
// Make a redirect to avoid to launch the delete later after a back button // Make a redirect to avoid to launch the delete later after a back button
header("Location: list.php".($param ? '?'.$param : '')); header("Location: list.php".($param ? '?'.$param : ''));
exit; exit;
} } else {
else
{
setEventMessages("NoRecordDeleted", null, 'warnings'); setEventMessages("NoRecordDeleted", null, 'warnings');
} }
} }
@ -373,9 +369,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
$result = $object->deleteMvtNum($mvt_num); $result = $object->deleteMvtNum($mvt_num);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} } else {
else
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} }
@ -418,7 +412,7 @@ $sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.lettering_code,"; $sql .= " t.lettering_code,";
$sql .= " t.montant,"; $sql .= " t.montant as amount,";
$sql .= " t.sens,"; $sql .= " t.sens,";
$sql .= " t.fk_user_author,"; $sql .= " t.fk_user_author,";
$sql .= " t.import_key,"; $sql .= " t.import_key,";
@ -480,9 +474,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} } else {
else
{
// Export files // Export files
$accountancyexport = new AccountancyExport($db); $accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines, $formatexportset); $accountancyexport->export($object->lines, $formatexportset);
@ -490,9 +482,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
if (!empty($accountancyexport->errors)) if (!empty($accountancyexport->errors))
{ {
setEventMessages('', $accountancyexport->errors, 'errors'); setEventMessages('', $accountancyexport->errors, 'errors');
} } else {
else
{
// Specify as export : update field date_export // Specify as export : update field date_export
$error = 0; $error = 0;
$db->begin(); $db->begin();
@ -521,9 +511,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
{ {
$db->commit(); $db->commit();
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
} } else {
else
{
$error++; $error++;
$db->rollback(); $db->rollback();
setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors');
@ -541,7 +529,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
$formother = new FormOther($db); $formother = new FormOther($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$title_page = $langs->trans("Bookkeeping"); $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
@ -559,9 +547,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
{ {
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} } else {
else
{
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
@ -622,41 +608,43 @@ if ($action == 'delbookkeepingyear') {
'default' => $deljournal 'default' => $deljournal
); );
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
print $formconfirm; print $formconfirm;
} }
//$param=''; param started before //$param=''; param started before
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.urlencode($sortfield).'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">';
print '<input type="hidden" name="page" value="'.$page.'">';
if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList");
else $buttonLabel = $langs->trans("ExportList"); else $buttonLabel = $langs->trans("ExportList");
// Button re-export // Button re-export
if (!empty($conf->global->ACCOUNTING_REEXPORT)) { if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> '; $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
} else { } else {
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> '; $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
} }
$newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>'; $newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
$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('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); $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('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer); $url = './card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid;
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
@ -682,12 +670,10 @@ if (!empty($arrayfields['t.doc_date']['checked']))
{ {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From').' '; print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to').' '; print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} }
@ -715,29 +701,25 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From').' ';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database. // use setup of keypress to select thirdparty and this hang browser on large database.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{ {
print $langs->trans('From').' ';
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
} } else {
else print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'" placeholder="'.$langs->trans("From").'">';
{
print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
} }
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to').' ';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database. // use setup of keypress to select thirdparty and this hang browser on large database.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{ {
print $langs->trans('to').' ';
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
} } else {
else print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'" placeholder="'.$langs->trans("to").'">';
{
print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
} }
print '</div>'; print '</div>';
print '</td>'; print '</td>';
@ -787,12 +769,10 @@ if (!empty($arrayfields['t.date_creation']['checked']))
{ {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From').' '; print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to').' '; print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} }
@ -801,12 +781,10 @@ if (!empty($arrayfields['t.tms']['checked']))
{ {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From').' '; print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to').' '; print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} }
@ -815,12 +793,10 @@ if (!empty($arrayfields['t.date_export']['checked']))
{ {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From').' '; print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to').' '; print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} }
@ -878,7 +854,8 @@ while ($i < min($num, $limit))
$line->label_operation = $obj->label_operation; $line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->amount; // deprecated
$line->amount = $obj->amount;
$line->sens = $obj->sens; $line->sens = $obj->sens;
$line->lettering_code = $obj->lettering_code; $line->lettering_code = $obj->lettering_code;
$line->fk_user_author = $obj->fk_user_author; $line->fk_user_author = $obj->fk_user_author;
@ -929,8 +906,7 @@ while ($i < min($num, $limit))
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} } elseif ($line->doc_type == 'supplier_invoice')
elseif ($line->doc_type == 'supplier_invoice')
{ {
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
@ -943,8 +919,7 @@ while ($i < min($num, $limit))
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} } elseif ($line->doc_type == 'expense_report')
elseif ($line->doc_type == 'expense_report')
{ {
$langs->loadLangs(array('trips')); $langs->loadLangs(array('trips'));
@ -957,9 +932,7 @@ while ($i < min($num, $limit))
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} } else {
else
{
// Other type // Other type
} }
@ -1068,10 +1041,10 @@ while ($i < min($num, $limit))
print '<td class="nowraponall center">'; print '<td class="nowraponall center">';
if (empty($line->date_export)) { if (empty($line->date_export)) {
if ($user->rights->accounting->mouvements->creer) { if ($user->rights->accounting->mouvements->creer) {
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>'; print '<a class="editfielda paddingleft marginrightonly" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>';
} }
if ($user->rights->accounting->mouvements->supprimer) { if ($user->rights->accounting->mouvements->supprimer) {
print '&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>'; print '<a class="reposition paddingleft marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
} }
} }
print '</td>'; print '</td>';

View File

@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("accountancy")); $langs->loadLangs(array("accountancy"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
@ -54,6 +54,7 @@ if ($search_accountancy_code_end == - 1) {
} }
$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
$search_label_operation = GETPOST('search_label_operation', 'alpha'); $search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_direction = GETPOST('search_direction', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_debit = GETPOST('search_debit', 'alpha'); $search_debit = GETPOST('search_debit', 'alpha');
@ -67,8 +68,8 @@ if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page; $offset = $limit * $page;
@ -79,12 +80,13 @@ if ($sortfield == "") $sortfield = "t.doc_date,t.rowid";
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new BookKeeping($db); $object = new BookKeeping($db);
$formfile = new FormFile($db);
$hookmanager->initHooks(array('bookkeepingbyaccountlist')); $hookmanager->initHooks(array('bookkeepingbyaccountlist'));
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$form = new Form($db); $form = new Form($db);
if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search_date_startday') && GETPOSTISSET('search_date_startmonth') && GETPOSTISSET('search_date_starthour')) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) {
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql .= $db->plimit(1); $sql .= $db->plimit(1);
@ -147,6 +149,7 @@ if (empty($reshook))
$search_label_account = ''; $search_label_account = '';
$search_doc_ref = ''; $search_doc_ref = '';
$search_label_operation = ''; $search_label_operation = '';
$search_mvt_num = '';
$search_direction = ''; $search_direction = '';
$search_ledger_code = ''; $search_ledger_code = '';
$search_date_start = ''; $search_date_start = '';
@ -191,6 +194,10 @@ if (empty($reshook))
$filter['t.label_compte'] = $search_label_account; $filter['t.label_compte'] = $search_label_account;
$param .= '&search_label_compte=' . urlencode($search_label_account); $param .= '&search_label_compte=' . urlencode($search_label_account);
} }
if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
$param .= '&search_mvt_num=' . urlencode($search_mvt_num);
}
if (!empty($search_doc_ref)) { if (!empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref; $filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref=' . urlencode($search_doc_ref); $param .= '&search_doc_ref=' . urlencode($search_doc_ref);
@ -255,18 +262,14 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} } else {
else
{
setEventMessages("RecordDeleted", null, 'mesgs'); setEventMessages("RecordDeleted", null, 'mesgs');
} }
// Make a redirect to avoid to launch the delete later after a back button // Make a redirect to avoid to launch the delete later after a back button
header("Location: listbyaccount.php".($param ? '?'.$param : '')); header("Location: listbyaccount.php".($param ? '?'.$param : ''));
exit; exit;
} } else {
else
{
setEventMessages("NoRecordDeleted", null, 'warnings'); setEventMessages("NoRecordDeleted", null, 'warnings');
} }
} }
@ -277,9 +280,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
$result = $object->deleteMvtNum($mvt_num); $result = $object->deleteMvtNum($mvt_num);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} } else {
else
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} }
@ -298,7 +299,7 @@ $formfile = new FormFile($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$form = new Form($db); $form = new Form($db);
$title_page = $langs->trans("Bookkeeping").' '.strtolower($langs->trans("By")).' '.strtolower($langs->trans("AccountAccounting")); $title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("Bookkeeping").')';
llxHeader('', $title_page); llxHeader('', $title_page);
@ -362,7 +363,7 @@ if ($action == 'delbookkeepingyear') {
'default' => $deljournal 'default' => $deljournal
); );
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
print $formconfirm; print $formconfirm;
} }
@ -374,16 +375,19 @@ if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$opt
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); $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 .= ' &nbsp; ';
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create');
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit, 0, 0, 1);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
@ -398,10 +402,10 @@ $moreforfilter = '';
// Accountancy account // Accountancy account
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('AccountAccounting').': '; $moreforfilter .= $langs->trans('AccountAccounting').': ';
$moreforfilter .= '<div class="nowrap">'; $moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $langs->trans('From').' '; $moreforfilter .= $langs->trans('From').' ';
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
$moreforfilter .= $langs->trans('to').' '; $moreforfilter .= ' '.$langs->trans('to').' ';
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
$moreforfilter .= '</div>'; $moreforfilter .= '</div>';
$moreforfilter .= '</div>'; $moreforfilter .= '</div>';
@ -429,12 +433,10 @@ if (!empty($arrayfields['t.code_journal']['checked'])) {
if (!empty($arrayfields['t.doc_date']['checked'])) { if (!empty($arrayfields['t.doc_date']['checked'])) {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From') . ': '; print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to') . ': '; print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} }
@ -539,9 +541,7 @@ while ($i < min($num, $limit))
print price($sous_total_debit - $sous_total_credit); print price($sous_total_debit - $sous_total_credit);
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
} } else {
else
{
print '<td></td>'; print '<td></td>';
print '<td class="nowraponall right">'; print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit); print price($sous_total_credit - $sous_total_debit);
@ -613,8 +613,7 @@ while ($i < min($num, $limit))
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} } elseif ($line->doc_type == 'supplier_invoice')
elseif ($line->doc_type == 'supplier_invoice')
{ {
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
@ -627,8 +626,7 @@ while ($i < min($num, $limit))
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} } elseif ($line->doc_type == 'expense_report')
elseif ($line->doc_type == 'expense_report')
{ {
$langs->loadLangs(array('trips')); $langs->loadLangs(array('trips'));
@ -641,9 +639,7 @@ while ($i < min($num, $limit))
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} } else {
else
{
// Other type // Other type
} }
@ -707,10 +703,10 @@ while ($i < min($num, $limit))
print '<td class="nowraponall center">'; print '<td class="nowraponall center">';
if (empty($line->date_export)) { if (empty($line->date_export)) {
if ($user->rights->accounting->mouvements->creer) { if ($user->rights->accounting->mouvements->creer) {
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>'; print '<a class="editfielda" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>';
} }
if ($user->rights->accounting->mouvements->supprimer) { if ($user->rights->accounting->mouvements->supprimer) {
print '&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>'; print ' &nbsp; <a class="paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
} }
} }
print '</td>'; print '</td>';
@ -744,9 +740,7 @@ if ($balance > 0 )
print price($sous_total_debit - $sous_total_credit); print price($sous_total_debit - $sous_total_credit);
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
} } else {
else
{
print '<td></td>'; print '<td></td>';
print '<td class="nowraponall right">'; print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit); print price($sous_total_credit - $sous_total_debit);

View File

@ -147,7 +147,7 @@ $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '".$object->code_compta."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER."' )"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )";
/* /*
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {

View File

@ -146,7 +146,7 @@ $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated "; $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated ";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '".$object->code_compta_fournisseur."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER."' )"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )";
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
$sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND '".$db->idate($search_date_end)."' )"; $sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND '".$db->idate($search_date_end)."' )";
} }

View File

@ -209,9 +209,7 @@ class AccountancyCategory // extends CommonObject
} }
$this->db->rollback(); $this->db->rollback();
return -1 * $error; return -1 * $error;
} } else {
else
{
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} }
@ -241,8 +239,7 @@ class AccountancyCategory // extends CommonObject
$sql .= " t.active"; $sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t";
if ($id) $sql .= " WHERE t.rowid = ".$id; if ($id) $sql .= " WHERE t.rowid = ".$id;
else else {
{
$sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid $sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid
if ($code) $sql .= " AND t.code = '".$this->db->escape($code)."'"; if ($code) $sql .= " AND t.code = '".$this->db->escape($code)."'";
elseif ($label) $sql .= " AND t.label = '".$this->db->escape($label)."'"; elseif ($label) $sql .= " AND t.label = '".$this->db->escape($label)."'";
@ -270,9 +267,7 @@ class AccountancyCategory // extends CommonObject
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;
} } else {
else
{
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
@ -335,9 +330,7 @@ class AccountancyCategory // extends CommonObject
} }
$this->db->rollback(); $this->db->rollback();
return -1 * $error; return -1 * $error;
} } else {
else
{
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -375,9 +368,7 @@ class AccountancyCategory // extends CommonObject
} }
$this->db->rollback(); $this->db->rollback();
return -1 * $error; return -1 * $error;
} } else {
else
{
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -709,9 +700,7 @@ class AccountancyCategory // extends CommonObject
$listofaccount .= "'".$cptcursor."'"; $listofaccount .= "'".$cptcursor."'";
} }
$sql .= " AND t.numero_compte IN (".$listofaccount.")"; $sql .= " AND t.numero_compte IN (".$listofaccount.")";
} } else {
else
{
$sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'";
} }
if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end
@ -833,9 +822,7 @@ class AccountancyCategory // extends CommonObject
$sql .= " WHERE t.fk_accounting_category = ".$cat_id; $sql .= " WHERE t.fk_accounting_category = ".$cat_id;
$sql .= " AND t.entity = ".$conf->entity; $sql .= " AND t.entity = ".$conf->entity;
$sql .= " ORDER BY t.account_number"; $sql .= " ORDER BY t.account_number";
} } else {
else
{
$sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql = "SELECT t.rowid, t.account_number, t.label as account_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " WHERE ".$predefinedgroupwhere; $sql .= " WHERE ".$predefinedgroupwhere;

View File

@ -362,7 +362,7 @@ class AccountancyExport
if ($line->sens == 'D') { if ($line->sens == 'D') {
print price($line->montant).$separator; print price($line->montant).$separator;
print ''.$separator; print ''.$separator;
}elseif ($line->sens == 'C') { } elseif ($line->sens == 'C') {
print ''.$separator; print ''.$separator;
print price($line->montant).$separator; print price($line->montant).$separator;
} }
@ -518,11 +518,12 @@ class AccountancyExport
$Tab['contrepartie'] = str_repeat(' ', 8); $Tab['contrepartie'] = str_repeat(' ', 8);
// elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting // elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting
if (!empty($data->date_echeance)) if (!empty($data->date_echeance)) {
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
else } else {
$Tab['date_echeance'] = '000000'; $Tab['date_echeance'] = '000000';
}
//elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5) //elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
//$Tab['lettrage'] = str_repeat(' ', 5); //$Tab['lettrage'] = str_repeat(' ', 5);
@ -597,12 +598,11 @@ class AccountancyExport
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0');
if($data->sens == 'D'){ if ($data->sens == 'D') {
$Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
} } else {
else{
$Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT);
@ -616,11 +616,12 @@ class AccountancyExport
$Tab['code_stat'] = str_repeat(' ', 4); $Tab['code_stat'] = str_repeat(' ', 4);
if (!empty($data->date_echeance)) if (!empty($data->date_echeance)) {
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%Y'); $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%Y');
else } else {
$Tab['date_echeance'] = dol_print_date($data->doc_date, '%d%m%Y'); $Tab['date_echeance'] = dol_print_date($data->doc_date, '%d%m%Y');
}
$Tab['monnaie'] = '1'; $Tab['monnaie'] = '1';
@ -897,12 +898,10 @@ class AccountancyExport
if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
{ {
$sammelBuchung = true; $sammelBuchung = true;
} } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
{ {
$sammelBuchung = true; $sammelBuchung = true;
} } elseif ($aIndex + 1 < $aSize
elseif ($aIndex + 1 < $aSize
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
&& $aIndex - 1 < $aSize && $aIndex - 1 < $aSize
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
@ -924,9 +923,7 @@ class AccountancyExport
if ($line->sens == 'D') if ($line->sens == 'D')
{ {
print 'S'.$this->separator; print 'S'.$this->separator;
} } else {
else
{
print 'H'.$this->separator; print 'H'.$this->separator;
} }
//Grp //Grp
@ -937,14 +934,10 @@ class AccountancyExport
if ($line->piece_num == $thisPieceNum) if ($line->piece_num == $thisPieceNum)
{ {
print length_accounta($thisPieceAccountNr).$this->separator; print length_accounta($thisPieceAccountNr).$this->separator;
} } else {
else
{
print "div".$this->separator; print "div".$this->separator;
} }
} } else {
else
{
print length_accounta($line->code_tiers).$this->separator; print length_accounta($line->code_tiers).$this->separator;
} }
//SId //SId
@ -960,9 +953,7 @@ class AccountancyExport
if ($sammelBuchung) if ($sammelBuchung)
{ {
print "2".$this->separator; print "2".$this->separator;
} } else {
else
{
print "1".$this->separator; print "1".$this->separator;
} }
// Code // Code
@ -971,9 +962,7 @@ class AccountancyExport
if ($line->montant >= 0) if ($line->montant >= 0)
{ {
print $line->montant.$this->separator; print $line->montant.$this->separator;
} } else {
else
{
print ($line->montant * -1).$this->separator; print ($line->montant * -1).$this->separator;
} }
// Steuer // Steuer
@ -1171,7 +1160,8 @@ class AccountancyExport
// TYPE C // TYPE C
if ($last_codeinvoice != $line->doc_ref) { if ($last_codeinvoice != $line->doc_ref) {
//recherche societe en fonction de son code client //recherche societe en fonction de son code client
$sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code."'"; $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE code_client = '".$this->db->escape($line->thirdparty_code)."'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) if ($resql && $this->db->num_rows($resql) > 0)
@ -1458,7 +1448,9 @@ class AccountancyExport
print self::trunc($line->code_journal, 6).$separator; //Journal code print self::trunc($line->code_journal, 6).$separator; //Journal code
if (!empty($line->subledger_account)) $account = $line->subledger_account; if (!empty($line->subledger_account)) $account = $line->subledger_account;
else $account = $line->numero_compte; else {
$account = $line->numero_compte;
}
print self::trunc($account, 15).$separator; //Account number print self::trunc($account, 15).$separator; //Account number
print self::trunc($line->label_compte, 60).$separator; //Account label print self::trunc($line->label_compte, 60).$separator; //Account label

View File

@ -101,7 +101,7 @@ class AccountancySystem
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
$sql .= " WHERE"; $sql .= " WHERE";
if ($rowid) { if ($rowid) {
$sql .= " a.rowid = '".$rowid."'"; $sql .= " a.rowid = ".((int) $rowid);
} elseif ($ref) { } elseif ($ref) {
$sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; $sql .= " a.pcg_version = '".$this->db->escape($ref)."'";
} }

View File

@ -448,9 +448,10 @@ class AccountingAccount extends CommonObject
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label)
* @param string $option 'ledger', 'journals', 'accountcard'
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0) public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '')
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -459,7 +460,16 @@ class AccountingAccount extends CommonObject
$result = ''; $result = '';
$url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$this->id; if (empty($option) || $option == 'ledger') {
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
$labelurl = $langs->trans("ShowAccountingAccountInLedger");
} elseif ($option == 'journals') {
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
$labelurl = $langs->trans("ShowAccountingAccountInJournals");
} elseif ($option == 'accountcard') {
$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
$labelurl = $langs->trans("ShowAccountingAccount");
}
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
@ -476,7 +486,7 @@ class AccountingAccount extends CommonObject
$labeltoshow = $this->labelshort; $labeltoshow = $this->labelshort;
} }
$label = '<u>'.$langs->trans("ShowAccountingAccount").'</u>'; $label = '<u>'.$labelurl.'</u>';
if (!empty($this->account_number)) if (!empty($this->account_number))
$label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number); $label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
if (!empty($labeltoshow)) if (!empty($labeltoshow))
@ -488,7 +498,7 @@ class AccountingAccount extends CommonObject
{ {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{ {
$label = $langs->trans("ShowAccountingAccount"); $label = $labelurl;
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
@ -609,8 +619,7 @@ class AccountingAccount extends CommonObject
if ($mode == 0) if ($mode == 0)
{ {
$fieldtouse = 'active'; $fieldtouse = 'active';
} } elseif ($mode == 1)
elseif ($mode == 1)
{ {
$fieldtouse = 'reconcilable'; $fieldtouse = 'reconcilable';
} }
@ -661,28 +670,23 @@ class AccountingAccount extends CommonObject
{ {
if ($status == 1) return $langs->trans('Enabled'); if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled'); elseif ($status == 0) return $langs->trans('Disabled');
} } elseif ($mode == 1)
elseif ($mode == 1)
{ {
if ($status == 1) return $langs->trans('Enabled'); if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled'); elseif ($status == 0) return $langs->trans('Disabled');
} } elseif ($mode == 2)
elseif ($mode == 2)
{ {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
} } elseif ($mode == 3)
elseif ($mode == 3)
{ {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
} } elseif ($mode == 4)
elseif ($mode == 4)
{ {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
} } elseif ($mode == 5)
elseif ($mode == 5)
{ {
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');

View File

@ -108,9 +108,8 @@ class AccountingJournal extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE"; $sql .= " WHERE";
if ($rowid) { if ($rowid) {
$sql .= " rowid = ".(int) $rowid; $sql .= " rowid = ".((int) $rowid);
} } elseif ($journal_code)
elseif ($journal_code)
{ {
$sql .= " code = '".$this->db->escape($journal_code)."'"; $sql .= " code = '".$this->db->escape($journal_code)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
@ -136,9 +135,7 @@ class AccountingJournal extends CommonObject
} else { } else {
return 0; return 0;
} }
} } else {
else
{
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = "Error ".$this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
@ -311,8 +308,7 @@ class AccountingJournal extends CommonObject
elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); elseif ($nature == 3) return $langs->trans('AccountingJournalType3');
elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); elseif ($nature == 2) return $langs->trans('AccountingJournalType2');
elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); elseif ($nature == 1) return $langs->trans('AccountingJournalType1');
} } elseif ($mode == 1)
elseif ($mode == 1)
{ {
if ($nature == 9) return $langs->trans('AccountingJournalType9'); if ($nature == 9) return $langs->trans('AccountingJournalType9');
elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); elseif ($nature == 5) return $langs->trans('AccountingJournalType5');

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2014-2017 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2014-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2017 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015-2017 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -57,109 +57,115 @@ class BookKeeping extends CommonObject
*/ */
public $id; public $id;
/** /**
* @var string Date of source document, in db date NOT NULL * @var string Date of source document, in db date NOT NULL
*/ */
public $doc_date; public $doc_date;
/** /**
* @var int Deadline for payment * @var int Deadline for payment
*/ */
public $date_lim_reglement; public $date_lim_reglement;
/** /**
* @var string doc_type * @var string doc_type
*/ */
public $doc_type; public $doc_type;
/** /**
* @var string doc_ref * @var string doc_ref
*/ */
public $doc_ref; public $doc_ref;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_doc; public $fk_doc;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_docdet; public $fk_docdet;
/** /**
* @var string thirdparty code * @var string thirdparty code
*/ */
public $thirdparty_code; public $thirdparty_code;
/** /**
* @var string subledger account * @var string subledger account
*/ */
public $subledger_account; public $subledger_account;
/** /**
* @var string subledger label * @var string subledger label
*/ */
public $subledger_label; public $subledger_label;
/** /**
* @var string doc_type * @var string doc_type
*/ */
public $numero_compte; public $numero_compte;
/** /**
* @var string label compte * @var string label compte
*/ */
public $label_compte; public $label_compte;
/** /**
* @var string label operation * @var string label operation
*/ */
public $label_operation; public $label_operation;
/** /**
* @var float FEC:Debit * @var float FEC:Debit
*/ */
public $debit; public $debit;
/** /**
* @var float FEC:Credit * @var float FEC:Credit
*/ */
public $credit; public $credit;
/** /**
* @var float FEC:Amount (Not necessary) * @var float FEC:Amount (Not necessary)
*/ * @deprecated Use $amount
*/
public $montant; public $montant;
/** /**
* @var string FEC:Sens (Not necessary) * @var float FEC:Amount (Not necessary)
*/ */
public $amount;
/**
* @var string FEC:Sens (Not necessary)
*/
public $sens; public $sens;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_user_author; public $fk_user_author;
/** /**
* @var string key for import * @var string key for import
*/ */
public $import_key; public $import_key;
/** /**
* @var string code journal * @var string code journal
*/ */
public $code_journal; public $code_journal;
/** /**
* @var string label journal * @var string label journal
*/ */
public $journal_label; public $journal_label;
/** /**
* @var int accounting transaction id * @var int accounting transaction id
*/ */
public $piece_num; public $piece_num;
/** /**
@ -173,8 +179,8 @@ class BookKeeping extends CommonObject
* *
* @param DoliDb $db Database handler * @param DoliDb $db Database handler
*/ */
public function __construct(DoliDB $db) public function __construct(DoliDB $db)
{ {
$this->db = $db; $this->db = $db;
} }
@ -185,8 +191,8 @@ class BookKeeping extends CommonObject
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function create(User $user, $notrigger = false) public function create(User $user, $notrigger = false)
{ {
global $conf, $langs; global $conf, $langs;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -258,9 +264,7 @@ class BookKeeping extends CommonObject
if (in_array($this->doc_type, array('bank', 'expense_report'))) if (in_array($this->doc_type, array('bank', 'expense_report')))
{ {
$this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type);
} } else {
else
{
//$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte);
$mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; $mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte;
if ($this->subledger_account && $this->subledger_account != $this->numero_compte) if ($this->subledger_account && $this->subledger_account != $this->numero_compte)
@ -477,8 +481,7 @@ class BookKeeping extends CommonObject
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
@ -501,11 +504,11 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function createStd(User $user, $notrigger = false, $mode = '') public function createStd(User $user, $notrigger = false, $mode = '')
{ {
global $conf, $langs; global $conf, $langs;
$langs->loadLangs(array("accountancy", "bills", "compta")); $langs->loadLangs(array("accountancy", "bills", "compta"));
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -575,7 +578,7 @@ class BookKeeping extends CommonObject
$now = dol_now(); $now = dol_now();
// Check parameters // Check parameters
$this->journal_label = $langs->trans($this->journal_label); $this->journal_label = $langs->trans($this->journal_label);
// Insert request // Insert request
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.$mode.' ('; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.$mode.' (';
@ -670,8 +673,8 @@ class BookKeeping extends CommonObject
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = null, $mode = '') public function fetch($id, $ref = null, $mode = '')
{ {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -768,8 +771,8 @@ class BookKeeping extends CommonObject
* *
* @return int <0 if KO, >=0 if OK * @return int <0 if KO, >=0 if OK
*/ */
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{ {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -901,11 +904,11 @@ class BookKeeping extends CommonObject
* @param int $offset Offset limit * @param int $offset Offset limit
* @param array $filter Filter array * @param array $filter Filter array
* @param string $filtermode Filter mode (AND or OR) * @param string $filtermode Filter mode (AND or OR)
* @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default)) * @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default))
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $showAlreadyExportMovements = 1) public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $showAlreadyExportMovements = 1)
{ {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -937,7 +940,7 @@ class BookKeeping extends CommonObject
$sql .= " t.date_creation,"; $sql .= " t.date_creation,";
$sql .= " t.date_lim_reglement,"; $sql .= " t.date_lim_reglement,";
$sql .= " t.tms as date_modification,"; $sql .= " t.tms as date_modification,";
$sql .= " t.date_export"; $sql .= " t.date_export";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
// Manage filter // Manage filter
$sqlwhere = array(); $sqlwhere = array();
@ -957,8 +960,8 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.tms>=' || $key == 't.tms<=') { } elseif ($key == 't.tms>=' || $key == 't.tms<=') {
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') { } elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1); $sqlwhere[] = natural_search($key, $value, 1, 1);
} else { } else {
@ -967,9 +970,9 @@ class BookKeeping extends CommonObject
} }
} }
$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')'; $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
if ($showAlreadyExportMovements == 0) { if ($showAlreadyExportMovements == 0) {
$sql .= " AND t.date_export IS NULL"; $sql .= " AND t.date_export IS NULL";
} }
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
} }
@ -1017,7 +1020,7 @@ class BookKeeping extends CommonObject
$line->date_creation = $this->db->jdate($obj->date_creation); $line->date_creation = $this->db->jdate($obj->date_creation);
$line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement); $line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement);
$line->date_modification = $this->db->jdate($obj->date_modification); $line->date_modification = $this->db->jdate($obj->date_modification);
$line->date_export = $this->db->jdate($obj->date_export); $line->date_export = $this->db->jdate($obj->date_export);
$this->lines[] = $line; $this->lines[] = $line;
@ -1130,8 +1133,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode ('' or _tmp') * @param string $mode Mode ('' or _tmp')
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function update(User $user, $notrigger = false, $mode = '') public function update(User $user, $notrigger = false, $mode = '')
{ {
$error = 0; $error = 0;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -1297,8 +1300,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete(User $user, $notrigger = false, $mode = '') public function delete(User $user, $notrigger = false, $mode = '')
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -1345,8 +1348,8 @@ class BookKeeping extends CommonObject
* @param string $importkey Import key * @param string $importkey Import key
* @return int Result * @return int Result
*/ */
public function deleteByImportkey($importkey) public function deleteByImportkey($importkey)
{ {
$this->db->begin(); $this->db->begin();
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
@ -1376,11 +1379,11 @@ class BookKeeping extends CommonObject
* @param int $delmonth Month * @param int $delmonth Month
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function deleteByYearAndJournal($delyear = 0, $journal = '', $mode = '', $delmonth = 0) public function deleteByYearAndJournal($delyear = 0, $journal = '', $mode = '', $delmonth = 0)
{ {
global $langs; global $langs;
if (empty($delyear) && empty($journal)) if (empty($delyear) && empty($journal))
{ {
$this->error = 'ErrorOneFieldRequired'; $this->error = 'ErrorOneFieldRequired';
return -1; return -1;
@ -1425,8 +1428,8 @@ class BookKeeping extends CommonObject
* @param int $piecenum Piecenum to delete * @param int $piecenum Piecenum to delete
* @return int Result * @return int Result
*/ */
public function deleteMvtNum($piecenum) public function deleteMvtNum($piecenum)
{ {
global $conf; global $conf;
$this->db->begin(); $this->db->begin();
@ -1460,8 +1463,8 @@ class BookKeeping extends CommonObject
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone(User $user, $fromid) public function createFromClone(User $user, $fromid)
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -1508,8 +1511,8 @@ class BookKeeping extends CommonObject
* *
* @return void * @return void
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
global $user; global $user;
$now = dol_now(); $now = dol_now();
@ -1545,8 +1548,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchPerMvt($piecenum, $mode = '') public function fetchPerMvt($piecenum, $mode = '')
{ {
global $conf; global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation"; $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation";
@ -1610,8 +1613,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAllPerMvt($piecenum, $mode = '') public function fetchAllPerMvt($piecenum, $mode = '')
{ {
global $conf; global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
@ -1661,16 +1664,16 @@ class BookKeeping extends CommonObject
return 1; return 1;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Export bookkeeping * Export bookkeeping
* *
* @param string $model Model * @param string $model Model
* @return int Result * @return int Result
*/ */
public function export_bookkeeping($model = 'ebp') public function export_bookkeeping($model = 'ebp')
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
@ -1736,10 +1739,10 @@ class BookKeeping extends CommonObject
$this->db->begin(); $this->db->begin();
if ($direction == 0) if ($direction == 0)
{ {
$next_piecenum = $this->getNextNumMvt(); $next_piecenum = $this->getNextNumMvt();
$now = dol_now(); $now = dol_now();
if ($next_piecenum < 0) { if ($next_piecenum < 0) {
$error++; $error++;
@ -1752,14 +1755,14 @@ class BookKeeping extends CommonObject
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.", '".$this->db->idate($now)."'"; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.", '".$this->db->idate($now)."'";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$this->db->escape($piece_num); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = 'Error '.$this->db->lasterror(); $this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
} }
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$this->db->escape($piece_num); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
@ -1767,7 +1770,7 @@ class BookKeeping extends CommonObject
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
} }
} elseif ($direction == 1) { } elseif ($direction == 1) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$piece_num; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
@ -1782,14 +1785,14 @@ class BookKeeping extends CommonObject
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.$piece_num; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = 'Error '.$this->db->lasterror(); $this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
} }
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$piece_num; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
@ -1816,22 +1819,22 @@ class BookKeeping extends CommonObject
*/ */
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of accounts with label by chart of accounts * Return list of accounts with label by chart of accounts
* *
* @param string $selectid Preselected chart of accounts * @param string $selectid Preselected chart of accounts
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param array $event Event options * @param array $event Event options
* @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1) * @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out Set value returned by select 0=rowid (default), 1=account_number * @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number * @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
* @return string String with HTML select * @return string String with HTML select
*/ */
public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -1888,7 +1891,7 @@ class BookKeeping extends CommonObject
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Description of a root accounting account * Description of a root accounting account
* *
@ -1897,7 +1900,7 @@ class BookKeeping extends CommonObject
*/ */
public function get_compte_racine($account = null) public function get_compte_racine($account = null)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
@ -1907,7 +1910,7 @@ class BookKeeping extends CommonObject
$sql .= " AND asy.rowid = ".$pcgver; $sql .= " AND asy.rowid = ".$pcgver;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid";
$sql .= " WHERE aa.account_number = '".$account."'"; $sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'";
$sql .= " AND parent.active = 1"; $sql .= " AND parent.active = 1";
$sql .= " AND root.active = 1"; $sql .= " AND root.active = 1";
$sql .= " AND aa.entity IN (".getEntity('accountancy').")"; $sql .= " AND aa.entity IN (".getEntity('accountancy').")";
@ -1929,24 +1932,24 @@ class BookKeeping extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Description of accounting account * Description of accounting account
* *
* @param string $account Accounting account * @param string $account Accounting account
* @return string Account desc * @return string Account desc
*/ */
public function get_compte_desc($account = null) public function get_compte_desc($account = null)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa "; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND aa.account_number = '".$account."'"; $sql .= " AND aa.account_number = '".$this->db->escape($account)."'";
$sql .= " AND asy.rowid = ".$pcgver; $sql .= " AND asy.rowid = ".((int) $pcgver);
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
$sql .= " WHERE aa.entity IN (".getEntity('accountancy').")"; $sql .= " WHERE aa.entity IN (".getEntity('accountancy').")";
@ -1986,13 +1989,13 @@ class BookKeepingLine
public $doc_ref; public $doc_ref;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_doc; public $fk_doc;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_docdet; public $fk_docdet;
public $thirdparty_code; public $thirdparty_code;
@ -2003,13 +2006,27 @@ class BookKeepingLine
public $label_operation; public $label_operation;
public $debit; public $debit;
public $credit; public $credit;
public $montant;
public $sens;
public $lettering_code;
/** /**
* @var int ID * @var float Amount
*/ * @deprecated see $amount
*/
public $montant;
/**
* @var float Amount
*/
public $amount;
/**
* @var string Sens
*/
public $sens;
public $lettering_code;
/**
* @var int ID
*/
public $fk_user_author; public $fk_user_author;
public $import_key; public $import_key;
@ -2018,17 +2035,17 @@ class BookKeepingLine
public $piece_num; public $piece_num;
/** /**
* @var integer|string date_creation * @var integer|string date_creation
*/ */
public $date_creation; public $date_creation;
/** /**
* @var integer|string $date_modification; * @var integer|string $date_modification;
*/ */
public $date_modification; public $date_modification;
/** /**
* @var integer|string $date_export; * @var integer|string $date_export;
*/ */
public $date_export; public $date_export;
} }

View File

@ -68,11 +68,11 @@ class Lettering extends BookKeeping
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
$sql .= " WHERE ( "; $sql .= " WHERE ( ";
if ($object->code_compta != "") if ($object->code_compta != "")
$sql .= " bk.subledger_account = '".$object->code_compta."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") if ($object->code_compta != "" && $object->code_compta_fournisseur != "")
$sql .= " OR "; $sql .= " OR ";
if ($object->code_compta_fournisseur != "") if ($object->code_compta_fournisseur != "")
$sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' ";
$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) "; $sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
$sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) "; $sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) ";
@ -95,19 +95,19 @@ class Lettering extends BookKeeping
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf "; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='".$obj->code_journal."')"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='".$this->db->escape($obj->code_journal)."')";
$sql .= " WHERE payfacf.fk_paiementfourn = '".$obj->url_id."' "; $sql .= " WHERE payfacf.fk_paiementfourn = '".$this->db->escape($obj->url_id)."' ";
$sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '".$object->code_compta."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' ";
} }
$sql .= " ) "; $sql .= " ) ";
@ -129,13 +129,13 @@ class Lettering extends BookKeeping
$sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '".$object->code_compta."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' ";
} }
$sql .= ") "; $sql .= ") ";
@ -154,19 +154,19 @@ class Lettering extends BookKeeping
$sql .= " FROM ".MAIN_DB_PREFIX."facture fac "; $sql .= " FROM ".MAIN_DB_PREFIX."facture fac ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement as pay ON payfac.fk_paiement=pay.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement as pay ON payfac.fk_paiement=pay.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='".$obj->code_journal."')"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='".$this->db->escape($obj->code_journal)."')";
$sql .= " WHERE payfac.fk_paiement = '".$obj->url_id."' "; $sql .= " WHERE payfac.fk_paiement = '".$this->db->escape($obj->url_id)."' ";
$sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '".$object->code_compta."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' ";
} }
$sql .= " )"; $sql .= " )";
@ -188,13 +188,13 @@ class Lettering extends BookKeeping
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND ( "; $sql .= " AND ( ";
if ($object->code_compta != "") { if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '".$object->code_compta."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
} }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
} }
if ($object->code_compta_fournisseur != "") { if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' ";
} }
$sql .= " ) "; $sql .= " ) ";
@ -238,7 +238,7 @@ class Lettering extends BookKeeping
$lettre = 'AAA'; $lettre = 'AAA';
$sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; $sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
$sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1; "; $sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
@ -252,7 +252,7 @@ class Lettering extends BookKeeping
} }
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE ";
$sql .= " rowid IN (".implode(',', $ids).") AND date_validated IS NULL "; $sql .= " rowid IN (".implode(',', $ids).") AND date_validated IS NULL";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@ -272,7 +272,7 @@ class Lettering extends BookKeeping
if (!$error) if (!$error)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql .= " lettering_code='".$lettre."'"; $sql .= " lettering_code='".$this->db->escape($lettre)."'";
$sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false $sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false
$sql .= " WHERE rowid IN (".implode(',', $ids).") AND date_validated IS NULL "; $sql .= " WHERE rowid IN (".implode(',', $ids).") AND date_validated IS NULL ";
$this->db->begin(); $this->db->begin();

View File

@ -42,8 +42,7 @@ if (!$user->rights->accounting->fiscalyear->write)
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else else {
{
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
} }

View File

@ -42,8 +42,7 @@ if ($user->socid > 0)
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else else {
{
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
} }

View File

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("bills", "accountancy")); $langs->loadLangs(array("bills", "accountancy"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -59,9 +59,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} } else {
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage)
{ {

View File

@ -47,8 +47,7 @@ if (!$user->rights->accounting->bind->write)
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else else {
{
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
} }
@ -132,9 +131,9 @@ if ($action == 'validatehistory') {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2"; $sql .= " AND l.product_type <= 2";
@ -202,8 +201,7 @@ if ($action == 'validatehistory') {
if ($error) if ($error)
{ {
$db->rollback(); $db->rollback();
} } else {
else {
$db->commit(); $db->commit();
setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
} }
@ -258,6 +256,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND f.fk_statut > 0"; $sql .= " AND f.fk_statut > 0";
$sql .= " AND fd.product_type <= 2"; $sql .= " AND fd.product_type <= 2";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
@ -279,15 +281,13 @@ if ($resql) {
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} } else print length_accountg($row[0]);
else print length_accountg($row[0]);
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} } else print $row[1];
else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
@ -334,6 +334,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0"; $sql .= " AND f.fk_statut > 0";
$sql .= " AND fd.product_type <= 2"; $sql .= " AND fd.product_type <= 2";
@ -355,16 +359,14 @@ if ($resql) {
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} } else print length_accountg($row[0]);
else print length_accountg($row[0]);
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} } else print $row[1];
else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
@ -400,7 +402,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '".$langs->trans("TotalVente")."' AS total,"; $sql = "SELECT '".$db->escape($langs->trans("TotalVente"))."' AS total,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
@ -411,6 +413,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0"; $sql .= " AND f.fk_statut > 0";
$sql .= " AND fd.product_type <= 2"; $sql .= " AND fd.product_type <= 2";
@ -453,7 +459,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '".$langs->trans("Vide")."' AS marge,"; $sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
@ -464,6 +470,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0"; $sql .= " AND f.fk_statut > 0";
$sql .= " AND fd.product_type <= 2"; $sql .= " AND fd.product_type <= 2";

View File

@ -61,8 +61,8 @@ $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0; if (empty($page) || $page < 0) $page = 0;
$offset = $limit * $page; $offset = $limit * $page;
@ -93,7 +93,7 @@ $formaccounting = new FormAccounting($db);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
$search_label = ''; $search_label = '';
@ -203,7 +203,7 @@ if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("fd.rowid", $search_lineid, 1); $sql .= natural_search("fd.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
@ -251,13 +251,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -309,9 +309,9 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall">'; print '<td class="liste_titre center nowraponall">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
} }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); $formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
@ -344,22 +344,23 @@ if ($result) {
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
$checkpicto = $form->showCheckAddButtons(); $checkpicto = $form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$thirdpartystatic = new Societe($db); $thirdpartystatic = new Societe($db);
$facture_static = new Facture($db); $facturestatic = new Facture($db);
$product_static = new Product($db); $productstatic = new Product($db);
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
$i = 0;
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$facture_static->ref = $objp->ref; $facturestatic->ref = $objp->ref;
$facture_static->id = $objp->facid; $facturestatic->id = $objp->facid;
$facture_static->type = $objp->ftype; $facturestatic->type = $objp->ftype;
$thirdpartystatic->id = $objp->socid; $thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->name; $thirdpartystatic->name = $objp->name;
@ -372,10 +373,10 @@ if ($result) {
$thirdpartystatic->email = $objp->email; $thirdpartystatic->email = $objp->email;
$thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->country_code = $objp->country_code;
$product_static->ref = $objp->product_ref; $productstatic->ref = $objp->product_ref;
$product_static->id = $objp->product_id; $productstatic->id = $objp->product_id;
$product_static->label = $objp->product_label; $productstatic->label = $objp->product_label;
$product_static->type = $objp->line_type; $productstatic->type = $objp->line_type;
$accountingaccountstatic->rowid = $objp->fk_compte; $accountingaccountstatic->rowid = $objp->fk_compte;
$accountingaccountstatic->label = $objp->label; $accountingaccountstatic->label = $objp->label;
@ -388,15 +389,15 @@ if ($result) {
print '<td>'.$objp->rowid.'</td>'; print '<td>'.$objp->rowid.'</td>';
// Ref Invoice // Ref Invoice
print '<td class="nowraponall">'.$facture_static->getNomUrl(1).'</td>'; print '<td class="nowraponall">'.$facturestatic->getNomUrl(1).'</td>';
// Date invoice // Date invoice
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref Product // Ref Product
print '<td class="tdoverflowmax100">'; print '<td class="tdoverflowmax100">';
if ($product_static->id > 0) print $product_static->getNomUrl(1); if ($productstatic->id > 0) print $productstatic->getNomUrl(1);
if ($product_static->id > 0 && $objp->product_label) print '<br>'; if ($productstatic->id > 0 && $objp->product_label) print '<br>';
if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>'; if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>';
print '</td>'; print '</td>';
@ -411,7 +412,7 @@ if ($result) {
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>'; print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
// Country // Country
print '<td>'; print '<td>';
@ -423,8 +424,9 @@ if ($result) {
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
print '<td>'; print '<td class="center">';
print $accountingaccountstatic->getNomUrl(0, 1, 1).' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>'; print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
@ -432,14 +434,14 @@ if ($result) {
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
print "</div>"; print "</div>";
if ($nbtotalofrecords > $limit) { if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
} }
print '</form>'; print '</form>';
} else { } else {
print $db->lasterror(); print $db->lasterror();
} }

View File

@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "productbatch")); $langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "productbatch"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
@ -69,8 +69,8 @@ $btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page; $offset = $limit * $page;
@ -114,7 +114,7 @@ if (empty($reshook))
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_societe=''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
@ -140,50 +140,48 @@ if (empty($reshook))
if ($massaction == 'ventil') { if ($massaction == 'ventil') {
$msg = ''; $msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><span style="color:red">' . $langs->trans("Processing") . '...</span></div>';
if (!empty($mesCasesCochees)) { if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">'; $msg .= '<div class="detail">';
$cpt = 0; $cpt = 0;
$ok = 0; $ok = 0;
$ko = 0; $ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) { foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0)
{ {
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("NoAccountSelected").'</span></div>';
$ko++; $ko++;
} } else {
else $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
{ $sql .= " SET fk_code_ventilation = ".((int) $monCompte);
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql .= " WHERE rowid = ".((int) $monId);
$sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db); $accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, ''); $accountventilated->fetch($monCompte, '', 1);
dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG); dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $msg .= '<div><span style="color:green">'.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</span></div>';
$ok++; $ok++;
} else { } else {
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></font></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></span></div>';
$ko++; $ko++;
} }
} }
$cpt++; $cpt++;
} }
$msg .= '</div>'; $msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
} }
} }
@ -201,8 +199,8 @@ if (empty($chartaccountcode))
{ {
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
exit; exit;
} }
@ -224,38 +222,42 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2"; $sql .= " AND l.product_type <= 2";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Add search filter like // Add search filter like
if ($search_societe) { if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
} }
if (strlen(trim($search_ref))) { if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref); $sql .= natural_search("p.ref", $search_ref);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= natural_search("p.label", $search_label); $sql .= natural_search("p.label", $search_label);
} }
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= natural_search("l.description", $search_desc); $sql .= natural_search("l.description", $search_desc);
} }
if (strlen(trim($search_amount))) { if (strlen(trim($search_amount))) {
$sql .= natural_search("l.total_ht", $search_amount, 1); $sql .= natural_search("l.total_ht", $search_amount, 1);
} }
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {
$sql .= natural_search("aa.account_number", $search_account); $sql .= natural_search("aa.account_number", $search_account);
} }
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1); $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
} }
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
@ -293,13 +295,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -334,9 +336,9 @@ if ($result) {
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
@ -374,8 +376,8 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
} }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); $formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
@ -384,9 +386,9 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
@ -409,7 +411,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = ''; $checkpicto = '';
@ -423,7 +425,7 @@ if ($result) {
$isSellerInEEC = isInEEC($mysoc); $isSellerInEEC = isInEEC($mysoc);
$accountingaccount_codetotid_cache = array(); $accountingaccount_codetotid_cache = array();
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
@ -462,29 +464,29 @@ if ($result) {
$code_sell_p_notset = ''; $code_sell_p_notset = '';
$objp->aarowid_suggest = ''; // Will be set later $objp->aarowid_suggest = ''; // Will be set later
$isBuyerInEEC = isInEEC($objp); $isBuyerInEEC = isInEEC($objp);
// Search suggested default account for product/service // Search suggested default account for product/service
$suggestedaccountingaccountbydefaultfor = ''; $suggestedaccountingaccountbydefaultfor = '';
if ($objp->type_l == 1) { if ($objp->type_l == 1) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = ''; $suggestedaccountingaccountbydefaultfor = '';
} else { } else {
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eecwithvat'; $suggestedaccountingaccountbydefaultfor = 'eecwithvat';
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec'; $suggestedaccountingaccountbydefaultfor = 'eec';
} else { // Foreign sale } else { // Foreign sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'export'; $suggestedaccountingaccountbydefaultfor = 'export';
} }
} }
} elseif ($objp->type_l == 0) { } elseif ($objp->type_l == 0) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
@ -510,28 +512,36 @@ if ($result) {
// Search suggested account for product/service (similar code exists in page index.php to make automatic binding) // Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; $objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
} else { } else {
if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; $objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = 'eecwithvat'; $suggestedaccountingaccountfor = 'eecwithvat';
} elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
$suggestedaccountingaccountfor = 'eecwithoutvatnumber'; $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra; $objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra; $objp->aarowid_suggest = $objp->aarowid_intra;
$suggestedaccountingaccountfor = 'eec'; $suggestedaccountingaccountfor = 'eec';
} else { // Foreign sale } else { // Foreign sale
$objp->code_sell_p = $objp->code_sell_export; $objp->code_sell_p = $objp->code_sell_export;
$objp->aarowid_suggest = $objp->aarowid_export; $objp->aarowid_suggest = $objp->aarowid_export;
$suggestedaccountingaccountfor = 'export'; $suggestedaccountingaccountfor = 'export';
} }
} }
// Manage Deposit
if ($objp->description == "(DEPOSIT)") {
$accountdeposittoventilated = new AccountingAccount($db);
$accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1);
$objp->code_sell_l = $accountdeposittoventilated->ref;
$objp->aarowid_suggest = $accountdeposittoventilated->rowid;
}
if (!empty($objp->code_sell_p)) { if (!empty($objp->code_sell_p)) {
// Value was defined previously // Value was defined previously
@ -555,14 +565,14 @@ if ($result) {
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref Product // Ref Product
print '<td>'; print '<td class="tdoverflowmax150">';
if ($product_static->id > 0) { if ($product_static->id > 0) {
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
} }
if ($objp->product_label) print '<br><span class="opacitymedium">'.$objp->product_label.'</span>'; if ($objp->product_label) print '<br><span class="opacitymedium small">'.$objp->product_label.'</span>';
print '</td>'; print '</td>';
print '<td class="tdoverflowonsmartphone">'; print '<td class="tdoverflowonsmartphone small">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
@ -580,35 +590,35 @@ if ($result) {
print '</td>'; print '</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
// Country // Country
print '<td>'; print '<td>';
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
print $labelcountry; print $labelcountry;
print '</td>'; print '</td>';
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
// Found accounts // Found accounts
print '<td>'; print '<td>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>'; $s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$shelp = ''; $shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
$s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>'); $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
if ($objp->product_id > 0) if ($objp->product_id > 0)
{ {
print '<br>'; print '<br>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>'; $s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$shelp = ''; $shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT"); elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber"); elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p)); $s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
} }
print '</td>'; print '</td>';
@ -629,8 +639,7 @@ if ($result) {
$suggestedid = $tmpaccount->id; $suggestedid = $tmpaccount->id;
} }
$accountingaccount_codetotid_cache[$objp->code_sell_l] = $tmpaccount->id; $accountingaccount_codetotid_cache[$objp->code_sell_l] = $tmpaccount->id;
} } else {
else {
$suggestedid = $accountingaccount_codetotid_cache[$objp->code_sell_l]; $suggestedid = $accountingaccount_codetotid_cache[$objp->code_sell_l];
} }
} }

View File

@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("bills", "accountancy", "trips")); $langs->loadLangs(array("bills", "accountancy", "trips"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -63,9 +63,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} } else {
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage)
{ {

View File

@ -43,8 +43,7 @@ if (!$user->rights->accounting->bind->write)
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else else {
{
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
} }
@ -162,7 +161,7 @@ for ($i = 1; $i <= 12; $i++) {
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
@ -175,6 +174,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_e
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
@ -190,26 +193,24 @@ if ($resql) {
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} } else print length_accountg($row[0]);
else print length_accountg($row[0]);
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} } else print $row[1];
else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right">'.price($row[13]).'</td>'; print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
@ -233,7 +234,7 @@ for ($i = 1; $i <= 12; $i++) {
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
@ -246,6 +247,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_e
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
@ -261,27 +266,25 @@ if ($resql) {
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} } else print length_accountg($row[0]);
else print length_accountg($row[0]);
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} } else print $row[1];
else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right">'.price($row[13]).'</td>'; print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
@ -290,56 +293,60 @@ print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
{ {
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print load_fiche_titre($langs->trans("OtherInfo"), '', ''); //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>'; print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; $sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(erd.total_ht) as total"; $sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; // Define begin binding date
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/expensereport/index.php'); dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr><td>'.$row[0].'</td>'; print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
} }
// End of page // End of page

View File

@ -26,21 +26,23 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch")); $langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch", "hrm"));
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$account_parent = GETPOST('account_parent', 'int'); $account_parent = GETPOST('account_parent', 'int');
$changeaccount = GETPOST('changeaccount'); $changeaccount = GETPOST('changeaccount');
// Search Getpost // Search Getpost
$search_login = GETPOST('search_login', 'alpha');
$search_expensereport = GETPOST('search_expensereport', 'alpha'); $search_expensereport = GETPOST('search_expensereport', 'alpha');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha');
@ -53,8 +55,8 @@ $search_year = GETPOST("search_year", "int");
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0; if (empty($page) || $page < 0) $page = 0;
$pageprev = $page - 1; $pageprev = $page - 1;
@ -84,6 +86,7 @@ $formaccounting = new FormAccounting($db);
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
{ {
$search_login = '';
$search_expensereport = ''; $search_expensereport = '';
$search_label = ''; $search_label = '';
$search_desc = ''; $search_desc = '';
@ -162,14 +165,21 @@ print '<script type="text/javascript">
*/ */
$sql = "SELECT er.ref, er.rowid as erid,"; $sql = "SELECT er.ref, er.rowid as erid,";
$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, erd.vat_src_code, erd.date,"; $sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, erd.vat_src_code, erd.date,";
$sql .= " aa.label, aa.labelshort, aa.account_number,"; $sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label"; $sql .= " u.rowid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
$sql .= " aa.label, aa.labelshort, aa.account_number";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
$sql .= " , ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql .= " , ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <> 0 "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
$sql .= " AND aa.rowid = erd.fk_code_ventilation"; $sql .= " WHERE erd.fk_code_ventilation > 0";
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
// Add search filter like
if (strlen(trim($search_login))) {
$sql .= natural_search("u.login", $search_login);
}
if (strlen(trim($search_expensereport))) { if (strlen(trim($search_expensereport))) {
$sql .= natural_search("er.ref", $search_expensereport); $sql .= natural_search("er.ref", $search_expensereport);
} }
@ -197,13 +207,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -218,6 +228,7 @@ if ($result) {
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_login) $param .= '&search_login='.urlencode($search_login);
if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport); if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport);
if ($search_label) $param .= "&search_label=".urlencode($search_label); if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
@ -246,13 +257,14 @@ if ($result) {
$moreforfilter = ''; $moreforfilter = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>'; print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
@ -266,15 +278,16 @@ if ($result) {
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
$searchpicto = $form->showFilterButtons(); $searchpicto = $form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
} }
print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
@ -282,19 +295,32 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
$checkpicto = $form->showCheckAddButtons(); $checkpicto = $form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$expensereport_static = new ExpenseReport($db); $expensereportstatic = new ExpenseReport($db);
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
$userstatic = new User($db);
$i = 0;
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$expensereport_static->ref = $objp->ref; $expensereportstatic->ref = $objp->ref;
$expensereport_static->id = $objp->erid; $expensereportstatic->id = $objp->erid;
$userstatic->id = $objp->rowid;
$userstatic->ref = $objp->label;
$userstatic->login = $objp->login;
$userstatic->statut = $objp->statut;
$userstatic->email = $objp->email;
$userstatic->gender = $objp->gender;
$userstatic->firstname = $objp->firstname;
$userstatic->lastname = $objp->lastname;
$userstatic->employee = $objp->employee;
$userstatic->photo = $objp->photo;
$accountingaccountstatic->rowid = $objp->fk_compte; $accountingaccountstatic->rowid = $objp->fk_compte;
$accountingaccountstatic->label = $objp->label; $accountingaccountstatic->label = $objp->label;
@ -303,32 +329,44 @@ if ($result) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Login
print '<td class="nowraponall">';
print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
print '</td>';
// Line id
print '<td>'.$objp->rowid.'</td>'; print '<td>'.$objp->rowid.'</td>';
// Ref Invoice // Ref Expense report
print '<td>'.$expensereport_static->getNomUrl(1).'</td>'; print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
// Date validation // Date validation
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
} }
print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
// Fees label
print '<td class="tdoverflow">'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>'; print '<td class="tdoverflow">'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>';
// Fees description -- Can be null
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
print '</td>'; print '</td>';
// Amount without taxes
print '<td class="nowrap right">'.price($objp->total_ht).'</td>'; print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
// Vat rate
print '<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>'; print '<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
print '<td>'; // Accounting account affected
print $accountingaccountstatic->getNomUrl(0, 1, 1).' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print '<td class="center">';
print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
print ' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>'; print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
@ -341,7 +379,7 @@ if ($result) {
print "</div>"; print "</div>";
if ($nbtotalofrecords > $limit) { if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
} }
print '</form>'; print '</form>';

View File

@ -28,6 +28,7 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -35,14 +36,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "trips", "productbatch")); $langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "trips", "productbatch", "hrm"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'expensereportlist'; // To manage different context of search
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
@ -50,6 +51,7 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always ''
$mesCasesCochees = GETPOST('toselect', 'array'); $mesCasesCochees = GETPOST('toselect', 'array');
// Search Getpost // Search Getpost
$search_login = GETPOST('search_login', 'alpha');
$search_lineid = GETPOST('search_lineid', 'alpha'); $search_lineid = GETPOST('search_lineid', 'alpha');
$search_expensereport = GETPOST('search_expensereport', 'alpha'); $search_expensereport = GETPOST('search_expensereport', 'alpha');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
@ -63,8 +65,8 @@ $search_year = GETPOST("search_year", "int");
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page; $offset = $limit * $page;
@ -100,15 +102,16 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_expensereport = ''; $search_login = '';
$search_label = ''; $search_expensereport = '';
$search_desc = ''; $search_label = '';
$search_amount = ''; $search_desc = '';
$search_account = ''; $search_amount = '';
$search_vat = ''; $search_account = '';
$search_day = ''; $search_vat = '';
$search_month = ''; $search_day = '';
$search_year = ''; $search_month = '';
$search_year = '';
} }
// Mass actions // Mass actions
@ -121,48 +124,46 @@ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'ventil') { if ($massaction == 'ventil') {
$msg = ''; $msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><span style="color:red">' . $langs->trans("Processing") . '...</span></div>';
if (!empty($mesCasesCochees)) { if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">'; $msg .= '<div class="detail">';
$cpt = 0; $cpt = 0;
$ok = 0; $ok = 0;
$ko = 0; $ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) { foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0)
{ {
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>';
$ko++; $ko++;
} } else {
else $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
{ $sql .= " SET fk_code_ventilation = ".$monCompte;
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql .= " WHERE rowid = ".$monId;
$sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db); $accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, ''); $accountventilated->fetch($monCompte, '', 1);
dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $msg .= '<div><span style="color:green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</span></div>';
$ok++; $ok++;
} else { } else {
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></span></div>';
$ko++; $ko++;
} }
} }
$cpt++; $cpt++;
} }
$msg .= '</div>'; $msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
} }
} }
@ -180,8 +181,8 @@ if (empty($chartaccountcode))
{ {
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
exit; exit;
} }
@ -189,30 +190,39 @@ if (empty($chartaccountcode))
$sql = "SELECT er.ref, er.rowid as erid, er.date_debut, er.date_valid,"; $sql = "SELECT er.ref, er.rowid as erid, er.date_debut, er.date_valid,";
$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,"; $sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,";
$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,"; $sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,";
$sql .= " u.rowid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
$sql .= " aa.rowid as aarowid"; $sql .= " aa.rowid as aarowid";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
$sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; $sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Add search filter like // Add search filter like
if (strlen(trim($search_login))) {
$sql .= natural_search("u.login", $search_login);
}
if (strlen(trim($search_expensereport))) { if (strlen(trim($search_expensereport))) {
$sql .= natural_search("er.ref", $search_expensereport); $sql .= natural_search("er.ref", $search_expensereport);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= natural_search("f.label", $search_label); $sql .= natural_search("f.label", $search_label);
} }
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= natural_search("erd.comments", $search_desc); $sql .= natural_search("erd.comments", $search_desc);
} }
if (strlen(trim($search_amount))) { if (strlen(trim($search_amount))) {
$sql .= natural_search("erd.total_ht", $search_amount, 1); $sql .= natural_search("erd.total_ht", $search_amount, 1);
} }
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {
$sql .= natural_search("aa.account_number", $search_account); $sql .= natural_search("aa.account_number", $search_account);
} }
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("erd.tva_tx", $search_vat, 1); $sql .= natural_search("erd.tva_tx", $search_vat, 1);
} }
$sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year);
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
@ -223,13 +233,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -245,6 +255,7 @@ if ($result) {
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_login) $param .= '&search_login='.urlencode($search_login);
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month); if ($search_month) $param .= '&search_month='.urlencode($search_month);
@ -256,7 +267,7 @@ if ($result) {
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); if ($search_vat) $param .= '&search_vat='.urlencode($search_vat);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil' => $langs->trans("Ventilate") 'ventil' => $langs->trans("Ventilate")
); );
$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
@ -284,14 +295,15 @@ if ($result) {
$moreforfilter = ''; $moreforfilter = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// We add search filter // We add search filter
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
@ -312,9 +324,10 @@ if ($result) {
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
} }
print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
@ -331,6 +344,7 @@ if ($result) {
$expensereport_static = new ExpenseReport($db); $expensereport_static = new ExpenseReport($db);
$userstatic = new User($db);
$form = new Form($db); $form = new Form($db);
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
@ -342,8 +356,24 @@ if ($result) {
$expensereport_static->ref = $objp->ref; $expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid; $expensereport_static->id = $objp->erid;
$userstatic->id = $objp->rowid;
$userstatic->ref = $objp->label;
$userstatic->login = $objp->login;
$userstatic->statut = $objp->statut;
$userstatic->email = $objp->email;
$userstatic->gender = $objp->gender;
$userstatic->firstname = $objp->firstname;
$userstatic->lastname = $objp->lastname;
$userstatic->employee = $objp->employee;
$userstatic->photo = $objp->photo;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Login
print '<td class="nowraponall">';
print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
print '</td>';
// Line id // Line id
print '<td>'.$objp->rowid.'</td>'; print '<td>'.$objp->rowid.'</td>';
@ -351,7 +381,7 @@ if ($result) {
print '<td>'.$expensereport_static->getNomUrl(1).'</td>'; print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
// Date validation // Date validation
if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
} }
@ -370,6 +400,7 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
print '</td>'; print '</td>';
// Amount without taxes
print '<td class="nowrap right">'; print '<td class="nowrap right">';
print price($objp->price); print price($objp->price);
print '</td>'; print '</td>';

View File

@ -38,6 +38,7 @@ if ($user->socid > 0)
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array('accountancyindex')); $hookmanager->initHooks(array('accountancyindex'));
/* /*
* Actions * Actions
*/ */
@ -54,6 +55,7 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis
if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null);
} }
/* /*
* View * View
*/ */
@ -240,9 +242,7 @@ if ($conf->accounting->enabled)
print $boxlist; print $boxlist;
print '</div>'; print '</div>';
} } else {
else
{
print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span><br>\n";

View File

@ -90,17 +90,19 @@ if ($user->socid > 0 && empty($id_journal))
$error = 0; $error = 0;
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_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); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_startmonth) || empty($date_endmonth))
{
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
}
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form 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_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
@ -124,6 +126,10 @@ $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 $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)."'"; $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 // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already')
{ {
@ -231,7 +237,7 @@ if ($result) {
); );
// Set accountancy code for user // Set accountancy code for user
$compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : '');
$tabuser[$obj->rowid] = array( $tabuser[$obj->rowid] = array(
'id' => $obj->userid, 'id' => $obj->userid,
@ -278,8 +284,7 @@ if ($result) {
// We save tabtype for a future use, to remember what kind of payment it is // We save tabtype for a future use, to remember what kind of payment it is
$tabpay[$obj->rowid]['type'] = $links[$key]['type']; $tabpay[$obj->rowid]['type'] = $links[$key]['type'];
$tabtype[$obj->rowid] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type'];
} } elseif (in_array($links[$key]['type'], array('company', 'user')))
elseif (in_array($links[$key]['type'], array('company', 'user')))
{ {
if ($tabpay[$obj->rowid]['type'] == 'unknown') if ($tabpay[$obj->rowid]['type'] == 'unknown')
{ {
@ -554,9 +559,7 @@ if (!$error && $action == 'writebookkeeping') {
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@ -580,9 +583,7 @@ if (!$error && $action == 'writebookkeeping') {
if ($tabtype[$key] == 'banktransfert') if ($tabtype[$key] == 'banktransfert')
{ {
$reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
} } else {
else
{
$reflabel .= dol_string_nohtmltag($val['soclib']); $reflabel .= dol_string_nohtmltag($val['soclib']);
} }
@ -704,9 +705,7 @@ if (!$error && $action == 'writebookkeeping') {
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@ -714,8 +713,7 @@ if (!$error && $action == 'writebookkeeping') {
} }
} }
} }
} } else { // If thirdparty unknown, output the waiting account
else { // If thirdparty unknown, output the waiting account
foreach ($tabbq[$key] as $k => $mt) { foreach ($tabbq[$key] as $k => $mt) {
if ($mt) if ($mt)
{ {
@ -752,9 +750,7 @@ if (!$error && $action == 'writebookkeeping') {
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@ -775,9 +771,7 @@ if (!$error && $action == 'writebookkeeping') {
if (!$errorforline) if (!$errorforline)
{ {
$db->commit(); $db->commit();
} } else {
else
{
//print 'KO for line '.$key.' '.$error.'<br>'; //print 'KO for line '.$key.' '.$error.'<br>';
$db->rollback(); $db->rollback();
@ -792,13 +786,10 @@ if (!$error && $action == 'writebookkeeping') {
if (empty($error) && count($tabpay) > 0) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} } elseif (count($tabpay) == $error)
elseif (count($tabpay) == $error)
{ {
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} } else {
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
} }
@ -884,9 +875,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if ($tabtype[$key] == 'banktransfert') if ($tabtype[$key] == 'banktransfert')
{ {
$reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
} } else {
else
{
$reflabel .= dol_string_nohtmltag($val['soclib']); $reflabel .= dol_string_nohtmltag($val['soclib']);
} }
@ -981,11 +970,11 @@ if (empty($action) || $action == 'view') {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->nb > 0) if ($obj->nb > 0)
{ {
print '<br>'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount");
print ' : '.$langs->trans("AccountancyAreaDescBank", 9, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>'); print ' : '.$langs->trans("AccountancyAreaDescBank", 9, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>');
print '</div>';
} }
} } else dol_print_error($db);
else dol_print_error($db);
// Button to write into Ledger // Button to write into Ledger
@ -1004,8 +993,7 @@ if (empty($action) || $action == 'view') {
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
|| ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} } else {
else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
} }
@ -1077,8 +1065,7 @@ if (empty($action) || $action == 'view') {
if (empty($accounttoshow) || $accounttoshow == 'NotDefined') if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
} } else print $accounttoshow;
else print $accounttoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -1109,9 +1096,7 @@ if (empty($action) || $action == 'view') {
if ($tabtype[$key] == 'banktransfert') if ($tabtype[$key] == 'banktransfert')
{ {
$reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer;
} } else {
else
{
$reflabel .= $val['soclib']; $reflabel .= $val['soclib'];
} }
@ -1139,14 +1124,10 @@ if (empty($action) || $action == 'view') {
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 '<span class="error">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; print '<span class="error">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>';
} } else {
else
{
print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account
} }
} } else {
else
{
// We will refuse writing // We will refuse writing
$errorstring = 'UnknownAccountForThirdpartyBlocking'; $errorstring = 'UnknownAccountForThirdpartyBlocking';
if ($tabtype[$key] == 'payment') $errorstring = 'MainAccountForCustomersNotDefined'; if ($tabtype[$key] == 'payment') $errorstring = 'MainAccountForCustomersNotDefined';
@ -1157,8 +1138,7 @@ if (empty($action) || $action == 'view') {
if ($tabtype[$key] == 'member') $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; if ($tabtype[$key] == 'member') $errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
print '<span class="error">'.$langs->trans($errorstring).'</span>'; print '<span class="error">'.$langs->trans($errorstring).'</span>';
} }
} } else print $accounttoshow;
else print $accounttoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
@ -1182,13 +1162,10 @@ if (empty($action) || $action == 'view') {
} else { } else {
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
} }
} } else {
else
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>';
} }
} } else print $accounttoshowsubledger;
else print $accounttoshowsubledger;
} }
} }
print "</td>"; print "</td>";
@ -1294,57 +1271,49 @@ function getSourceDocRef($val, $typerecord)
$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; $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"]; $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=".$val["paymentid"];
$ref = $langs->transnoentitiesnoconv("Invoice"); $ref = $langs->transnoentitiesnoconv("Invoice");
} } elseif ($typerecord == 'payment_supplier')
elseif ($typerecord == 'payment_supplier')
{ {
$sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; $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 .= " 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"]; $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".$val["paymentsupplierid"];
$ref = $langs->transnoentitiesnoconv("SupplierInvoice"); $ref = $langs->transnoentitiesnoconv("SupplierInvoice");
} } elseif ($typerecord == 'payment_expensereport')
elseif ($typerecord == 'payment_expensereport')
{ {
$sqlmid = 'SELECT e.rowid as id, e.ref'; $sqlmid = 'SELECT e.rowid as id, e.ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; $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"; $sqlmid .= " WHERE pe.rowid=".$val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid";
$ref = $langs->transnoentitiesnoconv("ExpenseReport"); $ref = $langs->transnoentitiesnoconv("ExpenseReport");
} } elseif ($typerecord == 'payment_salary')
elseif ($typerecord == 'payment_salary')
{ {
$sqlmid = 'SELECT s.rowid as ref'; $sqlmid = 'SELECT s.rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sqlmid .= " WHERE s.rowid=".$val["paymentsalid"]; $sqlmid .= " WHERE s.rowid=".$val["paymentsalid"];
$ref = $langs->transnoentitiesnoconv("SalaryPayment"); $ref = $langs->transnoentitiesnoconv("SalaryPayment");
} } elseif ($typerecord == 'sc')
elseif ($typerecord == 'sc')
{ {
$sqlmid = 'SELECT sc.rowid as ref'; $sqlmid = 'SELECT sc.rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc";
$sqlmid .= " WHERE sc.rowid=".$val["paymentscid"]; $sqlmid .= " WHERE sc.rowid=".$val["paymentscid"];
$ref = $langs->transnoentitiesnoconv("SocialContribution"); $ref = $langs->transnoentitiesnoconv("SocialContribution");
} } elseif ($typerecord == 'payment_vat')
elseif ($typerecord == 'payment_vat')
{ {
$sqlmid = 'SELECT v.rowid as ref'; $sqlmid = 'SELECT v.rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v";
$sqlmid .= " WHERE v.rowid=".$val["paymentvatid"]; $sqlmid .= " WHERE v.rowid=".$val["paymentvatid"];
$ref = $langs->transnoentitiesnoconv("PaymentVat"); $ref = $langs->transnoentitiesnoconv("PaymentVat");
} } elseif ($typerecord == 'payment_donation')
elseif ($typerecord == 'payment_donation')
{ {
$sqlmid = 'SELECT payd.fk_donation as ref'; $sqlmid = 'SELECT payd.fk_donation as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd";
$sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"]; $sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"];
$ref = $langs->transnoentitiesnoconv("Donation"); $ref = $langs->transnoentitiesnoconv("Donation");
} } elseif ($typerecord == 'payment_loan')
elseif ($typerecord == 'payment_loan')
{ {
$sqlmid = 'SELECT l.rowid as ref'; $sqlmid = 'SELECT l.rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l";
$sqlmid .= " WHERE l.rowid=".$val["paymentloanid"]; $sqlmid .= " WHERE l.rowid=".$val["paymentloanid"];
$ref = $langs->transnoentitiesnoconv("LoanPayment"); $ref = $langs->transnoentitiesnoconv("LoanPayment");
} } elseif ($typerecord == 'payment_various')
elseif ($typerecord == 'payment_various')
{ {
$sqlmid = 'SELECT v.rowid as ref'; $sqlmid = 'SELECT v.rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
@ -1367,8 +1336,7 @@ function getSourceDocRef($val, $typerecord)
{ {
$ref .= ' '.$objmid->ref; $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 $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300

View File

@ -70,17 +70,19 @@ $accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code; $journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label; $journal_label = $accountingjournalstatic->label;
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_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); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_startmonth) || empty($date_endmonth))
{
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
}
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form 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_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
@ -101,6 +103,10 @@ $sql .= " AND erd.fk_code_ventilation > 0";
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'"; $sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already')
{ {
@ -231,9 +237,7 @@ if ($action == 'writebookkeeping') {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@ -281,9 +285,7 @@ if ($action == 'writebookkeeping') {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@ -341,9 +343,7 @@ if ($action == 'writebookkeeping') {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
@ -365,9 +365,7 @@ if ($action == 'writebookkeeping') {
if (!$errorforline) if (!$errorforline)
{ {
$db->commit(); $db->commit();
} } else {
else
{
$db->rollback(); $db->rollback();
if ($error >= 10) if ($error >= 10)
@ -382,13 +380,10 @@ if ($action == 'writebookkeeping') {
if (empty($error) && count($tabpay) > 0) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} } elseif (count($tabpay) == $error)
elseif (count($tabpay) == $error)
{ {
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} } else {
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
} }
@ -511,8 +506,7 @@ if (empty($action) || $action == 'view') {
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} } else {
else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
} }
@ -582,8 +576,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -612,8 +605,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("MainAccountForUsersNotDefined").'</span>'; print '<span class="error">'.$langs->trans("MainAccountForUsersNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -621,8 +613,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("UserAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("UserAccountNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print '</td>'; print '</td>';
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>"; print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>"; print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
@ -649,8 +640,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";

View File

@ -75,17 +75,19 @@ $accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code; $journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label; $journal_label = $accountingjournalstatic->label;
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_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); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_startmonth) || empty($date_endmonth))
{
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
}
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form 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_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
@ -111,6 +113,10 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} }
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already')
{ {
@ -152,8 +158,9 @@ if ($result) {
if (empty($compta_prod)) { if (empty($compta_prod)) {
if ($obj->product_type == 0) if ($obj->product_type == 0)
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined';
else else {
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined';
}
} }
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
@ -226,8 +233,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
{ {
$errorforinvoice[$key] = 'somelinesarenotbound'; $errorforinvoice[$key] = 'somelinesarenotbound';
} }
} } else dol_print_error($db);
else dol_print_error($db);
} }
//var_dump($errorforinvoice);exit; //var_dump($errorforinvoice);exit;
@ -331,9 +337,7 @@ if ($action == 'writebookkeeping') {
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'other'; $errorforinvoice[$key] = 'other';
@ -383,9 +387,7 @@ if ($action == 'writebookkeeping') {
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'other'; $errorforinvoice[$key] = 'other';
@ -446,9 +448,7 @@ if ($action == 'writebookkeeping') {
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'other'; $errorforinvoice[$key] = 'other';
@ -499,9 +499,7 @@ if ($action == 'writebookkeeping') {
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'other'; $errorforinvoice[$key] = 'other';
@ -524,9 +522,7 @@ if ($action == 'writebookkeeping') {
if (!$errorforline) if (!$errorforline)
{ {
$db->commit(); $db->commit();
} } else {
else
{
$db->rollback(); $db->rollback();
if ($error >= 10) if ($error >= 10)
@ -541,13 +537,10 @@ if ($action == 'writebookkeeping') {
if (empty($error) && count($tabpay) > 0) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} } elseif (count($tabpay) == $error)
elseif (count($tabpay) == $error)
{ {
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} } else {
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
} }
@ -743,8 +736,7 @@ if (empty($action) || $action == 'view') {
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} } else {
else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
} }
@ -871,8 +863,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>'; print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -880,8 +871,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print '</td>'; print '</td>';
print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."</td>"; print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>"; print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
@ -904,8 +894,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -937,8 +926,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").')</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").')</span>';
} } else print $accountoshow;
else print $accountoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -968,8 +956,7 @@ if (empty($action) || $action == 'view') {
if ($accountoshow == '' || $accountoshow == 'NotDefined') if ($accountoshow == '' || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
} } else print $accountoshow;
else print $accountoshow;
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";

View File

@ -78,17 +78,19 @@ $accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code; $journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label; $journal_label = $accountingjournalstatic->label;
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_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); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_startmonth) || empty($date_endmonth))
{
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
}
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form 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_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
@ -115,6 +117,10 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common s
$sql .= " AND fd.product_type IN (0,1)"; $sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already')
{ {
@ -158,8 +164,9 @@ if ($result) {
if (empty($compta_prod)) { if (empty($compta_prod)) {
if ($obj->product_type == 0) if ($obj->product_type == 0)
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
else else {
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
}
} }
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
@ -240,8 +247,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
{ {
$errorforinvoice[$key] = 'somelinesarenotbound'; $errorforinvoice[$key] = 'somelinesarenotbound';
} }
} } else dol_print_error($db);
else dol_print_error($db);
} }
//var_dump($errorforinvoice);exit; //var_dump($errorforinvoice);exit;
@ -342,9 +348,7 @@ if ($action == 'writebookkeeping') {
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'other'; $errorforinvoice[$key] = 'other';
@ -394,9 +398,7 @@ if ($action == 'writebookkeeping') {
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'other'; $errorforinvoice[$key] = 'other';
@ -456,9 +458,7 @@ if ($action == 'writebookkeeping') {
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} } else {
else
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'other'; $errorforinvoice[$key] = 'other';
@ -482,9 +482,7 @@ if ($action == 'writebookkeeping') {
if (!$errorforline) if (!$errorforline)
{ {
$db->commit(); $db->commit();
} } else {
else
{
$db->rollback(); $db->rollback();
if ($error >= 10) if ($error >= 10)
@ -499,13 +497,9 @@ if ($action == 'writebookkeeping') {
if (empty($error) && count($tabpay) > 0) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} } elseif (count($tabpay) == $error) {
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} } else {
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
} }
@ -659,8 +653,9 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$description .= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
else else {
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
}
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
@ -680,8 +675,7 @@ if (empty($action) || $action == 'view') {
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} } else {
else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
} }
@ -807,8 +801,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>'; print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -816,8 +809,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print '</td>'; print '</td>';
print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>"; print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>"; print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
@ -841,8 +833,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
} } else print $accountoshow;
else print $accountoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -875,8 +866,7 @@ if (empty($action) || $action == 'view') {
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')</span>';
} } else print $accountoshow;
else print $accountoshow;
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";

View File

@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("bills", "accountancy")); $langs->loadLangs(array("bills", "accountancy"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -63,9 +63,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} } else {
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage)
{ {

View File

@ -45,8 +45,7 @@ if (!$user->rights->accounting->bind->write)
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else else {
{
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
} }
@ -129,9 +128,9 @@ if ($action == 'validatehistory') {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2"; $sql .= " AND l.product_type <= 2";
@ -192,8 +191,7 @@ if ($action == 'validatehistory') {
if ($error) if ($error)
{ {
$db->rollback(); $db->rollback();
} } else {
else {
$db->commit(); $db->commit();
setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
} }
@ -234,7 +232,7 @@ for ($i = 1; $i <= 12; $i++) {
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
@ -247,6 +245,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND ff.fk_statut > 0"; $sql .= " AND ff.fk_statut > 0";
$sql .= " AND ffd.product_type <= 2"; $sql .= " AND ffd.product_type <= 2";
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
@ -263,15 +265,13 @@ if ($resql) {
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} } else print length_accountg($row[0]);
else print length_accountg($row[0]);
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} } else print $row[1];
else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
@ -305,7 +305,7 @@ for ($i = 1; $i <= 12; $i++) {
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
@ -318,6 +318,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND ff.fk_statut > 0"; $sql .= " AND ff.fk_statut > 0";
$sql .= " AND ffd.product_type <= 2"; $sql .= " AND ffd.product_type <= 2";
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
@ -327,33 +331,31 @@ $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('htdocs/accountancy/supplier/index.php'); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} } else print length_accountg($row[0]);
else print length_accountg($row[0]);
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} } else print $row[1];
else print $row[1];
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right">'.price($row[13]).'</td>'; print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
@ -362,56 +364,60 @@ print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
{ {
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print load_fiche_titre($langs->trans("OtherInfo"), '', ''); //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>'; print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; $sql = "SELECT '".$db->escape($langs->trans("CAHTF"))."' AS label,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND ff.fk_statut > 0"; // Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
$sql .= " AND ff.fk_statut > 0";
$sql .= " AND ffd.product_type <= 2"; $sql .= " AND ffd.product_type <= 2";
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/supplier/index.php'); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr><td>'.$row[0].'</td>'; print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
} }
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>'; print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
} }
// End of page // End of page

View File

@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@ -62,8 +62,8 @@ $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0; if (empty($page) || $page < 0) $page = 0;
$offset = $limit * $page; $offset = $limit * $page;
@ -94,7 +94,7 @@ $formaccounting = new FormAccounting($db);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
$search_label = ''; $search_label = '';
@ -177,7 +177,7 @@ print '<script type="text/javascript">
*/ */
$sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,"; $sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
$sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,"; $sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
$sql .= " aa.label, aa.labelshort, aa.account_number, "; $sql .= " aa.label, aa.labelshort, aa.account_number,";
$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,"; $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,";
$sql .= " co.code as country_code, co.label as country,"; $sql .= " co.code as country_code, co.label as country,";
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur";
@ -196,7 +196,7 @@ if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
@ -250,13 +250,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -318,7 +318,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
// print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; // print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@ -343,17 +343,19 @@ if ($result) {
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
$checkpicto = $form->showCheckAddButtons(); $checkpicto = $form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$thirdpartystatic = new Societe($db); $thirdpartystatic = new Societe($db);
$facturefournisseur_static = new FactureFournisseur($db); $facturefournisseur_static = new FactureFournisseur($db);
$product_static = new ProductFournisseur($db); $productstatic = new ProductFournisseur($db);
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
while ($i < min($num_lines, $limit)) { $i = 0;
while ($i < min($num_lines, $limit))
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->ref = $objp->ref;
@ -370,10 +372,10 @@ if ($result) {
$thirdpartystatic->email = $objp->email; $thirdpartystatic->email = $objp->email;
$thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->country_code = $objp->country_code;
$product_static->ref = $objp->product_ref; $productstatic->ref = $objp->product_ref;
$product_static->id = $objp->product_id; $productstatic->id = $objp->product_id;
$product_static->label = $objp->product_label; $productstatic->label = $objp->product_label;
$product_static->type = $objp->line_type; $productstatic->type = $objp->line_type;
$accountingaccountstatic->rowid = $objp->fk_compte; $accountingaccountstatic->rowid = $objp->fk_compte;
$accountingaccountstatic->label = $objp->label; $accountingaccountstatic->label = $objp->label;
@ -397,8 +399,8 @@ if ($result) {
// Ref Product // Ref Product
print '<td class="tdoverflowmax100">'; print '<td class="tdoverflowmax100">';
if ($product_static->id > 0) print $product_static->getNomUrl(1); if ($productstatic->id > 0) print $productstatic->getNomUrl(1);
if ($product_static->id > 0 && $objp->product_label) print '<br>'; if ($productstatic->id > 0 && $objp->product_label) print '<br>';
if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>'; if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>';
print '</td>'; print '</td>';
@ -413,7 +415,7 @@ if ($result) {
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>'; print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
// Country // Country
print '<td>'; print '<td>';
@ -425,8 +427,9 @@ if ($result) {
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
print '<td>'; print '<td class="center">';
print $accountingaccountstatic->getNomUrl(0, 1, 1).' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>'; print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
@ -434,14 +437,14 @@ if ($result) {
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
print "</div>"; print "</div>";
if ($nbtotalofrecords > $limit) { if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
} }
print '</form>'; print '</form>';
} else { } else {
print $db->lasterror(); print $db->lasterror();
} }

View File

@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "productbatch")); $langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "productbatch"));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
@ -69,8 +69,8 @@ $btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page; $offset = $limit * $page;
@ -118,7 +118,7 @@ if (empty($reshook))
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_societe=''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
@ -144,50 +144,48 @@ if (empty($reshook))
if ($massaction == 'ventil') { if ($massaction == 'ventil') {
$msg = ''; $msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><span style="color:red">' . $langs->trans("Processing") . '...</span></div>';
if (!empty($mesCasesCochees)) { if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">'; $msg .= '<div class="detail">';
$cpt = 0; $cpt = 0;
$ok = 0; $ok = 0;
$ko = 0; $ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) { foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0)
{ {
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>';
$ko++; $ko++;
} } else {
else $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
{ $sql .= " SET fk_code_ventilation = ".$monCompte;
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql .= " WHERE rowid = ".$monId;
$sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db); $accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, ''); $accountventilated->fetch($monCompte, '', 1);
dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG); dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $msg .= '<div><span style="color:green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</span></div>';
$ok++; $ok++;
} else { } else {
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></span></div>';
$ko++; $ko++;
} }
} }
$cpt++; $cpt++;
} }
$msg .= '</div>'; $msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
} }
} }
@ -205,8 +203,8 @@ if (empty($chartaccountcode))
{ {
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
exit; exit;
} }
@ -228,38 +226,42 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2"; $sql .= " AND l.product_type <= 2";
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
}
// Add search filter like // Add search filter like
if ($search_societe) { if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
} }
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= natural_search("f.ref", $search_invoice); $sql .= natural_search("f.ref", $search_invoice);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= natural_search("f.libelle", $search_label); $sql .= natural_search("f.libelle", $search_label);
} }
if (strlen(trim($search_ref))) { if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref); $sql .= natural_search("p.ref", $search_ref);
} }
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= natural_search("l.description", $search_desc); $sql .= natural_search("l.description", $search_desc);
} }
if (strlen(trim($search_amount))) { if (strlen(trim($search_amount))) {
$sql .= natural_search("l.total_ht", $search_amount, 1); $sql .= natural_search("l.total_ht", $search_amount, 1);
} }
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {
$sql .= natural_search("aa.account_number", $search_account); $sql .= natural_search("aa.account_number", $search_account);
} }
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1); $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
} }
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
@ -297,13 +299,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -320,7 +322,7 @@ if ($result) {
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_societe) $param.='&search_societe='.urlencode($search_societe); if ($search_societe) $param .= '&search_societe='.urlencode($search_societe);
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month); if ($search_month) $param .= '&search_month='.urlencode($search_month);
@ -335,9 +337,9 @@ if ($result) {
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
@ -373,7 +375,7 @@ if ($result) {
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
@ -383,9 +385,9 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
@ -400,7 +402,7 @@ if ($result) {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder); //print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
//print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
@ -409,7 +411,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = ''; $checkpicto = '';
@ -417,7 +419,7 @@ if ($result) {
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
$thirdpartystatic=new Societe($db); $thirdpartystatic = new Societe($db);
$facturefourn_static = new FactureFournisseur($db); $facturefourn_static = new FactureFournisseur($db);
$product_static = new Product($db); $product_static = new Product($db);
@ -461,6 +463,7 @@ if ($result) {
$facturefourn_static->ref = $objp->ref; $facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid; $facturefourn_static->id = $objp->facid;
$facturefourn_static->type = $objp->type; $facturefourn_static->type = $objp->type;
$facturefourn_static->label = $objp->invoice_label;
$code_buy_p_notset = ''; $code_buy_p_notset = '';
$objp->aarowid_suggest = ''; // Will be set later $objp->aarowid_suggest = ''; // Will be set later
@ -533,21 +536,22 @@ if ($result) {
// Ref Invoice // Ref Invoice
print '<td class="nowraponall">'.$facturefourn_static->getNomUrl(1).'</td>'; print '<td class="nowraponall">'.$facturefourn_static->getNomUrl(1).'</td>';
print '<td class="tdoverflowonsmartphone">'; /*print '<td class="tdoverflowonsmartphone">';
print $objp->invoice_label; print $objp->invoice_label;
print '</td>'; print '</td>';
*/
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref Product // Ref Product
print '<td>'; print '<td class="tdoverflowmax150">';
if ($product_static->id > 0) if ($product_static->id > 0)
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
if ($objp->product_label) print '<br><span class="opacitymedium">'.$objp->product_label.'</span>'; if ($objp->product_label) print '<br><span class="opacitymedium small">'.$objp->product_label.'</span>';
print '</td>'; print '</td>';
// Description // Description
print '<td class="tdoverflowonsmartphone">'; print '<td class="tdoverflowonsmartphone small">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
@ -565,15 +569,15 @@ if ($result) {
print '</td>'; print '</td>';
// Thirdparty // Thirdparty
print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>'; print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
// Country // Country
print '<td>'; print '<td>';
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
print $labelcountry; print $labelcountry;
print '</td>'; print '</td>';
// VAT Num // VAT Num
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
// Found accounts // Found accounts
@ -609,8 +613,7 @@ if ($result) {
$suggestedid = $tmpaccount->id; $suggestedid = $tmpaccount->id;
} }
$accountingaccount_codetotid_cache[$objp->code_buy_l] = $tmpaccount->id; $accountingaccount_codetotid_cache[$objp->code_buy_l] = $tmpaccount->id;
} } else {
else {
$suggestedid = $accountingaccount_codetotid_cache[$objp->code_buy_l]; $suggestedid = $accountingaccount_codetotid_cache[$objp->code_buy_l];
} }
} }

View File

@ -58,9 +58,7 @@ if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$
$endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard'); $endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard');
$completefilename = $siren."FEC".$endaccountingperiod.".txt"; $completefilename = $siren."FEC".$endaccountingperiod.".txt";
} } else {
else
{
$completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format; $completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format;
} }

View File

@ -41,7 +41,7 @@ if (!$user->admin) accessforbidden();
$type = array('yesno', 'texte', 'chaine'); $type = array('yesno', 'texte', 'chaine');
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
/* /*
@ -49,8 +49,7 @@ $action = GETPOST('action', 'alpha');
*/ */
// //
if ($action == 'updateall') if ($action == 'updateall') {
{
$db->begin(); $db->begin();
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
$res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
@ -58,36 +57,29 @@ if ($action == 'updateall')
$res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
$res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
// Use vat for invoice creation // Use vat for invoice creation
if ($conf->facture->enabled) if ($conf->facture->enabled) {
{
$res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
{
$res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
} }
} }
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
{
setEventMessages('ErrorFailedToSaveDate', null, 'errors'); setEventMessages('ErrorFailedToSaveDate', null, 'errors');
$db->rollback(); $db->rollback();
} } else {
else
{
setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
$db->commit(); $db->commit();
} }
} }
// Action to update or add a constant // Action to update or add a constant
if ($action == 'update' || $action == 'add') if ($action == 'update' || $action == 'add') {
{
$constname = GETPOST('constname', 'alpha'); $constname = GETPOST('constname', 'alpha');
$constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue')); $constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue = ''; if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue = '';
if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') { // Invert choice
{
if ($constvalue) $constvalue = 0; if ($constvalue) $constvalue = 0;
else $constvalue = 1; else $constvalue = 1;
} }
@ -98,32 +90,25 @@ if ($action == 'update' || $action == 'add')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} } else {
else
{
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
// Action to enable of a submodule of the adherent module // Action to enable of a submodule of the adherent module
if ($action == 'set') if ($action == 'set') {
{
$result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
if ($result < 0) if ($result < 0) {
{
print $db->error(); print $db->error();
} }
} }
// Action to disable a submodule of the adherent module // Action to disable a submodule of the adherent module
if ($action == 'unset') if ($action == 'unset') {
{
$result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
if ($result < 0) if ($result < 0) {
{
print $db->error(); print $db->error();
} }
} }
@ -183,33 +168,27 @@ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty(
if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice"); if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice");
print '<td>'; print '<td>';
print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0);
if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') {
{
print '<br><div style="padding-top: 5px;"><span class="opacitymedium">'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'</span></div>'; print '<br><div style="padding-top: 5px;"><span class="opacitymedium">'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'</span></div>';
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Use vat for invoice creation // Use vat for invoice creation
if ($conf->facture->enabled) if ($conf->facture->enabled) {
{
print '<tr class="oddeven"><td>'.$langs->trans("VATToUseForSubscriptions").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("VATToUseForSubscriptions").'</td>';
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{
print '<td>'; print '<td>';
print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0); print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0);
print '</td>'; print '</td>';
} } else {
else
{
print '<td class="right">'; print '<td class="right">';
print $langs->trans("WarningModuleNotActive", $langs->transnoentities("Module85Name")); print $langs->trans("WarningModuleNotActive", $langs->transnoentities("Module85Name"));
print '</td>'; print '</td>';
} }
print "</tr>\n"; print "</tr>\n";
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
{
print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
print '<td>'; print '<td>';
$form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0); $form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0);
@ -234,12 +213,12 @@ print '<br>';
*/ */
$constantes = array( $constantes = array(
'ADHERENT_CARD_TYPE', 'ADHERENT_CARD_TYPE',
// 'ADHERENT_CARD_BACKGROUND', //'ADHERENT_CARD_BACKGROUND',
'ADHERENT_CARD_HEADER_TEXT', 'ADHERENT_CARD_HEADER_TEXT',
'ADHERENT_CARD_TEXT', 'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT', 'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_CARD_FOOTER_TEXT' 'ADHERENT_CARD_FOOTER_TEXT'
); );
print load_fiche_titre($langs->trans("MembersCards"), '', ''); print load_fiche_titre($langs->trans("MembersCards"), '', '');

View File

@ -41,21 +41,21 @@ if (!$user->admin) accessforbidden();
$oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones $oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
$error = 0; $error = 0;
// Editing global variables not related to a specific theme // Editing global variables not related to a specific theme
$constantes = array( $constantes = array(
'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
'ADHERENT_MAIL_FROM'=>'string', 'ADHERENT_MAIL_FROM'=>'string',
'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
); );
@ -65,32 +65,27 @@ $constantes = array(
*/ */
// //
if ($action == 'updateall') if ($action == 'updateall') {
{ $db->begin();
$db->begin(); $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) setEventMessages('ErrorFailedToSaveDate', null, 'errors');
{ $db->rollback();
setEventMessages('ErrorFailedToSaveDate', null, 'errors'); } else {
$db->rollback(); setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
} $db->commit();
else }
{
setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
$db->commit();
}
} }
// Action to update or add a constant // Action to update or add a constant
if ($action == 'update' || $action == 'add') if ($action == 'update' || $action == 'add') {
{
$constlineid = GETPOST('rowid', 'int'); $constlineid = GETPOST('rowid', 'int');
$constname = GETPOST('constname', 'alpha'); $constname = GETPOST('constname', 'alpha');
$constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue')); $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alphanohtml') : GETPOST('constvalue'));
$consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype')); $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
$constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote')); $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'restricthtml') : GETPOST('constnote'));
$typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype]; $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
$constvalue = preg_replace('/:member$/', '', $constvalue); $constvalue = preg_replace('/:member$/', '', $constvalue);
@ -99,18 +94,14 @@ if ($action == 'update' || $action == 'add')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} } else {
else
{
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
/* /*
* View * View
*/ */

Some files were not shown because too many files have changed in this diff Show More