diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/.travis.yml b/.travis.yml index 529f3ea0ae3..6f54232a1d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # We use dist: precise to have php 5.3 available -dist: precise +dist: trusty sudo: required language: php @@ -31,7 +31,6 @@ addons: - pgloader php: -- '5.3' - '5.4' - '5.5' - '5.6' @@ -64,8 +63,6 @@ matrix: - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: '5.4' - env: DB=postgresql - php: '5.5' env: DB=postgresql - php: '5.6' @@ -123,7 +120,7 @@ install: - | echo "Installing PHP Unit" - if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then + if [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then composer -n require phpunit/phpunit ^4 fi if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then @@ -143,137 +140,143 @@ install: echo "Adding path of binaries tools installed by composer to the PATH" export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" echo - + + before_script: -- | - echo Start travis - echo Current dir is `pwd` - echo Home dir is `echo ~` - echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR + - | + echo Start travis + echo Current dir is `pwd` + echo Home dir is `echo ~` + echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR -- | - echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" - phpenv config-add /tmp/xdebug.ini - echo - -- | - echo "Setting up PHP" - echo - echo "Set timezone" - echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then - #echo - #echo "Enabling APC for PHP <= 5.4" - # Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6! - #echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + - | + echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" + phpenv config-add /tmp/xdebug.ini echo - echo "Enabling Memcached for PHP <= 5.4" - # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly! - echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - fi - phpenv rehash - echo -- | - if [ "$DEBUG" = true ]; then - echo "Debugging informations" + - | + echo "Setting up PHP" + echo + echo "Set timezone" + echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + if [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then + #echo + #echo "Enabling APC for PHP <= 5.4" + # Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6! + #echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + echo + echo "Enabling Memcached for PHP <= 5.4" + # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly! + echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + fi + phpenv rehash + echo + + - | + echo "Versions information" # Check PHP - php -i + echo "PHP version" + php -i | head - # Check PHP CodeSniffer installation + echo "PHPCS version" which phpcs - phpcs --version - phpcs -i + phpcs --version | head - + phpcs -i | head - # Check PHPUnit installation + echo "PHPUnit version" which phpunit - phpunit --version - # Check MySQL - mysql --version - mysql -e "SELECT VERSION();" + phpunit --version | head - + # Check Apache version + echo "Apache version" + apache2 -v | head - + # Check MariaDb + echo "MariaDb version" + mysql --version | head - + mysql -e "SELECT VERSION();" | head - echo - fi -- | - echo "Setting up database" - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then - echo "MySQL" - mysql -e 'DROP DATABASE IF EXISTS travis;' - mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' - mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' - mysql -e 'FLUSH PRIVILEGES;' - mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - fi - if [ "$DB" = 'postgresql' ]; then - #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr - pgloader mysql://root@127.0.0.1/travis postgresql:///travis - fi - # TODO: SQLite - echo + - | + echo "Setting up database" + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then + echo "MySQL" + mysql -e 'DROP DATABASE IF EXISTS travis;' + mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' + mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql -e 'FLUSH PRIVILEGES;' + mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + fi + if [ "$DB" = 'postgresql' ]; then + #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + pgloader mysql://root@127.0.0.1/travis postgresql:///travis + fi + # TODO: SQLite + echo -- | - export CONF_FILE=htdocs/conf/conf.php - echo "Setting up Dolibarr $CONF_FILE" - echo ' $CONF_FILE - echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE - echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE - echo '$'dolibarr_main_data_root=\'$TRAVIS_BUILD_DIR/documents\'';' >> $CONF_FILE - echo '$'dolibarr_main_db_host=\'127.0.0.1\'';' >> $CONF_FILE - echo '$'dolibarr_main_db_name=\'travis\'';' >> $CONF_FILE - echo '$'dolibarr_main_db_user=\'travis\'';' >> $CONF_FILE - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then - echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE - fi - if [ "$DB" = 'postgresql' ]; then - echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE - fi - # TODO: SQLite - echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE - cat $CONF_FILE - echo + - | + export CONF_FILE=htdocs/conf/conf.php + echo "Setting up Dolibarr $CONF_FILE" + echo ' $CONF_FILE + echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE + echo '$'dolibarr_main_data_root=\'$TRAVIS_BUILD_DIR/documents\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_host=\'127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_name=\'travis\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_user=\'travis\'';' >> $CONF_FILE + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then + echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE + fi + if [ "$DB" = 'postgresql' ]; then + echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE + fi + # TODO: SQLite + echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE + cat $CONF_FILE + echo -- | - echo "Create documents directory and set permissions" - # and admin/temp subdirectory needed for unit tests - mkdir -p documents/admin/temp - echo "first line" > documents/dolibarr.log - echo + - | + echo "Create documents directory and set permissions" + # and admin/temp subdirectory needed for unit tests + mkdir -p documents/admin/temp + echo "first line" > documents/dolibarr.log + echo -- | - echo "Setting up Apache + FPM" + + - echo "Setting up Apache + FPM" + - sudo apt-get update + - sudo apt-get install apache2 libapache2-mod-fastcgi # enable php-fpm - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - # Copy the included pool - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf - fi - if [ "$DEBUG" = true ]; then - cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - fi - sudo a2enmod rewrite actions fastcgi alias - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - if [ "$DEBUG" = true ]; then - cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - fi - ~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm - # configure apache virtual hosts - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/default - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default - if [ "$DEBUG" = true ]; then - sudo cat /etc/apache2/sites-available/default - fi - sudo service apache2 restart - echo + - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf + - | + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + # Copy the included pool + sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf + fi + - sudo a2enmod rewrite actions fastcgi alias + - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars + - sudo chown -R travis:travis /var/lib/apache2/fastcgi + - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm + # configure apache virtual hosts for precise + #- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default + #- sudo cat /etc/apache2/sites-available/default + # configure apache virtual hosts for trusty + - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf + - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf + - sudo cat /etc/apache2/sites-available/000-default.conf + - sudo service apache2 restart + + script: - | - echo "Checking webserver availability" + echo "Checking webserver availability by a wget -O - http://127.0.0.1" # Ensure we catch errors set -e - wget http://127.0.0.1 - if [ "$DEBUG" = true ]; then - cat index.html - fi + # The wget should return a page with line ' + wget -O - http://127.0.0.1 > test.html + head test.html set +e echo @@ -341,7 +344,6 @@ script: - | echo "Unit testing" - phpunit --version # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. set -e phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..9a84fdbbda0 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,84 @@ +# Code of Conduct + +## 1. Purpose + +A primary goal of Dolibarr is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). + +This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior. + +We invite all those who participate in Dolibarr to help us create safe and positive experiences for everyone. + +## 2. Open Source Citizenship + +A supplemental goal of this Code of Conduct is to increase open source citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community. + +Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society. + +If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know. + +## 3. Expected Behavior + +The following behaviors are expected and requested of all community members: + +* Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. +* Exercise consideration and respect in your speech and actions. +* Attempt collaboration before conflict. +* Refrain from demeaning, discriminatory, or harassing behavior and speech. +* Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. +* Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. + +## 4. Unacceptable Behavior + +The following behaviors are considered harassment and are unacceptable within our community: + +* Violence, threats of violence or violent language directed against another person. +* Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. +* Posting or displaying sexually explicit or violent material. +* Posting or threatening to post other people’s personally identifying information ("doxing"). +* Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. +* Inappropriate photography or recording. +* Inappropriate physical contact. You should have someone’s consent before touching them. +* Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances. +* Deliberate intimidation, stalking or following (online or in person). +* Advocating for, or encouraging, any of the above behavior. +* Sustained disruption of community events, including talks and presentations. + +## 5. Consequences of Unacceptable Behavior + +Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated. + +Anyone asked to stop unacceptable behavior is expected to comply immediately. + +If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event). + +## 6. Reporting Guidelines + +If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. contact@dolibarr.org. + + + +Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress. + +## 7. Addressing Grievances + +If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify Dolibarr with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. + + + +## 8. Scope + +We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues–online and in-person–as well as in all one-on-one communications pertaining to community business. + +This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members. + +## 9. Contact info + +contact@dolibarr.org + +## 10. License and attribution + +This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). + +Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). + +Retrieved on November 22, 2016 from [http://citizencodeofconduct.org/](http://citizencodeofconduct.org/) diff --git a/ChangeLog b/ChangeLog index 610f34d669f..410e49eaf4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ English Dolibarr ChangeLog WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Remove old deprecated hook 'insertExtraFields'. Triggers must be used for action on CRUD events. * Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from 'doaction' into 'sendMail'. * Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and @@ -20,8 +21,100 @@ Following changes may create regressions for some external modules, but were nec * Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better. * The hook contaxt commcard has been renamed thirdpartycomm * The hook contaxt thirdpartycard has been renamed thirdpartycontact +* Remove method Categorie:get_nb_categories() that was not used. + +***** ChangeLog for 7.0.2 compared to 7.0.1 ***** +FIX: #8023 +FIX: #8259 can't update contact birthday with REST API +FIX: #8359 +FIX: #8389 +FIX: #8478 !empty instead of count to avoid warning +FIX: #8488 +FIX: #8559 Bug to generate cheque receipt +FIX: #8571 +FIX: #8574 +FIX: #8580 +FIX: #8650 +FIX: actioncomm export: type filtering not working +FIX: Add a test to avoid to reset binding by error. +FIX: addline on invoice supplier manage rank on its own if not provided +FIX: Add warning when expense report line not into range +FIX: avoid Error: Call to undefined method mysqli::get_charset() +FIX: avoid focus problem when select2 is in a modal dialog window +FIX: Binding pages must start on fiscal month not calendar month +FIX: button "Classify bill" on supplier order was not visible +FIX: Button receive products not visible +FIX: can bypass the CSRF protection with url with domain inside +FIX: Can't edit option PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY +FIX: commonobject: don't require notnull field if default set +FIX: CommonObject: don't require 'notnull' field if 'default' set +FIX: cron script disabled if module disabled +FIX: CVE-2018-10092 +FIX: CVE-2018-10094 +FIX: CVE-2018-10095 +FIX: CVE-2018-9019 +FIX: CWE-89 +FIX: Data on income/expense report was always 0 +FIX: default addupdatedelete actions: uniformize add/update value checks +FIX: default currency not set on supplier order creation from commercial menu #8459 +FIX: delete all product variants of a parent product +FIX: Detail per account not visible when total < 0 +FIX: DOL_AUTOSET_COOKIE was not correctly setting value of cookie +FIX: don't print empty date in CommonObject::showOutputField +FIX: dont print empty date in CommonObject::showOutputField +FIX: Draft invoice must be excluded from report +FIX: environment shown on cron card +FIX: Error in ContractLigne not return to Contract +FIX: extrafields price and double were lost during a failed post. +FIX: File name not visible in email preview +FIX: filter/sorting on extrafield on contact list from contact tab +FIX: Initial month on report income/expense per predefined group +FIX: issue #8037 +FIX: Issue #8455 +FIX: issue #8470 +FIX: label in getnomurl projectlist +FIX: limit access of email template page to internal users +FIX: look and feel v7 "back to" for bookkeeping record +FIX: Max nb of generation of recurring invoice should not show warning +FIX: missing english name for object +FIX: Missing include +FIX: missing User object with API REST +FIX: modulebuilder: could not create html fields +FIX: modulebuilder: handle 'price' fieldtype +FIX: multiple creation of same event +FIX: Name of user not visible on journalizing expense report payments +FIX: Not approved holidays must not be visible into timesheet +FIX: Only approved expense report must be journalized +FIX: payment term doc-specific label was not used +FIX: payment term doc-specific label was not used (issue #8414) +FIX: project category is type 6 not 5 +FIX: Projet is not prefilled when created from overwiew page +FIX: Related contact printed in societe agenda +FIX: Removed error when no error on accounting setup page +FIX: remove var_dump +FIX: sanitize setup params +FIX: selectForFormsList: entity checked even is object not multi-entity managed +FIX: service creation, right is tested regarding the product type +FIX: some localtaxes errors +FIX: Some report have data when several chart of accounts exists +FIX: sql error using no category +FIX: SQL Injection CWE-89 +FIX: Support or multicompany for sheduled jobs +FIX: Test on mandatory status when closing proposal failed +FIX: to allow IRPF not null even if main VAT is null. +FIX: update wrong datetime extrafield +FIX: Use priority to define order of sheduled jobs +FIX: various modulebuilder-related issues +FIX: view of balance before field +FIX: weird password autocompletion in Goocle Chrome (issue #8479) +FIX: weird password autocompletion in Google Chrome (issue #8479) +FIX: When clearing filter, we must not save tmp criterias in session +FIX: With x extrafields, request for multicompany label was done x times +FIX: several XSS +FIX: zip not filtered + ***** ChangeLog for 7.0.1 compared to 7.0.0 ***** FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php FIX: #8200 @@ -377,7 +470,22 @@ Following changes may create regressions for some external modules, but were nec -***** ChangeLog for 6.0.6 compared to 6.0.6 ***** +***** ChangeLog for 6.0.7 compared to 6.0.6 ***** +FIX: #8023 +FIX: #8259 can't update contact birthday with REST API +FIX: #8478 !empty instead of count to avoid warning +FIX: #8488 +FIX: actioncomm export: type filtering not working +FIX: addline on invoice supplier manage rank on its own if not provided +FIX: issue #8037 +FIX: label in getnomurl projectlist +FIX: payment term doc-specific label was not used +FIX: payment term doc-specific label was not used (issue #8414) +FIX: project category is type 6 not 5 !! +FIX: some localtaxes errors +FIX: weird password autocompletion in Google Chrome (issue #8479) + +***** ChangeLog for 6.0.6 compared to 6.0.5 ***** FIX: #7974 Contract - Invalid reference on the document FIX: #8139 FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php diff --git a/README-FR.md b/README-FR.md index 8e6a2c5aac0..a9745bb8dbb 100644 --- a/README-FR.md +++ b/README-FR.md @@ -138,9 +138,10 @@ Voici un liste de fonctionnalites pas encore gérées par Dolibarr: Les documentations utilisateur, développeur et traducteur sont disponible sous forme de ressources de la communautés via la site [Wiki](https://wiki.dolibarr.org). -## CONTRIBUTING +## CONTRIBUER -Voir le fichier [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) +Ce projet existe grâce à ses nombreux contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. + ## CREDITS diff --git a/README.md b/README.md index 3d9ba75f1f5..b68e8b65558 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). -## FUTURE +## WHAT DOLIBARR CAN'T DO YET These are features that Dolibarr does **not** yet fully support: @@ -179,7 +179,8 @@ Administrator, user, developer and translator's documentations are available alo ## CONTRIBUTING -See [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) file +This project exists thanks to all the people who contribute. [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. + ## CREDITS @@ -199,3 +200,8 @@ Follow Dolibarr project on: - [LinkedIn](https://www.linkedin.com/company/association-dolibarr) - [YouTube](https://www.youtube.com/user/DolibarrERPCRM) - [GitHub](https://github.com/Dolibarr/dolibarr) + + +### Sponsors + +Support this project by becoming a sponsor. Your logo will show up here. 🙏 [[Become a sponsor/backer](https://opencollective.com/dolibarr#backer)] diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 5f54c95d7e0..93ee76e3359 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -45,7 +45,7 @@ $includeconstants=array(); if (empty($argv[1])) { - print "Usage: ".$script_file." release=auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n"; exit -1; } @@ -68,30 +68,52 @@ while ($i < $argc) $i++; } +if (empty($release)) +{ + print "Error: Missing release paramater\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + exit -1; +} + +$savrelease = $release; + // If release is auto, we take current version $tmpver=explode('-', $release, 2); -if ($tmpver[0] == 'auto') +if ($tmpver[0] == 'auto' || $tmpver[0] == 'autostable') { $release=DOL_VERSION; - if ($tmpver[1]) $release.='-'.$tmpver[1]; + if ($tmpver[1] && $tmpver[0] == 'auto') $release.='-'.$tmpver[1]; } if (empty($includecustom)) { - $tmpver=explode('-', $release, 2); - if (DOL_VERSION != $tmpver[0]) - { - print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpver[0].')'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; - exit -1; - } + $tmpverbis=explode('-', $release, 2); + if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable') + { + if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') + { + print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + exit -1; + } + } + else + { + $tmpverter=explode('-', DOL_VERSION, 2); + if ($tmpverter[0] != $tmpverbis[0]) + { + print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + exit -1; + } + } } else { if (! preg_match('/'.preg_quote(DOL_VERSION,'/').'-/',$release)) { - print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parmater (ex: '.DOL_VERSION.'-mydistrib).'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; exit -1; } } diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 77d78da1dc5..1ab3269d0de 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -466,10 +466,12 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.deb`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.dsc`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.tar.gz`; + $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.tar.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.deb`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.rpm`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar.gz`; + $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tgz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.zip`; @@ -849,6 +851,8 @@ if ($nboftargetok) { unlink("$NEWDESTI/${FILENAMEDEB}.changes"); print "Remove target ${FILENAMEDEB}.debian.tar.gz...\n"; unlink("$NEWDESTI/${FILENAMEDEB}.debian.tar.gz"); + print "Remove target ${FILENAMEDEB}.debian.tar.xz...\n"; + unlink("$NEWDESTI/${FILENAMEDEB}.debian.tar.xz"); print "Remove target ${FILENAMEDEBNATIVE}.orig.tar.gz...\n"; unlink("$NEWDESTI/${FILENAMEDEBNATIVE}.orig.tar.gz"); @@ -1024,7 +1028,7 @@ if ($nboftargetok) { $ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.dsc "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.orig.tar.gz "$NEWDESTI/"`; - $ret=`mv $BUILDROOT/*.debian.tar.gz "$NEWDESTI/"`; + $ret=`mv $BUILDROOT/*.debian.tar.xz "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.changes "$NEWDESTI/"`; next; } @@ -1168,7 +1172,7 @@ if ($nboftargetok) { "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'Dolibarr installer for Debian-Ubuntu (DoliDeb)', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'none', # none means it won't be published on SF - "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'none', # none means it won't be published on SF + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.xz"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'none', # none means it won't be published on SF "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'Dolibarr installer for Windows (DoliWamp)', "$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM', @@ -1181,8 +1185,7 @@ if ($nboftargetok) { "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'package_debian-ubuntu', - "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'package_debian-ubuntu', - "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.xz"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows', "$DESTI/standard/$FILENAMETGZ.tgz"=>'standard', diff --git a/build/travis-ci/apache.conf b/build/travis-ci/apache.conf index 5ba713924f2..a4965c40d68 100644 --- a/build/travis-ci/apache.conf +++ b/build/travis-ci/apache.conf @@ -1,11 +1,10 @@ DocumentRoot %TRAVIS_BUILD_DIR%/htdocs - + Options FollowSymLinks MultiViews ExecCGI AllowOverride All - Order deny,allow - Allow from all + Require all granted # Wire up Apache to use Travis CI's php-fpm. @@ -14,5 +13,9 @@ Action php5-fcgi /php5-fcgi Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization + + + Require all granted + diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 9e6ab3a8ddc..cdbc2e2bb40 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -90,6 +90,14 @@ var vTmpNode=this.newNode(vTmpCell, 'div', null, ''); vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']); vTmpNode.setAttribute('href',vTaskList[i].getLink()); +* Replace '% Comp.' to have a smaller text column header +'comp':'% Comp.' +with +'comp':'%' + + + + JCROP: ------ diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index e5485b280ae..5e2337fd67e 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -138,9 +138,7 @@ - - 0 - + @@ -156,8 +154,8 @@ - - + + diff --git a/dev/tools/github_authors_peryear.sh b/dev/tools/github_authors_peryear.sh index 99b28d4d417..1f3a7fea5f6 100755 --- a/dev/tools/github_authors_peryear.sh +++ b/dev/tools/github_authors_peryear.sh @@ -1,7 +1,13 @@ #!/bin/sh -FROM=2016-01-01 -TO=2016-12-31 +if [ "x$1" = "x" ]; then + echo "Usage: $0 YEAR" + exit +fi + + +FROM=$1-01-01 +TO=$1-12-31 echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l diff --git a/dev/tools/github_commits_perversion.sh b/dev/tools/github_commits_perversion.sh index 40ddafee617..bf76e68bc43 100755 --- a/dev/tools/github_commits_perversion.sh +++ b/dev/tools/github_commits_perversion.sh @@ -1,10 +1,11 @@ #/bin/bash -Releases=("3.8" "3.9" "4.0" "5.0", "develop") -Dates=("2010-01-01", "2011-01-01", "2012-01-01", "2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01") +Releases=("3.8" "3.9" "4.0" "5.0" "6.0" " 7.0" "develop") +Dates=("2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01", "2017-02-01", "2017-07-01", "2018-02-01", "2050-01-01") let "counter = 1" for i in "${Releases[@]}" do + echo "=== $counter git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]}" git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]} echo -n "Total $i: " git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l diff --git a/dev/tools/test/testtcpdf.php b/dev/tools/test/testtcpdf.php index ad67bce8af9..e14dae9c2a3 100755 --- a/dev/tools/test/testtcpdf.php +++ b/dev/tools/test/testtcpdf.php @@ -101,7 +101,7 @@ $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks -$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); +$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); diff --git a/dev/tools/test/testutf.php b/dev/tools/test/testutf.php index cb83f431b93..c626a92a57d 100644 --- a/dev/tools/test/testutf.php +++ b/dev/tools/test/testutf.php @@ -76,7 +76,7 @@ $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks -$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); +$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); //set image scale factor //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 7d73202eb79..b831a242bbf 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -28,12 +28,7 @@ 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 . '/accountancy/class/accountingaccount.class.php'; -// Langs -$langs->load("compta"); -$langs->load("bills"); -$langs->load("admin"); -$langs->load("accountancy"); -$langs->load("salaries"); +$langs->loadLangs(array("compta","bills","admin","accountancy","salaries")); $mesg = ''; $action = GETPOST('action','aZ09'); @@ -175,9 +170,9 @@ $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; -if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent"; -else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf->entity; +if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity; +else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity; $sql .= " WHERE asy.rowid = " . $pcgver; //print $sql; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); @@ -193,6 +188,11 @@ 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); @@ -225,9 +225,11 @@ if ($resql) print ''; print ''; - $htmlbuttonadd = '' . $langs->trans("Addanaccount") . ''; + $newcardbutton = '' . $langs->trans("Addanaccount"); + $newcardbutton.= ''; + $newcardbutton.= ''; - print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $htmlbuttonadd, '', $limit); + 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 print $langs->trans("Selectchartofaccounts") . " : "; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 9728a9524ea..f8a31b239bb 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel @@ -45,7 +45,7 @@ $langs->loadLangs(array("errors","admin","companies","resource","holiday","compt $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); -$id=GETPOST('id','int'); +$id=31; $rowid=GETPOST('rowid','alpha'); $code=GETPOST('code','alpha'); @@ -58,8 +58,8 @@ $listoffset=GETPOST('listoffset'); $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $active = 1; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +$sortfield = GETPOST("sortfield",'aZ09comma'); +$sortorder = GETPOST("sortorder",'aZ09comma'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $listlimit * $page ; @@ -84,59 +84,48 @@ $hookmanager->initHooks(array('admin')); $tabname=array(); $tabname[31]= MAIN_DB_PREFIX."accounting_system"; -$tabname[32]= MAIN_DB_PREFIX."c_accounting_category"; // Dictionary labels $tablib=array(); $tablib[31]= "Pcg_version"; -$tablib[32]= "DictionaryAccountancyCategory"; // Requests to extract data $tabsql=array(); $tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1"; -$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; // Criteria to sort dictionaries $tabsqlsort=array(); $tabsqlsort[31]="pcg_version ASC"; -$tabsqlsort[32]="position ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); $tabfield[31]= "pcg_version,label,country_id,country"; -$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); $tabfieldvalue[31]= "pcg_version,label,country"; -$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); $tabfieldinsert[31]= "pcg_version,label,fk_country"; -$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on $tabrowid=array(); $tabrowid[31]= ""; -$tabrowid[32]= ""; // Condition to show dictionary in setup page $tabcond=array(); $tabcond[31]= ! empty($conf->accounting->enabled); -$tabcond[32]= ! empty($conf->accounting->enabled); // List of help for fields $tabhelp=array(); $tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); -$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode")); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); $tabfieldcheck[31] = array(); -$tabfieldcheck[32] = array(); // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") @@ -484,7 +473,7 @@ print "
\n"; // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.urlencode($page).'&':'').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); } //var_dump($elementList); @@ -503,24 +492,9 @@ if ($id) $sql.= " c.rowid = ".$search_country_id; } - if ($sortfield) - { - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield='country_code'; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); //print $sql; @@ -643,25 +617,13 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) unset($fieldlist[2]); - if (empty($reshook)) { - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'hide'); - } - else - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); - } + fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); } print ''; - if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit') - { - print ''; - } + print ''; print ''; print ""; @@ -683,7 +645,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; @@ -880,7 +841,7 @@ if ($id) $valuetoshow=price($valuetoshow); } else if ($fieldlist[$field]=='libelle_facture') { - $langs->load("bills"); + $langs->loadLangs(array("bills")); $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=nl2br($valuetoshow); @@ -890,7 +851,7 @@ if ($id) $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { - $langs->load("propal"); + $langs->loadLangs(array("propal")); $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } @@ -915,17 +876,17 @@ if ($id) $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { - $langs->load('agenda'); + $langs->loadLangs(array("agenda")); $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { - $langs->load("bills"); + $langs->loadLangs(array("bills")); $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { - $langs->load("bills"); + $langs->loadLangs(array("bills")); $key=$langs->trans("PaymentType".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } @@ -934,12 +895,12 @@ if ($id) $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { - $langs->load("orders"); + $langs->loadLangs(array("orders")); $key=$langs->trans($obj->code); $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]}; } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { - $langs->load("sendings"); + $langs->loadLangs(array("sendings")); $key=$langs->trans("SendingMethod".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } @@ -950,7 +911,7 @@ if ($id) } else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') { - $langs->load('trips'); + $langs->loadLangs(array("trips")); $key = $langs->trans(strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } @@ -961,11 +922,11 @@ if ($id) $valuetoshow = $langs->getCurrencySymbol($obj->code,1); } else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { - $langs->load("products"); + $langs->loadLangs(array("products")); $valuetoshow=$langs->trans($obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { - $langs->load("products"); + $langs->loadLangs(array("products")); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) @@ -1062,7 +1023,6 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') global $form; global $region_id; global $elementList,$sourceList; - global $bc; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); @@ -1162,16 +1122,11 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') } elseif (in_array($fieldlist[$field], array('content'))) { - if ($tabname == MAIN_DB_PREFIX.'c_email_templates') - { - print ''; // To create an artificial CR for the current tr we are on - } - else print ''; + print ''; if ($context != 'hide') { //print ''; $okforextended=true; - if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false; $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_5, '90%'); print $doleditor->Create(1); } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 61166f88d07..669283077d9 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -31,9 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $error = 0; -// Langs -$langs->load("bills"); -$langs->load("accountancy"); +$langs->loadLangs(array("bills","accountancy")); $mesg = ''; $action = GETPOST('action','aZ09'); diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index a91c22ffe4c..34a857d65d4 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $error = 0; -$langs->load("bills"); -$langs->load("accountancy"); +$langs->loadLangs(array("bills","accountancy")); $mesg = ''; $id = GETPOST('id', 'int'); @@ -71,7 +70,7 @@ if (! empty($selectcpt)) { if ($return<0) { setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); } } if ($action == 'delete') { @@ -94,7 +93,7 @@ $formaccounting = new FormAccounting($db); llxheader('', $langs->trans('AccountingCategory')); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; print load_fiche_titre($langs->trans('AccountingCategory'), $linkback); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index fb7561dda94..681030a179f 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -54,8 +54,8 @@ $listoffset=GETPOST('listoffset'); $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $active = 1; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +$sortfield = GETPOST("sortfield",'aZ09comma'); +$sortorder = GETPOST("sortorder",'aZ09comma'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $listlimit * $page ; @@ -178,7 +178,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } if (! is_numeric(GETPOST('position','alpha'))) { - $langs->load("errors"); + $langs->loadLangs(array("errors")); $ok=0; setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors'); } @@ -300,7 +300,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); @@ -324,10 +324,10 @@ if ($action == $acts[0]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -344,10 +344,10 @@ if ($action == $acts[1]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -364,10 +364,10 @@ if ($action == 'activate_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -384,10 +384,10 @@ if ($action == 'disable_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -437,24 +437,9 @@ if ($id) $sql.= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; } - if ($sortfield) - { - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield='country_code'; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); //print $sql; @@ -471,7 +456,6 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; - $var=false; $fieldlist=explode(',',$tabfield[$id]); @@ -565,7 +549,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; @@ -735,7 +718,7 @@ if ($id) $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { - $langs->load("propal"); + $langs->loadLangs(array("propal")); $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } @@ -793,7 +776,7 @@ if ($id) print ''; if (empty($obj->formula)) { - print ''; + print ''; print $langs->trans("ListOfAccounts"); print ''; } diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index c4b31c0f169..9d254338526 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -34,12 +34,7 @@ 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/class/html.formaccounting.class.php'; -$langs->load("compta"); -$langs->load("bills"); -$langs->load("admin"); -$langs->load("accountancy"); -$langs->load("salaries"); -$langs->load("loan"); +$langs->loadLangs(array("compta","bills","admin","accountancy","salaries","loan")); // Security check if (empty($user->rights->accounting->chartofaccount)) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index dbe2a3b0c1c..6845491d003 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -28,15 +28,11 @@ */ require '../../main.inc.php'; -// Class 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 . '/accountancy/class/accountancyexport.class.php'; -$langs->load("compta"); -$langs->load("bills"); -$langs->load("admin"); -$langs->load("accountancy"); +$langs->loadLangs(array("compta","bills","admin","accountancy")); // Security access if (empty($user->rights->accounting->chartofaccount)) diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 147c140bdd1..3910e1148b4 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -39,8 +39,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="f.rowid"; // Set here default search field if (! $sortorder) $sortorder="ASC"; -$langs->load("admin"); -$langs->load("compta"); +$langs->loadLangs(array("admin","compta")); // Security check if ($user->societe_id > 0) @@ -95,6 +94,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 78c6510469b..db323881bdc 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -26,8 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; -$langs->load("admin"); -$langs->load("compta"); +$langs->loadLangs(array("admin","compta")); // Security check if ($user->societe_id > 0) diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index baadbdc0828..f8f0bd5668e 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -26,8 +26,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; -$langs->load("admin"); -$langs->load("compta"); +$langs->loadLangs(array("admin","compta")); // Security check if ($user->societe_id > 0) diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 93d41b3cbc6..6e235bc183e 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -24,16 +24,12 @@ */ require '../../main.inc.php'; -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -// langs -$langs->load("compta"); -$langs->load("bills"); -$langs->load("main"); -$langs->load("accountancy"); +// Load traductions files requiredby by page +$langs->loadLangs(array("compta","bills","accountancy")); // Security check if (! $user->admin) @@ -141,7 +137,6 @@ if ($result) { $form = new Form($db); $formaccounting = new FormAccounting($db); - $var = true; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); print ''; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 44c816530dd..64857fbfbb4 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -32,10 +32,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -$langs->load("compta"); -$langs->load("bills"); -$langs->load("admin"); -$langs->load("accountancy"); +$langs->loadLangs(array("compta","bills","admin","accountancy")); // Security access if (empty($user->rights->accounting->chartofaccount)) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index a7811a2d606..f43eb6c7444 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -30,13 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -$langs->load("admin"); -$langs->load("compta"); -$langs->load("accountancy"); +$langs->loadLangs(array("admin","compta","accountancy")); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); -$id=GETPOST('id','int'); +$id=35; $rowid=GETPOST('rowid','alpha'); $code=GETPOST('code','alpha'); @@ -86,7 +84,7 @@ $tablib[35]= "DictionaryAccountancyJournal"; // Requests to extract data $tabsql=array(); -$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; +$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a WHERE a.entity=".$conf->entity; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -102,7 +100,7 @@ $tabfieldvalue[35]= "code,label,nature"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[35]= "code,label,nature"; +$tabfieldinsert[35]= "code,label,nature,entity"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on @@ -401,24 +399,9 @@ if ($id) $sql=$tabsql[$id]; $sql.= " WHERE a.entity = ".$conf->entity; - if ($sortfield) - { - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield='country_code'; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); $fieldlist=explode(',',$tabfield[$id]); @@ -434,7 +417,6 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; - $var=false; $fieldlist=explode(',',$tabfield[$id]); @@ -514,7 +496,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; @@ -629,7 +610,7 @@ if ($id) $valuetoshow=$langs->trans('All'); } else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { - $langs->load("accountancy"); + $langs->loadLangs(array("accountancy")); $key=$langs->trans("AccountingJournalType".strtoupper($obj->nature)); $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]}); } diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index f6552d3d1e1..eb4d331f228 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -26,7 +26,6 @@ */ require '../../main.inc.php'; -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; @@ -35,12 +34,8 @@ 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 . '/product/class/product.class.php'; -// Langs -$langs->load("companies"); -$langs->load("compta"); -$langs->load("main"); -$langs->load("accountancy"); -$langs->load("products"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies","compta","accountancy","products")); // Security check if (empty($conf->accounting->enabled)) { @@ -261,7 +256,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } + $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); @@ -360,7 +361,6 @@ if ($result) $product_static = new Product($db); - $var = true; $i=0; while ($i < min($num,$limit)) { diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 15e7acd7deb..d8a59a5ba43 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2017 Alexandre Spangaro +/* Copyright (C) 2016 Olivier Geffroy + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2016-2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; // Langs -$langs->load("accountancy"); +$langs->loadLangs(array("accountancy")); $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); @@ -138,8 +138,7 @@ if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $journal = 'balance'; - + $filename = 'balance'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; $result = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); @@ -153,7 +152,6 @@ if ($action == 'export_csv') { print $object->get_compte_desc($line->numero_compte) . $sep; print price($line->debit) . $sep; print price($line->credit) . $sep; - print price($line->debit) . $sep; print price($line->credit - $line->debit) . $sep; print "\n"; } @@ -188,7 +186,7 @@ else { print ''; print ''; - $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; + $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); $moreforfilter = ''; @@ -254,8 +252,8 @@ else { print ''; // Permet d'afficher le compte comptable - if ($root_account_description != $displayed_account) { - + if (empty($displayed_account) || $root_account_description != $displayed_account) + { // Affiche un Sous-Total par compte comptable if ($displayed_account != "") { print '' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ''; @@ -263,9 +261,9 @@ else { print ''; } - // Affiche le compte comptable en d�but de ligne + // Affiche le compte comptable en debut de ligne print ""; - print '' . $root_account_description . ''; + print '' . $line->numero_compte . ($root_account_description ? ' - ' . $root_account_description : '') . ''; print ''; $displayed_account = $root_account_description; diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 1d746b4d4df..a433e19a09d 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -26,16 +26,11 @@ */ require '../../main.inc.php'; -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -// Langs -$langs->load("main"); -$langs->load("compta"); -$langs->load("bills"); -$langs->load("other"); -$langs->load("accountancy"); +// Load traductions files requiredby by page +$langs->loadLangs(array("bills","compta","accountancy","other")); // Filter $year = GETPOST("year",'int'); @@ -75,8 +70,6 @@ if ($result) { $y = $year_current; -$var = true; - print ''; print ''; @@ -108,7 +101,7 @@ if ($resql) { $row = $db->fetch_row($resql); - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f655d245e86..f0cc48a4878 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2017 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2017 Laurent Destailleur +/* Copyright (C) 2013-2017 Olivier Geffroy + * Copyright (C) 2013-2017 Florian Henry + * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,9 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -$langs->load("accountancy"); -$langs->load("bills"); -$langs->load("compta"); +$langs->loadLangs(array("accountancy", "bills", "compta")); $action = GETPOST('action','aZ09'); @@ -89,36 +87,36 @@ if ($action == "confirm_update") { if (! $error) { - $book = new BookKeeping($db); + $object = new BookKeeping($db); - $result = $book->fetch($id, null, $mode); + $result = $object->fetch($id, null, $mode); if ($result < 0) { $error++; - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { - $book->numero_compte = $account_number; - $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; - $book->label_operation= $label_operation; - $book->debit = $debit; - $book->credit = $credit; + $object->numero_compte = $account_number; + $object->subledger_account = $subledger_account; + $object->label_compte = $label_compte; + $object->label_operation= $label_operation; + $object->debit = $debit; + $object->credit = $credit; if (floatval($debit) != 0.0) { - $book->montant = $debit; - $book->sens = 'D'; + $object->montant = $debit; + $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $book->montant = $credit; - $book->sens = 'C'; + $object->montant = $credit; + $object->sens = 'C'; } - $result = $book->update($user, false, $mode); + $result = $object->update($user, false, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $debit = 0; @@ -147,39 +145,39 @@ else if ($action == "add") { } if (! $error) { - $book = new BookKeeping($db); + $object = new BookKeeping($db); - $book->numero_compte = $account_number; - $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; - $book->label_operation= $label_operation; - $book->debit = $debit; - $book->credit = $credit; - $book->doc_date = GETPOST('doc_date','alpha'); - $book->doc_type = GETPOST('doc_type','alpha'); - $book->piece_num = $piece_num; - $book->doc_ref = GETPOST('doc_ref','alpha'); - $book->code_journal = GETPOST('code_journal','alpha'); - $book->fk_doc = GETPOST('fk_doc','alpha'); - $book->fk_docdet = GETPOST('fk_docdet','alpha'); + $object->numero_compte = $account_number; + $object->subledger_account = $subledger_account; + $object->label_compte = $label_compte; + $object->label_operation= $label_operation; + $object->debit = $debit; + $object->credit = $credit; + $object->doc_date = GETPOST('doc_date','alpha'); + $object->doc_type = GETPOST('doc_type','alpha'); + $object->piece_num = $piece_num; + $object->doc_ref = GETPOST('doc_ref','alpha'); + $object->code_journal = GETPOST('code_journal','alpha'); + $object->fk_doc = GETPOST('fk_doc','alpha'); + $object->fk_docdet = GETPOST('fk_docdet','alpha'); if (floatval($debit) != 0.0) { - $book->montant = $debit; - $book->sens = 'D'; + $object->montant = $debit; + $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $book->montant = $credit; - $book->sens = 'C'; + $object->montant = $credit; + $object->sens = 'C'; } - $result = $book->createStd($user, false, $mode); + $result = $object->createStd($user, false, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $debit = 0; @@ -191,17 +189,17 @@ else if ($action == "add") { } else if ($action == "confirm_delete") { - $book = new BookKeeping($db); + $object = new BookKeeping($db); - $result = $book->fetch($id, null, $mode); - $piece_num = $book->piece_num; + $result = $object->fetch($id, null, $mode); + $piece_num = $object->piece_num; if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { - $result = $book->delete($user, false, $mode); + $result = $object->delete($user, false, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } $action = ''; @@ -210,7 +208,7 @@ else if ($action == "confirm_delete") { else if ($action == "confirm_create") { $error = 0; - $book = new BookKeeping($db); + $object = new BookKeeping($db); if (! GETPOST('code_journal','alpha') || GETPOST('code_journal','alpha') == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); @@ -225,29 +223,29 @@ else if ($action == "confirm_create") { if (! $error) { - $book->label_compte = ''; - $book->debit = 0; - $book->credit = 0; - $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth','int'), GETPOST('doc_dateday','int'), GETPOST('doc_dateyear','int')); - $book->doc_type = GETPOST('doc_type','alpha'); - $book->piece_num = GETPOST('next_num_mvt','alpha'); - $book->doc_ref = GETPOST('doc_ref','alpha'); - $book->code_journal = GETPOST('code_journal','alpha'); - $book->fk_doc = 0; - $book->fk_docdet = 0; - $book->montant = 0; + $object->label_compte = ''; + $object->debit = 0; + $object->credit = 0; + $object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth','int'), GETPOST('doc_dateday','int'), GETPOST('doc_dateyear','int')); + $object->doc_type = GETPOST('doc_type','alpha'); + $object->piece_num = GETPOST('next_num_mvt','alpha'); + $object->doc_ref = GETPOST('doc_ref','alpha'); + $object->code_journal = GETPOST('code_journal','alpha'); + $object->fk_doc = 0; + $object->fk_docdet = 0; + $object->montant = 0; - $result = $book->createStd($user,0, $mode); + $result = $object->createStd($user,0, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = 'update'; - $id=$book->id; - $piece_num = $book->piece_num; + $id=$object->id; + $piece_num = $object->piece_num; } } } @@ -260,7 +258,7 @@ if ($action == 'setdate') { } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = ''; } @@ -274,7 +272,7 @@ if ($action == 'setjournal') { } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = ''; } @@ -288,7 +286,7 @@ if ($action == 'setdocref') { } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = ''; } @@ -326,8 +324,8 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("CreateMvts")); - $book = new BookKeeping($db); - $next_num_mvt = $book->getNextNumMvt('_tmp'); + $object = new BookKeeping($db); + $next_num_mvt = $object->getNextNumMvt('_tmp'); if (empty($next_num_mvt)) { @@ -361,7 +359,7 @@ if ($action == 'create') print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -384,13 +382,13 @@ if ($action == 'create') print ''; } else { - $book = new BookKeeping($db); - $result = $book->fetchPerMvt($piece_num, $mode); + $object = new BookKeeping($db); + $result = $object->fetchPerMvt($piece_num, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } - if (! empty($book->piece_num)) + if (! empty($object->piece_num)) { $backlink = '' . $langs->trans('BackToList') . ''; @@ -398,14 +396,14 @@ if ($action == 'create') $head=array(); $h=0; - $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$book->piece_num.($mode?'&mode='.$mode:''); + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode?'&mode='.$mode:''); $head[$h][1] = $langs->trans("Transaction"); $head[$h][2] = 'transaction'; $h++; dol_fiche_head($head, 'transaction', '', -1); - //dol_banner_tab($book, '', $backlink); + //dol_banner_tab($object, '', $backlink); print '
'; print '
'; @@ -416,7 +414,7 @@ if ($action == 'create') // Account movement print '
'; print ''; - print ''; + print ''; print ''; // Date @@ -425,19 +423,19 @@ if ($action == 'create') print $langs->trans('Docdate'); print ''; if ($action != 'editdate') - print ''; + print ''; print '
' . $langs->trans("Label") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . 'Total
' . length_accountg($row[0]) . '
' . length_accountg($row[0]) . '' . price($row[1]) . '' . price($row[2]) . '' . price($row[3]) . '
' . $langs->trans("Docref") . '' . $langs->trans("Piece") . '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '' . $object->piece_num . '
piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'
'; print ''; if ($action == 'editdate') { - print '
'; + print ''; print ''; print ''; print ''; - $form->select_date($book->doc_date ? $book->doc_date : - 1, 'doc_date', '', '', '', "setdate"); + $form->select_date($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); print ''; print '
'; } else { - print $book->doc_date ? dol_print_date($book->doc_date, 'day') : ' '; + print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; } print ''; print ''; @@ -448,19 +446,19 @@ if ($action == 'create') print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; + print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; print ''; print ''; if ($action == 'editjournal') { - print '
'; + print ''; print ''; print ''; print ''; - print $formaccounting->select_journal($book->code_journal,'code_journal',0,0,array(),1,1); + print $formaccounting->select_journal($object->code_journal,'code_journal',0,0,array(),1,1); print ''; print '
'; } else { - print $book->code_journal ; + print $object->code_journal ; } print ''; print ''; @@ -468,22 +466,22 @@ if ($action == 'create') // Ref document print ''; print ''; if ($action != 'editdocref') - print ''; + print ''; print '
'; - print $langs->trans('Docref'); + print $langs->trans('Piece'); print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'
'; print ''; if ($action == 'editdocref') { - print '
'; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'; } else { - print $book->doc_ref ; + print $object->doc_ref ; } print ''; print ''; @@ -498,11 +496,11 @@ if ($action == 'create') print ''; // Doc type - if(! empty($book->doc_type)) + if(! empty($object->doc_type)) { print ''; print ''; - print ''; + print ''; print ''; } @@ -510,7 +508,7 @@ if ($action == 'create') print ''; print ''; print ''; print ''; @@ -519,7 +517,7 @@ if ($action == 'create') print ''; print ''; print ''; print ''; - if ($book->doc_type == 'customer_invoice') + if ($object->doc_type == 'customer_invoice') { $sqlmid = 'SELECT rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; - $sqlmid .= " WHERE fac.rowid=" . $book->fk_doc; + $sqlmid .= " WHERE fac.rowid=" . $object->fk_doc; dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) { @@ -563,24 +561,24 @@ if ($action == 'create') print '
'; - $result = $book->fetchAllPerMvt($piece_num, $mode); + $result = $object->fetchAllPerMvt($piece_num, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { print load_fiche_titre($langs->trans("ListeMvts"), '', ''); - print ''; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; + print ''; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; print '' . "\n"; print "
' . $langs->trans("Doctype") . '' . $book->doc_type . '' . $object->doc_type . '
' . $langs->trans("DateCreation") . ''; - print $book->date_creation ? dol_print_date($book->date_creation, 'day') : ' '; + print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; print '
' . $langs->trans("Status") . ''; - if (empty($book->validated)) { + if (empty($object->validated)) { print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; @@ -536,11 +534,11 @@ if ($action == 'create') /* print '
' . $langs->trans("Control") . '
"; - if (count($book->linesmvt) > 0) { + if (count($object->linesmvt) > 0) { $total_debit = 0; $total_credit = 0; @@ -597,7 +595,7 @@ if ($action == 'create') print "\n"; - foreach ($book->linesmvt as $line) { + foreach ($object->linesmvt as $line) { print ''; $total_debit += $line->debit; $total_credit += $line->credit; @@ -619,7 +617,7 @@ if ($action == 'create') } print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -692,11 +690,11 @@ if ($action == 'create') print '
'; if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + print ''.$langs->trans("ValidTransaction").''; } else { - print ''; + print ''; } print '   '; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 9a7ebf9716e..26a4cacf2c9 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -32,8 +32,7 @@ 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 . '/core/lib/date.lib.php'; -// Langs -$langs->load("accountancy"); +$langs->loadLangs(array("accountancy")); $action = GETPOST('action', 'alpha'); $search_mvt_num = GETPOST('search_mvt_num', 'int'); @@ -272,6 +271,7 @@ if (! empty($search_credit)) { $param .= '&search_credit=' . urlencode($search_credit); } + if ($action == 'delbookkeeping') { $import_key = GETPOST('importkey', 'alpha'); @@ -437,10 +437,12 @@ else $button.= $langs->trans("ExportList"); $button.= ''; -$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; -$addbutton = '' . $langs->trans("NewAccountingMvt") . ''; +$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; +$newcardbutton = '' . $langs->trans("NewAccountingMvt"); +$newcardbutton.= ''; +$newcardbutton.= ''; -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$addbutton, '', $limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$newcardbutton, '', $limit); $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 04708fe7726..499865233db 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro +/* Copyright (C) 2016 Neil Orley + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,15 +26,14 @@ require '../../main.inc.php'; -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.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/lib/date.lib.php'; -// Langs -$langs->load("accountancy"); +$langs->loadLangs(array("accountancy")); $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); @@ -44,17 +43,21 @@ $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', '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_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; } +$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); +if ($search_accountancy_code_end == - 1) { + $search_accountancy_code_end = ''; +} $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $search_label_operation = GETPOST('search_label_operation', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); +$search_debit = GETPOST('search_debit', 'alpha'); +$search_credit = GETPOST('search_credit', 'alpha'); // 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); @@ -96,63 +99,17 @@ if (empty($search_date_start) && empty($search_date_end)) { $object = new BookKeeping($db); - -$options = ''; -$filter = array (); - -if (! empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $options .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); -} -if (! empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $options .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); -} -if (! empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); -} - -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 (! empty($search_accountancy_code_start)) { - $filter['t.numero_compte'] = $search_accountancy_code_start; - $options .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); - } - if (! empty($search_label_account)) { - $filter['t.label_compte'] = $search_label_account; - $options .= '&search_label_compte=' . urlencode($search_label_account); - } - if (! empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $options .= '&search_doc_ref=' . urlencode($search_doc_ref); - } - if (! empty($search_label_operation)) { - $filter['t.label_operation'] = $search_label_operation; - $options .= '&search_label_operation=' . urlencode($search_label_operation); - } - if (! empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $options .= '&search_direction=' . urlencode($search_direction); - } - if (! empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - $options .= '&search_ledger_code=' . urlencode($search_ledger_code); - } -} - - /* * Action */ - 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_doc_date = ''; $search_accountancy_code = ''; $search_accountancy_code_start = ''; - $search_label_account = ''; - $search_doc_ref = ''; + $search_accountancy_code_end = ''; + $search_label_account = ''; + $search_doc_ref = ''; $search_label_operation = ''; $search_direction = ''; $search_ledger_code = ''; @@ -164,8 +121,64 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_date_endyear=''; $search_date_endmonth=''; $search_date_endday=''; + $search_debit = ''; + $search_credit = ''; } +// Must be after the remove filter action, before the export. +$param = ''; +$filter = array (); + +if (! empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); +} +if (! empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); +} +if (! empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); +} +if (! empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); +} +if (! empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); +} +if (! empty($search_label_account)) { + $filter['t.label_compte'] = $search_label_account; + $param .= '&search_label_compte=' . urlencode($search_label_account); +} +if (! empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $param .= '&search_doc_ref=' . urlencode($search_doc_ref); +} +if (! empty($search_label_operation)) { + $filter['t.label_operation'] = $search_label_operation; + $param .= '&search_label_operation=' . urlencode($search_label_operation); +} +if (! empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $param .= '&search_direction=' . urlencode($search_direction); +} +if (! empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $param .= '&search_ledger_code=' . urlencode($search_ledger_code); +} +if (! empty($search_debit)) { + $filter['t.debit'] = $search_debit; + $param .= '&search_debit=' . urlencode($search_debit); +} +if (! empty($search_credit)) { + $filter['t.credit'] = $search_credit; + $param .= '&search_credit=' . urlencode($search_credit); +} + + if ($action == 'delmouvconfirm') { $mvt_num = GETPOST('mvt_num', 'int'); @@ -189,7 +202,7 @@ $formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); -$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting"); +$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting")); llxHeader('', $title_page); @@ -239,28 +252,37 @@ if ($action == 'delbookkeepingyear') { } -$param=$options; - print ''; -$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; -$addbutton = '' . $langs->trans("NewAccountingMvt") . ''; +$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; +$newcardbutton = '' . $langs->trans("NewAccountingMvt"); +$newcardbutton.= ''; +$newcardbutton.= ''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); 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.$addbutton, '', $limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit); // Reverse sort order if ( preg_match('/^asc/i', $sortorder) ) - $sortorder = "asc"; + $sortorder = "asc"; else - $sortorder = "desc"; + $sortorder = "desc"; print '
'; @@ -656,7 +654,7 @@ if ($action == 'create') if ($total_debit != $total_credit) { - setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings'); + setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); } if ($action == "" || $action == 'add') { @@ -677,7 +675,7 @@ if ($action == 'create') } print '
'; print ''; -print ''; +print ''; print ''; print ''; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; print ''; print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF']); -print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $options, 'align="right"', $sortfield, $sortorder); -print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre("Piece", $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre("Piece", $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label"); -print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); -print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); -print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); +print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; print ''; @@ -308,34 +330,34 @@ while ($i < min($num, $limit)) $total_debit += $line->debit; $total_credit += $line->credit; - $accountg = length_accountg($line->numero_compte); + $accountg = length_accountg($line->numero_compte); //if (empty($accountg)) $accountg = '-'; // Is it a break ? - if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { + if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { - // Affiche un Sous-Total par compte comptable - if (isset($displayed_account_number)) { - print ''; - print "\n"; - print "\n"; - print ''; - } + // Affiche un Sous-Total par compte comptable + if (isset($displayed_account_number)) { + print ''; + print "\n"; + print "\n"; + print ''; + } - // Show the break account - $colspan = 9; - print ""; - print ''; - print ''; + // Show the break account + $colspan = 9; + print ""; + print ''; + print ''; - $displayed_account_number = $accountg; - //if (empty($displayed_account_number)) $displayed_account_number='-'; - $sous_total_debit = 0; - $sous_total_credit = 0; - } + $displayed_account_number = $accountg; + //if (empty($displayed_account_number)) $displayed_account_number='-'; + $sous_total_debit = 0; + $sous_total_credit = 0; + } print ''; print ''; @@ -344,22 +366,27 @@ while ($i < min($num, $limit)) // TODO Add a link according to doc_type and fk_doc print ''; + print ''; - // Affiche un lien vers la facture client/fournisseur - $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; + // Affiche un lien vers la facture client/fournisseur + $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; print ''; print ''; - print ''; + + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('',$line->code_journal); + $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal); + print ''; + print ''; print "\n"; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php index 550ea1d933a..67d89bcda90 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php @@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +$langs->loadLangs(array("compta")); + $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); @@ -141,7 +143,6 @@ if ($object->check_codeclient() != 0) print ''; print ''; -$langs->load('compta'); print ''; print ''; print ''; -$langs->load('compta'); print ''; print ''; -echo '
' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . ''; +print '
'; +print $langs->trans('From').' '; +print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); +print '
'; +print '
'; +print $langs->trans('to').' '; +print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); +print '
'; +print '
'; print $langs->trans('From') . ': '; @@ -271,8 +293,8 @@ print $form->select_date($search_date_end, 'search_date_end', 0, 0, 1); print '  '; $searchpicto=$form->showFilterAndCheckAddButtons(0); @@ -281,14 +303,14 @@ print '
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).'  
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).'  
'; - if (! empty($line->numero_compte) && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte); - else print ''.$langs->trans("Unknown").''; - print '
'; + if (! empty($line->numero_compte) && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte); + else print ''.$langs->trans("Unknown").''; + print '
 '; - //if ($line->doc_type == 'supplier_invoice') - //if ($line->doc_type == 'customer_invoice') + //if ($line->doc_type == 'supplier_invoice') + //if ($line->doc_type == 'customer_invoice') print $line->doc_ref; - print '' . $line->label_operation . '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')
' . $line->label_operation . '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')
' . ($line->debit ? price($line->debit) :''). '' . ($line->credit ? price($line->credit) : '') . '' . $line->code_journal . '' . $journaltoshow . ''; print '' . img_edit() . ' '; - print '' . img_delete() . ''; + print '' . img_delete() . ''; print '
'; print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php index 35bdcfa23fe..96317a3a740 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php @@ -35,6 +35,8 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +$langs->loadLangs(array("compta")); + $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); @@ -157,7 +159,6 @@ if ($object->check_codefournisseur() != 0) print '
'; print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 0a538f0a6ae..27254ef31d1 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -360,9 +360,11 @@ class AccountancyCategory // extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ public function display($id) { + global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = " . $id; + $sql .= " AND t.entity = " . $conf->entity; $this->lines_display = array(); @@ -400,13 +402,14 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " SELECT t.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = " . $id . ")"; + $sql .= " WHERE t.fk_accounting_category = " . $id . " AND t.entity = " . $conf->entity.")"; $sql .= " AND t.numero_compte IN ("; $sql .= " SELECT DISTINCT aa.account_number"; $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 .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1)"; + $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = = " . $conf->entity . ")"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " ORDER BY t.numero_compte"; @@ -448,6 +451,7 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; @@ -492,6 +496,7 @@ class AccountancyCategory // extends CommonObject $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $this->db->begin(); @@ -581,7 +586,7 @@ class AccountancyCategory // extends CommonObject */ public function getCatsCpts() { - global $mysoc; + global $mysoc,$conf; $sql = ""; @@ -595,8 +600,10 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1"; + $sql .= " AND c.entity = " . $conf->entity; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " AND t.entity = " . $conf->entity; $sql .= " ORDER BY cat.position ASC"; $resql = $this->db->query($sql); @@ -685,7 +692,7 @@ class AccountancyCategory // extends CommonObject */ public function getCats($categorytype=-1) { - global $db, $langs, $user, $mysoc; + global $db, $langs, $user, $mysoc, $conf; if (empty($mysoc->country_id)) { dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); @@ -695,6 +702,7 @@ class AccountancyCategory // extends CommonObject $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1 "; + $sql .= " AND c.entity = " . $conf->entity; if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " ORDER BY c.position ASC"; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3a12d606fdd..52b5f1c411f 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1,14 +1,14 @@ - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Florian Henry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016-2017 Alexandre Spangaro - * Copyright (C) 2013-2017 Olivier Geffroy - * Copyright (C) 2017 Elarifr. Ari Elbaz - * Copyright (C) 2017 Frédéric France + * Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Pierre-Henry Favre + * Copyright (C) 2016-2018 Alexandre Spangaro + * Copyright (C) 2013-2017 Olivier Geffroy + * Copyright (C) 2017 Elarifr. Ari Elbaz + * Copyright (C) 2017 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -177,7 +177,7 @@ class AccountancyExport */ public static function downloadFile() { global $conf; - $journal = 'bookkepping'; + $filename = 'general_ledger'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 0b0d42b0075..d1870fabc38 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -566,7 +566,7 @@ class AccountingAccount extends CommonObject function LibStatut($statut,$mode=0) { global $langs; - $langs->load('users'); + $langs->loadLangs(array("users")); if ($mode == 0) { diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 2e48fc8a54a..454de6d7b84 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -256,7 +256,7 @@ class AccountingJournal extends CommonObject { global $langs; - $langs->load("accountancy"); + $langs->loadLangs(array("accountancy")); if ($mode == 0) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a703e025c76..f7fed2e2b5b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -170,7 +170,7 @@ class BookKeeping extends CommonObject // Check parameters if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') { - $langs->load("errors"); + $langs->loadLangs(array("errors")); if (in_array($this->doc_type, array('bank', 'expense_report'))) { $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); @@ -246,9 +246,6 @@ class BookKeeping extends CommonObject } $now = dol_now(); - if (empty($this->date_create)) { - $this->date_create = $now; - } $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; $sql .= "doc_date"; @@ -291,7 +288,7 @@ class BookKeeping extends CommonObject $sql .= "," . $this->montant; $sql .= ",'" . $this->db->escape($this->sens) . "'"; $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; - $sql .= ",'" . $this->db->idate($this->date_create). "'"; + $sql .= ",'" . $this->db->idate($now). "'"; $sql .= ",'" . $this->db->escape($this->code_journal) . "'"; $sql .= ",'" . $this->db->escape($this->journal_label) . "'"; $sql .= "," . $this->db->escape($this->piece_num); @@ -496,9 +493,6 @@ class BookKeeping extends CommonObject $this->credit = price2num($this->credit, 'MT'); $now = dol_now(); - if (empty($this->date_create)) { - $this->date_create = $now; - } // Check parameters // Put here code to add control on parameters values @@ -545,7 +539,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ','; $sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ','; $sql .= ' ' . $user->id . ','; - $sql .= ' ' . "'" . $this->db->idate($this->date_create) . "',"; + $sql .= ' ' . "'" . $this->db->idate($now) . "',"; $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 92d8f7b1c37..d0e5adc97fd 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -24,13 +24,10 @@ */ require '../../main.inc.php'; -// Class require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -// Langs -$langs->load("bills"); -$langs->load("accountancy"); +$langs->loadLangs(array("bills","accountancy")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index aedaeda0e5b..8b88d8f396b 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -32,11 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; // Langs -$langs->load("compta"); -$langs->load("bills"); -$langs->load("other"); -$langs->load("main"); -$langs->load("accountancy"); +$langs->loadLangs(array("compta","bills","other","main","accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -129,6 +125,7 @@ llxHeader('', $langs->trans("CustomersVentilation")); $textprevyear = '' . img_previous() . ''; $textnextyear = ' ' . img_next() . ''; + print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); // Clean database @@ -160,8 +157,8 @@ $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; - -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); +print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); +//print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print '
'; print ''; @@ -236,7 +233,8 @@ print ''; print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); +print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); +//print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print '
'; @@ -315,7 +313,8 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
'; print '
'; - print_fiche_titre($langs->trans("OtherInfo"), '', ''); + print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); + //print_fiche_titre($langs->trans("OtherInfo"), '', ''); print '
'; print '
'; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index e696b4774d1..7bc929a7e6b 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -27,7 +27,6 @@ */ require '../../main.inc.php'; -// Class require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -35,12 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -// Langs -$langs->load("bills"); -$langs->load("compta"); -$langs->load("main"); -$langs->load("accountancy"); -$langs->load("productbatch"); +$langs->loadLangs(array("bills","compta","accountancy","productbatch")); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); @@ -116,10 +110,10 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); } - $db->begin(); - if (! $error) { + $db->begin(); + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; @@ -173,20 +167,24 @@ print ''; -} -*/ llxFooter(); $db->close(); diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 790445f7032..5c17fd32eb0 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -1,6 +1,6 @@ - * Copyright (C) 2017 Regis Houssin +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2017-2018 Regis Houssin * * 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 @@ -212,9 +212,9 @@ print "
\n"; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($optioncss != '') $param.='&optioncss='.$optioncss; -if (defaulturl) $param.='&defaulturl='.urlencode(defaulturl); -if (defaultkey) $param.='&defaultkey='.urlencode(defaultkey); -if (defaultvalue) $param.='&defaultvalue='.urlencode(defaultvalue); +if ($defaulturl) $param.='&defaulturl='.urlencode($defaulturl); +if ($defaultkey) $param.='&defaultkey='.urlencode($defaultkey); +if ($defaultvalue) $param.='&defaultvalue='.urlencode($defaultvalue); print 'entity) && $debug)?'?debug=1':'').'" method="POST">'; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 37f66427225..4cf423b317f 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -144,7 +144,7 @@ if ($action == 'update') $plus=''; if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; // Update values - for($i=0;$i<4;$i++) { + for($i=0; $i<4; $i++) { if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity); } @@ -172,7 +172,6 @@ if ($action == 'edit') print ''; print ''; print ''; - $var=true; print '
'; print ''; @@ -215,7 +214,6 @@ else print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; print ''; - $var=true; foreach($modules as $module => $delays) { @@ -241,7 +239,6 @@ else print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; print ''; - $var=false; print ''; print ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d8d2382a59f..74e4dd6bd4e 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -953,14 +953,14 @@ if (empty($id)) print "
\n"; -$param = '&id='.$id; -if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; +$param = '&id='.urlencode($id); +if ($search_country_id > 0) $param.= '&search_country_id='.urlencode($search_country_id); if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); if ($entity != '') $param.= '&entity=' . (int) $entity; $paramwithsearch = $param; -if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; -if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; -if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); +if ($sortorder) $paramwithsearch.= '&sortorder='.urlencode($sortorder); +if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield); +if (GETPOST('from')) $paramwithsearch.= '&from='.urlencode(GETPOST('from','alpha')); // Confirmation de la suppression de la ligne @@ -987,10 +987,10 @@ if ($id) { // If sort order is "country", we use country_code instead if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; + $sql.= " ORDER BY ".$db->escape($sortfield); if ($sortorder) { - $sql.=" ".strtoupper($sortorder); + $sql.=" ".strtoupper($db->escape($sortorder)); } $sql.=", "; // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 10653df9dc0..de3ca683519 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -118,9 +118,9 @@ class PrestaShopWebservice public function executeRequest($url, $curl_params = array()) { $defaultParams = array( - CURLOPT_HEADER => TRUE, - CURLOPT_RETURNTRANSFER => TRUE, - CURLINFO_HEADER_OUT => TRUE, + CURLOPT_HEADER => true, + CURLOPT_RETURNTRANSFER => true, + CURLINFO_HEADER_OUT => true, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $this->key.':', CURLOPT_HTTPHEADER => array( 'Expect:' ) diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index dd9e748de02..cf1992dce5f 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -33,7 +33,7 @@ if (! $user->admin) accessforbidden(); /* * Action */ -if (preg_match('/set_(.*)/',$action,$reg)) +if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) @@ -47,7 +47,7 @@ if (preg_match('/set_(.*)/',$action,$reg)) } } -if (preg_match('/del_(.*)/',$action,$reg)) +if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) @@ -80,7 +80,6 @@ print ''; print ''."\n"; print ''; -$var=true; $form = new Form($db); // Mail required for members diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index b2d9bd97980..6f4dce93e8c 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -31,9 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; if (!$user->admin) accessforbidden(); -$langs->load("users"); -$langs->load("admin"); -$langs->load("other"); +// Load traductions files requiredby by page +$langs->loadLangs(array("users","admin","other")); $action=GETPOST('action','aZ09'); @@ -42,7 +41,6 @@ $securityevent=new Events($db); $eventstolog=$securityevent->eventstolog; - /* * Actions */ @@ -88,8 +86,6 @@ $head=security_prepare_head(); dol_fiche_head($head, 'audit', $langs->trans("Security"), -1); - -$var=true; print "
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_METEO").'' . yn($conf->global->MAIN_DISABLE_METEO) . '
 '.$langs->trans("Value").'
"; print ""; print ""; @@ -98,8 +94,7 @@ print "\n"; foreach ($eventstolog as $key => $arr) { if ($arr['id']) - { - + { print ''; print ''; print '\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/expensereport/doc"); @@ -376,7 +373,6 @@ foreach ($dirmodels as $reldir) if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); @@ -480,7 +476,6 @@ print ''; print ''; print ''; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -488,7 +483,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; + echo ''; // Label echo ''; @@ -175,7 +172,6 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; echo ''; - $var=!$var; } } diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index bf615676f81..ef915e196a2 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -30,11 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.php'; -$langs->load('admin'); -$langs->load('other'); -$langs->load('trips'); -$langs->load('errors'); -$langs->load('dict'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","other","trips","errors","dict")); if (!$user->admin) accessforbidden(); @@ -176,8 +173,7 @@ if ($action != 'edit') echo ''; echo ''; - $var=true; - echo ''; + echo ''; echo ''; echo ''; echo ''; -$var=true; foreach ($rules as $rule) { - echo ''; + echo ''; echo ''; - echo ''; echo ''; - $var=!$var; } diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 4a184aa95a0..a1d542203cf 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -250,8 +250,6 @@ if ($resql) $rssparser=new RssParser($db); $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp); - $var=true; - print "
"; print ""; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 8ce73fd441f..71fa035ee00 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -310,8 +310,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -342,7 +340,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - $var = !$var; print ''; print "\n"; clearstatcache(); + $activatedModels = array(); -$var=true; + foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -533,7 +531,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print '
".$langs->trans("LogEvents")."
'.$arr['id'].''; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 442a85c9c6a..311398a78e1 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -6,7 +6,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,10 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -$langs->load("admin"); -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('other'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); if (! $user->admin) accessforbidden(); diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 28ced963f87..6d164b25282 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -233,8 +233,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (substr($file, 0, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -351,7 +349,6 @@ print "
'.$langs->trans("Parameter").'
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename='EXPENSEREPORT_FREE_TEXT'; diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index adf18433caa..bb68ea2182e 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -30,11 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php'; -$langs->load('admin'); -$langs->load('other'); -$langs->load('trips'); -$langs->load('errors'); -$langs->load('dict'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","trips","errors","other","dict")); if (!$user->admin) accessforbidden(); @@ -129,7 +126,7 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) if ($Tab['active'] == 0) continue; $tranche=1; - $var = true; + foreach ($Tab['ranges'] as $k => $range) { if (isset($Tab['ranges'][$k+1])) $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k+1]->range_ik-1)); @@ -137,7 +134,7 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) if ($range->range_active == 0) $label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3); - echo '
['.$langs->trans('RangeNum', $tranche++).'] - '.$label.'
 
'; echo '
'.$form->selectarray('apply_to', $tab_apply, '', 0).'
'; echo '
'.$form->select_dolusers('', 'fk_user').'
'; @@ -220,10 +216,9 @@ echo '
'.$langs->trans('ExpenseReportRestrictive').' 
'; if ($action == 'edit' && $object->id == $rule->id) @@ -260,7 +255,6 @@ foreach ($rules as $rule) echo ''; if ($action == 'edit' && $object->id == $rule->id) { @@ -335,7 +329,6 @@ foreach ($rules as $rule) echo '
'; echo preg_replace('/\-.*$/','',preg_replace('/mod_facture_/','',preg_replace('/\.php$/','',$file))); print "\n"; @@ -495,8 +492,9 @@ print ''.$langs->trans("Preview").'
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -614,8 +611,6 @@ foreach ($dirmodels as $reldir) print '
'; - - /* * Document templates generators */ @@ -666,7 +661,6 @@ print ''; print ''; print ''; -$var=True; print ''; print ''; print ''; print ''; print "\n"; -$var=true; // Force date validation -$var=! $var; print ''; print ''; print ''; @@ -785,7 +777,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 70b79acb931..53a2f8bf2da 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -139,8 +139,6 @@ $linkback=''; -$var=true; - if (empty($conf->use_javascript_ajax)) { setEventMessages(array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), null, 'errors'); @@ -158,7 +156,6 @@ else { // Si condition non remplie, on ne propose pas l'option if (! $conditions[$const]) continue; - print ''; print ''; diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index bf588ca90ae..59ce46921a7 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -30,8 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; if (!$user->admin) accessforbidden(); -$langs->load("admin"); -$langs->load("errors"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","errors")); $action = GETPOST('action','aZ09'); @@ -94,7 +94,6 @@ else } // Mode -$var=true; print ''; print ''; print ''; @@ -105,7 +104,6 @@ print ''; print "\n"; - print ''; print ''; print "\n"; // Type - print ''; // Version - print ''; // Serveur primaire - print ''; // Serveur secondaire - print ''; // Port - print ''; // DNserver - print ''; // Utiliser TLS - print ''; print "\n"; // DNAdmin - print ''; // Pass - print ''; break; } - if (! is_array($coll_listbuy) && $coll_listbuy == -2) + if (! is_array($x_paye) && $coll_listbuy == -2) { print ''; break; @@ -227,46 +390,121 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu print ''; - print ''; + print ''; - $x_coll = 0; - foreach($coll_listsell as $vatrate=>$val) + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) { - $x_coll+=$val['vat']; - } - $subtotalcoll = $subtotalcoll + $x_coll; - print ""; + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - $x_paye = 0; - foreach($coll_listbuy as $vatrate=>$val) + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + print ""; + + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) { - $x_paye+=$val['vat']; - } - $subtotalpaye = $subtotalpaye + $x_paye; - print ""; + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - $diff = $x_coll - $x_paye; + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + print ""; + + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; + + $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; - $subtotal = $subtotal + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print "\n"; + print "\n"; print "\n"; print "\n"; - $i++; + $i++; $m++; if ($i > 2) { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; $i = 0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; } } -print ''; +print ''; print "\n"; print ''; @@ -276,32 +514,44 @@ print '
'; @@ -730,7 +724,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE clos = 0"; $sql.= " AND courant = 1"; $sql.= " AND entity IN (".getEntity('bank_account').")"; -$var=True; + $resql=$db->query($sql); if ($resql) { @@ -763,10 +757,8 @@ print ''.$langs->trans("Parameter").''.$langs->trans("Value").' 
'.img_object("",$picto[$const]).''.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").''; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 23cc0600705..ed687288a0a 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -108,10 +108,18 @@ if ($action == 'update') if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val,'chaine',0,'',$conf->entity); + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array())))); + if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); + else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity); + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val,'chaine',0,'',$conf->entity); + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'),array())))); + if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); + else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val,'chaine',0,'',$conf->entity); + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val,'chaine',0,'',$conf->entity); @@ -126,17 +134,13 @@ if ($action == 'update') if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity); - $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity); - - if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black) - else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity); - $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity); + if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black) + else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity); @@ -543,6 +547,8 @@ else // Show print '
'; // Login page + print '
'; + print ''; print ''; @@ -573,6 +579,7 @@ else // Show print ''; print '
'.$langs->trans("LoginPage").'
'."\n"; + print '
'; print '
'; print ''.$langs->trans("Modify").''; diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 5655c0c2714..141273a8f8c 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -102,7 +102,6 @@ if (! function_exists("ldap_connect")) } -$var=true; $form=new Form($db); @@ -180,7 +179,6 @@ print '
'.$langs->trans("Example").'
'.$langs->trans("Type").''; $arraylist=array(); $arraylist['activedirectory']='Active Directory'; @@ -190,7 +188,6 @@ print $form->selectarray('type',$arraylist,$conf->global->LDAP_SERVER_TYPE); print ' 
'.$langs->trans("Version").''; $arraylist=array(); $arraylist['3']='Version 3'; @@ -199,21 +196,18 @@ print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION',$arraylist,$conf->global- print ''.$langs->trans("LDAPServerProtocolVersion").'
'; print $langs->trans("LDAPPrimaryServer").''; print ''; print ''.$langs->trans("LDAPServerExample").'
'; print $langs->trans("LDAPSecondaryServer").''; print ''; print ''.$langs->trans("LDAPServerExample").'
'.$langs->trans("LDAPServerPort").''; if (! empty($conf->global->LDAP_SERVER_PORT)) { @@ -226,13 +220,11 @@ else print ''.$langs->trans("LDAPServerPortExample").'
'.$langs->trans("LDAPServerDn").''; print ''; print ''.$langs->trans("LDAPServerDnExample").'
'.$langs->trans("LDAPServerUseTLS").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); @@ -245,13 +237,11 @@ print ''.$langs->trans("ForANonAnonymousAccess").'
'.$langs->trans("LDAPAdminDn").''; print ''; print ''.$langs->trans("LDAPAdminDnExample").'
'.$langs->trans("LDAPPassword").''; if (! empty($conf->global->LDAP_ADMIN_PASS)) { diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 07910185956..a16f147586a 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -$langs->load("admin"); -$langs->load("errors"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","errors")); if (!$user->admin) accessforbidden(); @@ -117,15 +117,12 @@ print ''; print ''; print ''; -$var=true; print ''; print ''; print "\n"; - // DN Pour les contacts - print ''; @@ -133,7 +130,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -143,7 +139,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeContacts").'
'.$langs->trans("LDAPContactDn").''; print ''; print ''.$langs->trans("LDAPContactDnExample").' 
'.$langs->trans("LDAPContactObjectClassList").''; print ''; print ''.$langs->trans("LDAPContactObjectClassListExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -152,7 +147,6 @@ print ''; print "\n"; // Common name - print ''; @@ -160,7 +154,6 @@ print ''; @@ -168,7 +161,6 @@ print ''; @@ -176,7 +168,6 @@ print ''; @@ -184,7 +175,6 @@ print ''; @@ -192,7 +182,6 @@ print ''; @@ -200,7 +189,6 @@ print ''; @@ -208,7 +196,6 @@ print ''; @@ -216,7 +203,6 @@ print ''; @@ -224,7 +210,6 @@ print ''; @@ -232,7 +217,6 @@ print ''; @@ -240,7 +224,6 @@ print ''; @@ -248,7 +231,6 @@ print ''; @@ -256,7 +238,6 @@ print ''; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 5a4e36b7792..a1d69c7216b 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; -$langs->load("admin"); -$langs->load("errors"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","errors")); if (!$user->admin) accessforbidden(); @@ -109,14 +109,12 @@ print ''; $form=new Form($db); print '
'.$langs->trans("LDAPDolibarrMapping").''.$langs->trans("LDAPNamingAttribute").'
'.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''.$langs->trans("LDAPFieldFirstName").''; print ''; print ''.$langs->trans("LDAPFieldFirstNameExample").''.$langs->trans("LDAPFieldCompany").''; print ''; print ''.$langs->trans("LDAPFieldCompanyExample").''.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''.$langs->trans("LDAPFieldPhone").''; print ''; print ''.$langs->trans("LDAPFieldPhoneExample").''.$langs->trans("LDAPFieldHomePhone").''; print ''; print ''.$langs->trans("LDAPFieldHomePhoneExample").''.$langs->trans("LDAPFieldMobile").''; print ''; print ''.$langs->trans("LDAPFieldMobileExample").''.$langs->trans("LDAPFieldSkype").''; print ''; print ''.$langs->trans("LDAPFieldSkypeExample").''.$langs->trans("LDAPFieldFax").''; print ''; print ''.$langs->trans("LDAPFieldFaxExample").''.$langs->trans("LDAPFieldAddress").''; print ''; print ''.$langs->trans("LDAPFieldAddressExample").''.$langs->trans("LDAPFieldZip").''; print ''; print ''.$langs->trans("LDAPFieldZipExample").''.$langs->trans("LDAPFieldTown").''; print ''; print ''.$langs->trans("LDAPFieldTownExample").''.$langs->trans("LDAPFieldCountry").''; print ''; print ' 
'; -$var=true; print ''; print ''; print "\n"; // DN pour les groupes - print ''; @@ -124,7 +122,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -134,7 +131,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeGroups").'
'.$langs->trans("LDAPGroupDn").''; print ''; print ''.$langs->trans("LDAPGroupDnExample").' 
'.$langs->trans("LDAPGroupObjectClassList").''; print ''; print ''.$langs->trans("LDAPGroupObjectClassListExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -145,7 +141,6 @@ print "\n"; // Filtre // Common name - print ''; @@ -162,7 +157,6 @@ print ''; */ // Description - print ''; @@ -170,7 +164,6 @@ print ''; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index a6385c9690c..d363d8811e4 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -133,17 +133,13 @@ dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescMembers").'
'; print '
'; - print '
'.$langs->trans("LDAPDolibarrMapping").'
'.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldCommonNameExample").'
'.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").''.$langs->trans("LDAPFieldGroupMembers").''; print ''; print ''.$langs->trans("LDAPFieldGroupMembersExample").'
'; -$var=true; - print ''; print ''; print "\n"; // DN Pour les adherents - print ''; @@ -151,7 +147,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -159,7 +154,6 @@ print ''; print ''; // Filter, used to filter search - print ''; @@ -169,7 +163,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeMembers").'
'.$langs->trans("LDAPMemberDn").''; print ''; print ''.$langs->trans("LDAPMemberDnExample").' 
'.$langs->trans("LDAPMemberObjectClassList").''; print ''; print ''.$langs->trans("LDAPMemberObjectClassListExample").' 
'.$langs->trans("LDAPFilterConnection").''; print ''; print ''.$langs->trans("LDAPFilterConnectionExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -180,7 +173,6 @@ print "\n"; // Filtre // Common name - print ''; @@ -188,7 +180,6 @@ print ''; @@ -196,7 +187,6 @@ print ''; @@ -204,7 +194,6 @@ print ''; print ''; // Login unix - print ''; @@ -212,7 +201,6 @@ print ''; @@ -220,7 +208,6 @@ print ''; @@ -228,7 +215,6 @@ print ''; print ''; // Password crypted - print ''; @@ -236,7 +222,6 @@ print ''; print ''; // Mail - print ''; @@ -244,7 +229,6 @@ print ''; @@ -260,7 +244,6 @@ print ''; print ''; // Mobile - print ''; @@ -268,7 +251,6 @@ print ''; print ''; // Skype - print ''; @@ -276,7 +258,6 @@ print ''; print ''; // Fax - print ''; @@ -284,7 +265,6 @@ print ''; print ''; // Company - print ''; @@ -292,7 +272,6 @@ print ''; print ''; // Address - print ''; @@ -300,7 +279,6 @@ print ''; print ''; // ZIP - print ''; @@ -308,7 +286,6 @@ print ''; print ''; // TOWN - print ''; @@ -316,7 +293,6 @@ print ''; print ''; // COUNTRY - print ''; @@ -324,7 +300,6 @@ print ''; print ''; // Description - print ''; @@ -332,7 +307,6 @@ print ''; print ''; // Public Note - print ''; @@ -348,7 +322,6 @@ print ''; print ''; // Status - print ''; @@ -364,7 +337,6 @@ print ''; print ''; // First subscription amount - print ''; @@ -372,7 +344,6 @@ print ''; print ''; // Last subscription date - print ''; @@ -380,7 +351,6 @@ print ''; print ''; // Last subscription amount - print ''; @@ -388,7 +358,6 @@ print ''; print ''; // End last subscriptions - print ''; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 2c08ec9fae8..b5f278a8968 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -108,14 +108,12 @@ print ''; $form=new Form($db); print '
'.$langs->trans("LDAPDolibarrMapping").'
'.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''.$langs->trans("LDAPFieldFirstName").''; print ''; print ''.$langs->trans("LDAPFieldFirstNameExample").' 
'.$langs->trans("LDAPFieldLoginUnix").''; print ''; print ''.$langs->trans("LDAPFieldLoginExample").''.$langs->trans("LDAPFieldLoginSamba").''; print ''; print ''.$langs->trans("LDAPFieldLoginSambaExample").''.$langs->trans("LDAPFieldPasswordNotCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldPasswordCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''.$langs->trans("LDAPFieldPhone").''; print ''; print ''.$langs->trans("LDAPFieldPhoneExample").' 
'.$langs->trans("LDAPFieldMobile").''; print ''; print ''.$langs->trans("LDAPFieldMobileExample").' 
'.$langs->trans("LDAPFieldSkype").''; print ''; print ''.$langs->trans("LDAPFieldSkypeExample").' 
'.$langs->trans("LDAPFieldFax").''; print ''; print ''.$langs->trans("LDAPFieldFaxExample").' 
'.$langs->trans("LDAPFieldCompany").''; print ''; print ''.$langs->trans("LDAPFieldCompanyExample").' 
'.$langs->trans("LDAPFieldAddress").''; print ''; print ''.$langs->trans("LDAPFieldAddressExample").' 
'.$langs->trans("LDAPFieldZip").''; print ''; print ''.$langs->trans("LDAPFieldZipExample").' 
'.$langs->trans("LDAPFieldTown").''; print ''; print ''.$langs->trans("LDAPFieldTownExample").' 
'.$langs->trans("LDAPFieldCountry").''; print ''; print '  
'.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").' 
'.$langs->trans("LDAPFieldNotePublic").''; print ''; print ''.$langs->trans("LDAPFieldNotePublicExample").' 
'.$langs->trans("LDAPFieldStatus").''; print ''; print '  
'.$langs->trans("LDAPFieldFirstSubscriptionAmount").''; print ''; print '  
'.$langs->trans("LDAPFieldLastSubscriptionDate").''; print ''; print '  
'.$langs->trans("LDAPFieldLastSubscriptionAmount").''; print ''; print '  
'.$langs->trans("LDAPFieldEndLastSubscription").''; print ''; print ' 
'; -$var=true; print ''; print ''; print "\n"; // DN pour les types de membres - print ''; @@ -123,7 +121,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -133,7 +130,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeMembersTypes").'
'.$langs->trans("LDAPMemberTypeDn").''; print ''; print ''.$langs->trans("LDAPMemberTypepDnExample").' 
'.$langs->trans("LDAPMemberTypeObjectClassList").''; print ''; print ''.$langs->trans("LDAPMemberTypeObjectClassListExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -144,7 +140,6 @@ print "\n"; // Filtre // Common name - print ''; @@ -152,7 +147,6 @@ print ''; @@ -160,7 +154,6 @@ print ''; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index a2e40abfed2..1181d2860fb 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -124,17 +124,13 @@ print $langs->trans("LDAPDescUsers").'
'; print '
'; - - print '
'.$langs->trans("LDAPDolibarrMapping").'
'.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldCommonNameExample").''.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").''.$langs->trans("LDAPFieldGroupMembers").''; print ''; print ''.$langs->trans("LDAPFieldGroupMembersExample").'
'; -$var=true; print ''; print ''; print "\n"; // DN Pour les utilisateurs - print ''; @@ -142,7 +138,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -150,7 +145,6 @@ print ''; print ''; // Filter, used to filter search - print ''; @@ -160,7 +154,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeUsers").'
'.$langs->trans("LDAPUserDn").''; print ''; print ''.$langs->trans("LDAPUserDnExample").' 
'.$langs->trans("LDAPUserObjectClassList").''; print ''; print ''.$langs->trans("LDAPUserObjectClassListExample").' 
'.$langs->trans("LDAPFilterConnection").''; print ''; print ''.$langs->trans("LDAPFilterConnectionExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -169,7 +162,6 @@ print ''; print "\n"; // Common name - print ''; @@ -177,7 +169,6 @@ print ''; @@ -185,7 +176,6 @@ print ''; @@ -193,7 +183,6 @@ print ''; @@ -201,7 +190,6 @@ print ''; @@ -209,7 +197,6 @@ print ''; @@ -217,7 +204,6 @@ print ''; print ''; // Password crypted - print ''; @@ -225,7 +211,6 @@ print ''; print ''; // Mail - print ''; @@ -233,7 +218,6 @@ print ''; @@ -241,7 +225,6 @@ print ''; @@ -249,7 +232,6 @@ print ''; @@ -257,7 +239,6 @@ print ''; @@ -265,7 +246,6 @@ print ''; @@ -273,7 +253,6 @@ print ''; print ''; // Address - print ''; @@ -281,7 +260,6 @@ print ''; print ''; // ZIP - print ''; @@ -289,7 +267,6 @@ print ''; print ''; // TOWN - print ''; @@ -297,7 +274,6 @@ print ''; print ''; // COUNTRY - print ''; @@ -305,7 +281,6 @@ print ''; print ''; // Title - print ''; @@ -313,7 +288,6 @@ print ''; print ''; // Note - print ''; @@ -321,7 +295,6 @@ print ''; print ''; // Sid - print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 4c18069b415..0af26a0a2b7 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -6,8 +6,8 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2015 Claudio Aschieri * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,10 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; -$langs->load("admin"); -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('other'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); if (!$user->admin) accessforbidden(); @@ -216,7 +214,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -337,7 +334,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/livraison/doc/"); @@ -452,7 +448,6 @@ print ''; print ''; print ''; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -460,7 +455,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 7abb16a0729..3aa3b3364c0 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -27,8 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -$langs->load("admin"); -$langs->load("mails"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "mails")); if (!$user->admin) accessforbidden(); @@ -105,29 +105,24 @@ print ''; print ''; print ''; -$var=true; - print '
'.$langs->trans("LDAPDolibarrMapping").''.$langs->trans("LDAPNamingAttribute").'
'.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''; // Firstname - print '
'.$langs->trans("LDAPFieldFirstName").''; print ''; print ''.$langs->trans("LDAPFieldFirstNameExample").''.$langs->trans("LDAPFieldLoginUnix").''; print ''; print ''.$langs->trans("LDAPFieldLoginExample").''; // Login samba - print '
'.$langs->trans("LDAPFieldLoginSamba").''; print ''; print ''.$langs->trans("LDAPFieldLoginSambaExample").''.$langs->trans("LDAPFieldPasswordNotCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldPasswordCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''; // Phone - print '
'.$langs->trans("LDAPFieldPhone").''; print ''; print ''.$langs->trans("LDAPFieldPhoneExample").''; // Mobile - print '
'.$langs->trans("LDAPFieldMobile").''; print ''; print ''.$langs->trans("LDAPFieldMobileExample").''.$langs->trans("LDAPFieldSkype").''; print ''; print ''.$langs->trans("LDAPFieldSkypeExample").''; // Fax - print '
'.$langs->trans("LDAPFieldFax").''; print ''; print ''.$langs->trans("LDAPFieldFaxExample").''; // Company - print '
'.$langs->trans("LDAPFieldCompany").''; print ''; print ''.$langs->trans("LDAPFieldCompanyExample").' 
'.$langs->trans("LDAPFieldAddress").''; print ''; print ''.$langs->trans("LDAPFieldAddressExample").' 
'.$langs->trans("LDAPFieldZip").''; print ''; print ''.$langs->trans("LDAPFieldZipExample").' 
'.$langs->trans("LDAPFieldTown").''; print ''; print ''.$langs->trans("LDAPFieldTownExample").' 
'.$langs->trans("LDAPFieldCountry").''; print ''; print '  
'.$langs->trans("LDAPFieldTitle").''; print ''; print ''.$langs->trans("LDAPFieldTitleExample").' 
'.$langs->trans("Note").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").' 
'.$langs->trans("LDAPFieldSid").''; print ''; print ''.$langs->trans("LDAPFieldSidExample").'
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; print ''; print ''; print ''; print "\n"; - print ''; - print ''; - print ''; - print ''; @@ -261,7 +272,7 @@ if ($action == 'create') print ''; // Amount - print ''; + print ''; if (! empty($conf->banque->enabled)) { @@ -306,6 +317,13 @@ if ($id) dol_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment'); + $morehtmlref='
'; + // Label of social contribution + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + // Project + $morehtmlref.='
'; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); @@ -316,18 +334,17 @@ if ($id) print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $langs->trans("MailingEMailFrom").''; print ''; if (!empty($conf->global->MAILING_EMAIL_FROM) && ! isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("MailingEMailError").''; print ''; if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("MailingDelay").''; print ''; diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 89416a72e36..bb53349d1b7 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -32,9 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -$langs->load("admin"); -$langs->load("members"); -$langs->load("mailmanspip"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "members", "mailmanspip")); if (! $user->admin) accessforbidden(); @@ -49,7 +48,7 @@ $testunsubscribeemail = GETPOST("testunsubscribeemail"); * Actions */ -// Action mise a jour ou ajout d'une constante +// Action updated or added a constant if ($action == 'update' || $action == 'add') { foreach($_POST['constname'] as $key => $val) @@ -156,9 +155,6 @@ print load_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'title_setup' $head = mailmanspip_admin_prepare_head(); - -$var=true; - if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { print ''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 28d243a3b13..f4c5a2531ff 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -27,12 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$langs->load("companies"); -$langs->load("products"); -$langs->load("admin"); -$langs->load("mails"); -$langs->load("other"); -$langs->load("errors"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors")); $action=GETPOST('action','alpha'); @@ -71,6 +67,7 @@ if ($action == 'update' && empty($_POST["cancel"])) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"),'chaine',0,'',$conf->entity); // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity); @@ -259,13 +256,11 @@ if ($action == 'edit') clearstatcache(); - $var=true; print ''; print ''; // Disable - print ''; @@ -275,12 +270,16 @@ if ($action == 'edit') print ''; print ''; - // Separator + //Add user to select destinaries list + print ''; + + // Separator print ''; // Method - print ''; // Port - print ''; // From - print ''; print ''; @@ -490,22 +486,19 @@ if ($action == 'edit') } else dol_print_error($db);*/ - print ''; // Separator - print ''; // From - print ''; print ''; // Autocopy to - print ''; print ''; @@ -528,15 +521,11 @@ else print $langs->trans("EMailsDesc")."
\n"; print "
\n"; - - - $var=true; - + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_MAILS").''; print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1); print '
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''; + print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT',$conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT,1); + print '
 
'.$langs->trans("MAIN_MAIL_SENDMODE").''; // SuperAdministrator access only @@ -331,7 +330,6 @@ if ($action == 'edit') print '
'; if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { @@ -404,7 +402,6 @@ if ($action == 'edit') } // TLS - print '
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { @@ -462,7 +459,6 @@ if ($action == 'edit') print '
 
'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; + print '
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE, 0); print '
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").'
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'
'; print ''; // Disable - print ''; // Force e-mail recipient @@ -544,12 +533,13 @@ else if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO) && ! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); print ''; - // Separator + //Add user to select destinaries list + print ''; + // Separator print ''; // Method - print ''; // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -568,7 +557,6 @@ else } // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -579,21 +567,18 @@ else } // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // TLS - print ''; // STARTTLS - print ''; // From - print ''; print ''; // Separator - print ''; // Errors To - print ''; print ''; // Autocopy to - print ''; print ''; } if (! empty($arrayfields['p.ref_client']['checked'])) { print ''; } if (! empty($arrayfields['pr.ref']['checked'])) { print ''; } if (! empty($arrayfields['s.nom']['checked'])) { print ''; } if (! empty($arrayfields['s.town']['checked'])) print ''; @@ -521,15 +594,16 @@ if ($resql) { print ''; } // Date if (! empty($arrayfields['p.date']['checked'])) { - print ''; @@ -537,34 +611,59 @@ if ($resql) // Date end if (! empty($arrayfields['p.fin_validite']['checked'])) { - print ''; + print ''; + } + // Date delivery + if (! empty($arrayfields['p.date_livraison']['checked'])) + { + print ''; + } + // Availability + if (! empty($arrayfields['ava.rowid']['checked'])) + { + print ''; } if (! empty($arrayfields['p.total_ht']['checked'])) { // Amount print ''; } if (! empty($arrayfields['p.total_vat']['checked'])) { // Amount print ''; } if (! empty($arrayfields['p.total_ttc']['checked'])) { // Amount print ''; } if (! empty($arrayfields['u.login']['checked'])) { // Author print ''; } // Extra fields @@ -615,6 +714,8 @@ if ($resql) if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'],$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'],$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'],$_SERVER["PHP_SELF"],'ddelivery','',$param, 'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'],$_SERVER["PHP_SELF"],'availability','',$param, '',$sortfield,$sortorder); if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'],$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder); @@ -780,6 +881,28 @@ if ($resql) } if (! $i) $totalarray['nbfield']++; } + // Date delivery + if (! empty($arrayfields['p.date_livraison']['checked'])) + { + if ($obj->ddelivery) + { + print ''; + } + else + { + print ''; + } + if (! $i) $totalarray['nbfield']++; + } + // Availability + if (! empty($arrayfields['ava.rowid']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Amount HT if (! empty($arrayfields['p.total_ht']['checked'])) diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 273862f68bf..50ec740ea4a 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -329,7 +329,7 @@ print '
'; // Show graphs -print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_MAILS").''.yn($conf->global->MAIN_DISABLE_ALL_MAILS).'
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'
 
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; if (empty($text)) $text=$langs->trans("Undefined").img_warning(); @@ -557,7 +547,6 @@ else print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -607,7 +592,6 @@ else print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -624,7 +608,6 @@ else if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') { // DKIM - print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) { @@ -654,11 +637,9 @@ else } // Separator - print '
 
'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); @@ -713,18 +694,15 @@ else print '
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").''.$conf->global->MAIN_MAIL_ERRORS_TO; if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); print '
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 1202e9817d3..1cb92ae8377 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -228,7 +228,6 @@ if ($action == 'edit') clearstatcache(); - $var=true; print ''; print ''; @@ -341,7 +340,6 @@ if ($action == 'edit') // PW if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { - $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING:''); print ''; - if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { + print ''; + $tmpaction='edit'; $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook=$hookmanager->executeHooks('editEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -787,10 +775,23 @@ if ($resql) print ''; } } + + print "\n"; } else { - $tmpaction = 'view'; + $keyforobj='type_template'; + if (! in_array($obj->$keyforobj, array_keys($elementList))) + { + $i++; + continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) + } + // TODO Test on 'enabled' + + + print ''; + + $tmpaction = 'view'; $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook=$hookmanager->executeHooks('viewEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks @@ -876,7 +877,6 @@ if ($resql) } print ''; - /* $fieldsforcontent = array('content'); if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) @@ -904,8 +904,9 @@ if ($resql) } }*/ + + print "\n"; } - print "\n"; $i++; diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 5e0b6fac6f6..a5f2fb2a2ff 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -30,11 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $action=GETPOST('action','aZ09'); $cancel=GETPOST('cancel','alpha'); -$langs->load("companies"); -$langs->load("products"); -$langs->load("admin"); -$langs->load("users"); -$langs->load("other"); +$langs->loadLangs(array("companies","products","admin","users","other")); // Security check if (! $user->admin) accessforbidden(); @@ -167,8 +163,6 @@ if ($action == 'edit') clearstatcache(); // Gestionnaires de menu - $var=true; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''; // SuperAdministrator access only @@ -405,14 +403,10 @@ else print $langs->trans("EMailsDesc")."
\n"; print "
\n"; - - $var=true; - print ''; print ''; // Method - print ''; @@ -433,7 +426,6 @@ else } // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) { print ''; @@ -444,21 +436,18 @@ else } // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { print ''; } // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { print ''; } // TLS - print ''; // STARTTLS - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; if (empty($text)) $text=$langs->trans("Undefined").img_warning(); @@ -422,7 +416,6 @@ else if (! empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) { print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { @@ -472,7 +461,6 @@ else print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 69d1d8a8cea..5f0288525a0 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -21,21 +22,6 @@ * \brief Page to adminsiter email sender profiles */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - - require '../main.inc.php'; require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -244,6 +230,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); @@ -387,7 +378,7 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 89f3700c4f7..60db9fae8c4 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2017 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel @@ -169,9 +169,6 @@ if ($conf->adherent->enabled) $elementList['member']=$langs->trans('Mai if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject'); $elementList['user']=$langs->trans('MailToUser'); -$elementList['all'] =$langs->trans('VisibleEverywhere'); -$elementList['none']=$langs->trans('VisibleNowhere'); - $parameters=array('elementList'=>$elementList); $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks @@ -181,6 +178,12 @@ if ($reshook == 0) { } } +// Add all and none after the sort +$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; +$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; + +asort($elementList); + $id = 25; @@ -210,7 +213,7 @@ if (empty($reshook)) } // Actions add or modify an entry into a dictionary - if (GETPOST('actionadd') || GETPOST('actionmodify')) + if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) { $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); $listfieldinsert=explode(',',$tabfieldinsert[$id]); @@ -226,7 +229,7 @@ if (empty($reshook)) if ($value == 'content') continue; if ($value == 'content_lines') continue; - if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; + if (GETPOST('actionmodify','alpha') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { @@ -268,8 +271,8 @@ if (empty($reshook)) if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; - if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="null"; + if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } @@ -315,12 +318,16 @@ if (empty($reshook)) if ($field == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; $sql.= $field."="; - if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + +// print $keycode.' - '.$_POST[$keycode].'
'; + if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1 else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - +//print $sql;exit; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); @@ -430,24 +437,9 @@ if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_ if ($search_lang) $sql.=natural_search('lang', $search_lang); if ($search_fk_user != '' && $search_fk_user != '-1') $sql.=natural_search('fk_user', $search_fk_user, 2); if ($search_topic) $sql.=natural_search('topic', $search_topic); -if ($sortfield) -{ - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); -} -else { - $sql.=" ORDER BY "; -} -$sql.=$tabsqlsort[$id]; +// If sort order is "country", we use country_code instead +if ($sortfield == 'country') $sortfield='country_code'; +$sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); //print $sql; @@ -455,7 +447,6 @@ $fieldlist=explode(',',$tabfield[$id]); // Form to add a new line $alabelisused=0; -$var=false; print ''; print ''; @@ -599,9 +590,7 @@ $colspan=count($fieldlist)+1; print '
'; print ''; - print ''; - print '
'; @@ -619,7 +608,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; $paramwithsearch = $param; @@ -726,10 +714,10 @@ if ($resql) { $obj = $db->fetch_object($resql); - print '
'; print ''; print ''; // Menu top - print ''; print ''; // Menu smartphone - print ''; print ''; @@ -169,14 +165,12 @@ if ($result) $num = $db->num_rows($result); if ($num > 0) - { - $var = true; + { $i = 0; - while ($i < $num ) + while ($i < $num ) { $obj = $db->fetch_object($result); - print ''; print ''; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index f9fad78a1f0..a85e5e4c01e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -32,7 +32,7 @@ $result=restrictedArea($user,'mailing'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; @@ -104,7 +104,13 @@ if ($result) $title=$langs->trans("ListOfEMailings"); if ($filteremail) $title.=' ('.$langs->trans("SentTo",$filteremail).')'; - $newcardbutton=''.$langs->trans('NewMailing').''; + $newcardbutton=''; + if ($user->rights->mailing->creer) + { + $newcardbutton=''.$langs->trans('NewMailing'); + $newcardbutton.= ''; + $newcardbutton.= ''; + } $i = 0; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8be7fa249b8..004b32a83fc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1745,11 +1745,12 @@ if ($action == 'create') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->labelstatut [2],3=>$object->labelstatut [3])), - array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) + array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), + array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) ); - if (! empty($conf->notification->enabled)) { + if (! empty($conf->notification->enabled)) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $formquestion = array_merge($formquestion, array( diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 63b26373f60..d153489dcc8 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -176,7 +176,7 @@ class Proposals extends DolibarrApi * @param array $request_data Request data * @return int ID of proposal */ - function post($request_data = NULL) + function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401, "Insuffisant rights"); @@ -241,7 +241,7 @@ class Proposals extends DolibarrApi * * @return int */ - function postLine($id, $request_data = NULL) + function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -307,7 +307,7 @@ class Proposals extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = NULL) + function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -410,7 +410,7 @@ class Proposals extends DolibarrApi * * @return int */ - function put($id, $request_data = NULL) { + function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6e98329a4cc..b6e9d1411c5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -142,9 +142,9 @@ class Propal extends CommonObject public $cond_reglement_code; public $mode_reglement_code; - public $remise; - public $remise_percent; - public $remise_absolue; + public $remise = 0; + public $remise_percent = 0; + public $remise_absolue = 0; public $fk_address; public $address_type; public $address; @@ -198,6 +198,7 @@ class Propal extends CommonObject */ const STATUS_BILLED = 4; // Todo rename into STATUS_CLOSE ? + /** * Constructor * @@ -210,26 +211,13 @@ class Propal extends CommonObject global $conf,$langs; $this->db = $db; + $this->socid = $socid; $this->id = $propalid; + $this->products = array(); - $this->remise = 0; - $this->remise_percent = 0; - $this->remise_absolue = 0; $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; - - $langs->load("propal"); - $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); - $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); - $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); - $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); - $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); - $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); - $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); - $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); - $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); - $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); } @@ -1114,12 +1102,8 @@ class Propal extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -1130,9 +1114,8 @@ class Propal extends CommonObject } } } - else if ($reshook < 0) $error++; - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PROPAL_CREATE',$user); @@ -1658,7 +1641,7 @@ class Propal extends CommonObject $this->db->free($result); - return 1; + return $num; } else { @@ -3096,10 +3079,24 @@ class Propal extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function LibStatut($statut,$mode=1) + function LibStatut($statut,$mode=1) { - global $langs; - $langs->load("propal"); + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("propal"); + $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); + $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); + $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); + $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); + $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); + $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); + $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); + $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); + $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); + $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); + } $statuttrans=''; if ($statut==self::STATUS_DRAFT) $statuttrans='statut0'; @@ -3819,6 +3816,8 @@ class PropaleLigne extends CommonObjectLine $this->multicurrency_total_tva = $objp->multicurrency_total_tva; $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->fetch_optionals(); + $this->db->free($result); return 1; @@ -3953,7 +3952,7 @@ class PropaleLigne extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEPROPAL_INSERT',$user); @@ -4136,7 +4135,7 @@ class PropaleLigne extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEPROPAL_UPDATE',$user); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 8ef875f0a23..aab9cfcb30a 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -160,7 +160,7 @@ if ($object->id > 0) // Files infos print ''; - print ''; + print ''; print "
'.$langs->trans("Menu").''; @@ -180,7 +174,6 @@ if ($action == 'edit') print '
'.$langs->trans("DefaultMenuManager").''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled'); @@ -191,7 +184,6 @@ if ($action == 'edit') print '
'.$langs->trans("DefaultMenuSmartphoneManager").''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled'); @@ -206,8 +198,6 @@ if ($action == 'edit') else { // Gestionnaires de menu - $var=true; - print ''; print ''; print '"; print ''; - // Hide any PDF informations - - print ''; - //Desc print ''; if (is_array($resCached)) { - $var = ! $var; print ''; print ""; print ''; print ""; - $var = ! $var; + print ''; print ""; print ''; @@ -301,17 +291,16 @@ if (is_array($resCached) || is_array($resRemoved)) { } if (is_array($resRemoved)) { - $var = ! $var; print ''; print ""; print ''; print ""; - $var = ! $var; + print ''; print ""; print ''; print ""; - $var = ! $var; + print ''; print ""; print ''; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 01ab314df73..f3d2057395f 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -41,7 +41,7 @@ $page = GETPOST("page",'int'); if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="date"; if ($page < 0) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $user->admin) accessforbidden(); @@ -280,7 +280,7 @@ function backup_tables($outputfile, $tables='*') //cycle through $handle = fopen($outputfile, 'w+'); - if (fwrite($handle, '') === FALSE) + if (fwrite($handle, '') === false) { $langs->load("errors"); dol_syslog("Failed to open file ".$outputfile,LOG_ERR); diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index ac520ce22b3..48d3ef57fd5 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -184,6 +184,11 @@ $nbtotalofrecords = ''; { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } }*/ $sql.= $db->plimit($conf->liste_limit+1, $offset); diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index 76f7debf3e7..70b0987732b 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -137,12 +137,8 @@ if ($savehandler == 'files') print_liste_field_titre(''); print "\n"; - $var=True; - foreach ($listofsessions as $key => $sessionentry) { - - print ''; // Login diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php index 58ca4e0eded..ca14869cb2e 100644 --- a/htdocs/admin/triggers.php +++ b/htdocs/admin/triggers.php @@ -65,10 +65,8 @@ print getTitleFieldOfList($langs->trans("Active"), 0, $_SERVER["PHP_SELF"], 'act print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder, '', 1)."\n"; print ''; -$var=True; foreach ($triggers as $trigger) { - print ''; print ''; print ''; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index ee5faefeaee..a7b1c5b9373 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -86,7 +86,7 @@ elseif ($action == 'setdoc') } $res = true; } -elseif (preg_match('/set_(.*)/',$action,$reg)) +elseif (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) @@ -100,7 +100,7 @@ elseif (preg_match('/set_(.*)/',$action,$reg)) } } -elseif (preg_match('/del_(.*)/',$action,$reg)) +elseif (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 5a1cf94e59f..75497e9d19d 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -83,7 +83,7 @@ elseif ($action == 'setdoc') } $res = true; } -elseif (preg_match('/set_(.*)/',$action,$reg)) +elseif (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) @@ -97,7 +97,7 @@ elseif (preg_match('/set_(.*)/',$action,$reg)) } } -elseif (preg_match('/del_(.*)/',$action,$reg)) +elseif (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index e3854c4eb11..73063c2b036 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -436,24 +436,7 @@ if ($id) { // Complete requete recherche valeurs avec critere de tri $sql=$tabsql[$id]; - - if ($sortfield) - { - // If sort order is "country", we use country_code instead - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($limit+1, $offset); //print $sql; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 22c763100d4..ef2b4c8bb6d 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -170,7 +170,7 @@ class Setup extends DolibarrApi // and then apply the filter if there is one. $this->translateLabel($country, $lang); - if (empty($filter) || stripos($country->label, $filter) !== FALSE) { + if (empty($filter) || stripos($country->label, $filter) !== false) { $list[] = $this->_cleanObjectDatas($country); } } @@ -385,7 +385,7 @@ class Setup extends DolibarrApi * @param string $sortorder Sort order * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" - * @return List of events types + * @return List of extra fields * * @url GET extrafields * @@ -584,7 +584,7 @@ class Setup extends DolibarrApi * Do a test of integrity for files and setup. * * @param string $target Can be 'local' or 'default' or Url of the signatures file to use for the test. Must be reachable by the tested Dolibarr. - * @return Result of file and setup integrity check + * @return Result of file and setup integrity check * * @url GET checkintegrity * diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 353b945cfda..e66a19c981a 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -24,12 +24,7 @@ * \file htdocs/api/index.php */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php diff --git a/htdocs/assets/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php similarity index 95% rename from htdocs/assets/admin/assets_extrafields.php rename to htdocs/asset/admin/assets_extrafields.php index 85c596b6e37..52c1f042836 100644 --- a/htdocs/assets/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -17,8 +17,8 @@ */ /** - * \file htdocs/assets/admin/assets_extrafields.php - * \ingroup assets + * \file htdocs/asset/admin/asset_extrafields.php + * \ingroup asset * \brief Page to setup extra fields of assets */ @@ -65,7 +65,7 @@ print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); $head = AssetsAdminPrepareHead(); -dol_fiche_head($head, 'attributes', $langs->trans("Assets"), 0, 'generic'); +dol_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'generic'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/assets/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php similarity index 97% rename from htdocs/assets/admin/assets_type_extrafields.php rename to htdocs/asset/admin/assets_type_extrafields.php index 8d136ed1278..261c7de99b7 100644 --- a/htdocs/assets/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -18,8 +18,8 @@ /** /** - * \file htdocs/assets/admin/assets_type_extrafields.php - * \ingroup assets + * \file htdocs/asset/admin/assets_type_extrafields.php + * \ingroup asset * \brief Page to setup extra fields type of assets */ require '../../main.inc.php'; @@ -66,7 +66,7 @@ print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); $head = AssetsAdminPrepareHead(); -dol_fiche_head($head, 'attributes_type', $langs->trans("Assets"), 0, 'generic'); +dol_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, 'generic'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/assets/admin/setup.php b/htdocs/asset/admin/setup.php similarity index 96% rename from htdocs/assets/admin/setup.php rename to htdocs/asset/admin/setup.php index 19de7b3b752..8708396fb7f 100644 --- a/htdocs/assets/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -60,10 +60,7 @@ print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); $head = AssetsAdminPrepareHead(); -dol_fiche_head($head, 'settings', $langs->trans("Assets"), 0, 'generic'); - -// Setup page goes here -echo $langs->trans("AssetsSetupPage"); +dol_fiche_head($head, 'settings', $langs->trans("Assets"), -1, 'generic'); if ($action == 'edit') diff --git a/htdocs/assets/card.php b/htdocs/asset/card.php similarity index 85% rename from htdocs/assets/card.php rename to htdocs/asset/card.php index 4424ca0cf93..a76bf3d069e 100644 --- a/htdocs/assets/card.php +++ b/htdocs/asset/card.php @@ -18,18 +18,18 @@ /** * \file card.php - * \ingroup assets - * \brief Page to create/edit/view assets + * \ingroup asset + * \brief Page to create/edit/view asset */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); // Load traductions files requiredby by page -$langs->loadLangs(array("assets")); +$langs->loadLangs(array("asset")); // Get parameters $id = GETPOST('id', 'int'); @@ -39,12 +39,12 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetscard')); // Note that conf->hooks_modules contains array +$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Initialize array of search criterias @@ -60,7 +60,7 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'assets', $id); +//$result = restrictedArea($user, 'asset', $id); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); @@ -84,9 +84,9 @@ if (empty($reshook)) { $error=0; - $permissiontoadd = $user->rights->assets->create; - $permissiontodelete = $user->rights->assets->delete; - $backurlforlist = dol_buildpath('/assets/list.php',1); + $permissiontoadd = $user->rights->asset->create; + $permissiontodelete = $user->rights->asset->delete; + $backurlforlist = dol_buildpath('/asset/list.php',1); // Actions cancel, add, update or delete include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -97,7 +97,7 @@ if (empty($reshook)) // Actions to send emails $trigger_name='MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; - $trackid='assets'.$object->id; + $trackid='asset'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -241,13 +241,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; /* // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->assets->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->assets->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); */ @@ -289,7 +289,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send print '' . $langs->trans('SendMail') . ''."\n"; - if ($user->rights->assets->write) + if ($user->rights->asset->write) { print ''.$langs->trans("Modify").''."\n"; } @@ -298,7 +298,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } - if ($user->rights->assets->delete) + if ($user->rights->asset->delete) { print ''.$langs->trans('Delete').''."\n"; } @@ -324,15 +324,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Documents /*$objref = dol_sanitizeFileName($object->ref); $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->assets->dir_output . '/' . $objref; + $filedir = $conf->asset->dir_output . '/' . $objref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->assets->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->assets->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('assets', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + $genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->asset->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('assets')); + $linktoelem = $form->showLinkToObjectBlock($object, null, array('asset')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); @@ -340,14 +340,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; - $morehtmlright = ''; + $morehtmlright = ''; $morehtmlright.= $langs->trans("SeeAll"); $morehtmlright.= ''; // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'assets', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + $somethingshown = $formactions->showactions($object, 'asset', $socid, 1, '', $MAXEVENT, '', $morehtmlright); print '
'; } diff --git a/htdocs/assets/class/asset.class.php b/htdocs/asset/class/asset.class.php similarity index 95% rename from htdocs/assets/class/asset.class.php rename to htdocs/asset/class/asset.class.php index efacac10822..86da8ae5379 100644 --- a/htdocs/assets/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -17,9 +17,9 @@ */ /** - * \file assets/class/assets.class.php - * \ingroup assets - * \brief This file is a CRUD class file for assets (Create/Read/Update/Delete) + * \file asset/class/asset.class.php + * \ingroup asset + * \brief This file is a CRUD class file for asset (Create/Read/Update/Delete) */ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; @@ -27,30 +27,30 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** - * Class for Assets + * Class for Asset */ -class Assets extends CommonObject +class Asset extends CommonObject { /** * @var string ID to identify managed object */ - public $element = 'assets'; + public $element = 'asset'; /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'assets'; + public $table_element = 'asset'; /** - * @var int Does assets support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int Does module support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 0; /** - * @var int Does assets support extrafields ? 0=No, 1=Yes + * @var int Does asset support extrafields ? 0=No, 1=Yes */ public $isextrafieldmanaged = 1; /** - * @var string String with name of icon for assets. Must be the part after the 'object_' into object_assets.png + * @var string String with name of icon for asset. Must be the part after the 'object_' into object_asset.png */ - public $picto = 'assets'; + public $picto = 'asset'; /** @@ -111,21 +111,21 @@ class Assets extends CommonObject /** * @var int Name of subtable line */ - //public $table_element_line = 'assetsdet'; + //public $table_element_line = 'assetdet'; /** * @var int Field with ID of parent key if this field has a parent */ - //public $fk_element = 'fk_assets'; + //public $fk_element = 'fk_asset'; /** * @var int Name of subtable class that manage subtable lines */ - //public $class_element_line = 'Assetsline'; + //public $class_element_line = 'Assetline'; /** * @var array Array of child tables (child tables to delete before deleting a record) */ - //protected $childtables=array('assetsdet'); + //protected $childtables=array('assetdet'); /** - * @var AssetsLine[] Array of subtable lines + * @var AssetLine[] Array of subtable lines */ //public $lines = array(); diff --git a/htdocs/assets/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php similarity index 92% rename from htdocs/assets/class/asset_type.class.php rename to htdocs/asset/class/asset_type.class.php index 9889ceeb5d1..9fbcca64d8b 100644 --- a/htdocs/assets/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -16,8 +16,8 @@ */ /** - * \file htdocs/assets/class/asset_type.class.php - * \ingroup assets + * \file htdocs/asset/class/asset_type.class.php + * \ingroup asset * \brief File of class to manage asset types */ @@ -155,22 +155,15 @@ class AssetType extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('assettypedao')); - $parameters=array('assettype'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { @@ -382,7 +375,7 @@ class AssetType extends CommonObject $result=''; $label=$langs->trans("ShowTypeCard",$this->label); - $linkstart = ''; + $linkstart = ''; $linkend=''; $result .= $linkstart; diff --git a/htdocs/assets/document.php b/htdocs/asset/document.php similarity index 83% rename from htdocs/assets/document.php rename to htdocs/asset/document.php index 490fb8f36a4..fbd2fe6cdb8 100644 --- a/htdocs/assets/document.php +++ b/htdocs/asset/document.php @@ -18,13 +18,13 @@ /** * \file document.php - * \ingroup assets + * \ingroup asset * \brief Tab for documents linked to Assets */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; @@ -42,7 +42,7 @@ $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'assets', $id); +//$result = restrictedArea($user, 'asset', $id); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); @@ -56,12 +56,12 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetsdocument')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('assetdocument')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals @@ -110,7 +110,7 @@ if ($object->id) // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -131,15 +131,15 @@ if ($object->id) dol_fiche_end(); - $modulepart = 'assets'; - //$permission = $user->rights->assets->create; + $modulepart = 'asset'; + //$permission = $user->rights->asset->create; $permission = 1; - //$permtoedit = $user->rights->assets->create; + //$permtoedit = $user->rights->asset->create; $permtoedit = 1; $param = '&id=' . $object->id; - //$relativepathwithnofile='assets/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile='assets/' . dol_sanitizeFileName($object->ref).'/'; + //$relativepathwithnofile='asset/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='asset/' . dol_sanitizeFileName($object->ref).'/'; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } diff --git a/htdocs/assets/info.php b/htdocs/asset/info.php similarity index 88% rename from htdocs/assets/info.php rename to htdocs/asset/info.php index 9017a9e6845..c953a09c83b 100644 --- a/htdocs/assets/info.php +++ b/htdocs/asset/info.php @@ -17,16 +17,16 @@ /** * \file info.php - * \ingroup assets + * \ingroup asset * \brief Page to show an asset information */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; -$langs->loadLangs(array("assets")); +$langs->loadLangs(array("asset")); $id = GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -34,9 +34,9 @@ $action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'assets', $id, ''); +$result = restrictedArea($user, 'asset', $id, ''); -$object = new Assets($db); +$object = new Asset($db); $object->fetch($id); /* diff --git a/htdocs/assets/list.php b/htdocs/asset/list.php similarity index 88% rename from htdocs/assets/list.php rename to htdocs/asset/list.php index c8ac1f869f1..d9860dc32a3 100644 --- a/htdocs/assets/list.php +++ b/htdocs/asset/list.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -18,31 +19,16 @@ /** * \file list.php - * \ingroup assets - * \brief List page for assets + * \ingroup asset + * \brief List page for asset */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - - // Load Dolibarr environment require '../main.inc.php'; require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load traductions files requiredby by page $langs->loadLangs(array("assets")); @@ -70,12 +56,12 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetslist')); // Note that conf->hooks_modules contains array +$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Default sort order (if not yet defined by previous GETPOST) @@ -89,7 +75,7 @@ if ($user->societe_id > 0) //$socid = $user->societe_id; accessforbidden(); } -//$result = restrictedArea($user, 'assets', $id,''); +//$result = restrictedArea($user, 'asset', $id,''); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); @@ -161,11 +147,11 @@ if (empty($reshook)) } // Mass actions - $objectclass='Assets'; - $objectlabel='Assets'; - $permtoread = $user->rights->assets->read; - $permtodelete = $user->rights->assets->delete; - $uploaddir = $conf->assets->dir_output; + $objectclass='Asset'; + $objectlabel='Asset'; + $permtoread = $user->rights->asset->read; + $permtodelete = $user->rights->asset->delete; + $uploaddir = $conf->asset->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -181,7 +167,7 @@ $form=new Form($db); $now=dol_now(); -//$help_url="EN:Module_Assets|FR:Module_Assets_FR|ES:Módulo_Assets"; +//$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset"; $help_url=''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets")); @@ -239,6 +225,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); @@ -300,7 +291,7 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->assets->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if ($user->rights->asset->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); @@ -318,8 +309,8 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort // Add code for pre mass action (confirmation or email presend form) $topicmail="SendAssetsRef"; -$modelmail="assets"; -$objecttmp=new Assets($db); +$modelmail="asset"; +$objecttmp=new Asset($db); $trackid='xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; @@ -394,7 +385,7 @@ foreach($object->fields as $key => $val) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; @@ -524,10 +515,10 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $urlsource.=str_replace('&','&',$param); $filedir=$diroutputmassaction; - $genallowed=$user->rights->assets->read; - $delallowed=$user->rights->assets->create; + $genallowed=$user->rights->asset->read; + $delallowed=$user->rights->asset->create; - print $formfile->showdocuments('massfilesarea_assets','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + print $formfile->showdocuments('massfilesarea_asset','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else { diff --git a/htdocs/assets/note.php b/htdocs/asset/note.php similarity index 82% rename from htdocs/assets/note.php rename to htdocs/asset/note.php index b0db48e2abe..9ed9053dc5c 100644 --- a/htdocs/assets/note.php +++ b/htdocs/asset/note.php @@ -18,16 +18,16 @@ /** * \file note.php - * \ingroup assets - * \brief Card with notes on Assets + * \ingroup asset + * \brief Card with notes on Asset */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load traductions files requiredby by page -$langs->loadLangs(array("assets","companies")); +$langs->loadLangs(array("asset","companies")); // Get parameters $id = GETPOST('id', 'int'); @@ -37,24 +37,24 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetsnote')); // Note that conf->hooks_modules contains array +$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'assets', $id); +//$result = restrictedArea($user, 'asset', $id); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->assets->multidir_output[$object->entity] . "/" . $object->id; +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; $permissionnote=1; -//$permissionnote=$user->rights->assets->creer; // Used by the include of actions_setnotes.inc.php +//$permissionnote=$user->rights->asset->creer; // Used by the include of actions_setnotes.inc.php /* @@ -84,7 +84,7 @@ if ($id > 0 || ! empty($ref)) // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; /* @@ -98,7 +98,7 @@ if ($id > 0 || ! empty($ref)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->assets->creer) + if ($user->rights->asset->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; diff --git a/htdocs/assets/type.php b/htdocs/asset/type.php similarity index 95% rename from htdocs/assets/type.php rename to htdocs/asset/type.php index 51445f86254..d26175d168f 100644 --- a/htdocs/assets/type.php +++ b/htdocs/asset/type.php @@ -16,15 +16,15 @@ */ /** - * \file htdocs/assets/type.php - * \ingroup assets + * \file htdocs/asset/type.php + * \ingroup asset * \brief Asset's type setup */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/asset.class.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/asset_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("assets"); @@ -51,7 +51,7 @@ $label=GETPOST("label","alpha"); $comment=GETPOST("comment"); // Security check -$result=restrictedArea($user,'assets',$rowid,'asset_type'); +$result=restrictedArea($user,'asset',$rowid,'asset_type'); $object = new AssetType($db); @@ -86,7 +86,7 @@ if ($cancel) { } } -if ($action == 'add' && $user->rights->assets->write) +if ($action == 'add' && $user->rights->asset->write) { $object->label = trim($label); $object->accountancy_code_asset = trim($accountancy_code_asset); @@ -135,7 +135,7 @@ if ($action == 'add' && $user->rights->assets->write) } } -if ($action == 'update' && $user->rights->assets->write) +if ($action == 'update' && $user->rights->asset->write) { $object->fetch($rowid); @@ -166,7 +166,7 @@ if ($action == 'update' && $user->rights->assets->write) exit; } -if ($action == 'confirm_delete' && $user->rights->assets->write) +if ($action == 'confirm_delete' && $user->rights->asset->write) { $object->fetch($rowid); $res=$object->delete(); @@ -255,7 +255,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print '
'; print ''; print ''; - if ($user->rights->adherent->configurer) + if ($user->rights->asset->configurer) print ''; else print ''; @@ -281,7 +281,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') /* ************************************************************************** */ if ($action == 'create') { - $object = new AdherentType($db); + $object = new AssetType($db); print load_fiche_titre($langs->trans("NewMemberType")); @@ -317,7 +317,7 @@ if ($action == 'create') $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } @@ -344,7 +344,7 @@ if ($rowid > 0) { if ($action != 'edit') { - $object = new AdherentType($db); + $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); @@ -360,7 +360,7 @@ if ($rowid > 0) dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'rowid', $linkback); @@ -398,7 +398,7 @@ if ($rowid > 0) print '
'; // Edit - if ($user->rights->adherent->configurer) + if ($user->rights->asset->configurer) { print ''; } @@ -407,7 +407,7 @@ if ($rowid > 0) print ''; // Delete - if ($user->rights->adherent->configurer) + if ($user->rights->asset->configurer) { print ''; } @@ -464,6 +464,9 @@ if ($rowid > 0) { $sql.=" AND datefin < '".$db->idate($now)."'"; } + + $sql.= " ".$db->order($sortfield,$sortorder); + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -471,9 +474,13 @@ if ($rowid > 0) $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($result); else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } - // Add order and limit - $sql.= " ".$db->order($sortfield,$sortorder); + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); @@ -568,7 +575,7 @@ if ($rowid > 0) $datefin=$db->jdate($objp->datefin); - $adh=new Adherent($db); + $adh=new Asset($db); $adh->lastname=$objp->lastname; $adh->firstname=$objp->firstname; @@ -636,12 +643,12 @@ if ($rowid > 0) // Actions print '
'.$langs->trans("Menu").''; @@ -271,7 +261,6 @@ if ($action == 'edit') print ''; - if ($action != 'edit') { print '
'; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index dd90774a05b..8d44421186d 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -17,21 +17,11 @@ */ /** - * \file htdocs/admin/modules.php + * \file htdocs/admin/modulehelp.php * \brief Page to activate/disable all modules */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 25feceda0d1..467ffffeb41 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -48,10 +48,11 @@ $action = GETPOST('action', 'alpha'); */ -if (preg_match('/set_(.*)/',$action,$reg)) +if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; - if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) + $value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); + if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -62,7 +63,7 @@ if (preg_match('/set_(.*)/',$action,$reg)) } } -if (preg_match('/del_(.*)/',$action,$reg)) +if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 5f57ac99efc..f71bc87fc2d 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -128,8 +128,6 @@ print '
'; print ''; print ''; -$var=true; - print ''; print ''; print ''; @@ -168,7 +166,6 @@ $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); print ''; print '\n"; $notificationtrigger=new InterfaceNotification($db); $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); -$var=true; foreach($listofnotifiedevents as $notifiedevent) { diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 339b4fef566..4fe15379629 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -26,10 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('bills'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "errors", "bills")); if (! $user->admin) accessforbidden(); @@ -131,8 +129,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -249,7 +245,6 @@ print ''; print "\n"; // Allow payments on different thirdparties bills but same parent company -$var=! $var; print ''; } - - print load_fiche_titre($langs->trans("PDFLocaltax",$locales),'',''); - - print '
'.$langs->trans("Parameter").'
'; -$var=true; $i=0; foreach($listofnotifiedevents as $notifiedevent) { @@ -212,7 +209,6 @@ print "
 
'; print $langs->trans("PaymentOnDifferentThirdBills"); print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 2f1ae179948..e0c2d776d7a 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -133,7 +133,7 @@ if ($action == 'edit') // Edit // Misc options - print load_fiche_titre($langs->trans("DictionaryPaperFormat"),'','').'
'; + print load_fiche_titre($langs->trans("DictionaryPaperFormat"),'',''); print '
'; print ''; @@ -168,7 +168,7 @@ if ($action == 'edit') // Edit // Addresses - print load_fiche_titre($langs->trans("PDFAddressForging"),'','').'
'; + print load_fiche_titre($langs->trans("PDFAddressForging"),'',''); print '
'; print '
'; @@ -255,14 +255,15 @@ if ($action == 'edit') // Edit print '
'; print '
'; + print '
'; + // Localtaxes + $locales =''; + $text=''; if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { - $locales =''; - $text=''; - if ($mysoc->useLocalTax(1)) { $locales = $langs->transcountry("LT1",$mysoc->country_code); @@ -279,31 +280,39 @@ if ($action == 'edit') // Edit $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); $text.= '
'; - print ''; - print $text; - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print '
'; - } + $title = $langs->trans("PDFRulesForSalesTax"); + if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) + { + $title.=' - '.$langs->trans("PDFLocaltax",$locales); + } + + print load_fiche_titre($title,'',''); + + print ''; + print ''; + + // Hide any information on Sale tax / VAT + + print ''; + + // Locataxes + print $text; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("HideAnyVATInformationOnPDF").''; + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1); + print '
'; + print '
'; + + // Other - print load_fiche_titre($langs->trans("Other"),'','').'
'; + print load_fiche_titre($langs->trans("Other"),'',''); print '
'; print ''; print ''; - // Hide any PDF informations - - print ''; - //Desc print ''; } - print load_fiche_titre($langs->trans("PDFLocaltax",$locales),'',''); - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("HideAnyVATInformationOnPDF").''; - print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1); - print '
'.$langs->trans("HideDescOnPDF").''; @@ -491,11 +500,10 @@ else // Show print '
'; // Localtaxes + $locales =''; + $text=''; if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { - $locales =''; - $text=''; - if ($mysoc->useLocalTax(1)) { $locales = $langs->transcountry("LT1",$mysoc->country_code); @@ -513,16 +521,27 @@ else // Show $text.= '
'; - print ''; - print $text; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print '
'; - } + // Sales TAX / VAT information + $title=$langs->trans("PDFRulesForSalesTax",$locales); + if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) $title.=' - '.$langs->trans("PDFLocaltax",$locales); + + print load_fiche_titre($title,'',''); + + print ''; + print ''; + + print ''; + + print $text; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("HideAnyVATInformationOnPDF").''; + print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1); + print '
'; + print '
'; + + // Other print load_fiche_titre($langs->trans("Other"),'',''); @@ -558,12 +577,6 @@ else // Show print "
'.$langs->trans("HideAnyVATInformationOnPDF").''; - print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1); - print '
'.$langs->trans("HideDescOnPDF").''; @@ -601,7 +614,7 @@ else // Show */ print '
'; - print load_fiche_titre($langs->trans("Library")); + print load_fiche_titre($langs->trans("Library"), '', ''); print '
'; print ''."\n"; @@ -644,7 +657,6 @@ else // Show print ' ('.@constant('TCPDI_PATH').')'; $i++; } - print ''; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 602b80c3855..203b4ed9bc5 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -29,8 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.p require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->load("admin"); -$langs->load("withdrawals"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","withdrawals")); // Security check if (!$user->admin) accessforbidden(); @@ -274,7 +274,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -417,7 +416,6 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) if ($resql) { $num = $db->num_rows($resql); - $var = true; $i = 0; while ($i < $num) { diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index c533ea94795..7ee44a93b52 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -33,10 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('propal'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "errors", "propal")); if (! $user->admin) accessforbidden(); @@ -266,8 +265,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -386,7 +383,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -531,7 +527,6 @@ print ''; print ''; /* -$var=! $var; print ''; print ''; print ''; @@ -631,7 +626,7 @@ print "\n"; print " \n"; print " \n"; print "\n"; -print "\n \n \n\n"; +print "\n \n \n\n"; print "
".$langs->trans("Name")."".$langs->trans("Value")."
".$langs->trans("PathDirectory")."".$conf->propal->multidir_output[$conf->entity]."
".$langs->trans("PathDirectory")."".$conf->propal->multidir_output[$conf->entity]."
\n
"; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index ee22f377200..a9028635991 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -26,10 +26,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -$langs->load("users"); -$langs->load("admin"); -$langs->load("other"); - +// Load traductions files requiredby by page +$langs->loadLangs(array("other", "users", "admin")); if (!$user->admin) accessforbidden(); @@ -124,7 +122,6 @@ if ($conf->use_javascript_ajax) // Timeout -$var=true; print ''; @@ -163,7 +160,7 @@ print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; // Also send to main email address -print ''; -print ''; + print ''; + print ''; + print ''; } -print ''; -print ''; -print ''; // Limiter la vue des tickets à ceux assignés à l'utilisateur print ''; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 7b2c8805f55..1c985e23090 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2012 Regis Houssin +/* Copyright (C) 2006-2018 Laurent Destailleur + * Copyright (C) 2006-2018 Regis Houssin * * 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 @@ -36,8 +36,8 @@ $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="date"; -if ($page < 0) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +if (empty($page) || $page == -1) { $page = 0; } +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $user->admin) diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 68d56bd2ded..d3253c02514 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -116,8 +116,7 @@ function revcompare($x, $y) */ function create_script_table($list) { - global $sortby,$bc,$langs; - $var=true; + global $sortby,$langs; if (GETPOT('order') == "asc" || GETPOST('order') =="desc") { $order = GETPOST('order'); @@ -173,7 +172,6 @@ function create_script_table($list) } foreach($list as $script) { - $var = ! $var; print ''; print ''; print ''; @@ -194,8 +192,7 @@ function create_script_table($list) */ function create_key_table($list) { - global $bc,$langs; - $var=true; + global $langs; print '
'.$langs->trans("MAIN_PROXY_HOST").''; print ''; @@ -172,7 +169,7 @@ print '
'.$langs->trans("MAIN_PROXY_PORT").''; print ''; @@ -181,7 +178,7 @@ print '
'.$langs->trans("MAIN_PROXY_USER").''; print ''; @@ -190,7 +187,7 @@ print '
'.$langs->trans("MAIN_PROXY_PASS").''; print ''; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9627164f534..38cd2d12c1b 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -127,7 +127,7 @@ if ($action == 'activate_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); @@ -135,7 +135,7 @@ if ($action == 'activate_encryptdbpassconf') } else { - setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); + setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); } } else if ($action == 'disable_encryptdbpassconf') @@ -144,7 +144,7 @@ else if ($action == 'disable_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); header("Location: security.php"); @@ -233,6 +233,7 @@ if (is_resource($handle)) } closedir($handle); } +asort($arrayhandler); print ''; print ''; @@ -299,42 +300,42 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print '
'.$langs->trans("PasswordPatternDesc").'
' . $langs->trans("MinLength")."
' . $langs->trans("NbMajMin")."
' . $langs->trans("NbNumMin")."
' . $langs->trans("NbSpeMin")."
' . $langs->trans("NbIteConsecutive")."
' . $langs->trans("NoAmbiCaracAutoGeneration")." '.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'
'; print '
'; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 1053658b191..7ce087ead6f 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -51,41 +51,17 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) dol_add_file_process($upload_dir, 0, 0, 'userfile'); } -if (preg_match('/set_(.*)/',$action,$reg)) +if ($action == 'updateform') { - $code=$reg[1]; - $value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); - if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) - { - Header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } -} + $antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND','none'); // Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe + $antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM','none'); // Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib" + $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command + $antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&")); // Sanitize params -else if (preg_match('/del_(.*)/',$action,$reg)) -{ - $code=$reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - Header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } -} - -else if ($action == 'updateform') -{ $res3=dolibarr_set_const($db, 'MAIN_UPLOAD_DOC',GETPOST('MAIN_UPLOAD_DOC','alpha'),'chaine',0,'',$conf->entity); $res4=dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK','alpha'),'chaine',0,'',$conf->entity); - $res5=dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim(GETPOST('MAIN_ANTIVIRUS_COMMAND','none')),'chaine',0,'',$conf->entity); // Use GETPOST none because we must accept " - $res6=dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim(GETPOST('MAIN_ANTIVIRUS_PARAM','none')),'chaine',0,'',$conf->entity); // Use GETPOST none because we must accept " + $res5=dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand),'chaine',0,'',$conf->entity); + $res6=dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam),'chaine',0,'',$conf->entity); if ($res3 && $res4 && $res5 && $res6) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } @@ -95,10 +71,10 @@ else if ($action == 'updateform') else if ($action == 'delete') { $langs->load("other"); - $file = $conf->admin->dir_temp . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $conf->admin->dir_temp . '/' . GETPOST('urlfile','alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $ret=dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile','alpha')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile','alpha')), null, 'errors'); Header('Location: '.$_SERVER["PHP_SELF"]); exit; } diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index e5c66d9e24b..60d0888ed91 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -43,10 +43,10 @@ $action=GETPOST('action','alpha'); * Actions */ -if (preg_match('/set_(.*)/',$action,$reg)) +if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; - $value=(GETPOST($code) ? GETPOST($code) : 1); + $value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); @@ -58,7 +58,7 @@ if (preg_match('/set_(.*)/',$action,$reg)) } } -else if (preg_match('/del_(.*)/',$action,$reg)) +else if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index e434f669f45..bd2e07ef97d 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -31,8 +31,8 @@ global $conf; if (!$user->admin) accessforbidden(); -$langs->load("admin"); -$langs->load("other"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","other")); $error=0; $action = GETPOST('action','aZ09'); @@ -50,7 +50,6 @@ foreach ($dirsyslogs as $reldir) { $handle = opendir($newdir); if (is_resource($handle)) { - $var = true; while (($file = readdir($handle)) !== false) { if (substr($file, 0, 11) == 'mod_syslog_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index eee003b0872..82e8481c2dd 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -140,7 +140,7 @@ $configfilelib=array( 'Limit nb of email sent by page', 'Strict mode is on/off' ); -$var=true; + print ''; print ''; print ''; diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index d6e05ed2e72..cef493c95f8 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -66,7 +66,6 @@ else if ($resql) { $num = $db->num_rows($resql); - $var=True; $i=0; while ($i < $num) { @@ -109,7 +108,7 @@ else //$sql = "DESCRIBE ".$table; $sql = "SHOW FULL COLUMNS IN ".$db->escape($table); - + $resql = $db->query($sql); if ($resql) { @@ -129,7 +128,7 @@ else print ""; - + print ''; print ''; $i++; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 6fd623bf1bb..76202c2df2b 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -86,8 +86,8 @@ if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signa // Test if remote test is ok -$enableremotecheck = True; -if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=False; +$enableremotecheck = true; +if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=false; $enableremotecheck = true; print ''; diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 55584df6445..1e757b72f63 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -50,7 +50,7 @@ llxHeader(); print load_fiche_titre($langs->trans("PerfDolibarr"),'','title_setup'); -print $langs->trans("YouMayFindPerfAdviceHere",'http://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; +print $langs->trans("YouMayFindPerfAdviceHere",'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; // Recupere la version de PHP $phpversion=version_php(); diff --git a/htdocs/admin/ticketsup.php b/htdocs/admin/ticketsup.php index 4f6839d1e59..9b0cc0e2684 100644 --- a/htdocs/admin/ticketsup.php +++ b/htdocs/admin/ticketsup.php @@ -23,7 +23,7 @@ */ 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."/ticketsup/class/ticketsup.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/ticketsup.lib.php"; @@ -71,7 +71,7 @@ if ($action == 'updateMask') { if (!empty($notification_email)) { $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', '000000', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); } if (!$res > 0) { $error++; @@ -82,7 +82,7 @@ if ($action == 'updateMask') { if (!empty($notification_email_to)) { $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', '000000', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); } if (!$res > 0) { $error++; @@ -172,12 +172,6 @@ if ($action == 'setvarother') { $error++; } - $param_extrafields_public = GETPOST('TICKETS_EXTRAFIELDS_PUBLIC', 'alpha'); - $res = dolibarr_set_const($db, 'TICKETS_EXTRAFIELDS_PUBLIC', $param_extrafields_public, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - $param_disable_email = GETPOST('TICKETS_DISABLE_ALL_MAILS', 'alpha'); $res = dolibarr_set_const($db, 'TICKETS_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); if (!$res > 0) { @@ -190,16 +184,22 @@ if ($action == 'setvarother') { $error++; } - $param_show_module_logo = GETPOST('TICKETS_SHOW_MODULE_LOGO', 'alpha'); - $res = dolibarr_set_const($db, 'TICKETS_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_show_module_logo = GETPOST('TICKETS_SHOW_MODULE_LOGO', 'alpha'); + $res = dolibarr_set_const($db, 'TICKETS_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } } - $param_notification_also_main_addressemail = GETPOST('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_notification_also_main_addressemail = GETPOST('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } } $param_limit_view = GETPOST('TICKETS_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); @@ -241,7 +241,7 @@ dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "tickets print $langs->trans("TicketsupSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; -print $langs->trans("TicketsupPublicAccess") . ' : ' . dol_buildpath('/ticketsup/public/index.php', 2) . ''; +print $langs->trans("TicketsupPublicAccess") . ' : ' . dol_buildpath('/public/ticketsup/index.php', 2) . ''; dol_fiche_end(); @@ -269,7 +269,6 @@ foreach ($dirmodels as $reldir) { if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { - $var = true; while (($file = readdir($handle)) !== false) { if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) { @@ -290,8 +289,7 @@ foreach ($dirmodels as $reldir) { } if ($module->isEnabled()) { - $var = !$var; - print ''; @@ -386,20 +384,23 @@ print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'h print ''; print ''; -// Show logo for module -print ''; -print ''; -print ''; -print ''; +/*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +{ + // Show logo for module + print ''; + print ''; + print ''; + print ''; +}*/ // Show logo for company print ''; @@ -416,21 +417,6 @@ print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, ' print ''; print ''; -// Display extrafields into public interface -print ''; -print ''; -print ''; -print ''; - print '
'.$langs->trans("Label").''.$langs->trans("Parameter").'".(isset($link[$row[0]][0])?$link[$row[0]][0]:'')."."; print (isset($link[$row[0]][1])?$link[$row[0]][1]:'')."
' . $module->name . "\n"; + print '
' . $module->name . "\n"; print $module->info(); print '
' . $langs->trans("TicketsShowModuleLogo") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKETS_SHOW_MODULE_LOGO'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKETS_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKETS_SHOW_MODULE_LOGO); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsShowModuleLogo") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKETS_SHOW_MODULE_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKETS_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKETS_SHOW_MODULE_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowCompanyLogo") . '
' . $langs->trans("TicketsShowExtrafieldsIntoPublicArea") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKETS_EXTRAFIELDS_PUBLIC'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKETS_EXTRAFIELDS_PUBLIC", $arrval, $conf->global->TICKETS_EXTRAFIELDS_PUBLIC); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsShowExtrafieldsIntoPublicAreaHelp"), 1, 'help'); -print '

'; print_titre($langs->trans("TicketParams")); @@ -467,19 +453,22 @@ print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS); +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +{ + print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print '
'; -print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsLimitViewAssignedOnly") . '
'.dol_trunc($script['file'],80,'left').''.dol_print_date($script['mtime'],'dayhour').'
'; print ''; @@ -206,7 +203,6 @@ function create_key_table($list) print ''; foreach($list as $key) { - $var = !$var; print ''; print ''; print ''; @@ -229,54 +225,49 @@ function create_key_table($list) $form=new Form($db); print load_fiche_titre('Dolibarr eAccelerator '.$info['version'].' control panel','','title_setup'); -$var=true; - print '
'; - print '
'.dol_trunc($key['name'],80,'left').''.dol_print_date($key['created'],'dayhour').'
'; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; print '
Information
Caching enabled'.($info['cache']?'yes':'no').'
Optimizer enabled'.$info['optimizer']?'yes':'no'.'
Memory usage'.number_format(100 * $info['memoryAllocated']/$info['memorySize'], 2).'%('.number_format($info['memoryAllocated'] / (1024*1024), 2).'MB / '.number_format($info['memorySize']/(1024*1024), 2).'MB)
Free memory in reserved cache'.number_format($info['memoryAvailable']/(1024*1024), 2).'MB
Cached scripts'.$info['cachedScripts'].'
Removed scripts'.$info['removedScripts'].'
Cached keys'.(isset($info['cachedKeys'])?$info['cachedKeys']:'').'
'; -$var=true; - $resCached = @eaccelerator_cached_scripts(); // If success return an array $resRemoved = @eaccelerator_removed_scripts(); @@ -288,12 +279,11 @@ if (is_array($resCached) || is_array($resRemoved)) { print '
Actions
Caching
Optimizer
Clear cache
Clean cache
Purge cache
'.$trigger['picto'].''.$trigger['file'].''.dol_escape_htmltag($objp->label).''.yn($objp->subscription).''.yn($objp->vote).'rowid.'">'.img_edit().' '; - if ($user->rights->adherent->creer) + if ($user->rights->asset->creer) { print ''.img_edit().''; } print ' '; - if ($user->rights->adherent->supprimer) + if ($user->rights->asset->supprimer) { print ''.img_picto($langs->trans("Resiliate"),'disable.png').''; } @@ -675,7 +682,7 @@ if ($rowid > 0) if ($action == 'edit') { - $object = new AdherentType($db); + $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); @@ -715,7 +722,7 @@ if ($rowid > 0) $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } @@ -723,7 +730,7 @@ if ($rowid > 0) print '
'; // Extra field - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print '

'; foreach($extrafields->attribute_label as $key=>$label) diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 69a9a96f032..8cd5ff979a0 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -28,8 +28,6 @@ * write = system,call,log,verbose,command,agent,user */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 5e684b4091d..806a88325fb 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -212,7 +212,8 @@ if ($conf->societe->enabled) { $nbno=$nbtotal=0; - print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','object_company'); + print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','title_companies'); + print '
'."\n"; $sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe where barcode IS NULL or barcode = ''"; $resql=$db->query($sql); @@ -253,7 +254,7 @@ if ($conf->product->enabled || $conf->product->service) $nbno=$nbtotal=0; - print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','object_product'); + print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','title_products'); print '
'."\n"; $sql ="SELECT count(rowid) as nb, fk_product_type, datec"; diff --git a/htdocs/blockedlog/ajax/authority.php b/htdocs/blockedlog/ajax/authority.php index 929fd8401d5..7bde15aa879 100644 --- a/htdocs/blockedlog/ajax/authority.php +++ b/htdocs/blockedlog/ajax/authority.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); $res=require '../../master.inc.php'; diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index 24fd71f0514..873b904e7a2 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); $res=require '../../main.inc.php'; diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index d4d4eef4e07..7a4ebebb2cf 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); require '../../main.inc.php'; diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php index 4b50474b4a9..199f9051e07 100644 --- a/htdocs/blockedlog/ajax/check_signature.php +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); require '../../main.inc.php'; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index b580b947e6b..0210491fba7 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -313,12 +313,15 @@ class BlockedLog * @param Object $object object to store * @param string $action action * @param string $amounts amounts + * @param User $fuser User object (forced) * @return int >0 if OK, <0 if KO */ - public function setObjectData(&$object, $action, $amounts) + public function setObjectData(&$object, $action, $amounts, $fuser = null) { global $langs, $user, $mysoc; + if (is_object($fuser)) $user = $fuser; + // Generic fields // action diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index b1262b7a554..fa46f683e50 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -81,7 +81,13 @@ $userstatic=new User($db); llxHeader('', $langs->trans("ListOfBookmarks")); -$newcardbutton=''.$langs->trans('NewBookmark').''; +$newcardbutton=''; +if ($user->rights->bookmark->creer) +{ + $newcardbutton=''.$langs->trans('NewBookmark'); + $newcardbutton.= ''; + $newcardbutton.= ''; +} print_barre_liste($langs->trans("ListOfBookmarks"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', -1, '', 'title_generic.png', 0, $newcardbutton); @@ -119,12 +125,10 @@ if ($resql) print_liste_field_titre(''); print "\n"; - $var=True; while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; // Id diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 769a69a23fa..a0e992e9da9 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -292,7 +292,7 @@ class Facturation else if ( $aId == 'RESET' ) { - $this->id = NULL; + $this->id = null; } else @@ -318,7 +318,7 @@ class Facturation } else if ( $aRef == 'RESET' ) { - $this->ref = NULL; + $this->ref = null; } else { @@ -342,7 +342,7 @@ class Facturation else if ( $aQte == 'RESET' ) { - $this->qte = NULL; + $this->qte = null; } else { @@ -366,7 +366,7 @@ class Facturation } else if ( $aStock == 'RESET' ) { - $this->stock = NULL; + $this->stock = null; } else { @@ -390,7 +390,7 @@ class Facturation } else if ($aRemisePercent == 'RESET') { - $this->remise_percent = NULL; + $this->remise_percent = null; } else { @@ -414,7 +414,7 @@ class Facturation } else if ( $aMontantRemise == 'RESET' ) { - $this->montant_remise = NULL; + $this->montant_remise = null; } else { @@ -439,7 +439,7 @@ class Facturation } else if ( $aPrix == 'RESET' ) { - $this->prix = NULL; + $this->prix = null; } else { @@ -463,7 +463,7 @@ class Facturation } else if ( $aTva == 'RESET' ) { - $this->tva = NULL; + $this->tva = null; } else { @@ -487,7 +487,7 @@ class Facturation } else if ( $aNumFacture == 'RESET' ) { - $this->num_facture = NULL; + $this->num_facture = null; } else { @@ -511,7 +511,7 @@ class Facturation } else if ( $aModeReglement == 'RESET' ) { - $this->mode_reglement = NULL; + $this->mode_reglement = null; } else { @@ -536,7 +536,7 @@ class Facturation } else if ( $aMontantEncaisse == 'RESET' ) { - $this->montant_encaisse = NULL; + $this->montant_encaisse = null; } else { @@ -560,7 +560,7 @@ class Facturation return $this->montant_rendu; } else if ( $aMontantRendu == 'RESET' ) { - $this->montant_rendu = NULL; + $this->montant_rendu = null; } else { @@ -584,7 +584,7 @@ class Facturation } else if ( $aPaiementLe == 'RESET' ) { - $this->paiement_le = NULL; + $this->paiement_le = null; } else { @@ -607,7 +607,7 @@ class Facturation } else if ( $aTotalHt == 'RESET' ) { - $this->prix_total_ht = NULL; + $this->prix_total_ht = null; } else { @@ -630,7 +630,7 @@ class Facturation } else if ( $aMontantTva == 'RESET' ) { - $this->montant_tva = NULL; + $this->montant_tva = null; } else { @@ -654,7 +654,7 @@ class Facturation } else if ( $aTotalTtc == 'RESET' ) { - $this->prix_total_ttc = NULL; + $this->prix_total_ttc = null; } else { diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index 72fbd509535..e1a1dcc6bc8 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -24,16 +24,12 @@ */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // Change this following line to use the correct relative path (../, ../../, etc) require '../main.inc.php'; diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index c1564e1b892..518d8903edd 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -38,7 +38,7 @@ $action=GETPOST('action','aZ09'); * Actions */ -if (preg_match('/set_(.*)/',$action,$reg)) +if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) @@ -52,7 +52,7 @@ if (preg_match('/set_(.*)/',$action,$reg)) } } -if (preg_match('/del_(.*)/',$action,$reg)) +if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) { $code=$reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 9f49e42f060..60689dd37aa 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -268,7 +268,7 @@ if ($user->rights->categorie->creer) $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 46332f9f979..c559d760f0f 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -172,7 +172,7 @@ class Categories extends DolibarrApi * @param array $request_data Request data * @return int ID of category */ - function post($request_data = NULL) + function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); @@ -197,7 +197,7 @@ class Categories extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = NULL) + function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d8d5b10a2b5..044f3e68c0f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -338,28 +338,23 @@ class Categorie extends CommonObject $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO the hook duplicates the trigger !! - $hookmanager->initHooks(array('HookModuleNamedao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; - // Call trigger - $result=$this->call_trigger('CATEGORY_CREATE',$user); - if ($result < 0) { $error++; } - // End call triggers + if (! $error) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } if ( ! $error ) { @@ -432,28 +427,23 @@ class Categorie extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO the hook duplicates the trigger !! - $hookmanager->initHooks(array('HookCategorydao')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; - // Call trigger - $result=$this->call_trigger('CATEGORY_MODIFY',$user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers + if (! $error) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_MODIFY',$user); + if ($result < 0) { $error++; $this->db->rollback(); return -1; } + // End call triggers + } $this->db->commit(); @@ -771,11 +761,9 @@ class Categorie extends CommonObject dol_syslog(get_class($this).'::del_type', LOG_DEBUG); if ($this->db->query($sql)) { - // Save object we want to unlink category off into category instance to provide information to trigger - $this->unlinkoff=$obj; - // Call trigger - $result=$this->call_trigger('CATEGORY_UNLINK',$user); + $this->context=array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result=$this->call_trigger('CATEGORY_UNLINK',$user); if ($result < 0) { $error++; } // End call triggers @@ -905,24 +893,22 @@ class Categorie extends CommonObject $sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND sub.'.$subcol_name.' = '.$id; + $sql.= $this->db->order($sortfield, $sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $this->db->query($sql); $nbtotalofrecords = $this->db->num_rows($result); - } - - $sql.= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { $page = 0; + $offset = 0; } - $offset = $limit * $page; - - $sql.= $this->db->plimit($limit + 1, $offset); } + $sql.= $this->db->plimit($limit + 1, $offset); + $result = $this->db->query($sql); if ($result) { @@ -1219,30 +1205,6 @@ class Categorie extends CommonObject } } - /** - * Returns total number of categories - * - * @return int Number of categories - * @deprecated function not used ? - */ - function get_nb_categories() - { - $sql = "SELECT count(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE entity IN (".getEntity('category').")"; - $res = $this->db->query($sql); - if ($res) - { - $res = $this->db->fetch_array($res); - return $res[0]; - } - else - { - dol_print_error($this->db); - return -1; - } - } - /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 4ccd9116d74..67190aee2e2 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -176,7 +176,7 @@ print ''; $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (empty($reshook) && ! empty($extrafields->attribute_label)) +if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index f6a0417bbda..825abfc5fe5 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -368,13 +368,12 @@ if ($type == Categorie::TYPE_PRODUCT) print '\n"; // Link to delete from category print '\n"; // Link to delete from category print '\n"; // Link to delete from category print '\n"; // Link to delete from category print '\n"; // Link to delete from category print '\n"; // Link to delete from category print ''."\n"; print '\n"; print '\n"; print '\n"; // Link to delete from category print ''; print "\n"; - $var=True; $i = 0; while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - - print ''; print ''; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 255bb036c93..eab813653d6 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -228,7 +228,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_statut = 0"; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; + $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; @@ -349,7 +349,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'customer',16); print ''; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } $i++; $total += $obj->total_ttc; } @@ -432,7 +437,12 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'supplier',16); print ''; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } $i++; $total += $obj->total_ttc; } @@ -744,7 +754,12 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''."\n"; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } print ''."\n"; print ''."\n"; $i++; @@ -843,7 +858,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; print ''."\n"; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } print ''."\n"; print ''."\n"; $i++; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index a8bbb05fb84..bb68f85ea16 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -244,7 +244,7 @@ if (empty($reshook)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); } } - /* For backward compatibility */ + /* For backward compatibility, deprecated */ if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); @@ -754,7 +754,7 @@ if ($action == 'create') $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } @@ -1235,7 +1235,7 @@ else $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 48949881659..676c9c3e98e 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -425,7 +425,13 @@ if ($object->fetch($id) >= 0) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } + //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets $sql .= $db->plimit($limit+1, $offset); diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 52eacf6c115..4175c4e4446 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -52,7 +52,6 @@ print '
'; //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo //{ // Recherche emails - $var=false; print ''; print ''; print '
'.$prod->label."'; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -416,13 +415,12 @@ if ($type == Categorie::TYPE_SUPPLIER) print "'; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -470,13 +468,12 @@ if($type == Categorie::TYPE_CUSTOMER) print "'; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -524,13 +521,12 @@ if ($type == Categorie::TYPE_MEMBER) print ''.$member->firstname."'; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -575,14 +571,12 @@ if ($type == Categorie::TYPE_CONTACT) print "'; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_CONTACT) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -629,14 +623,12 @@ if ($type == Categorie::TYPE_ACCOUNT) print ''.$account->number."'; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -676,20 +668,18 @@ if ($type == Categorie::TYPE_PROJECT) { print "\t".'
'; - print $project->getNomUrl(1,0); + print $project->getNomUrl(1); print "'.$project->ref."'.$project->title."'; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index d0d97f83435..fb9c5944baf 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -908,7 +908,7 @@ if ($action == 'create') $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } @@ -1260,7 +1260,7 @@ if ($id > 0) $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7960bbd764d..5234a05db43 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -384,23 +384,15 @@ class ActionComm extends CommonObject { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } - else if ($reshook < 0) $error++; } if (! $error && ! $notrigger) @@ -865,23 +857,15 @@ class ActionComm extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } - else if ($reshook < 0) $error++; // Now insert assignedusers if (! $error) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index b507d9c72b9..f5d9c7db762 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -187,7 +187,7 @@ class AgendaEvents extends DolibarrApi * @param array $request_data Request data * @return int ID of Agenda Event */ - function post($request_data = NULL) + function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); @@ -226,7 +226,7 @@ class AgendaEvents extends DolibarrApi * @return int */ /* - function put($id, $request_data = NULL) { + function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 9fae2dd47a9..d967d94e9e1 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Eric Seigne - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2014 Cedric GROSS @@ -44,7 +44,7 @@ if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MA if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; -$filter = GETPOST("filter",'',3); +$filter = GETPOST("filter",'alpha',3); $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -59,7 +59,7 @@ $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page","int"); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="a.datec"; @@ -85,8 +85,8 @@ $month=GETPOST("month","int")?GETPOST("month","int"):date("m"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $day=GETPOST("day","int")?GETPOST("day","int"):0; $pid=GETPOST("projectid","int",3); -$status=GETPOST("status"); -$type=GETPOST("type"); +$status=GETPOST("status",'aZ09'); // status may be 0, 50, 100, 'todo' +$type=GETPOST("type",'az09'); $maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('actioncode','array')) @@ -102,7 +102,10 @@ if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->glob if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); - +if ($action == 'default') +{ + $action = ((! empty($conf->global->AGENDA_DEFAULT_VIEW) && $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month'); +} if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week') { $action='show_month'; $day=''; } // View by month @@ -126,7 +129,7 @@ $hookmanager->initHooks(array('agenda')); * Actions */ -if (GETPOST("viewlist") || $action == 'show_list') +if (GETPOST("viewlist",'alpha') || $action == 'show_list') { $param=''; if (is_array($_POST)) @@ -142,7 +145,7 @@ if (GETPOST("viewlist") || $action == 'show_list') exit; } -if (GETPOST("viewperuser") || $action == 'show_peruser') +if (GETPOST("viewperuser",'alpha') || $action == 'show_peruser') { $param=''; if (is_array($_POST)) @@ -677,7 +680,7 @@ if ($showbirthday) $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; + $sql.= " AND sp.entity IN (".getEntity('socpeople').")"; if ($action == 'show_day') { $sql.= ' AND MONTH(birthday) = '.$month; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 9221c7d2ede..cca1f59bf8e 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -25,12 +25,15 @@ * \brief Page to list actions */ +if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->loadLangs(array("users","companies","agenda","commercial")); @@ -64,7 +67,7 @@ $dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth','int'), GETPOST('dateendday' if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); -$filter = GETPOST("filter",'',3); +$filter = GETPOST("filter",'alpha',3); $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -318,6 +321,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); @@ -397,6 +405,7 @@ if ($resql) $s = $hookmanager->resPrint; } + $newcardbutton=''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $tmpforcreatebutton=dol_getdate(dol_now(), true); @@ -405,12 +414,12 @@ if ($resql) //$param='month='.$monthshown.'&year='.$year; $hourminsec='100000'; - $link = ''; - $link.= $langs->trans("AddAction"); - $link.= ''; + $newcardbutton = ''.$langs->trans("AddAction"); + $newcardbutton.= ''; + $newcardbutton.= ''; } - print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$link, '', $limit); + print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit); $moreforfilter=''; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 2d72fa4c3f8..93cbae527f1 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -38,7 +38,7 @@ $action=GETPOST('action','alpha'); $month=GETPOST('month'); $year=GETPOST('year'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -93,6 +93,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1,$offset); diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 5c160bfab16..fe2e3027dcf 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -34,7 +34,7 @@ $page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.name"; if ($page < 0) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; $type=GETPOST('type', 'alpha'); @@ -78,7 +78,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= " ".MAIN_DB_PREF $sql.= " ".MAIN_DB_PREFIX."socpeople as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND p.entity IN (".getEntity('societe').")"; +$sql.= " AND p.entity IN (".getEntity('socpeople').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($type == "c") $sql.= " AND s.client IN (1, 3)"; if ($type == "p") $sql.= " AND s.client IN (2, 3)"; @@ -144,14 +144,11 @@ if ($resql) print '
'.img_object($langs->trans("ShowContact"),"contact"); print ' '.$obj->name.''.price($obj->total_ttc).'
'.price($obj->total_ht).'
'.price($obj->total_ttc).'
'.price($obj->total_ttc).'
'.price($obj->total_ht).'
'.price($obj->total_ttc).'
'; print dol_print_date($db->jdate($obj->dp),'day').''.price($obj->total_ttc).''.price($obj->total_ht).''.price($obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut,3).'
'; print dol_print_date($db->jdate($obj->dp),'day').''.price($obj->total_ttc).''.price($obj->total_ht).''.price($obj->total_ttc).''.$orderstatic->LibStatut($obj->fk_statut,$obj->billed,3).'
'; @@ -62,7 +61,7 @@ print '
'; print '
'; print ''; - + print "
'; print $langs->trans("Other").':

\n"; //} @@ -74,7 +73,6 @@ print '
'.$langs->trans("TargetsStatistic $dir=DOL_DOCUMENT_ROOT."/core/modules/mailings"; $handle=opendir($dir); -$var=True; if (is_resource($handle)) { while (($file = readdir($handle))!==false) @@ -106,8 +104,6 @@ if (is_resource($handle)) // Si le module mailing est qualifi� if ($qualified) { - $var = !$var; - foreach ($mailmodule->getSqlArrayForStats() as $sql) { print '
'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
\n"; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 3259654ebcc..ced465dfdb7 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2017 Charlene Benke * Copyright (C) 2018 Nicolas ZABOURI * @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -$langs->loadLangs(array('companies','propal','compta','bills','orders','products')); +$langs->loadLangs(array('companies','propal','compta','bills','orders','products','deliveries')); $socid=GETPOST('socid','int'); @@ -76,6 +76,14 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_day=GETPOST("search_day","int"); $search_month=GETPOST("search_month","int"); $search_year=GETPOST("search_year","int"); +$search_dayfin=GETPOST("search_dayfin","int"); +$search_monthfin=GETPOST("search_monthfin","int"); +$search_yearfin=GETPOST("search_yearfin","int"); +$search_daydelivery=GETPOST("search_daydelivery","int"); +$search_monthdelivery=GETPOST("search_monthdelivery","int"); +$search_yeardelivery=GETPOST("search_yeardelivery","int"); +$search_availability=GETPOST('search_availability','int'); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $viewstatut=GETPOST('viewstatut','alpha'); $optioncss = GETPOST('optioncss','alpha'); @@ -85,7 +93,7 @@ $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alp $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -144,6 +152,8 @@ $arrayfields=array( 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), 'p.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.fin_validite'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1), + 'p.date_livraison'=>array('label'=>$langs->trans("DeliveryDate"), 'checked'=>0), + 'ava.rowid'=>array('label'=>$langs->trans("AvailabilityPeriod"), 'checked'=>0), 'p.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), @@ -201,10 +211,19 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_year=''; $search_month=''; $search_day=''; + $search_yearfin=''; + $search_monthfin=''; + $search_dayfin=''; + $search_yeardelivery=''; + $search_monthdelivery=''; + $search_daydelivery=''; + $search_availability=''; $viewstatut=''; $object_statut=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; + } if ($object_statut != '') $viewstatut=$object_statut; @@ -242,12 +261,15 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; +$sql.= " ava.rowid as availability,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; +$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= ' u.login'; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -258,12 +280,15 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ + $sql.= ', '.MAIN_DB_PREFIX.'propal as p'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal_extrafields as ef on (p.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) @@ -285,6 +310,7 @@ if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer); if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet); +if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')'; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_login) $sql .= natural_search("u.login", $search_login); @@ -294,6 +320,9 @@ if ($search_montant_ttc != '') $sql.= natural_search("p.total", $search_montant_ if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; + if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if ($viewstatut != '' && $viewstatut != '-1') @@ -313,6 +342,32 @@ else if ($search_year > 0) { $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } +if ($search_monthfin > 0) +{ + if ($search_yearfin > 0 && empty($search_dayfin)) + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_monthfin,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_monthfin,false))."'"; + else if ($search_yearfin > 0 && ! empty($search_dayfin)) + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthfin, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthfin, $search_dayfin, $search_yearfin))."'"; + else + $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_monthfin)."'"; +} +else if ($search_yearfin > 0) +{ + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,1,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,12,false))."'"; +} +if ($search_monthdelivery > 0) +{ + if ($search_yeardelivery > 0 && empty($search_daydelivery)) + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,$search_monthdelivery,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,$search_monthdelivery,false))."'"; + else if ($search_yeardelivery > 0 && ! empty($search_daydelivery)) + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."'"; + else + $sql.= " AND date_format(p.date_livraison, '%m') = '".$db->escape($search_monthdelivery)."'"; +} +else if ($search_yeardelivery > 0) +{ + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,1,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,12,false))."'"; +} if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); if ($search_user > 0) { @@ -335,6 +390,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); @@ -380,6 +441,8 @@ if ($resql) if ($search_zip) $param.='&search_zip='.urlencode($search_zip); if ($socid > 0) $param.='&socid='.urlencode($socid); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -397,7 +460,9 @@ if ($resql) $newcardbutton=''; if ($user->rights->propal->creer) { - $newcardbutton=''.$langs->trans('NewPropal').''; + $newcardbutton=''.$langs->trans('NewPropal'); + $newcardbutton.= ''; + $newcardbutton.= ''; } // Lignes des champs de filtre @@ -456,6 +521,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; @@ -479,25 +552,25 @@ if ($resql) if (! empty($arrayfields['p.ref']['checked'])) { print '
'; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ajax_combobox('search_type_thirdparty'); print ''; + print ''; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_year,'search_year',1, 20, 5); print ' '; + //print $langs->trans('Month').': '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $formother->select_year($search_yearfin,'search_yearfin',1, 20, 5); + print ''; + //print $langs->trans('Month').': '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $formother->select_year($search_yeardelivery,'search_yeardelivery',1, 20, 5); + print ''; + print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); + print ajax_combobox('search_availability'); + print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''.dol_print_date($db->jdate($obj->ddelivery),'day'); + print ' '; + $form->form_availability('', $obj->availability, 'none', 1); + print '
'."\n"; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 532d2e4c9b8..b9e8cac609a 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -43,7 +43,7 @@ $search_ref = GETPOST('search_ref','alpha'); $search_account = GETPOST('search_account','int'); $search_amount = GETPOST('search_amount','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -117,6 +117,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); @@ -134,7 +139,9 @@ if ($resql) $newcardbutton=''; if ($user->rights->banque->cheque) { - $newcardbutton = ''.$langs->trans('NewCheckDeposit').''; + $newcardbutton = ''.$langs->trans('NewCheckDeposit'); + $newcardbutton.= ''; + $newcardbutton.= ''; } print ''; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 6ca9f29c16e..017593316a7 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -59,7 +60,7 @@ $search_amount=GETPOST("search_amount",'alpha'); // alpha because we must be $search_company=GETPOST("search_company",'alpha'); $search_payment_num=GETPOST('search_payment_num','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -191,6 +192,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); @@ -229,21 +235,21 @@ if ($resql) // Lines for filters fields print ''; print ''; print ''; print ''; print ''; print ''; if (! empty($conf->banque->enabled)) { @@ -252,7 +258,7 @@ if ($resql) print ''; } print ''; print ''; // Ref print ''; print ''; - $var=True; - while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 04ec746d7f6..765e0cf4fa8 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -129,8 +129,6 @@ if ($resql) print ''; print ''; - $var = True; - $users = array(); while ($i < min($num,$limit)) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 64811c7604a..d446e64fe9b 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -170,6 +170,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 82431e3bdd2..2fbaaf7fbcb 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -169,6 +169,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 271ce4da7fe..64e1991064d 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -71,7 +71,6 @@ print '
'; $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); $bprev = new BonPrelevement($db); -$var=true; print '
'; +print ''; } if (! empty($arrayfields['c.date_delivery']['checked'])) { - print ''; } diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index bebcaa93097..c9acc111dc4 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -472,7 +472,7 @@ if ($action == 'create' && !$error) $parameters=array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { $object=new Facture($db); print $object->showOptionals($extrafields,'edit'); diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index b1baf7332a1..27d177cfbd3 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -354,7 +354,7 @@ print '
'; // Show graphs -print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 57aa7ce8b04..57b98d1a29a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -28,9 +28,9 @@ */ /** - * \file htdocs/commande/card.php + * \file htdocs/commande/card.php * \ingroup commande - * \brief Page to show customer order + * \brief Page to show customer order */ require '../main.inc.php'; @@ -68,6 +68,7 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility @@ -220,7 +221,7 @@ if (empty($reshook)) // Link to a project else if ($action == 'classin' && $user->rights->commande->creer) { - $object->setProject(GETPOST('projectid')); + $object->setProject(GETPOST('projectid','int')); } // Add order @@ -251,8 +252,8 @@ if (empty($reshook)) $object->note_private = GETPOST('note_private','none'); $object->note_public = GETPOST('note_public','none'); $object->source = GETPOST('source_id'); - $object->fk_project = GETPOST('projectid'); - $object->ref_client = GETPOST('ref_client'); + $object->fk_project = GETPOST('projectid','int'); + $object->ref_client = GETPOST('ref_client','alpha'); $object->modelpdf = GETPOST('model'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); @@ -1269,24 +1270,16 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('orderdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('ORDER_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) + // Actions on extra fields + $result = $object->insertExtraFields('ORDER_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); $error++; + } } - if ($error) - $action = 'edit_extras'; + if ($error) $action = 'edit_extras'; } if ($action == 'set_thirdparty' && $user->rights->commande->creer) @@ -1383,7 +1376,6 @@ if ($action == 'create' && $user->rights->commande->creer) if ($socid > 0) $res = $soc->fetch($socid); - $projectid = 0; $remise_absolue = 0; $currency_code = $conf->currency; @@ -1480,7 +1472,6 @@ if ($action == 'create' && $user->rights->commande->creer) $remise_percent = $soc->remise_percent; $remise_absolue = 0; $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; - $projectid = 0; if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; @@ -1488,7 +1479,6 @@ if ($action == 'create' && $user->rights->commande->creer) $note_public = $object->getDefaultCreateValueFor('note_public'); } - print '
'; print ''; print ''; @@ -1654,7 +1644,7 @@ if ($action == 'create' && $user->rights->commande->creer) $parameters = array('objectsrc' => $objectsrc, 'socid'=>$socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -2623,9 +2613,8 @@ if ($action == 'create' && $user->rights->commande->creer) $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show online payment link - //$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); - $useonlinepayment = $conf->global->ORDER_SHOW_ONLINE_PAYMENT_ON_ORDER; - + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + if (! empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment) { print '
'; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index cbd505a41b8..c0e494a1684 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -179,7 +179,7 @@ class Orders extends DolibarrApi * @param array $request_data Request data * @return int ID of order */ - function post($request_data = NULL) + function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401, "Insuffisant rights"); @@ -245,7 +245,7 @@ class Orders extends DolibarrApi * * @return int */ - function postLine($id, $request_data = NULL) { + function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } @@ -308,7 +308,7 @@ class Orders extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = NULL) { + function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } @@ -402,7 +402,7 @@ class Orders extends DolibarrApi * * @return int */ - function put($id, $request_data = NULL) { + function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index dd0e41ee836..a38cc3a442d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -823,7 +823,7 @@ class Commande extends CommonOrder $line = $this->lines[$i]; // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array - //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. + //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. if (! is_object($line)) $line = (object) $line; // Reset fk_parent_line for no child products and special product @@ -4208,7 +4208,7 @@ class OrderLine extends CommonOrderLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEORDER_UPDATE',$user); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 205efc3ad91..2d97b06238b 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -102,6 +102,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 5a3f0c1973f..84cc9977e20 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -164,7 +164,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - print ''; + print ''; print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
\n"; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8048d5a618f..f97dbc00617 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -73,6 +73,7 @@ $socid=GETPOST('socid','int'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); $search_total_ht=GETPOST('search_total_ht','alpha'); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $optioncss = GETPOST('optioncss','alpha'); $billed = GETPOST('billed','int'); $viewstatut=GETPOST('viewstatut'); @@ -193,6 +194,7 @@ if (empty($reshook)) $billed=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; } if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) @@ -208,6 +210,7 @@ if (empty($reshook)) $uploaddir = $conf->commande->dir_output; $trigger_name='ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + } @@ -237,6 +240,8 @@ $sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_clie $sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql.= ' c.date_creation as date_creation, c.tms as date_update,'; $sql.= " p.rowid as project_id, p.ref as project_ref"; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -247,6 +252,7 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; @@ -327,6 +333,8 @@ if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$sear if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1); if ($search_project_ref != '') $sql.= natural_search("p.ref",$search_project_ref); +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -342,6 +350,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); @@ -406,6 +420,8 @@ if ($resql) if ($show_files) $param.='&show_files=' .urlencode($show_files); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($billed != '') $param.='&billed='.urlencode($billed); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -413,6 +429,8 @@ if ($resql) $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), + 'cancelorders'=>$langs->trans("Cancel"), + ); if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); @@ -422,7 +440,9 @@ if ($resql) $newcardbutton=''; if ($contextpage == 'orderlist' && $user->rights->commande->creer) { - $newcardbutton=''.$langs->trans('NewOrder').''; + $newcardbutton=''.$langs->trans('NewOrder'); + $newcardbutton.= ''; + $newcardbutton.= ''; } // Lines of title fields @@ -530,6 +550,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; @@ -604,17 +632,17 @@ if ($resql) // Date order if (! empty($arrayfields['c.date_commande']['checked'])) { - print '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_orderyear?$search_orderyear:-1,'search_orderyear',1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_deliveryyear?$search_deliveryyear:-1,'search_deliveryyear',1, 20, 5); print '
"; print ''; - print ''; + print ''; print '
'; +print ''; } print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Type print ''; @@ -914,7 +914,7 @@ else $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 83e1f15ef36..fb514120d57 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -101,11 +101,10 @@ if ($result) $num = $db->num_rows($result); $i = 0; $total = 0; - $var=True; while ($i < $num) { $objp = $db->fetch_object($result); - + print ''; print ''; if (GETPOST('action','aZ09') == 'edit' && GETPOST("categid")== $objp->rowid) @@ -136,7 +135,7 @@ if ($result) */ if ($action != 'edit') { - + print ''; print ''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c773ef242ad..7228214e51c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -395,9 +395,10 @@ class Account extends CommonObject * @param string $emetteur Name of cheque writer * @param string $banque Bank of cheque writer * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. + * @param int $datev Date value * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='', $datev=null) { // Deprecatîon warning if (is_numeric($oper)) { @@ -447,7 +448,7 @@ class Account extends CommonObject $this->db->begin(); - $datev = $date; + if (is_null($datev) || empty($datev)) $datev = $date; $accline = new AccountLine($this->db); $accline->datec = $now; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 2fca317d1c4..a6e206c4b09 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -127,7 +127,7 @@ if ($id > 0 || !empty($ref)) { print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 27a167bc576..5e83b3032c1 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -20,16 +20,11 @@ * \brief File to return Ajax response on payment breakdown process */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) require '../main.inc.php'; @@ -66,7 +61,7 @@ foreach ($remains as $key => $value) } // Treatment -$result = $amountPayment != '' ? ($amountPayment - array_sum($amounts)) : ($amountPayment + array_sum($amounts)); // Remaining amountPayment +$result = ($amountPayment != '') ? ($amountPayment - array_sum($amounts)) : array_sum($amounts); // Remaining amountPayment $toJsonArray = array(); $totalRemaining = price2num(array_sum($remains)); $toJsonArray['label'] = $amountPayment == '' ? '' : $langs->transnoentities('RemainingAmountPayment'); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index c583e9180ff..3179a6486e9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1,12 +1,13 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012 Vinícius Nogueira * Copyright (C) 2014 Florian Henry * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -91,7 +92,7 @@ $num_releve=GETPOST("num_releve","alpha"); $cat=GETPOST("cat"); if (empty($dateop)) $dateop=-1; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -427,9 +428,9 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->banque->consolidate) { $newparam = $param; $newparam = preg_replace('/search_conciliated=\d+/i','',$newparam); - $buttonreconcile = ''.$langs->trans("Conciliate").''; + $buttonreconcile = ''.$langs->trans("Conciliate").''; } else { - $buttonreconcile = ''.$langs->trans("Conciliate").''; + $buttonreconcile = ''.$langs->trans("Conciliate").''; } } } @@ -722,7 +723,7 @@ if ($resql) // Title $bankcateg=new BankCateg($db); - $addbutton = ''; + $newcardbutton = ''; if ($action != 'addline' && $action != 'reconcile') { if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) @@ -730,27 +731,37 @@ if ($resql) if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments { if ($user->rights->banque->modifier) { - $addbutton = ''.$langs->trans("AddBankRecord").''; + $newcardbutton = ''.$langs->trans("AddBankRecord"); + $newcardbutton.= ''; + $newcardbutton.= ''; } else { - $addbutton = ''.$langs->trans("AddBankRecord").''; + $newcardbutton = ''.$langs->trans("AddBankRecord"); + $newcardbutton.= ''; + $newcardbutton.= ''; } } else // If direct entries is not done using miscellaneous payments { if ($user->rights->banque->modifier) { - $addbutton = ''.$langs->trans("AddBankRecord").''; + $newcardbutton = ''.$langs->trans("AddBankRecord"); + $newcardbutton.= ''; + $newcardbutton.= ''; } else { - $addbutton = ''.$langs->trans("AddBankRecord").''; + $newcardbutton = ''.$langs->trans("AddBankRecord"); + $newcardbutton.= ''; + $newcardbutton.= ''; } } } else { - $addbutton = ''.$langs->trans("AddBankRecord").''; + $newcardbutton = ''.$langs->trans("AddBankRecord"); + $newcardbutton.= ''; + $newcardbutton.= ''; } } - $morehtml='
'; + $morehtml='
'; $morehtml.= ' "; // ' Page '; $morehtml.=''; $morehtml.='/'.$nbtotalofpages.' '; @@ -761,7 +772,7 @@ if ($resql) $morehtml.=$buttonreconcile; } - $morehtml.=$addbutton; + $morehtml.=$newcardbutton; $picto='title_bank'; if ($id > 0 || ! empty($ref)) $picto=''; @@ -901,7 +912,7 @@ if ($resql) if (! empty($arrayfields['b.conciliated']['checked'])) { print '
'; - print $form->selectyesno('search_conciliated', $search_conciliated, 1, False, 1); + print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1); print ''; @@ -931,7 +942,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre('', $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 00db08f9d4d..6a9ce1d2ba1 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -413,7 +413,7 @@ if ($action == 'create') $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit',$parameters); } @@ -803,7 +803,7 @@ else print ''; print ''."\n\n"; - dol_fiche_head(array(), 0, '' ,0); + dol_fiche_head(array(), 0, '', 0); //print '
'; @@ -811,11 +811,11 @@ else // Ref print '
'.$langs->trans("Ref").'ref).'">
ref).'">
'.$langs->trans("Label").'label).'">
label).'">
'.$langs->trans("AccountType").'
'.$objp->rowid.'
 
'; print ''; - print ''; + print ''; print "
' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
' . $langs->trans("TotalSizeOfAttachedFiles") . '' . $totalsize . ' ' . $langs->trans("bytes") . '
' . $langs->trans("TotalSizeOfAttachedFiles") . '' .dol_print_size($totalsize,1,1).'
\n"; print ''; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index e3c2a5b94a9..9fc8f5028bb 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -5,6 +5,7 @@ use Stripe\BankAccount; * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -230,7 +231,9 @@ $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; if ($user->rights->banque->configurer) { - $newcardbutton.=''.$langs->trans("NewFinancialAccount").''; + $newcardbutton.=''.$langs->trans("NewFinancialAccount"); + $newcardbutton.= ''; + $newcardbutton.= ''; } @@ -389,7 +392,7 @@ if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titr // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'],$_SERVER["PHP_SELF"],"b.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 6a6557c5aef..5e9f98be02d 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -72,7 +72,7 @@ if ($user->rights->banque->consolidate && $action == 'dvprev' && ! empty($dvid)) } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -395,7 +395,6 @@ if (empty($numref)) $result = $db->query($sql); if ($result) { - $var=True; $numrows = $db->num_rows($result); $i = 0; @@ -572,7 +571,6 @@ else $result = $db->query($sql); if ($result) { - $var=False; $numrows = $db->num_rows($result); $i = 0; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index b6649250e64..2828963d889 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -349,7 +349,7 @@ if ($action == 'create') print '
'; print ''; print '   '; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index aa47d714bd9..f92090a0259 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -38,7 +38,7 @@ $result = restrictedArea($user, 'banque', '', '', ''); $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); $search_label = GETPOST('search_label','alpha'); @@ -153,7 +153,13 @@ if ($result) if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - $newcardbutton=''.$langs->trans('MenuNewVariousPayment').''; + $newcardbutton=''; + if ($user->rights->banque->modifier) + { + $newcardbutton=''.$langs->trans('MenuNewVariousPayment'); + $newcardbutton.= ''; + $newcardbutton.= ''; + } print '
'; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 321fad5baf6..7a11a709128 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -48,7 +48,7 @@ if (! $year && $mode != 'sconly') { $year=date("Y", time()); } $search_account = GETPOST('search_account','int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 1f3974ce041..76481c4c8c0 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -115,7 +115,7 @@ if ($object->id) //print "
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
'; print ''; diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 2cd3823bacd..64c5442299f 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -45,7 +45,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="d.dated"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; /* diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 807ddfee700..fad8d93b244 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -46,7 +46,7 @@ $search_company=GETPOST('search_company','alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 36bc107d672..d503d5e4c07 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -294,7 +294,7 @@ print '
'; // Show graphs -print ''; print ''; print ""; + print ""; print ''; print ""; print "\n"; @@ -79,7 +82,8 @@ if ($result) $localtax_static->ref=$obj->rowid; print "\n"; print "\n"; - print '\n"; + print '\n"; + print '\n"; $total = $total + $obj->amount; print ""; @@ -87,8 +91,8 @@ if ($result) $i++; } - print ''; - print ""; + print ''; + print ''; print "
'; +print ''; - // Date when + // Date when (next invoice generation) print ''; print ''; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 0a2b9f72d60..3e077e8a749 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -83,7 +83,7 @@ $search_frequency=GETPOST('search_frequency','alpha'); $search_unit_frequency=GETPOST('search_unit_frequency','alpha'); $search_status=GETPOST('search_status','int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -273,14 +273,20 @@ else if ($search_year_date_when > 0) $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'"; } +$sql.= $db->order($sortfield, $sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } -$sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); @@ -598,13 +604,20 @@ if ($resql) // Date next generation if (! empty($arrayfields['f.date_when']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.datec']['checked'])) { @@ -631,7 +644,11 @@ if ($resql) print ''; break; } - if (! is_array($coll_listbuy) && $coll_listbuy == -2) + if (! is_array($x_paye) && $coll_listbuy == -2) { print ''; break; @@ -240,76 +420,121 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu print ''; - print ''; - - if ($CalcLT==0) { - $x_coll = 0; - foreach($coll_listsell as $vatrate=>$val) { - $x_coll+=$val[$localTaxType==1?'localtax1':'localtax2']; - } - $subtotalcoll = $subtotalcoll + $x_coll; - print ""; + print ''; - $x_paye = 0; - foreach($coll_listbuy as $vatrate=>$val) { - $x_paye+=$val[$localTaxType==1?'localtax1':'localtax2']; - } - $subtotalpaye = $subtotalpaye + $x_paye; - print ""; - } elseif($CalcLT==1) { - $x_paye = 0; - foreach($coll_listbuy as $vatrate=>$val) { - $x_paye+=$val[$localTaxType==1?'localtax1':'localtax2']; + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; + + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['localtax'.$localTaxType]*$ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } - $subtotalpaye = $subtotalpaye + $x_paye; - print ""; - } elseif($CalcLT==2) { - $x_coll = 0; - foreach($coll_listsell as $vatrate=>$val) { - $x_coll+=$val[$localTaxType==1?'localtax1':'localtax2']; + } + print ""; + + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; + + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['localtax'.$localTaxType]*$ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; } - $subtotalcoll = $subtotalcoll + $x_coll; - print ""; - } + print ""; - if($CalcLT==0) { - $diff= $x_coll - $x_paye; - } elseif($CalcLT==1) { - $diff= $x_paye; - } elseif($CalcLT==2) { - $diff= $x_coll; - } + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; + $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; - $subtotal = $subtotal + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print "\n"; + print "\n"; print "\n"; print "\n"; - $i++; + $i++; $m++; if ($i > 2) { - print ''; - print ''; - if($CalcLT==0) { - print ''; - print ''; - print ''; - } elseif($CalcLT==1) { - print ''; - print ''; - } elseif($CalcLT==2) { - print ''; - print ''; - } - print ''; - $i = 0; - $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i = 0; + $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; } } -print ''; +print ''; print "\n"; print ''; @@ -318,27 +543,39 @@ print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6d0c6fffc1a..ecd9ad09bbf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -983,15 +983,13 @@ if (empty($reshook)) // Add link between credit note and origin if(! empty($object->fk_facture_source)) { $facture_source->fetch($object->fk_facture_source); - } - $facture_source->fetchObjectLinked(); + $facture_source->fetchObjectLinked(); - if(! empty($facture_source->linkedObjectsIds)) { - $linkedObjectIds = $facture_source->linkedObjectsIds; - $sourcetype = key($linkedObjectIds); - $fk_origin = current($facture_source->linkedObjectsIds[$sourcetype]); - - $object->add_object_linked($sourcetype, $fk_origin); + if(! empty($facture_source->linkedObjectsIds)) { + foreach($facture_source->linkedObjectsIds as $sourcetype => $TIds) { + $object->add_object_linked($sourcetype, current($TIds)); + } + } } } } @@ -2117,7 +2115,7 @@ if (empty($reshook)) $fromElement = GETPOST('fromelement'); $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - + if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { if($fromElement == 'commande') @@ -2164,7 +2162,7 @@ if (empty($reshook)) $fk_prev_id = ''; $fk_unit = $originLine->fk_unit; $pu_ht_devise = $originLine->multicurrency_subprice; - + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise); if($res > 0){ $importCount++; @@ -2172,18 +2170,18 @@ if (empty($reshook)) $error++; } } - else{ - $error++; + else{ + $error++; } } - + if($error) { setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors'); } } } - + // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -2209,22 +2207,15 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; - if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('invoicedao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('BILL_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error ++; + if (! $error) + { + // Actions on extra fields + $result = $object->insertExtraFields('BILL_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) @@ -2902,7 +2893,7 @@ if ($action == 'create') $parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="2"', 'cols'=>2); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -4577,16 +4568,16 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); - + $compatibleImportElementsList = false; - if($user->rights->facture->creer - && $object->statut == Facture::STATUS_DRAFT + if($user->rights->facture->creer + && $object->statut == Facture::STATUS_DRAFT && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) ) { $compatibleImportElementsList = array('commande'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem,$compatibleImportElementsList); - + // Show online payment link $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index a114829d43c..8547be8cb2c 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -196,7 +196,7 @@ class Invoices extends DolibarrApi * @param array $request_data Request datas * @return int ID of invoice */ - function post($request_data = NULL) + function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401, "Insuffisant rights"); @@ -313,7 +313,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function putLine($id, $lineid, $request_data = NULL) { + function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -414,7 +414,7 @@ class Invoices extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = NULL) + function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -499,7 +499,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 400 */ - function postLine($id, $request_data = NULL) { + function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -562,6 +562,59 @@ class Invoices extends DolibarrApi return $updateRes; } + /** + * Adds a contact to an invoice + * + * @param int $id Order ID + * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link + * @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING + * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) + * @param int $notrigger Disable all triggers + * + * @url POST {id}/contacts + * + * @return array + * + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 + * + */ + function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->add_contact($fk_socpeople,$type_contact,$source,$notrigger); + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->invoice->error); + } + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->invoice); + } + + + /** * Sets an invoice as draft * @@ -899,14 +952,13 @@ class Invoices extends DolibarrApi return $result; } - /** - * Add payment line to a specific invoice - * - * The model schema is defined by the PaymentData class. + + /** + * Add payment line to a specific invoice with the remain to pay as amount. * * @param int $id Id of invoice - * @param string $datepaye {@from body} Payment date {@type timestamp} - * @param int $paiementid {@from body} Payment mode Id {@min 1} + * @param string $datepaye {@from body} Payment date {@type timestamp} + * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} * @param string $num_paiement {@from body} Payment number (optional) @@ -922,63 +974,194 @@ class Invoices extends DolibarrApi * @throws 404 */ function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { + global $conf; + + require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; + + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(403); + } + if(empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (! empty($conf->banque->enabled)) { + if(empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } + } + + if(empty($paiementid)) { + throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + } + + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + + $this->db->begin(); + + $amounts = array(); + $multicurrency_amounts = array(); + + // Clean parameters amount if payment is for a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = -$resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = -$newvalue; + } else { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = $resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = $newvalue; + } + + + // Creation of payment line + $paiement = new Paiement($this->db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = $paiementid; + $paiement->paiementcode = dol_getIdFromCode($this->db,$paiementid,'c_paiement','id','code',1); + $paiement->num_paiement = $num_paiement; + $paiement->note = $comment; + + $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices + if ($paiement_id < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Payment error : '.$paiement->error); + } + + if (! empty($conf->banque->enabled)) { + $label='(CustomerInvoicePayment)'; + + if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { + throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); + } + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result=$paiement->addPaymentToBank(DolibarrApiAccess::$user,'payment',$label,$accountid,$chqemetteur,$chqbank); + if ($result < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Add payment to bank error : '.$paiement->error); + } + } + + $this->db->commit(); + + return $paiement_id; + } + + /** + * Add a payment to pay partially or completely one or several invoices. + * Warning: Take care that all invoices are owned by the same customer. + * Example of value for parameter arrayofamounts: {"1": "99.99", "2": "10"} + * + * @param string $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice + * @param string $datepaye {@from body} Payment date {@type timestamp} + * @param int $paiementid {@from body} Payment mode Id {@min 1} + * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} + * @param int $accountid {@from body} Account Id {@min 1} + * @param string $num_paiement {@from body} Payment number (optional) + * @param string $comment {@from body} Note (optional) + * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') + * @param string $chqbank {@from body} Issuer bank name (optional) + * + * @url POST /paymentsdistributed + * + * @return int Payment ID + * @throws 400 + * @throws 401 + * @throws 403 + * @throws 404 + */ + function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') + { global $conf; require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(403); } - if(empty($id)) { - throw new RestException(400, 'Invoice ID is mandatory'); - } - - if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + foreach($arrayofamounts as $id => $amount) { + if(empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory. Fill the invoice id and amount into arrayofamounts parameter. For example: {"1": "99.99", "2": "10"}'); + } + if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { + throw new RestException(403, 'Access not allowed on invoice ID '.$id.' for login '.DolibarrApiAccess::$user->login); + } } if (! empty($conf->banque->enabled)) { - if(empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); - } + if(empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } } - if(empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); } - - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - - // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); - $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); - $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - $this->db->begin(); $amounts = array(); $multicurrency_amounts = array(); - // Clean parameters amount if payment is for a credit note - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = -$resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = -$newvalue; - } else { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = $resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = $newvalue; - } + // Loop on each invoice to pay + foreach($arrayofamounts as $id => $amount) + { + $result = $this->invoice->fetch($id); + if( ! $result ) { + $this->db->rollback(); + throw new RestException(404, 'Invoice ID '.$id.' not found'); + } + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + if ($amount != 'remain') + { + if ($amount > $resteapayer) + { + $this->db->rollback(); + throw new RestException(400, 'Payment amount on invoice ID '.$id.' ('.$amount.') is higher than remain to pay ('.$resteapayer.')'); + } + $resteapayer = $amount; + } + // Clean parameters amount if payment is for a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = -$resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = -$newvalue; + } else { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = $resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = $newvalue; + } + } // Creation of payment line $paiement = new Paiement($this->db); @@ -989,17 +1172,14 @@ class Invoices extends DolibarrApi $paiement->paiementcode = dol_getIdFromCode($this->db,$paiementid,'c_paiement','id','code',1); $paiement->num_paiement = $num_paiement; $paiement->note = $comment; - $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices if ($paiement_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paiement->error); } - if (! empty($conf->banque->enabled)) { $label='(CustomerInvoicePayment)'; - if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); } @@ -1011,7 +1191,9 @@ class Invoices extends DolibarrApi throw new RestException(400, 'Add payment to bank error : '.$paiement->error); } } + $this->db->commit(); + return $paiement_id; } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8759f2eebf3..e52658d38e8 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -108,7 +108,7 @@ class FactureRec extends CommonInvoice if (empty($this->frequency)) { $this->frequency=0; - $this->date_when=NULL; + $this->date_when=null; } @@ -475,7 +475,6 @@ class FactureRec extends CommonInvoice $line->id = $objp->rowid; $line->rowid = $objp->rowid; - $line->label = $objp->custom_label; // Label line $line->desc = $objp->description; // Description line $line->description = $objp->description; // Description line $line->product_type = $objp->product_type; // Type of line @@ -488,6 +487,8 @@ class FactureRec extends CommonInvoice $line->qty = $objp->qty; $line->subprice = $objp->subprice; + $line->label = $objp->custom_label; // @deprecated + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; @@ -992,6 +993,7 @@ class FactureRec extends CommonInvoice $sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= ' AND suspended = 0'; + $sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here $sql.= $db->order('entity', 'ASC'); //print $sql;exit; @@ -1006,7 +1008,7 @@ class FactureRec extends CommonInvoice $saventity = $conf->entity; - while ($i < $num) // Loop on each template invoice + while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass. { $line = $db->fetch_object($resql); @@ -1015,49 +1017,59 @@ class FactureRec extends CommonInvoice $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); - // Set entity context - $conf->entity = $facturerec->entity; + if ($facturerec->id > 0) + { + // Set entity context + $conf->entity = $facturerec->entity; - dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); + dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); - $error=0; + $error=0; - $facture = new Facture($db); - $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice - $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice + $facture = new Facture($db); + $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice + $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice - $facture->type = self::TYPE_STANDARD; - $facture->brouillon = 1; - $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. - $facture->socid = $facturerec->socid; + $facture->type = self::TYPE_STANDARD; + $facture->brouillon = 1; + $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. + $facture->socid = $facturerec->socid; - $invoiceidgenerated = $facture->create($user); - if ($invoiceidgenerated <= 0) - { - $this->errors = $facture->errors; - $this->error = $facture->error; - $error++; - } - if (! $error && $facturerec->auto_validate) - { - $result = $facture->validate($user); - if ($result <= 0) - { - $this->errors = $facture->errors; - $this->error = $facture->error; - $error++; - } - } - if (! $error && $facturerec->generate_pdf) - { - $result = $facture->generateDocument($facturerec->modelpdf, $langs); - if ($result <= 0) - { - $this->errors = $facture->errors; - $this->error = $facture->error; - $error++; - } - } + $invoiceidgenerated = $facture->create($user); + if ($invoiceidgenerated <= 0) + { + $this->errors = $facture->errors; + $this->error = $facture->error; + $error++; + } + if (! $error && $facturerec->auto_validate) + { + $result = $facture->validate($user); + if ($result <= 0) + { + $this->errors = $facture->errors; + $this->error = $facture->error; + $error++; + } + } + if (! $error && $facturerec->generate_pdf) + { + $result = $facture->generateDocument($facturerec->modelpdf, $langs); + if ($result <= 0) + { + $this->errors = $facture->errors; + $this->error = $facture->error; + $error++; + } + } + } + else + { + $error++; + $this->error="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; + $this->errors[]="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity; + dol_syslog("createRecurringInvoices Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity); + } if (! $error && $invoiceidgenerated >= 0) { @@ -1503,7 +1515,7 @@ class FactureRec extends CommonInvoice } /** - * Update the auto validate invoice + * Update the auto validate flag of invoice * * @param int $validate 0 to create in draft, 1 to create and validate invoice * @return int <0 if KO, >0 if OK @@ -1791,7 +1803,7 @@ class FactureLigneRec extends CommonInvoiceLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_REC_UPDATE',$user); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c0285a65fdf..468ac928f07 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -613,7 +613,7 @@ class Facture extends CommonInvoice $line = $this->lines[$i]; // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array - //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. + //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. if (! is_object($line)) $line = (object) $line; if ($result >= 0) @@ -750,35 +750,20 @@ class Facture extends CommonInvoice { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - /* - $hookmanager->initHooks(array('invoicedao')); - $parameters=array('invoiceid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - {*/ + // Actions on extra fields if (! $error) { $result=$this->insertExtraFields(); if ($result < 0) $error++; } - /*} - } - else if ($reshook < 0) $error++;*/ - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('BILL_CREATE',$user); - if ($result < 0) $error++; - // End call triggers - } - } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + } if (! $error) { @@ -1999,6 +1984,7 @@ class Facture extends CommonInvoice $this->db->begin(); dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; $sql.= ' fk_statut='.self::STATUS_CLOSED; if (! $close_code) $sql.= ', paye=1'; @@ -2006,7 +1992,6 @@ class Facture extends CommonInvoice if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; $sql.= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::set_paid", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -2378,7 +2363,7 @@ class Facture extends CommonInvoice if (!empty($conf->global->INVOICE_USE_SITUATION)) { - $final = True; + $final = true; $nboflines = count($this->lines); while (($i < $nboflines) && $final) { $final = ($this->lines[$i]->situation_percent == 100); @@ -2580,6 +2565,7 @@ class Facture extends CommonInvoice // Deprecation warning if ($label) { dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + //var_dump(debug_backtrace(false));exit; } global $mysoc, $conf, $langs; @@ -2745,14 +2731,15 @@ class Facture extends CommonInvoice // Mise a jour informations denormalisees au niveau de la facture meme $result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + if ($result > 0) { $this->db->commit(); - return $this->line->rowid; + return $this->line->id; } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); $this->db->rollback(); return -1; } @@ -4500,11 +4487,11 @@ class FactureLigne extends CommonInvoiceLine $resql=$this->db->query($sql); if ($resql) { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); + $this->rowid=$this->id; // For backward compatibility if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $this->id=$this->rowid; $result=$this->insertExtraFields(); if ($result < 0) { @@ -4576,12 +4563,12 @@ class FactureLigne extends CommonInvoiceLine } $this->db->commit(); - return $this->rowid; + return $this->id; } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); $this->db->rollback(); return -2; } @@ -4700,7 +4687,7 @@ class FactureLigne extends CommonInvoiceLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_UPDATE',$user); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index a9396e445c9..70dcfebaacb 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -171,7 +171,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - print ''; + print ''; print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
\n"; print "\n"; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 6f96e74d345..1fc7fa1fb96 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -69,7 +69,7 @@ $projectid = GETPOST('projectid','int'); $year_date_when=GETPOST('year_date_when'); $month_date_when=GETPOST('month_date_when'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -417,7 +417,8 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; - if (! $error) { + if (! $error) + { $result = $object->insertExtraFields('BILLREC_MODIFY'); if ($result < 0) { @@ -1496,7 +1497,7 @@ else } print '
'; if ($action == 'date_when' || $object->frequency > 0) { @@ -1512,7 +1513,14 @@ else print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); } //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); - if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); + if (! $object->isMaxNbGenReached()) + { + if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); + } + else + { + print img_info($langs->trans("MaxNumberOfGenerationReached")); + } print '
'; - print '
'; - print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); - if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); - print '
'; - print '
'; + print '
'; + print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); + if (! $invoicerectmp->isMaxNbGenReached()) + { + if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); + } + else + { + print img_info($langs->trans("MaxNumberOfGenerationReached")); + } + print '
'; + print '
'; if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) { - if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) + if ($invoicerectmp->isMaxNbGenReached()) + { + print $langs->trans("MaxNumberOfGenerationReached"); + } + elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { print ''; print $langs->trans("CreateBill").''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 8845d0bc8d7..b6bde6605ad 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -96,6 +96,7 @@ $search_year = GETPOST('search_year','int'); $search_day_lim = GETPOST('search_day_lim','int'); $search_month_lim = GETPOST('search_month_lim','int'); $search_year_lim = GETPOST('search_year_lim','int'); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $option = GETPOST('search_option'); if ($option == 'late') { @@ -103,7 +104,7 @@ if ($option == 'late') { } $filtre = GETPOST('filtre','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -228,6 +229,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','a $search_month_lim=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; + } if (empty($reshook)) @@ -369,6 +372,8 @@ $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -379,6 +384,8 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ + $sql.= ', '.MAIN_DB_PREFIX.'facture as f'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)"; if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; @@ -435,6 +442,8 @@ if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_va if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; if ($search_status != '' && $search_status >= 0) { if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft @@ -515,6 +524,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1,$offset); @@ -535,8 +549,8 @@ if ($resql) } $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($sall) $param.='&sall='.urlencode($sall); if ($search_day) $param.='&search_day='.urlencode($search_day); if ($search_month) $param.='&search_month='.urlencode($search_month); @@ -561,6 +575,8 @@ if ($resql) if ($show_files) $param.='&show_files='.urlencode($show_files); if ($option) $param.="&search_option=".urlencode($option); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -569,30 +585,27 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); - if ($conf->prelevement->enabled) - { - $langs->load("withdrawals"); - $arrayofmassactions['withdrawrequest']=$langs->trans("MakeWithdrawRequest"); + if ($conf->prelevement->enabled) { + $langs->load("withdrawals"); + $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); } - if ($user->rights->facture->supprimer) - { - //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - { - // mass deletion never possible on invoices on such situation + if ($user->rights->facture->supprimer) { + if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { + $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); } - else - { - $arrayofmassactions['predelete']=$langs->trans("Delete"); - } - } - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + } + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; if($user->rights->facture->creer) { - $newcardbutton=''.$langs->trans('NewBill').''; + $newcardbutton=''.$langs->trans('NewBill'); + $newcardbutton.= ''; + $newcardbutton.= ''; } $i = 0; @@ -650,6 +663,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index d85255fbf4e..2f2692055e9 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -331,7 +331,7 @@ print '
'; // Show graphs -print '"; print "\n"; - $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); + $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); $action = "tvaclient"; $object = &$coll_list; @@ -247,7 +248,7 @@ if($calc ==0 || $calc == 1){ $company_static=new Societe($db); - $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); + $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); $parameters["direction"] = 'buy'; $parameters["type"] = 'localtax'.$local; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 39d8a1dfa6a..4e825469b14 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -44,13 +45,12 @@ if (empty($year)) } $date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); -// Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -81,10 +81,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); /** * print function * - * @param DoliDB $db Database handler - * @param string $sql SQL Request - * @param string $date Date - * @return void + * @param DoliDB $db Database handler + * @param string $sql SQL Request + * @param string $date Date + * @return void */ function pt ($db, $sql, $date) { @@ -96,25 +96,78 @@ function pt ($db, $sql, $date) $i = 0; $total = 0; print '
'; +print ''; - print ''; @@ -218,47 +221,48 @@ if ($action == 'create') } -/* ************************************************************************** */ -/* */ -/* Barre d'action */ -/* */ -/* ************************************************************************** */ - +// View mode if ($id) { $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$vatpayment->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$object->id; $head[$h][1] = $langs->trans('Card'); $head[$h][2] = 'card'; $h++; - dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment'); + dol_fiche_head($head, 'card', $langs->transcountry("LT".$object->ltt, $mysoc->country_code), -1, 'payment'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + + print '
'; + print '
'; print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index ad409145478..438427fa491 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -25,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; $langs->load("compta"); $langs->load("banks"); @@ -38,11 +39,11 @@ if (empty($refund)) $refund=0; $lttype=GETPOST('localTaxType', 'int'); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -$localtax = new Localtax($db); +$object = new Localtax($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('localtaxvatcard','globalcard')); @@ -52,8 +53,8 @@ $hookmanager->initHooks(array('localtaxvatcard','globalcard')); * Actions */ -//add payment of localtax -if($_POST["cancel"] == $langs->trans("Cancel")){ +if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id) +{ header("Location: list.php?localTaxType=".$lttype); exit; } @@ -66,15 +67,15 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $localtax->accountid=GETPOST("accountid"); - $localtax->paymenttype=GETPOST("paiementtype"); - $localtax->datev=$datev; - $localtax->datep=$datep; - $localtax->amount=price2num(GETPOST("amount")); - $localtax->label=GETPOST("label"); - $localtax->ltt=$lttype; + $object->accountid=GETPOST("accountid"); + $object->paymenttype=GETPOST("paiementtype"); + $object->datev=$datev; + $object->datep=$datep; + $object->amount=price2num(GETPOST("amount")); + $object->label=GETPOST("label"); + $object->ltt=$lttype; - $ret=$localtax->addPayment($user); + $ret=$object->addPayment($user); if ($ret > 0) { $db->commit(); @@ -84,7 +85,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) else { $db->rollback(); - setEventMessages($localtax->error, $localtax->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $_GET["action"]="create"; } } @@ -92,39 +93,39 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) //delete payment of localtax if ($action == 'delete') { - $result=$localtax->fetch($id); + $result=$object->fetch($id); - if ($localtax->rappro == 0) + if ($object->rappro == 0) { $db->begin(); - $ret=$localtax->delete($user); + $ret=$object->delete($user); if ($ret > 0) { - if ($localtax->fk_bank) + if ($object->fk_bank) { $accountline=new AccountLine($db); - $result=$accountline->fetch($localtax->fk_bank); + $result=$accountline->fetch($object->fk_bank); if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$localtax->ltt); + header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$object->ltt); exit; } else { - $localtax->error=$accountline->error; + $object->error=$accountline->error; $db->rollback(); - setEventMessages($localtax->error, $localtax->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { $db->rollback(); - setEventMessages($localtax->error, $localtax->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else @@ -136,17 +137,12 @@ if ($action == 'delete') /* -* View -*/ - -llxHeader(); - -$form = new Form($db); + * View + */ if ($id) { - $vatpayment = new Localtax($db); - $result = $vatpayment->fetch($id); + $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db); @@ -154,6 +150,13 @@ if ($id) } } +$form = new Form($db); + +$title=$langs->trans("LT".$object->ltt) . " - " . $langs->trans("Card"); +$help_url=''; +llxHeader("",$title,$helpurl); + + if ($action == 'create') { @@ -173,7 +176,7 @@ if ($action == 'create') print $form->select_date($datep,"datep",'','','','add',1,1); print '
'.$langs->trans("DateValue").''; + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; print $form->select_date($datev,"datev",'','','','add',1,1); print '
'; print ""; - print ''; print ""; print ''; - print ''; - print ''; + print ''; if (! empty($conf->banque->enabled)) { - if ($vatpayment->fk_account > 0) + if ($object->fk_account > 0) { $bankline=new AccountLine($db); - $bankline->fetch($vatpayment->fk_bank); + $bankline->fetch($object->fk_bank); print ''; print ''; @@ -271,22 +275,28 @@ if ($id) // Other attributes $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'.$langs->trans("Ref").''; - print $vatpayment->ref; + print ''.$langs->trans("Ref").''; + print $object->ref; print '
'.$langs->trans("DatePayment").''; - print dol_print_date($vatpayment->datep,'day'); + print dol_print_date($object->datep,'day'); print '
'.$langs->trans("DateValue").''; - print dol_print_date($vatpayment->datev,'day'); + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print dol_print_date($object->datev,'day'); print '
'.$langs->trans("Amount").''.price($vatpayment->amount).'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('BankTransactionLine').'
'; - dol_fiche_end(); + print ''; + + dol_fiche_end(); /* - * Boutons d'actions - */ + * Action buttons + */ print "
\n"; - if ($vatpayment->rappro == 0) - print ''.$langs->trans("Delete").''; + if ($object->rappro == 0) + { + print ''.$langs->trans("Delete").''; + } else + { print ''.$langs->trans("Delete").''; + } print "
"; } diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 79a88d11c4d..a75de537724 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -29,7 +29,11 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class Localtax extends CommonObject { - var $ltt; + public $element='localtax'; //!< Id that identify managed objects + public $table_element='localtax'; //!< Name of table without prefix where object is stored + public $picto='payment'; + + var $ltt; var $tms; var $datep; var $datev; @@ -607,4 +611,29 @@ class Localtax extends CommonObject return $result; } + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->statut,$mode); + } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut + */ + function LibStatut($status,$mode=0) + { + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + + return ''; + } + } diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 3dc3e2777c2..3c8a2a9aef6 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -26,6 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -163,7 +164,7 @@ if($calc ==0 || $calc == 2) print "
".$vatcust."
'; + print ''; - print ''; - print ''; - print ''."\n"; + print ''; + print ''; + print ''; print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; while ($i < $num) { $obj = $db->fetch_object($result); - print ''; - print '\n"; - $total = $total + $obj->mm; + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - print '\n"; - print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + } + + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaied; + } + + if ($obj->mode == 'paid') + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + } + else + { + $previousmode = $obj->mode; + } $i++; } - print '"; + + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + + $amountclaimed = 0; + $amountpaid = 0; + } + + print ''; + print ''; + print ''; + print ''; + print ""; print "
'.$date.''.$langs->trans("Amount").' '.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$obj->dm."
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.price($obj->mm)." 
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total")." :".price($total)." 
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
"; $db->free($result); @@ -149,11 +202,12 @@ if($localTaxType==1) { $CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC2; } -$description = ''; +$fsearch.=' '; +$description = $fsearch; // Show report header $name = $langs->trans("ReportByMonth"); -$description = $langs->trans($LT); +$description .= $langs->trans($LT); $calcmode = $langs->trans("LTReportBuildWithOptionDefinedInModule").' '; $calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')
'; @@ -173,6 +227,7 @@ llxHeader('', $name); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); + print '
'; print '
'; @@ -207,16 +262,141 @@ $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; $mcursor=0; while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { - $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); if ($m == 13) $y++; if ($m > 12) $m -= 12; $mcursor++; - $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + // Get array with details of each line + $x_coll = tax_by_rate(($localTaxType==1?'localtax1':'localtax2'), $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $x_paye = tax_by_rate(($localTaxType==1?'localtax1':'localtax2'), $db, $y, 0, 0, 0, $modetax, 'buy', $m); + + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach(array_keys($x_coll) as $my_coll_rate) + { + $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; + $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; + $x_both[$my_coll_rate]['coll']['localtax1'] = $x_coll[$my_coll_rate]['localtax1']; + $x_both[$my_coll_rate]['coll']['localtax2'] = $x_coll[$my_coll_rate]['localtax2']; + $x_both[$my_coll_rate]['paye']['totalht'] = 0; + $x_both[$my_coll_rate]['paye']['vat'] = 0; + $x_both[$my_coll_rate]['paye']['localtax1'] = 0; + $x_both[$my_coll_rate]['paye']['localtax2'] = 0; + $x_both[$my_coll_rate]['coll']['links'] = ''; + $x_both[$my_coll_rate]['coll']['detail'] = array(); + foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) { + //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; + //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; + //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; + //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); + $x_both[$my_coll_rate]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_rate]['facid'][$id], + 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], + 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], + 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], + 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], + 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], + + 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], + 'localtax1' =>$x_coll[$my_coll_rate]['localtax1_list'][$id], + 'localtax2' =>$x_coll[$my_coll_rate]['localtax2_list'][$id], + //'link' =>$invoice_customer->getNomUrl(1,'',12) + ); + } + } + + // tva paid + foreach (array_keys($x_paye) as $my_paye_rate) { + $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; + $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; + $x_both[$my_paye_rate]['paye']['localtax1'] = $x_paye[$my_paye_rate]['localtax1']; + $x_both[$my_paye_rate]['paye']['localtax2'] = $x_paye[$my_paye_rate]['localtax2']; + if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) { + $x_both[$my_paye_rate]['coll']['totalht'] = 0; + $x_both[$my_paye_rate]['coll']['vat'] = 0; + $x_both[$my_paye_rate]['coll']['localtax1'] = 0; + $x_both[$my_paye_rate]['coll']['localtax2'] = 0; + } + $x_both[$my_paye_rate]['paye']['links'] = ''; + $x_both[$my_paye_rate]['paye']['detail'] = array(); + + foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') + { + //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; + + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + //'link' =>$expensereport->getNomUrl(1) + ); + } + else + { + //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; + //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]); + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], + 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + //'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye $action = "tva"; - $object = array(&$coll_listsell, &$coll_listbuy); + $object = array(&$x_coll, &$x_paye, &$x_both); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; @@ -226,13 +406,13 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (! is_array($coll_listbuy) && $coll_listbuy == -1) + if (! is_array($x_coll) && $coll_listbuy == -1) { $langs->load("errors"); print '
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_coll)."'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_paye)."".price($x_paye)."".price(price2num($x_coll_sum,'MT'))."".price($x_coll)."".price(price2num($x_paye_sum,'MT'))."".price($diff)."".price(price2num($diff,'MT'))." 
'.$langs->trans("SubTotal").':'.price($subtotalcoll).''.price($subtotalpaye).''.price($subtotal).''.price($subtotalpaye).''.price($subtotal).''.price($subtotalcoll).''.price($subtotal).' 
'.$langs->trans("SubTotal").':'.price(price2num($subtotalcoll,'MT')).''.price(price2num($subtotalpaye,'MT')).''.price(price2num($subtotal,'MT')).' 
'.$langs->trans("TotalToPay").':'.price($total).'
'.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).' 
'; print '
'; -print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); + /* * Payed */ -$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; +print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); + +$sql=''; + +$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datev >= '".$db->idate($date_start)."'"; -$sql.= " AND f.datev <= '".$db->idate($date_end)."'"; +$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')"; $sql.= " AND localtaxtype=".$localTaxType; $sql.= " GROUP BY dm"; -$sql.= " ORDER BY dm ASC"; -pt($db, $sql,$langs->trans("Year")." $y"); +$sql.= " UNION "; + +$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode"; +$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f"; +$sql.= " WHERE f.entity = ".$conf->entity; +$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')"; +$sql.= " AND localtaxtype=".$localTaxType; +$sql.= " GROUP BY dm"; + +$sql.= " ORDER BY dm ASC, mode ASC"; +//print $sql; + +pt($db, $sql, $langs->trans("Month")); -print '
'; print '
'; - llxFooter(); $db->close(); diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 50bc87d4d27..6668e3d61db 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -44,15 +44,17 @@ $localtax_static = new Localtax($db); $newcardbutton=''; if ($user->rights->tax->charges->creer) { - $newcardbutton=''.$langs->trans('NewVATPayment').''; + $newcardbutton=''.$langs->trans('NewVATPayment'); + $newcardbutton.= ''; + $newcardbutton.= ''; } print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code), $newcardbutton); -$sql = "SELECT rowid, amount, label, f.datev as dm"; +$sql = "SELECT rowid, amount, label, f.datev, f.datep"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f "; $sql.= " WHERE f.entity = ".$conf->entity." AND localtaxtype=".$db->escape($ltt); -$sql.= " ORDER BY dm DESC"; +$sql.= " ORDER BY datev DESC"; $result = $db->query($sql); if ($result) @@ -65,6 +67,7 @@ if ($result) print '
'.$langs->trans("Ref").'".$langs->trans("Label")."".$langs->trans("PeriodEndDate")."'.$langs->trans("DatePayment").'".$langs->trans("PayedByThisPayment")."
".$localtax_static->getNomUrl(1)."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->dm),'day')."'.dol_print_date($db->jdate($obj->datev),'day')."'.dol_print_date($db->jdate($obj->datep),'day')."".price($obj->amount)."
'.$langs->trans("Total").'".price($total)."
'.$langs->trans("Total").''.price($total).'
"; $db->free($result); diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index db316a1d6dc..8d7843b5cea 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -22,8 +22,7 @@ /** * \file htdocs/compta/tva/quadri_detail.php * \ingroup tax - * \brief Trimestrial page - detailed version - * TODO Deal with recurrent invoices as well + * \brief Local tax by rate */ global $mysoc; @@ -31,18 +30,21 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $local=GETPOST('localTaxType', 'int'); // Date range -$year=GETPOST("year"); +$year=GETPOST("year","int"); if (empty($year)) { $year_current = strftime("%Y",dol_now()); @@ -51,16 +53,15 @@ if (empty($year)) $year_current = $year; $year_start = $year; } - -$date_start = dol_mktime( 0, 0, 0, GETPOST( "date_startmonth" ), GETPOST( "date_startday" ), GETPOST( "date_startyear" ) ); -$date_end = dol_mktime( 23, 59, 59, GETPOST( "date_endmonth" ), GETPOST( "date_endday" ), GETPOST( "date_endyear" ) ); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -83,7 +84,9 @@ if (empty($min)) $min = 0; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = $conf->global->TAX_MODE; +//$modetax = $conf->global->TAX_MODE; +$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; +$modetax=$conf->global->$calc; if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; @@ -92,121 +95,123 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -/** + + +/* * View */ + +$form=new Form($db); +$company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); + $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); -foreach($listofparams as $param) +foreach ($listofparams as $param) { if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); } -llxHeader('','','','',0,0,'','',$morequerystring); - -$form=new Form($db); - -$company_static=new Societe($db); -$invoice_customer=new Facture($db); -$invoice_supplier=new FactureFournisseur($db); -$product_static=new Product($db); -$payment_static=new Paiement($db); -$paymentfourn_static=new PaiementFourn($db); +llxHeader('',$langs->trans("LocalTaxReport"),'','',0,0,'','',$morequerystring); $fsearch.=' '; $fsearch.=' '; $fsearch.=' '; $name=$langs->transcountry($local==1?"LT1ReportByQuarters":"LT2ReportByQuarters", $mysoc->country_code); -$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; - -if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services -{ - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $prevyear=$year_start; $prevquarter=$q; - if ($prevquarter > 1) $prevquarter--; - else { $prevquarter=4; $prevyear--; } - $nextyear=$year_start; $nextquarter=$q; - if ($nextquarter < 4) $nextquarter++; - else { $nextquarter=1; $nextyear++; } - - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); - else $description.='
'.$langs->trans("DepositsAreIncluded"); - $description.=$fsearch; - $builddate=dol_now(); - - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("ProductOrService"); - $amountcust=$langs->trans("AmountHT"); - $vatcust=$langs->trans("VATReceived"); - if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')'; - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("ProductOrService"); - $amountsup=$langs->trans("AmountHT"); - $vatsup=$langs->trans("VATPaid"); - if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; +$calcmode=''; +if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); +if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); +if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); +$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; +// Set period +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +$prevyear=$year_start; $prevquarter=$q; +if ($prevquarter > 1) { + $prevquarter--; +} else { + $prevquarter=4; $prevyear--; } -if ($conf->global->$calc==2) // Invoice for goods, payment for services -{ - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $prevyear=$year_start; $prevquarter=$q; - if ($prevquarter > 1) $prevquarter--; - else { $prevquarter=4; $prevyear--; } - $nextyear=$year_start; $nextquarter=$q; - if ($nextquarter < 4) $nextquarter++; - else { $nextquarter=1; $nextyear++; } - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded"); - else $description.=' '.$langs->trans("DepositsAreIncluded"); - $description.=$fsearch; - $builddate=dol_now(); - - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("ProductOrService"); - $amountcust=$langs->trans("AmountHT"); - $vatcust=$langs->trans("VATReceived"); - if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')'; - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("ProductOrService"); - $amountsup=$langs->trans("AmountHT"); - $vatsup=$langs->trans("VATPaid"); - if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; +$nextyear=$year_start; $nextquarter=$q; +if ($nextquarter < 4) { + $nextquarter++; +} else { + $nextquarter=1; $nextyear++; } +$description.=$fsearch; +$builddate=dol_now(); + +/*if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.='
'.$langs->trans("DepositsAreNotIncluded"); +} +*/ +if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); + +// Customers invoices +$elementcust=$langs->trans("CustomersInvoices"); +$productcust=$langs->trans("ProductOrService"); +$amountcust=$langs->trans("AmountHT"); +$vatcust=$langs->trans("VATReceived"); +$namecust=$langs->trans("Name"); +if ($mysoc->tva_assuj) { + $vatcust.=' ('.$langs->trans("ToPay").')'; +} + +// Suppliers invoices +$elementsup=$langs->trans("SuppliersInvoices"); +$productsup=$productcust; +$amountsup=$amountcust; +$vatsup=$langs->trans("VATPaid"); +$namesup=$namecust; +if ($mysoc->tva_assuj) { + $vatsup.=' ('.$langs->trans("ToGetBack").')'; +} + + report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); if($local==1){ $vatcust=$langs->transcountry("LocalTax1", $mysoc->country_code); $vatsup=$langs->transcountry("LocalTax1", $mysoc->country_code); + $vatexpensereport=$langs->transcountry("LocalTax1", $mysoc->country_code); }else{ $vatcust=$langs->transcountry("LocalTax2", $mysoc->country_code); $vatsup=$langs->transcountry("LocalTax2", $mysoc->country_code); + $vatexpensereport=$langs->transcountry("LocalTax2", $mysoc->country_code); } // VAT Received and paid +echo ''; $y = $year_current; $total = 0; $i=0; +$columns = 5; // Load arrays of datas -$x_coll = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); - -echo '
'; +$x_coll = tax_by_rate('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_rate('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (! is_array($x_coll) || ! is_array($x_paye)) { $langs->load("errors"); if ($x_coll == -1) - print ''; + print ''; else if ($x_coll == -2) - print ''; + print ''; else - print ''; + print ''; } else { @@ -226,6 +231,7 @@ else $invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; $invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; $invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; + $company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); $x_both[$my_coll_rate]['coll']['detail'][] = array( 'id' =>$x_coll[$my_coll_rate]['facid'][$id], 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], @@ -237,20 +243,24 @@ else 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], + 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], + 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], 'localtax1'=> $x_coll[$my_coll_rate]['localtax1_list'][$id], 'localtax2'=> $x_coll[$my_coll_rate]['localtax2_list'][$id], 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1,'',12)); + 'link' =>$invoice_customer->getNomUrl(1,'',12) + ); } } // tva paid - foreach(array_keys($x_paye) as $my_paye_rate){ + foreach(array_keys($x_paye) as $my_paye_rate) { $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; - if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){ + if(!isset($x_both[$my_paye_rate]['coll']['totalht'])) { $x_both[$my_paye_rate]['coll']['totalht'] = 0; $x_both[$my_paye_rate]['coll']['vat'] = 0; } @@ -273,35 +283,39 @@ else 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], + 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), 'localtax1'=> $x_paye[$my_paye_rate]['localtax1_list'][$id], 'localtax2'=> $x_paye[$my_paye_rate]['localtax2_list'][$id], 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1,'',12)); + 'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); } } //now we have an array (x_both) indexed by rates for coll and paye + //print table headers for this quadri - incomes first + $x_coll_sum = 0; $x_coll_ht = 0; $x_paye_sum = 0; $x_paye_ht = 0; - $span=3; - if ($modetax == 0) $span+=2; + $span=$columns; + if ($modetax != 1) $span+=2; - if($conf->global->$calc ==0 || $conf->global->$calc == 2){ + //if ($modetax == 0 || $modetax == 2) + //{ // Customers invoices print ''; print ''; print ''; - if ($modetax == 0) - { - print ''; - print ''; - } + if ($modetax != 2) print ''; + if ($modetax != 1) print ''; print ''; print ''; print ''; @@ -317,8 +331,6 @@ else if (is_array($x_both[$rate]['coll']['detail'])) { // VAT Rate - $var=true; - if($rate!=0){ print ""; print ''; @@ -326,116 +338,116 @@ else } foreach($x_both[$rate]['coll']['detail'] as $index => $fields) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)){ - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; - - - print ''; - - // Ref - print ''; - - // Description - print ''; - // Total HT - if ($modetax == 0) - { - print ''; + + // Ref + print ''; + + // Description + print ''; - } - // Payment - $ratiopaymentinvoice=1; - if ($modetax == 0) - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + // Total HT + if ($modetax != 2) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + print ''; + } + + // Total collected print ''; + + // Localtax + print ''; + print ''; + + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } - - // Total collected - print ''; - - // Localtax - print ''; - print ''; - - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; } } - } - if($rate!=0){ - // Total customers for this vat rate - print ''; - print ''; - print ''; - if ($modetax == 0) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; - } + + // Total customers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''; } if (count($x_coll) == 0) // Show a total ine if nothing shown @@ -457,15 +469,15 @@ else print ''; print '
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("Error").'
'.$langs->trans("Error").'
'.$elementcust.''.$productcust.''.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("BI").''.$vatcust.'
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$fields['link'].''; - if ($fields['pid']) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); - } - else - { - if ($type) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) - { - if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); - elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); - else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; - // Show range - print_date_range($fields['ddate_start'],$fields['ddate_end']); - } - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) + print '
'.$fields['link'].''; + if ($fields['pid']) { - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + } + else + { + if ($type) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) + { + if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); } print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + } + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $payment_static->id=$fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NotUsedForGoods"); + } + else { + print price($fields['payment_amount']); + if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $payment_static->id=$fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NotUsedForGoods"); - } - else { - print price($fields['payment_amount']); - if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; - } + $temp_ht=$fields['totalht']; + if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT')); print ''; + $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; + print price(price2num($temp_vat,'MT')); + //print price($fields['vat']); + print '
'; - $temp_ht=$fields['totalht']; - if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht,'MT')); - print ''; - $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; - print price(price2num($temp_vat,'MT')); - //print price($fields['vat']); - print '
'.$langs->trans("Total").':  '.price(price2num($subtot_coll_total_ht,'MT')).''.price(price2num($subtot_coll_vat,'MT')).'
'.$langs->trans("Total").':  '.price(price2num($subtot_coll_total_ht,'MT')).''.price(price2num($subtot_coll_vat,'MT')).'
 
'; $diff=$x_coll_sum; - } + //} - if($conf->global->$calc ==0 || $conf->global->$calc == 1){ + //if($conf->global->$calc ==0 || $conf->global->$calc == 1){ echo ''; //print table headers for this quadri - expenses now print ''; print ''; print ''; - if ($modetax == 0) + if ($modetax != 1) { print ''; print ''; @@ -479,9 +491,8 @@ else $subtot_paye_total_ht = 0; $subtot_paye_vat = 0; - if(is_array($x_both[$rate]['paye']['detail'])) + if (is_array($x_both[$rate]['paye']['detail'])) { - $var=true; if($rate!=0){ print ""; print ''; @@ -489,149 +500,144 @@ else } foreach($x_both[$rate]['paye']['detail'] as $index=>$fields) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)){ - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; - - - print ''; - - // Ref - print ''; - - // Description - print ''; - // Total HT - if ($modetax == 0) - { - print ''; + + // Ref + print ''; + + // Description + print ''; - } - - // Payment - $ratiopaymentinvoice=1; - if ($modetax == 0) - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - print ''; + + // Total HT + if ($modetax != 2) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; + } + + // VAT paid + print ''; + + // Localtax + print ''; + print ''; + + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; } - - // VAT paid - print ''; - - // Localtax - print ''; - print ''; - - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; } } - } - if($rate!=0){ - // Total suppliers for this vat rate - print ''; - print ''; - print ''; - if ($modetax == 0) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; - } + + // Total suppliers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''; } - if (count($x_paye) == 0) // Show a total ine if nothing shown - { - print ''; - print ''; - print ''; - if ($modetax == 0) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; } print '
'.$elementsup.''.$productsup.''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$fields['link'].''; - if ($fields['pid']) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); - } - else - { - if ($type) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; - // Show range - print_date_range($fields['ddate_start'],$fields['ddate_end']); - } - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) + print '
'.$fields['link'].''; + if ($fields['pid']) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id=$fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NotUsedForGoods"); + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); } else { - print price($fields['payment_amount']); - if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + if ($type) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); } print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id=$fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NA"); + } + else + { + print price(price2num($fields['payment_amount'],'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + } + print ''; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT'),1); + print ''; + $temp_vat=($local==1?$fields['localtax1']:$fields['localtax2'])*$ratiopaymentinvoice;; + print price(price2num($temp_vat,'MT'),1); + //print price($fields['vat']); + print '
'; - $temp_ht=$fields['totalht']; - if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht,'MT')); - print ''; - $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; - print price(price2num($temp_vat,'MT')); - //print price($fields['vat']); - print '
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht,'MT')).''.price(price2num($subtot_paye_vat,'MT')).'
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht,'MT')).''.price(price2num($subtot_paye_vat,'MT')).'
 '.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
 '.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
'; - $diff=$x_paye_sum; - } + //} - if($conf->global->$calc ==0){$diff=$x_coll_sum - $x_paye_sum;} - echo ''; - // Total to pay - print '

'; - print '
'; - //$diff = $local==1?$x_coll_sum:$x_paye_sum; - print ''; - print ''; - print '\n"; - print "\n"; - - echo '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.price(price2num($diff,'MT'))."
'; + // Total to pay + print '

'; + print ''; + $diff = $x_coll_sum - $x_paye_sum; + print ''; + print ''; + print '\n"; + print "\n"; $i++; } +print '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.price(price2num($diff,'MT'))."
'; llxFooter(); $db->close(); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 77d9cd0a93d..8b6956a3942 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -819,7 +819,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (! GETPOST('action','aZ09')) { if ($page == -1) $page = 0 ; - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; if (! $sortorder) $sortorder='DESC'; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 8a165ebe811..8489e82ae33 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -54,7 +54,7 @@ $page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="b.dateo,b.rowid"; if (empty($page) || $page == -1) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; $dir=$conf->bank->dir_output.'/checkdeposits/'; diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 9ddbd0b5cf6..74fe9ea9455 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -94,7 +94,7 @@ $max=10; $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,"; $sql.= " bc.statut, bc.nbcheque,"; -$sql.= " ba.ref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.accountancy_journal,"; +$sql.= " ba.ref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,"; $sql.= " aj.code"; $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal"; @@ -130,6 +130,7 @@ if ($resql) $accountstatic->currency_code=$objp->currency_code; $accountstatic->account_number=$objp->account_number; $accountstatic->accountancy_journal=$objp->code; + $accountstatic->fk_accountancy_journal=$objp->fk_accountancy_journal; print '
'; - print ''; + print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($year?$year:-1,'year',1, 20, 5); print ''; - print ''; + print ''; print ''; $form->select_types_paiements($search_paymenttype,'search_paymenttype','',2,1,1); print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); @@ -278,7 +284,7 @@ if ($resql) print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","",$param,'align="right"',$sortfield,$sortorder); //print_liste_field_titre("Invoices"),"","","",$param,'align="left"',$sortfield,$sortorder); - $parameters=array(); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 7e16b525233..031a0ff354a 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -38,7 +38,7 @@ if ($user->societe_id > 0) } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); @@ -85,6 +85,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); @@ -94,7 +99,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=True; print_barre_liste($langs->trans("ReceivedCustomersPaymentsToValid"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num); diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index ea9bc5af42a..8e76a219c3d 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -245,13 +245,10 @@ if ($resql) if ($num > 0) { - $var=True; - while ($i < $num) { $objp = $db->fetch_object($resql); - print '
'; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 31dfbd5b610..02c6e7b08f0 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -37,7 +37,7 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); @@ -87,6 +87,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); @@ -101,7 +106,13 @@ if ($result) $selectedfields=''; - $newcardbutton = ''.$langs->trans('NewStandingOrder').''; + $newcardbutton=''; + if ($user->rights->prelevement->bons->creer) + { + $newcardbutton = ''.$langs->trans('NewStandingOrder'); + $newcardbutton.= ''; + $newcardbutton.= ''; + } // Lines of title fields print ''; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index ed0977ebabf..a6d739f1f0c 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -322,6 +322,11 @@ if ($id > 0 || $ref) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 57cf518db16..245b25be3b6 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -99,14 +99,6 @@ class BonPrelevement extends CommonObject $this->methodes_trans[0] = "Internet"; $this->_fetched = 0; - - - $langs->load("withdrawals"); - $this->labelstatut[0]=$langs->trans("StatusWaiting"); - $this->labelstatut[1]=$langs->trans("StatusTrans"); - $this->labelstatut[2]=$langs->trans("StatusCredited"); - - return 1; } /** @@ -1310,14 +1302,14 @@ class BonPrelevement extends CommonObject */ // SEPA Initialisation $CrLf = "\n"; - + $now = dol_now(); - + $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); $date_actu = $now; if (!empty($executiondate)) $date_actu=$executiondate; - + $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); $fileDebiteurSection = ''; @@ -1890,48 +1882,52 @@ class BonPrelevement extends CommonObject */ function LibStatut($statut,$mode=0) { - global $langs; + if (empty($this->labelstatut)) + { + global $langs; + $langs->load("withdrawals"); + $this->labelstatut[0]=$langs->trans("StatusWaiting"); + $this->labelstatut[1]=$langs->trans("StatusTrans"); + $this->labelstatut[2]=$langs->trans("StatusCredited"); + } if ($mode == 0) { - return $langs->trans($this->labelstatut[$statut]); + return $this->labelstatut[$statut]; } - if ($mode == 1) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + return $this->labelstatut[$statut]; } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut]; + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; } if ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6'); } if ($mode == 4) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut]; + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; } if ($mode == 5) { - if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } if ($mode == 6) { - if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index c94a786917f..c1d87a4c1b5 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -298,8 +298,6 @@ if ($result) print ''.$langs->trans("Date").''.$langs->trans("Amount").'
'; print ''; @@ -117,7 +116,6 @@ if ($resql) print ''; if ($num) { - $var = True; while ($i < $num && $i < 20) { $obj = $db->fetch_object($resql); @@ -184,7 +182,6 @@ if ($result) { $num = $db->num_rows($result); $i = 0; - $var=True; print"\n\n"; print '
'.$langs->trans("Statistics").'
'.$langs->trans("InvoiceWaitingWithdraw").' ('.$num.')
'; diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index ff6fe4e109c..10634670f5f 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -40,7 +40,7 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); @@ -111,6 +111,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index e8b00fc869b..c4131dc365b 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -90,7 +90,7 @@ $tmps=dol_getdate($date_start); $year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; -$nbofyear = ($year_end - $start_year) + 1; +$nbofyear = ($year_end - $year_start) + 1; //var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 71cfe997fe0..3a3f34b85b4 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -388,7 +388,11 @@ class PaymentSalary extends CommonObject -abs($this->amount), $this->num_payment, '', - $user + $user, + '', + '', + '', + $this->datev ); // Update fk_bank into llx_paiement. diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php index 03cef9c07e8..00bc6185ffd 100644 --- a/htdocs/compta/salaries/document.php +++ b/htdocs/compta/salaries/document.php @@ -118,7 +118,7 @@ if ($object->id) print '
'; print ''; - print ''; + print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
'; print ''; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index f9b9adf616c..a88ec8683a9 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -28,17 +28,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -$langs->load("compta"); -$langs->load("salaries"); -$langs->load("bills"); -$langs->load("hrm"); +$langs->loadLangs(array("compta","salaries","bills","hrm")); // Security check $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); $search_label = GETPOST('search_label','alpha'); @@ -52,8 +49,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="s.datep"; -if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="s.datep,s.rowid"; +if (! $sortorder) $sortorder="DESC,DESC"; $optioncss = GETPOST('optioncss','alpha'); $filtre=$_GET["filtre"]; @@ -150,9 +147,15 @@ if ($result) if ($typeid) $param.='&typeid='.$typeid; if ($optioncss != '') $param.='&optioncss='.$optioncss; - $newcardbutton=''.$langs->trans('NewSalaryPayment').''; + $newcardbutton=''; + if ($user->rights->salaries->payment->write) + { + $newcardbutton=''.$langs->trans('NewSalaryPayment'); + $newcardbutton.= ''; + $newcardbutton.= ''; + } - print ''; + print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -202,7 +205,7 @@ if ($result) print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Employee",$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep,s.rowid","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("PaymentMode",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); diff --git a/htdocs/compta/salaries/stats/index.php b/htdocs/compta/salaries/stats/index.php index 0ba0c29ea6f..dabe988909f 100644 --- a/htdocs/compta/salaries/stats/index.php +++ b/htdocs/compta/salaries/stats/index.php @@ -59,6 +59,7 @@ $year = GETPOST('year')>0?GETPOST('year'):$nowyear; $startyear=$year-1; $endyear=$year; + /* * View */ @@ -231,11 +232,11 @@ print ''; print '

'; print ''; -print ''; +print ''; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print ''; $oldyear=0; @@ -269,7 +270,7 @@ print '
'; // Show graphs -print '
'.$langs->trans("Year").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
"; // Period end date - print ""; + print ""; print "\n"; - // Array Data - $var=true; - if (count($name)) { foreach($name as $key=>$value) { print ''; // Product + print "\n"; + print $linkname; + print "\n"; // Quantity print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; $db->free($result); diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 1fa48738e66..1d386df6c6f 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -99,6 +99,12 @@ else { // TODO We define q } +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; $commonparams=array(); $commonparams['modecompta']=$modecompta; @@ -139,9 +145,7 @@ $form=new Form($db); if ($modecompta=="CREANCES-DETTES") { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); $calcmode=$langs->trans("CalcModeDebt"); - $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink="".img_previous()."".img_next().""; + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -150,14 +154,16 @@ if ($modecompta=="CREANCES-DETTES") { } else { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); $calcmode=$langs->trans("CalcModeEngagement"); - $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink="".img_previous()."".img_next().""; + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().''.img_next().''; +else $periodlink = ''; + $moreparam=array(); if (! empty($modecompta)) $moreparam['modecompta']=$modecompta; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index b7b37d0837c..5c1e8cc4db7 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -90,8 +90,8 @@ $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GE // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q")?GETPOST("q"):0; - if ($q==0) + $q=GETPOST("q","int")?GETPOST("q","int"):0; + if (empty($q)) { // We define date_start and date_end $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); @@ -120,6 +120,13 @@ else // TODO We define q } +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; + $commonparams=array(); $commonparams['modecompta']=$modecompta; $commonparams['sortorder'] = $sortorder; @@ -167,9 +174,7 @@ if ($modecompta=="CREANCES-DETTES") { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); $calcmode=$langs->trans("CalcModeDebt"); - $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink=''.img_previous().''.img_next().''; + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -178,14 +183,15 @@ if ($modecompta=="CREANCES-DETTES") } else { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); $calcmode=$langs->trans("CalcModeEngagement"); - $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink=''.img_previous().''.img_next().''; + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().''.img_next().''; +else $periodlink = ''; report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams,$calcmode); diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 598de2ba490..bb5cb25e30d 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -71,7 +71,6 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $month_end=$month_start-1; if ($month_end < 1) $month_end=12; - else $year_end++; } else $month_end=$month_start; $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); @@ -85,6 +84,12 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $userid=GETPOST('userid','int'); $socid = GETPOST('socid','int'); +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; + // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') $modecompta = $conf->global->ACCOUNTING_MODE; if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING'; @@ -114,7 +119,7 @@ if ($modecompta=="CREANCES-DETTES") $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()."".img_next()."":""); + $periodlink=($year_start?"".img_previous()."".img_next()."":""); $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -128,7 +133,7 @@ else if ($modecompta=="RECETTES-DEPENSES") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()."".img_next()."":""); + $periodlink=($year_start?"".img_previous()."".img_next()."":""); $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); @@ -141,7 +146,7 @@ else if ($modecompta=="BOOKKEEPING") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()."".img_next()."":""); + $periodlink=($year_start?"".img_previous()."".img_next()."":""); $description=$langs->trans("RulesCATotalSaleJournal"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); @@ -493,7 +498,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) } if (! $total[$annee-1] && $total[$annee]) { - print ''; + print ''; } if (! $total[$annee-1] && ! $total[$annee]) { @@ -551,7 +556,6 @@ print ''; if ($num) { - $var = True; $total_ttc_Rac = $totalam_Rac = $total_Rac = 0; while ($i < $num) { @@ -561,7 +565,7 @@ print ''; $i++; } - print ""; + print ""; } $db->free($resql); } @@ -602,7 +606,6 @@ print ''; if ($num) { - $var = True; $total_pr = 0; while ($i < $num) { @@ -611,7 +614,7 @@ print ''; $i++; } - print ""; + print ""; } $db->free($resql); } @@ -619,7 +622,7 @@ print ''; { dol_print_error($db); } - print ""; + print ""; } print "
'; +print ''; print ''; print ''; print ''; + // Date due + print ''; + print ''; + print ''; + print "\n"; + // Amount print ''; print ''; } - // Date due - print ''; - print ''; - print ''; - print "\n"; - print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index cdcabc5617b..d7bdd9c77e6 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -327,13 +327,23 @@ if ($action == 'create') // Date end period print '
'; - print $langs->trans("PeriodEndDate"); + print $form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")); print ''; print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1); print '
'; + print $langs->trans("DateDue"); + print ''; + print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1); + print '
'; @@ -370,16 +380,6 @@ if ($action == 'create') print '
'; - print $langs->trans("DateDue"); - print ''; - print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1); - print '
'; dol_fiche_end(); @@ -496,7 +496,7 @@ if ($id > 0) print "
".$langs->trans("PeriodEndDate")."
".$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).""; if ($action == 'edit') { diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index fa4127c3af6..f16d18c8143 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -192,7 +192,7 @@ class ChargeSociales extends CommonObject $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); //dol_syslog("ChargesSociales::create this->id=".$this->id); - $result=$this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE',$user); + $result=$this->call_trigger('SOCIALCONTRIBUTION_CREATE',$user); if ($result < 0) $error++; if(empty($error)) { diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 4cd0dfd2b59..ba9c671f755 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -164,6 +164,9 @@ class PaymentSocialContribution extends CommonObject } + $result = $this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE',$user); + if($result < 0) $error++; + if ($totalamount != 0 && ! $error) { $this->amount=$totalamount; diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 0bf1e7f6f13..0e2bcc5c986 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -150,7 +150,7 @@ if ($object->id) print ''; print ''; - print ''; + print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
'; print ''; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 3850ddfe5c5..d38ae348c90 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -42,7 +42,7 @@ $search_label = GETPOST('search_label','alpha'); $search_amount = GETPOST('search_amount','alpha'); $search_status = GETPOST('search_status','int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -149,7 +149,9 @@ if ($resql) $newcardbutton=''; if($user->rights->tax->charges->creer) { - $newcardbutton=''.$langs->trans('MenuNewSocialContribution').''; + $newcardbutton=''.$langs->trans('MenuNewSocialContribution'); + $newcardbutton.= ''; + $newcardbutton.= ''; } print '
'; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 879e9b69ee7..6abb6013095 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -45,7 +45,7 @@ $year=GETPOST("year",'int'); $filtre=GETPOST("filtre",'alpha'); if (! $year && $mode != 'sconly') { $year=date("Y", time()); } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php new file mode 100644 index 00000000000..b2186633413 --- /dev/null +++ b/htdocs/compta/stats/byratecountry.php @@ -0,0 +1,361 @@ + + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2006-2007, 2015 Yannick Warnier + * Copyright (C) 2014 Ferran Marcet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/tva/quadri_detail.php + * \ingroup tax + * \brief VAT by rate + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; + +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy")); + +$modecompta = GETPOST('modecompta','alpha'); + +// Date range +$year=GETPOST("year",'int'); +$month=GETPOST("month",'int'); +if (empty($year)) +{ + $year_current = strftime("%Y",dol_now()); + $month_current = strftime("%m",dol_now()); + $year_start = $year_current; +} else { + $year_current = $year; + $month_current = strftime("%m",dol_now()); + $year_start = $year; +} +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q=GETPOST("q","int"); + if (empty($q)) + { + // We define date_start and date_end + $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $year_end=$year_start; + $month_end=$month_start; + if (! GETPOST("month")) // If month not forced + { + if (! GETPOST('year') && $month_start > $month_current) + { + $year_start--; + $year_end--; + } + $month_end=$month_start-1; + if ($month_end < 1) $month_end=12; + else $year_end++; + } + $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); + } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } +} + +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; + +$tmp_date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; +if ($tmp_date_end < $date_end || $date_end < $date_start) $date_end = $tmp_date_end; + +$min = price2num(GETPOST("min","alpha")); +if (empty($min)) $min = 0; + +// Define modetax (0 or 1) +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products +$modetax = $conf->global->TAX_MODE; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'tax', '', '', 'charges'); + + + +/* + * View + */ + +$form=new Form($db); +$company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); + +$morequerystring=''; +$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); +foreach ($listofparams as $param) +{ + if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); +} + +llxHeader('',$langs->trans("TurnoverReport"),'','',0,0,'','',$morequerystring); + + +//print load_fiche_titre($langs->trans("VAT"),""); + +//$fsearch.='
'; +$fsearch.=' '; +$fsearch.=' '; +//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; +//$fsearch.=' '; + + +// Show report header +$name=$langs->trans("xxx"); +$calcmode=''; +if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); +if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); +if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); +$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; +// Set period +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +$prevyear=$year_start; $prevquarter=$q; +if ($prevquarter > 1) { + $prevquarter--; +} else { + $prevquarter=4; $prevyear--; +} +$nextyear=$year_start; $nextquarter=$q; +if ($nextquarter < 4) { + $nextquarter++; +} else { + $nextquarter=1; $nextyear++; +} +$description.=$fsearch; +$builddate=dol_now(); + +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.='
'.$langs->trans("DepositsAreNotIncluded"); +} +if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); + +// Customers invoices +$elementcust=$langs->trans("CustomersInvoices"); +$productcust=$langs->trans("ProductOrService"); +$amountcust=$langs->trans("AmountHT"); + +// Suppliers invoices +$elementsup=$langs->trans("SuppliersInvoices"); +$productsup=$productcust; +$amountsup=$amountcust; +$namesup=$namecust; + + + + +// Show report header +$name=$langs->trans("SalesTurnover").', '.$langs->trans("ByVatRate"); + +if ($modecompta=="CREANCES-DETTES") { + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + + $description=$langs->trans("RulesCADue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.= $langs->trans("DepositsAreNotIncluded"); + } else { + $description.= $langs->trans("DepositsAreIncluded"); + } + + $builddate=dol_now(); +} else { + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + + $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); + + $builddate=dol_now(); +} +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +else $periodlink = ''; + +$description.=' '; + +report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); + +if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') +{ + print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); +} + + +if ($modecompta == 'CREANCES-DETTES') +{ + +print ''; +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT fd.tva_tx AS vatrate,"; +$sql .= " fd.product_type AS product_type,"; +$sql .= " cc.label AS country,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " SUM(fd.total_ht) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; +$sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; +$sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; +$sql.= " AND f.fk_statut in (1,2)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND f.type IN (0,1,2,5)"; +} else { + $sql.= " AND f.type IN (0,1,2,3,5)"; +} +$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; +$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; + +dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + print ''; + if ($row[1] == 0) { + print ''; + } else { + print ''; + } + print ''; + + for($i = 3; $i <= 14; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql2 = "SELECT ffd.tva_tx AS vatrate,"; +$sql2 .= " ffd.product_type AS product_type,"; +$sql2 .= " cc.label AS country,"; +for($i = 1; $i <= 12; $i ++) { + $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql2 .= " SUM(ffd.total_ht) as total"; +$sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; +$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; +$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; +$sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; +$sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; +$sql.= " AND ff.fk_statut in (1,2)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND ff.type IN (0,1,2,5)"; +} else { + $sql.= " AND ff.type IN (0,1,2,3,5)"; +} +$sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; +$sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; + +//print $sql2; +dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); +$resql2 = $db->query($sql2); +if ($resql2) { + $num = $db->num_rows($resql2); + + while ( $row = $db->fetch_row($resql2)) { + print ''; + if ($row[1] == 0) { + print ''; + } else { + print ''; + } + print ''; + for($i = 3; $i <= 14; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql2); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' .$row[2] . '' . price($row[$i]) . '' . price($row[15]) . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' . $row[2] . '' . price($row[$i]) . '' . price($row[15]) . '
\n"; + +} else { + // $modecompta != 'CREANCES-DETTES' + // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an + // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ? + // Because there is no way to know this, this report is not relevant. + print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant") . '
'; +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index f367f8ee436..e4d1f16cb8b 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -29,9 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -$langs->load("products"); -$langs->load("categories"); -$langs->load("errors"); +$langs->loadLangs(array("products","categories","errors",'accountancy')); // Security pack (data & check) $socid = GETPOST('socid','int'); @@ -78,13 +76,13 @@ if (empty($year)) $month_current = strftime("%m",dol_now()); $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q")?GETPOST("q"):0; - if ($q==0) + $q=GETPOST("q","int"); + if (empty($q)) { // We define date_start and date_end $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); @@ -103,14 +101,24 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } else { // TODO We define q } +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; + $commonparams=array(); $commonparams['modecompta']=$modecompta; $commonparams['sortorder'] = $sortorder; @@ -154,9 +162,7 @@ $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByProductsAndServices") if ($modecompta=="CREANCES-DETTES") { $calcmode=$langs->trans("CalcModeDebt"); - $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -168,21 +174,22 @@ if ($modecompta=="CREANCES-DETTES") { $builddate=dol_now(); } else { $calcmode=$langs->trans("CalcModeEngagement"); - $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); } +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +else $periodlink = ''; report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams,$calcmode); if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { - print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); + print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); } @@ -199,17 +206,17 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; $sql.= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,"; $sql.= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l, ".MAIN_DB_PREFIX."product as p"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; if ($selected_cat === -2) // Without any category { - $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; } else if ($selected_cat) // Into a specific category { $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; } - $sql.= " WHERE l.fk_product = p.rowid"; - $sql.= " AND l.fk_facture = f.rowid"; + $sql.= " WHERE l.fk_facture = f.rowid"; $sql.= " AND f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (0,1,2,5)"; @@ -357,23 +364,21 @@ if ($modecompta == 'CREANCES-DETTES') ); print "
"; $fullname=$name[$key]; - if ($key >= 0) { + if ($key > 0) { $linkname=''.img_object($langs->trans("ShowProduct"),$type[$key]==0?'product':'service').' '.$fullname.''; } else { $linkname=$langs->trans("PaymentsNotLinkedToProduct"); } - - print "".$linkname."'; @@ -417,11 +422,11 @@ if ($modecompta == 'CREANCES-DETTES') // Total print '
'.$langs->trans("Total").''.price($qtytotal).' '.$qtytotal.'100%'.price($catotal_ht).''.price($catotal).' 100%
+zzzz'.$total[$annee-1].$langs->trans('Inf').'%+'.$langs->trans('Inf').'%
Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es
Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es
Signe et non facture:".price($total_pr)."<-- bug ici, ca devrait exclure le deja facture
Signe et non facture:".price($total_pr)."<-- bug ici, ca devrait exclure le deja facture
Total CA previsionnel : ".price($total_CA)."<-- bug ici car bug sur les 2 precedents
Total CA previsionnel : ".price($total_CA)."<-- bug ici car bug sur les 2 precedents
"; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 2411858a924..240a4624d44 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -59,10 +59,18 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id) exit; } +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('lib','alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + if ($action == 'setdatev' && $user->rights->tax->charges->creer) { $object->fetch($id); - $object->datev=dol_mktime(12,0,0,$_POST['datevmonth'],$_POST['datevday'],$_POST['datevyear']); + $object->datev=dol_mktime(12,0,0,GETPOST('datevmonth','int'),GETPOST('datevday','int'),GETPOST('datevyear','int')); $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); @@ -172,7 +180,8 @@ if ($action == 'delete') } else { - setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); + $mesg='Error try do delete a line linked to a conciliated bank transaction'; + setEventMessages($mesg, null, 'errors'); } } @@ -180,11 +189,13 @@ if ($action == 'delete') /* * View */ + +$form = new Form($db); + $title=$langs->trans("VAT") . " - " . $langs->trans("Card"); $help_url=''; llxHeader("",$title,$helpurl); -$form = new Form($db); if ($id) { @@ -248,7 +259,7 @@ if ($action == 'create') print $form->select_date($datep,"datep",'','','','add',1,1); print '
'.$langs->trans("DateValue").''; + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; print $form->select_date($datev,"datev",'','','','add',1,1); print '
'.$langs->trans("Label").'
'.$langs->trans("Amount").'
'.$langs->trans("Amount").'
'; // Label - print ''; + //print ''; print ""; - print ''; - print ''; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 80242103c51..af330910cdf 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class Tva extends CommonObject { - //public $element='tva'; //!< Id that identify managed objects - //public $table_element='tva'; //!< Name of table without prefix where object is stored + public $element='tva'; //!< Id that identify managed objects + public $table_element='tva'; //!< Name of table without prefix where object is stored public $picto='payment'; var $tms; @@ -48,8 +48,6 @@ class Tva extends CommonObject var $fk_user_creat; var $fk_user_modif; - - /** * Constructor * @@ -58,8 +56,6 @@ class Tva extends CommonObject function __construct($db) { $this->db = $db; - $this->element = 'tva'; - $this->table_element = 'tva'; } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 71376a566e1..734f4880e48 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -30,7 +30,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -84,10 +91,6 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') -$modecompta = $conf->global->ACCOUNTING_MODE; -if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); - /* @@ -96,13 +99,19 @@ if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); $form=new Form($db); $company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); -foreach($listofparams as $param) { - if (GETPOST($param)!='') { - $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); - } +foreach ($listofparams as $param) +{ + if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); } $special_report = false; @@ -118,15 +127,28 @@ $fsearch.=' '; $fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; $fsearch.=' '; -$description=''; - // Show report header -$name=$langs->trans("VATReportByCustomers"); +$name=$langs->trans("VATReportByThirdParties"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; +// Set period +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +$prevyear=$year_start; $prevquarter=$q; +if ($prevquarter > 1) { + $prevquarter--; +} else { + $prevquarter=4; $prevyear--; +} +$nextyear=$year_start; $nextquarter=$q; +if ($nextquarter < 4) { + $nextquarter++; +} else { + $nextquarter=1; $nextyear++; +} +$builddate=dol_now(); if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); @@ -137,23 +159,24 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); -$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"".img_previous()."".img_next()."":""); $description.=$fsearch; -$description.='
' - . ' ' - . $langs->trans('SimpleReport') - . '' - . '
' - . ' ' - . $langs->trans('AddExtraReport') - . '' - . '
'; -$builddate=dol_now(); -//$exportlink=$langs->trans("NotYetAvailable"); +if (! empty($conf->global->TAX_REPORT_EXTRA_REPORT)) +{ + $description.='
' + . ' ' + . $langs->trans('SimpleReport') + . '' + . '
' + . ' ' + . $langs->trans('AddExtraReport') + . '' + . '
'; +} $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("Description"); +$namerate=$langs->trans("VATRate"); $amountcust=$langs->trans("AmountHT"); if ($mysoc->tva_assuj) { $vatcust.=' ('.$langs->trans("ToPay").')'; @@ -172,152 +195,547 @@ $vatsup=$langs->trans("VATPaid"); // VAT Received -//print "
"; -//print load_fiche_titre($vatcust); - print "
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("DatePayment").''; + print ''.$langs->trans("DatePayment").''; print dol_print_date($object->datep,'day'); print '
'; - print $form->editfieldkey("DateValue", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); + print $form->editfieldkey($form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")), 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); print ''; - print $form->editfieldval("DateValue", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); + print $form->editfieldval("PeriodEndDate", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); //print dol_print_date($object->datev,'day'); print '
"; -print ""; -print '"; -print '"; -print ""; -print ""; -print ""; -print "\n"; -$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); +$y = $year_current; +$total = 0; +$i=0; +$columns = 5; -$action = "tvaclient"; -$object = &$coll_list; -$parameters["mode"] = $modetax; -$parameters["start"] = $date_start; -$parameters["end"] = $date_end; -$parameters["direction"] = 'sell'; -$parameters["type"] = 'vat'; +// Load arrays of datas +$x_coll = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'buy'); -// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('externalbalance')); -$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - -if (is_array($coll_list)) { - $var=true; - $total = 0; $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - - $intra = str_replace($find,$replace,$coll->tva_intra); - if(empty($intra)) { - if($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ''; - print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; - $company_static->client=1; - print ''; - $find = array(' ','.'); - $replace = array('',''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; - } - } - $x_coll_sum = $total; - - print ''; - print ''; - print ''; - print ''; -} else { +if (! is_array($x_coll) || ! is_array($x_paye)) +{ $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else if ($coll_list == -2) { - print ''; + if ($x_coll == -1) { + print ''; + } else if ($x_coll == -2) { + print ''; } else { - print ''; + print ''; } -} - -//print '
'.$langs->trans("Num")."'.$langs->trans("Customer")."".$langs->trans("VATIntra")."".$langs->trans("AmountHTVATRealReceived")."".$vatcust."
'.$i."'.$company_static->getNomUrl(1,'customer').''.$intra."".price($coll->amount)."".price($coll->tva)."
'.$langs->trans("Total").':'.price($totalamount).''.price($total).'
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
' . $langs->trans("Error") . '
'; - - -// VAT Paid - -//print "
"; -//print load_fiche_titre($vatsup); - -//print ""; -print ""; -print '"; -print '"; -print ""; -print ""; -print ""; -print "\n"; - -$company_static=new Societe($db); - -$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); - -$parameters["direction"] = 'buy'; -$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if (is_array($coll_list)) { - $var=true; - $total = 0; $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - - $intra = str_replace($find,$replace,$coll->tva_intra); - if (empty($intra)) { - if ($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ''; - print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; - $company_static->fournisseur=1; - print ''; - $find = array(' ','.'); - $replace = array('',''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; +} else { + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach(array_keys($x_coll) as $my_coll_thirdpartyid) + { + $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; + $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; + $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; + $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; + $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; + $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); + foreach($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { + $invoice_customer->id=$x_coll[$my_coll_thirdpartyid]['facid'][$id]; + $invoice_customer->ref=$x_coll[$my_coll_thirdpartyid]['facnum'][$id]; + $invoice_customer->type=$x_coll[$my_coll_thirdpartyid]['type'][$id]; + $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); + $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], + 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], + 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], + 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], + 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], + 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_customer->getNomUrl(1,'',12) + ); } } - $x_paye_sum = $total; + // tva paid + foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { + $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; + $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; + if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { + $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; + $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; + } + $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; + $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); - print ''; - print ''; - print ''; + foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') + { + $expensereport->id=$x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $expensereport->ref=$x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $expensereport->type=$x_paye[$my_paye_thirdpartyid]['type'][$id]; + + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$expensereport->getNomUrl(1) + ); + } + else + { + $invoice_supplier->id=$x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $invoice_supplier->ref=$x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $invoice_supplier->type=$x_paye[$my_paye_thirdpartyid]['type'][$id]; + $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], + 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye + + + //print table headers for this quadri - incomes first + + $x_coll_sum = 0; + $x_coll_ht = 0; + $x_paye_sum = 0; + $x_paye_ht = 0; + + $span=$columns; + if ($modetax != 1) $span+=2; + + //print ''; + + // Customers invoices + print ''; + print ''; + print ''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''; + else print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; print ''; + $action = "tvadetail"; + $parameters["mode"] = $modetax; + $parameters["start"] = $date_start; + $parameters["end"] = $date_end; + $parameters["type"] = 'vat'; + + $object = array(&$x_coll, &$x_paye, &$x_both); + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + foreach (array_keys($x_coll) as $thirdparty_id) { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; + + if (is_array($x_both[$thirdparty_id]['coll']['detail'])) + { + + // VAT Rate + print ""; + print ''; + print ''."\n"; + + foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + + print ''; + + // Ref + print ''; + + // Invoice date + print ''; + + // Payment date + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''; + else print ''; + + // Rate + print ''; + + // Description + print ''; + + // Total HT + if ($modetax != 1) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; + } + + // Total collected + print ''; + + // VAT + print ''; + print ''; + + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + // Total customers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + + // Blank line + print ''; + + // Print table headers for this quadri - expenses now + print ''; + print ''; + print ''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''; + else print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''."\n"; + + foreach (array_keys($x_paye) as $thirdparty_id) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; + + if (is_array($x_both[$thirdparty_id]['paye']['detail'])) + { + print ""; + print ''; + print ''."\n"; + + foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index=>$fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + + print ''; + + // Ref + print ''; + + // Invoice date + print ''; + + // Payment date + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''; + else print ''; + + // Company name + print ''; + + // Description + print ''; + + // Total HT + if ($modetax != 1) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; + } + + // VAT paid + print ''; + + // VAT + print ''; + print ''; + + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + // Total suppliers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + print '
'.$langs->trans("Num")."'.$langs->trans("Supplier")."".$langs->trans("VATIntra")."".$langs->trans("AmountHTVATRealPaid")."".$vatsup."
'.$i."'.$company_static->getNomUrl(1,'supplier').''.$intra."".price($coll->amount)."".price($coll->tva)."
'.$langs->trans("Total").':'.price($totalamount).''.price($total).'
'..')
'.$elementcust.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").''.$namerate.''.$productcust.''.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("AmountHTVATRealReceived").''.$vatcust.'
'; + if (is_numeric($thirdparty_id)) + { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } + else + { + $tmpid = preg_replace('/userid_/','',$thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print '
'.$fields['link'].'' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['drate'] . ''; + if ($fields['pid']) + { + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + } + } + else + { + if ($type) { + $text = img_object($langs->trans('Service'),'service'); + } else { + $text = img_object($langs->trans('Product'),'product'); + } + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) { + if ($reg[1]=='DEPOSIT') { + $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1]=='CREDIT_NOTE') { + $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); + } + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $payment_static->id=$fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'],'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + } + print ''; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT'),1); + print ''; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + print price(price2num($temp_vat,'MT'),1); + //print price($fields['vat']); + print '
'.$langs->trans("Total").':  '.price(price2num($subtot_coll_total_ht,'MT')).''.price(price2num($subtot_coll_vat,'MT')).'
'.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
 
'.$elementsup.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").''.$namesup.''.$productsup.''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("AmountHTVATRealPaid").''.$vatsup.'
'; + if (is_numeric($thirdparty_id)) + { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } + else + { + $tmpid = preg_replace('/userid_/','',$thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print '
'.$fields['link'].'' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['company_link'] . ''; + if ($fields['pid']) + { + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + } + } + else + { + if ($type) { + $text = img_object($langs->trans('Service'),'service'); + } else { + $text = img_object($langs->trans('Product'),'product'); + } + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) { + if ($reg[1]=='DEPOSIT') { + $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1]=='CREDIT_NOTE') { + $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); + } + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id=$fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } + + if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) + { + print $langs->trans("NA"); + } + else + { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'],'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + } + print ''; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT'),1); + print ''; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + print price(price2num($temp_vat,'MT'),1); + //print price($fields['vat']); + print '
'.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht,'MT')).''.price(price2num($subtot_paye_vat,'MT')).'
'.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
'; // Total to pay @@ -325,198 +743,15 @@ if (is_array($coll_list)) { print ''; $diff = $x_coll_sum - $x_paye_sum; print ''; - print ''; + print ''; print '\n"; print "\n"; -} else { - $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else if ($coll_list == -2) { - print ''; - } else { - print ''; - } + $i++; } print '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.price(price2num($diff,'MT'))."
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
'; -if ($special_report) { - // Get country 2-letters code - global $mysoc; - $country_id = $mysoc->country_id; - $country = new Ccountry($db); - $country->fetch($country_id); - - // Print listing of other-country customers as additional report - // This matches tax requirements to list all same-country customers (only) - print '

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

'; - print $langs->trans('BasedOnTwoFirstLettersOfVATNumberBeingDifferentFromYourCompanyCountry'); - $coll_list = vat_by_thirdparty($db, 0, $date_start, $date_end, $modetax, 'sell'); - - print ""; - print ""; - print '"; - print '"; - print ""; - print ""; - print ""; - print "\n"; - - if (is_array($coll_list)) { - $var = true; - $total = 0; - $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if (substr($coll->tva_intra, 0, 2) == $country->code) { - // Only use different-country VAT codes - continue; - } - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - $var = !$var; - $intra = str_replace($find, $replace, $coll->tva_intra); - if (empty($intra)) { - if ($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ""; - print '"; - $company_static->id = $coll->socid; - $company_static->name = $coll->name; - $company_static->client = 1; - print ''; - $find = array(' ', '.'); - $replace = array('', ''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; - } - } - $x_coll_sum = $total; - - print ''; - print ''; - print ''; - print ''; - } else { - $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else { - if ($coll_list == -2) { - print ''; - } else { - print ''; - } - } - } - print '
' . $langs->trans("Num") . "' . $langs->trans("Customer") . "" . $langs->trans("VATIntra") . "" . $langs->trans("AmountHTVATRealReceived") . "" . $vatcust . "
' . $i . "' . $company_static->getNomUrl(1, - 'customer') . '' . $intra . "" . price($coll->amount) . "" . price($coll->tva) . "
' . $langs->trans("Total") . ':' . price($totalamount) . '' . price($total) . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
'; - - // Print listing of same-country customers as additional report - // This matches tax requirements to list all same-country customers (only) - print '

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

'; - print $langs->trans('BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry'); - $coll_list = vat_by_thirdparty($db, 0, $date_start, $date_end, $modetax, 'sell'); - - print ""; - print ""; - print '"; - print '"; - print ""; - print ""; - print ""; - print "\n"; - - if (is_array($coll_list)) { - $var = true; - $total = 0; - $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if (substr($coll->tva_intra, 0, 2) != $country->code) { - // Only use same-country VAT codes - continue; - } - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - $var = !$var; - $intra = str_replace($find, $replace, $coll->tva_intra); - if (empty($intra)) { - if ($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ""; - print '"; - $company_static->id = $coll->socid; - $company_static->name = $coll->name; - $company_static->client = 1; - print ''; - $find = array(' ', '.'); - $replace = array('', ''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; - } - } - $x_coll_sum = $total; - - print ''; - print ''; - print ''; - print ''; - } else { - $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else { - if ($coll_list == -2) { - print ''; - } else { - print ''; - } - } - } - print '
' . $langs->trans("Num") . "' . $langs->trans("Customer") . "" . $langs->trans("VATIntra") . "" . $langs->trans("AmountHTVATRealReceived") . "" . $vatcust . "
' . $i . "' . $company_static->getNomUrl(1, 'customer') . '' . $intra . "" . price($coll->amount) . "" . price($coll->tva) . "
' . $langs->trans("Total") . ':' . price($totalamount) . '' . price($total) . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
'; -} llxFooter(); diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 2fb7ba272c8..04d65dfadf5 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -84,7 +84,7 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; if ($action == 'setlib' && $user->rights->tax->charges->creer) { $object->fetch($id); - $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + $result = $object->setValueFrom('label', GETPOST('lib','alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -111,23 +111,8 @@ if ($object->id) $morehtmlref='
'; // Label of social contribution - $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' : '; - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); $morehtmlref.='
'; $linkback = '' . $langs->trans("BackToList") . ''; @@ -151,7 +136,7 @@ if ($object->id) print ''; print ''; - print ''; + print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
'; print ''; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 1c9632fac61..e6cdf738b96 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -44,13 +45,12 @@ if (empty($year)) } $date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); -// Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -81,10 +81,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); /** * print function * - * @param DoliDB $db Database handler - * @param string $sql SQL Request - * @param string $date Date - * @return void + * @param DoliDB $db Database handler + * @param string $sql SQL Request + * @param string $date Date + * @return void */ function pt ($db, $sql, $date) { @@ -96,25 +96,81 @@ function pt ($db, $sql, $date) $i = 0; $total = 0; print ''; + print ''; - print ''; - print ''; - print ''."\n"; + print ''; + print ''; + print ''; print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmonth = ''; + $previousmode = ''; while ($i < $num) { $obj = $db->fetch_object($result); + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - print ''; - print '\n"; - $total = $total + $obj->mm; + $amountclaimed = 0; + $amountpaid = 0; + } - print '\n"; - print "\n"; + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaid; + } + + if ($obj->mode == 'paid') + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + $previousmonth = ''; + } + else + { + $previousmode = $obj->mode; + $previousmonth = $obj->dm; + } $i++; } - print '"; + + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + + $amountclaimed = 0; + $amountpaid = 0; + } + + print ''; + print ''; + print ''; + print ''; + print ""; print "
'.$date.''.$langs->trans("Amount").' '.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.price($obj->mm)." 
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total")." :".price($total)." 
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
"; $db->free($result); @@ -189,21 +245,128 @@ $m = $tmp['mon']; $tmp=dol_getdate($date_end); $yend = $tmp['year']; $mend = $tmp['mon']; - +//var_dump($m); $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; $mcursor=0; while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { - $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); if ($m == 13) $y++; if ($m > 12) $m -= 12; $mcursor++; - $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + $x_coll = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $x_paye = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach(array_keys($x_coll) as $my_coll_rate) + { + $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; + $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; + $x_both[$my_coll_rate]['paye']['totalht'] = 0; + $x_both[$my_coll_rate]['paye']['vat'] = 0; + $x_both[$my_coll_rate]['coll']['links'] = ''; + $x_both[$my_coll_rate]['coll']['detail'] = array(); + foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) { + //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; + //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; + //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; + //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); + $x_both[$my_coll_rate]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_rate]['facid'][$id], + 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], + 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], + 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], + 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], + 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], + 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], + //'link' =>$invoice_customer->getNomUrl(1,'',12) + ); + } + } + + // tva paid + foreach (array_keys($x_paye) as $my_paye_rate) { + $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; + $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; + if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) { + $x_both[$my_paye_rate]['coll']['totalht'] = 0; + $x_both[$my_paye_rate]['coll']['vat'] = 0; + } + $x_both[$my_paye_rate]['paye']['links'] = ''; + $x_both[$my_paye_rate]['paye']['detail'] = array(); + + foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') + { + //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; + + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + //'link' =>$expensereport->getNomUrl(1) + ); + } + else + { + //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; + //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]); + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], + 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + //'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye $action = "tva"; - $object = array(&$coll_listsell, &$coll_listbuy); + $object = array(&$x_coll, &$x_paye, &$x_both); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; @@ -213,13 +376,13 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (! is_array($coll_listbuy) && $coll_listbuy == -1) + if (! is_array($x_coll) && $coll_listbuy == -1) { $langs->load("errors"); print '
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_coll)."".price(price2num($x_coll_sum,'MT'))."".price($x_paye)."".price(price2num($x_paye_sum,'MT'))."".price($diff)."".price(price2num($diff,'MT'))." 
'.$langs->trans("SubTotal").':'.price($subtotalcoll).''.price($subtotalpaye).''.price($subtotal).''.price(price2num($subtotalcoll,'MT')).''.price(price2num($subtotalpaye,'MT')).''.price(price2num($subtotal,'MT')).' 
'.$langs->trans("TotalToPay").':'.price($total).'
'.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).' 
'; print '
'; -print load_fiche_titre($langs->trans("VATPaid"), '', ''); /* * Payed */ -$sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm"; +print load_fiche_titre($langs->trans("VATPaid"), '', ''); + +$sql=''; + +$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datep >= '".$db->idate($date_start)."'"; -$sql.= " AND f.datep <= '".$db->idate($date_end)."'"; -$sql.= " GROUP BY dm ORDER BY dm ASC"; +$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')"; +$sql.= " GROUP BY dm"; -pt($db, $sql,$langs->trans("Year")." $y"); +$sql.= " UNION "; +$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode"; +$sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; +$sql.= " WHERE f.entity = ".$conf->entity; +$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')"; +$sql.= " GROUP BY dm"; -print '
'; +$sql.= " ORDER BY dm ASC, mode ASC"; +//print $sql; + +pt($db, $sql, $langs->trans("Month")); if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { - /* + print '
'; + + /* * Recap */ - print load_fiche_titre($langs->trans("VATRecap"), '', ''); // need to add translation + print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation $sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f"; @@ -316,7 +566,7 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) print ''; print ""; - print ''; // need to add translation + print ''; print ''; print "\n"; @@ -327,7 +577,7 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $restopay = $total - $obj->mm; print ""; - print ''; // need to add translation + print ''; print ''; print "\n"; diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 6a3955403e7..24208aedf2a 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -37,10 +37,27 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); +$object = new Tva($db); + + + +/* + * Actions + */ + +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('lib','alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + /* * View */ + $title=$langs->trans("VAT") . " - " . $langs->trans("Info"); $help_url=''; llxHeader("",$title,$helpurl); @@ -53,6 +70,12 @@ $head = vat_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("VATPayment"), -1, 'payment'); +$morehtmlref='
'; +// Label of social contribution +$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); +$morehtmlref.='
'; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index e796ddacac7..efe436a3704 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -46,7 +46,7 @@ $search_account = GETPOST('search_account','int'); $month = GETPOST("month","int"); $year = GETPOST("year","int"); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -151,7 +151,9 @@ if ($result) $newcardbutton=''; if ($user->rights->tax->charges->creer) { - $newcardbutton=''.$langs->trans('NewVATPayment').''; + $newcardbutton=''.$langs->trans('NewVATPayment'); + $newcardbutton.= ''; + $newcardbutton.= ''; } print ''; @@ -168,11 +170,11 @@ if ($result) print '
' . $langs->trans("VATDue") . '' . $langs->trans("VATDue") . '' . price(price2num($total, 'MT')) . '
' . $langs->trans("VATRestopay") . '' . $langs->trans("RemainToPay") . '' . price(price2num($restopay, 'MT')) . '
'; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; @@ -197,7 +199,7 @@ if ($result) print ''; print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"t.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"t.label","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre("DateValue",$_SERVER["PHP_SELF"],"t.datev","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"t.datev","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"t.datep","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); @@ -264,7 +266,7 @@ if ($result) $colspan=5; if (! empty($conf->banque->enabled)) $colspan++; print ''; - print ""; + print ''; print ""; print "
'; - print ''; + print ''; + print ''; $syear = $year; $formother->select_year($syear?$syear:-1,'year',1, 20, 5); print '
'.$langs->trans("Total").'".price($total)."'.price($total).' 
"; diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php deleted file mode 100644 index e572eb7e006..00000000000 --- a/htdocs/compta/tva/quadri.php +++ /dev/null @@ -1,319 +0,0 @@ - - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2006 Yannick Warnier - * Copyright (C) 2005-2009 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/compta/tva/quadri.php - * \ingroup tax - * \brief Trimestrial page - * TODO Deal with recurrent invoices as well - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; - -$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); - -$year = GETPOST('year', 'int'); -if ($year == 0 ) -{ - $year_current = strftime("%Y",time()); - $year_start = $year_current; -} else { - $year_current = $year; - $year_start = $year; -} - -// Security check -$socid = GETPOST('socid','int'); -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'tax', '', '', 'charges'); - - -/** - * Gets VAT to collect for the given month of the given year - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines. - * This function also accounts recurrent invoices. - * - * @param DoliDB $db Database handler - * @param int $y Year - * @param int $q Year quarter (1-4) - * @return array - */ -function tva_coll($db,$y,$q) -{ - global $conf; - - if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") - { - // if vat paid on due invoices - $sql = "SELECT d.fk_facture as facid, f.facnumber as facnum, d.tva_tx as rate, d.total_ht as totalht, d.total_tva as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."facturedet as d" ; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; - $sql.= " AND f.rowid = d.fk_facture "; - $sql.= " AND date_format(f.datef,'%Y') = '".$y."'"; - $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3); - $sql.= " AND date_format(f.datef,'%m') <= ".($q*3).")"; - $sql.= " ORDER BY rate, facid"; - - } - else - { - // if vat paid on paiments - } - - $resql = $db->query($sql); - - if ($resql) - { - $list = array(); - $rate = -1; - while($assoc = $db->fetch_array($resql)) - { - if($assoc['rate'] != $rate){ //new rate - $list[$assoc['rate']]['totalht'] = $assoc['totalht']; - $list[$assoc['rate']]['vat'] = $assoc['amount']; - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - }else{ - $list[$assoc['rate']]['totalht'] += $assoc['totalht']; - $list[$assoc['rate']]['vat'] += $assoc['amount']; - if(!in_array($assoc['facid'],$list[$assoc['rate']]['facid'])){ - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - } - } - $rate = $assoc['rate']; - } - return $list; - } - else - { - dol_print_error($db); - } -} - - -/** - * Gets VAT to pay for the given month of the given year - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Year quarter (1-4) - * @return array - */ -function tva_paye($db, $y,$q) -{ - global $conf; - - if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") - { - // Si on paye la tva sur les factures dues (non brouillon) - $sql = "SELECT d.fk_facture_fourn as facid, f.ref_supplier as facnum, d.tva_tx as rate, d.total_ht as totalht, d.tva as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn_det as d" ; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = 1 "; - $sql.= " AND f.rowid = d.fk_facture_fourn "; - $sql.= " AND date_format(f.datef,'%Y') = '".$y."'"; - $sql.= " AND (round(date_format(f.datef,'%m')) > ".(($q-1)*3); - $sql.= " AND round(date_format(f.datef,'%m')) <= ".($q*3).")"; - $sql.= " ORDER BY rate, facid "; - } - else - { - // Si on paye la tva sur les payments - } - - $resql = $db->query($sql); - if ($resql) - { - $list = array(); - $rate = -1; - while($assoc = $db->fetch_array($resql)) - { - if($assoc['rate'] != $rate){ //new rate - $list[$assoc['rate']]['totalht'] = $assoc['totalht']; - $list[$assoc['rate']]['vat'] = $assoc['amount']; - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - }else{ - $list[$assoc['rate']]['totalht'] += $assoc['totalht']; - $list[$assoc['rate']]['vat'] += $assoc['amount']; - if(!in_array($assoc['facid'],$list[$assoc['rate']]['facid'])){ - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - } - } - $rate = $assoc['rate']; - } - return $list; - - } - else - { - dol_print_error($db); - } -} - - -/** - * View - */ - -llxHeader(); - -$textprevyear="".img_previous().""; -$textnextyear=" ".img_next().""; - -print load_fiche_titre($langs->trans("VAT"),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear"); - - -echo ''; -echo ''; - -echo ''; - -print "
'; -print load_fiche_titre($langs->trans("VATSummary")); -echo '
"; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print "\n"; - -if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") -{ - $y = $year_current; - - $total = 0; $subtotal = 0; - $i=0; - $subtot_coll_total = 0; - $subtot_coll_vat = 0; - $subtot_paye_total = 0; - $subtot_paye_vat = 0; - for ($q = 1 ; $q <= 4 ; $q++) { - print ""; - $var=true; - - $x_coll = tva_coll($db, $y, $q); - $x_paye = tva_paye($db, $y, $q); - $x_both = array(); - //now, from these two arrays, get another array with one rate per line - foreach(array_keys($x_coll) as $my_coll_rate){ - $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; - $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; - $x_both[$my_coll_rate]['paye']['totalht'] = 0; - $x_both[$my_coll_rate]['paye']['vat'] = 0; - $x_both[$my_coll_rate]['coll']['links'] = ''; - foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy){ - $x_both[$my_coll_rate]['coll']['links'] .= '..'.substr($x_coll[$my_coll_rate]['facnum'][$id],-2).' '; - } - } - foreach(array_keys($x_paye) as $my_paye_rate){ - $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; - $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; - if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){ - $x_both[$my_paye_rate]['coll']['total_ht'] = 0; - $x_both[$my_paye_rate]['coll']['vat'] = 0; - } - $x_both[$my_paye_rate]['paye']['links'] = ''; - foreach($x_paye[$my_paye_rate]['facid'] as $id=>$dummy){ - $x_both[$my_paye_rate]['paye']['links'] .= '..'.substr($x_paye[$my_paye_rate]['facnum'][$id],-2).' '; - } - } - //now we have an array (x_both) indexed by rates for coll and paye - - $x_coll_sum = 0; - $x_coll_ht = 0; - $x_paye_sum = 0; - $x_paye_ht = 0; - foreach($x_both as $rate => $both){ - - print ''; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - $x_coll_sum += $both['coll']['vat']; - $x_paye_sum += $both['paye']['vat']; - $subtot_coll_total += $both['coll']['totalht']; - $subtot_coll_vat += $both['coll']['vat']; - $subtot_paye_total += $both['paye']['totalht']; - $subtot_paye_vat += $both['paye']['vat']; - } - - $diff = $x_coll_sum - $x_paye_sum; - $total = $total + $diff; - $subtotal = $subtotal + $diff; - - - print ''; - print ''; - print "\n"; - print "\n"; - - $i++; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - -} -else -{ - print ''; - print ''; -} - -print '
".$langs->trans("Year")." $year_current".$langs->trans("Income")."".$langs->trans("VATToPay")."".$langs->trans("Invoices")."".$langs->trans("Outcome")."".$langs->trans("VATToCollect")."".$langs->trans("Invoices")."".$langs->trans("TotalToPay")."
".$langs->trans("Quadri")." $q (".dol_print_date(dol_mktime(0,0,0,(($q-1)*3)+1,1,$y),"%b %Y").' - '.dol_print_date(dol_mktime(0,0,0,($q*3),1,$y),"%b %Y").")
$rate%".price($both['coll']['totalht'])."".price($both['coll']['vat'])."".$both['coll']['links']."".price($both['paye']['totalht'])."".price($both['paye']['vat'])."".$both['paye']['links']."
".price($diff)."
'.$langs->trans("Total").':'.price($subtot_coll_total).''.price($subtot_coll_vat).''.price($subtot_paye_total).''.price($subtot_paye_vat).''.price($total).''; - print '
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureIsSupportedInInOutModeOnly").'
'; -echo '
'; - -llxFooter(); -$db->close(); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 713cab1dc13..0866bafad0c 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -22,7 +22,7 @@ /** * \file htdocs/compta/tva/quadri_detail.php * \ingroup tax - * \brief Trimestrial page - detailed version + * \brief VAT by rate */ require '../../main.inc.php'; @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -55,10 +56,10 @@ $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GE // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -96,6 +97,16 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); * View */ +$form=new Form($db); +$company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); + $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); foreach ($listofparams as $param) @@ -105,16 +116,6 @@ foreach ($listofparams as $param) llxHeader('',$langs->trans("VATReport"),'','',0,0,'','',$morequerystring); -$form=new Form($db); - -$company_static=new Societe($db); -$invoice_customer=new Facture($db); -$invoice_supplier=new FactureFournisseur($db); -$expensereport=new ExpenseReport($db); -$product_static=new Product($db); -$payment_static=new Paiement($db); -$paymentfourn_static=new PaiementFourn($db); -$paymentexpensereport_static=new PaymentExpenseReport($db); //print load_fiche_titre($langs->trans("VAT"),""); @@ -126,7 +127,7 @@ $fsearch.=' '; // Show report header -$name=$langs->trans("VATReportByPeriods"); +$name=$langs->trans("VATReportByRates"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); @@ -185,6 +186,7 @@ $vatcust=$langs->trans("VATReceived"); $vatsup=$langs->trans("VATPaid"); $vatexpensereport=$langs->trans("VATPaid"); + // VAT Received and paid print ''; @@ -194,8 +196,8 @@ $i=0; $columns = 5; // Load arrays of datas -$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); +$x_coll = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (! is_array($x_coll) || ! is_array($x_paye)) { @@ -362,14 +364,14 @@ if (! is_array($x_coll) || ! is_array($x_paye)) if (is_array($x_both[$rate]['coll']['detail'])) { // VAT Rate - $var=true; print ""; print ''; print ''."\n"; foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. if (!empty($fields['ddate_start'])) { @@ -401,10 +403,10 @@ if (! is_array($x_coll) || ! is_array($x_paye)) { $product_static->id=$fields['pid']; $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; + $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered print $product_static->getNomUrl(1); if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); } } else @@ -423,7 +425,7 @@ if (! is_array($x_coll) || ! is_array($x_paye)) $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); } } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); // Show range print_date_range($fields['ddate_start'],$fields['ddate_end']); @@ -503,7 +505,7 @@ if (! is_array($x_coll) || ! is_array($x_paye)) print ''; } - if (count($x_coll) == 0) // Show a total ine if nothing shown + if (count($x_coll) == 0) // Show a total line if nothing shown { print ''; print ''; @@ -543,14 +545,14 @@ if (! is_array($x_coll) || ! is_array($x_paye)) if (is_array($x_both[$rate]['paye']['detail'])) { - $var=true; print ""; print ''; print ''."\n"; foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) { // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. if (!empty($fields['ddate_start'])) { @@ -582,10 +584,10 @@ if (! is_array($x_coll) || ! is_array($x_paye)) { $product_static->id=$fields['pid']; $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; + $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered print $product_static->getNomUrl(1); if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); } } else @@ -595,7 +597,16 @@ if (! is_array($x_coll) || ! is_array($x_paye)) } else { $text = img_object($langs->trans('Product'),'product'); } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) { + if ($reg[1]=='DEPOSIT') { + $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1]=='CREDIT_NOTE') { + $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); // Show range print_date_range($fields['ddate_start'],$fields['ddate_end']); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 560acabaee9..bb67f0f183d 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -686,7 +686,7 @@ else $parameters=array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } @@ -963,7 +963,7 @@ else $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) + if (empty($reshook)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 83ad411b4b6..5053e07212f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -342,6 +342,7 @@ class Contact extends CommonObject $sql .= ", email='".$this->db->escape($this->email)."'"; $sql .= ", skype='".$this->db->escape($this->skype)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; + $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql .= ", note_public = ".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql .= ", phone = ".(isset($this->phone_pro)?"'".$this->db->escape($this->phone_pro)."'":"null"); @@ -366,11 +367,8 @@ class Contact extends CommonObject $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('contactdao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -381,7 +379,6 @@ class Contact extends CommonObject } } } - else if ($reshook < 0) $error++; if (! $error && $this->user_id > 0) { @@ -588,8 +585,8 @@ class Contact extends CommonObject $resql = $this->db->query($sql); if (! $resql) { - $error++; - $this->error=$this->db->lasterror(); + $error++; + $this->error=$this->db->lasterror(); } // Mis a jour alerte birthday @@ -690,7 +687,10 @@ class Contact extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; if ($id) $sql.= " WHERE c.rowid = ". $id; - elseif ($ref_ext) $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'"; + elseif ($ref_ext) { + $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; + $sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'"; + } $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 281924cb589..2d729d8ebb4 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -153,7 +153,7 @@ if ($object->id) print ''; print ''; - print ''; + print ''; print '
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
'; print ''; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 5c101401dac..8719c77f1b4 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -7,7 +7,8 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018 Juanjo Menent * * 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 @@ -259,7 +260,7 @@ if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -$sql.= ' WHERE p.entity IN ('.getEntity('societe').')'; +$sql.= ' WHERE p.entity IN ('.getEntity('socpeople').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { $sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)"; @@ -303,6 +304,7 @@ if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $sea if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype); if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); +if (strlen($search_zip)) $sql.= natural_search("p.zip",$search_zip); if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql.= natural_search("p.import_key",$search_import_key); if ($type == "o") // filtre sur type @@ -347,6 +349,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); @@ -415,7 +422,9 @@ $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; if ($user->rights->societe->contact->creer) { - $newcardbutton=''.$langs->trans('NewContactAddress').''; + $newcardbutton=''.$langs->trans('NewContactAddress'); + $newcardbutton.= ''; + $newcardbutton.= ''; } print ''; diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index 3fb55acc2ca..a33d020d74d 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013-2018 Philippe Grand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,9 +31,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -$langs->load("companies"); -$langs->load("admin"); -$langs->load("contracts"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies","admin","contracts")); $extrafields = new ExtraFields($db); $form = new Form($db); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 41cf0c12f3e..d474da18a85 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -46,12 +46,7 @@ if (! empty($conf->projet->enabled)) { } require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -$langs->load("contracts"); -$langs->load("orders"); -$langs->load("companies"); -$langs->load("bills"); -$langs->load("products"); -$langs->load('compta'); +$langs->loadLangs(array("contracts","orders","companies","bills","products",'compta')); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); @@ -1287,7 +1282,7 @@ if ($action == 'create') print $hookmanager->resPrint; // Other attributes - if (empty($reshook) && ! empty($extrafields->attribute_label)) { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -1554,6 +1549,7 @@ else print ''; // Area with common detail of line + print '
'; print ''; $sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.product_type, cd.description, cd.price_ht, cd.qty,"; @@ -1592,7 +1588,7 @@ else if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { - print ''; + print ''; // Label if ($objp->fk_product > 0) { @@ -1688,7 +1684,7 @@ else $colspan = 7; } - print ''; + print ''; print '"; + print ''; print ''; print ''; - + $colspan=6; if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++; if($conf->global->PRODUCT_USE_UNITS) $colspan++; // Ligne dates prevues - print ""; + print ''; print ''; + print ''; print ''; print "\n"; } print "
'; // Date planned @@ -1725,14 +1721,14 @@ else if (is_array($extralabelslines) && count($extralabelslines)>0) { $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid); - print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $line->showOptionals($extrafieldsline, 'view', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } } // Ligne en mode update else { // Ligne carac - print "
'; if ($objp->fk_product) { @@ -1781,13 +1777,13 @@ else print '
'; print '
'; print $langs->trans("DateStartPlanned").' '; $form->select_date($db->jdate($objp->date_debut),"date_start_update",$usehm,$usehm,($db->jdate($objp->date_debut)>0?0:1),"update"); @@ -1799,7 +1795,7 @@ else if (is_array($extralabelslines) && count($extralabelslines)>0) { $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid); - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } } @@ -1812,12 +1808,13 @@ else if ($object->statut > 0) { - print '

"; + print '
'; print "\n"; @@ -1889,7 +1886,7 @@ else { print ''; - print ''; + print ''; print ''; print ''; print "\n"; - print ''; + print ''; print ''; + print ''; print ''; @@ -1984,7 +1981,7 @@ else print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; } // Extra fields @@ -577,7 +584,7 @@ if (! empty($arrayfields['c.date_contrat']['checked'])) print_liste_field_t // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index f78ed639804..0fc475c19fb 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -204,6 +205,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk $sql.= " cd.date_ouverture_prevue,"; $sql.= " cd.date_ouverture,"; $sql.= " cd.date_fin_validite,"; +$sql.= " cd.date_cloture,"; $sql.= " cd.qty,"; $sql.= " cd.total_ht,"; $sql.= " cd.total_tva,"; @@ -255,6 +257,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -382,7 +389,7 @@ if (! empty($arrayfields['cd.date_cloture']['checked'])) print_liste_field_titre // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['cd.datec']['checked'])) print_liste_field_titre($arrayfields['cd.datec']['label'],$_SERVER["PHP_SELF"],"cd.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -525,7 +532,9 @@ print "\n"; $contractstatic=new Contrat($db); $productstatic=new Product($db); -$var=True; $i=0; +$var=true; +$i=0; +$totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -542,6 +551,7 @@ while ($i < min($num,$limit)) print ''; + if (! $i) $totalarray['nbfield']++; } // Service if (! empty($arrayfields['p.description']['checked'])) @@ -563,6 +573,7 @@ while ($i < min($num,$limit)) if ($obj->type == 1) print img_object($obj->description,'service').' '.dol_trunc($obj->description,24); } print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['cd.qty']['checked'])) @@ -570,30 +581,45 @@ while ($i < min($num,$limit)) print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['cd.total_ht']['checked'])) { - print ''; - } + $totalarray['totalht'] += $obj->total_ht; + if (! $i) { + $totalarray['displaytotalline']++; + $totalarray['nbfield']++; + $totalarray['totalhtfield']=$totalarray['nbfield']; + } + } if (! empty($arrayfields['cd.total_tva']['checked'])) { - print ''; - } + $totalarray['totalvat'] += $obj->total_tva; + if (! $i) { + $totalarray['nbfield']++; + $totalarray['totalvatfield']=$totalarray['nbfield']; + $totalarray['displaytotalline']++; + } + } if (! empty($arrayfields['cd.tva_tx']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['cd.subprice']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } @@ -606,26 +632,29 @@ while ($i < min($num,$limit)) $companystatic->client=1; print $companystatic->getNomUrl(1,'customer',28); print ''; + if (! $i) $totalarray['nbfield']++; } // Start date if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['cd.date_ouverture']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } // End date if (! empty($arrayfields['cd.date_fin_validite']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } + // Close date (real end date) if (! empty($arrayfields['cd.date_cloture']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } // Extra fields @@ -675,6 +707,7 @@ while ($i < min($num,$limit)) print $staticcontratligne->LibStatut($obj->statut,5,($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0); } print ''; + if (! $i) $totalarray['nbfield']++; } // Action column print '\n"; $i++; } + +// Show total line +if (isset($totalarray['displaytotalline'])) { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) { + $i++; + if ($i == 1) { + if ($num < $limit && empty($offset)) print ''; + else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; + else print ''; + } + print ''; +} + $db->free($resql); $parameters=array('sql' => $sql); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b8ede4d7d14..394680f4d8e 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -28,6 +28,7 @@ // $permissiontodelete must be defined // $backurlforlist must be defined // $backtopage may be defined +// $triggermodname may be defined if ($cancel) { @@ -47,13 +48,22 @@ if ($action == 'add' && ! empty($permissiontoadd)) if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields // Set value to insert - if (in_array($object->fields[$key]['type'], array('text', 'html'))) $value = GETPOST($key,'none'); - else $value = GETPOST($key,'alpha'); + if (in_array($object->fields[$key]['type'], array('text', 'html'))) { + $value = GETPOST($key,'none'); + } elseif ($object->fields[$key]['type']=='date') { + $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type']=='datetime') { + $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type']=='price') { + $value = price2num(GETPOST($key)); + } else { + $value = GETPOST($key,'alpha'); + } if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field $object->$key=$value; - if ($val['notnull'] > 0 && $object->$key == '') + if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); @@ -66,7 +76,7 @@ if ($action == 'add' && ! empty($permissiontoadd)) if ($result > 0) { // Creation OK - $urltogo=$backtopage?$backtopage:$backurlforlist; + $urltogo=$backtopage?str_replace('__ID__', $result, $backtopage):$backurlforlist; header("Location: ".$urltogo); exit; } @@ -95,11 +105,12 @@ if ($action == 'update' && ! empty($permissiontoadd)) // Set value to update if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key,'none'); - } - elseif ($object->fields[$key]['type']=='date') { + } elseif ($object->fields[$key]['type']=='date') { $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type']=='datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type']=='price') { + $value = price2num(GETPOST($key)); } else { $value = GETPOST($key,'alpha'); } @@ -107,7 +118,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field $object->$key=$value; - if ($val['notnull'] > 0 && $object->$key == '') + if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); @@ -124,8 +135,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) else { // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action='edit'; } } @@ -135,6 +145,27 @@ if ($action == 'update' && ! empty($permissiontoadd)) } } +// Action to update one extrafield +if ($action == "update_extras" && ! empty($permissiontoadd)) +{ + $object->fetch(GETPOST('id','int')); + $attributekey = GETPOST('attribute','alpha'); + $attributekeylong = 'options_'.$attributekey; + $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong,' alpha'); + + $result = $object->insertExtraFields(empty($triggermodname)?'':$triggermodname, $user); + if ($result > 0) + { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit_extras'; + } +} + // Action to delete if ($action == 'confirm_delete' && ! empty($permissiontodelete)) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 9a9298528eb..371dd75a8e2 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -357,6 +357,14 @@ if (! $error && $massaction == 'confirm_presend') $substitutionarray['__CHECK_READ__'] = ''; $parameters=array('mode'=>'formemail'); + + if ( ! empty( $listofobjectthirdparties ) ) { + $parameters['listofobjectthirdparties'] = $listofobjectthirdparties; + } + if ( ! empty( $listofobjectref ) ) { + $parameters['listofobjectref'] = $listofobjectref; + } + complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); $subject=make_substitutions($subject, $substitutionarray); @@ -728,6 +736,56 @@ if ($massaction == 'confirm_createbills') } } +if (!$error && $massaction == 'cancelorders') +{ + + $db->begin(); + + $nbok = 0; + + + $orders = GETPOST('toselect', 'array'); + foreach ($orders as $id_order) + { + + $cmd = new Commande($db); + if ($cmd->fetch($id_order) <= 0) + continue; + + if ($cmd->statut != Commande::STATUS_VALIDATED) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); + $error++; + break; + } + else + $result = $cmd->cancel(); + + if ($result < 0) + { + setEventMessages($cmd->error, $cmd->errors, 'errors'); + $error++; + break; + } + else + $nbok++; + } + if (!$error) + { + if ($nbok > 1) + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); + } +} + + if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) { if (empty($diroutputmassaction)) @@ -1021,24 +1079,23 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == $result=$objecttmp->fetch($toselectid); if ($result > 0) { - // Refuse deletion for some status ? - /* - if ($objectclass == 'Facture' && $objecttmp->status == Facture::STATUS_DRAFT) - { - $langs->load("errors"); - $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; - continue; - }*/ + // Refuse deletion for some objects/status + if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) + { + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; + continue; + } - if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); + if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; } else $nbok++; } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 8f7ee1287fe..18a236056b9 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -23,8 +23,8 @@ // $mysoc must be defined // $id must be defined -// $paramname must be defined -// $mode must be defined (used to know the automatic BCC to add) +// $paramname may be defined +// $autocopy may be defined (used to know the automatic BCC to add) // $trigger_name must be set (can be '') // $actiontypecode can be set // $object and $uobject may be defined @@ -129,38 +129,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $thirdparty=$object; if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; - elseif (! empty($conf->dolimail->enabled)) - { - $dolimail = new Dolimail($db); - $possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1"); - $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople - if (!$possibleaccounts && !$possibleuser) - { - setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors'); - } - elseif (count($possibleaccounts)>1) - { - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - - setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); - } - else - { - if($possibleaccounts){ - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - }elseif($possibleuser){ - $sendtosocid=$possibleuser[0]['id']; - - $result=$uobject->fetch($sendtosocid); - $object=$uobject; - } - - } - } } else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); + + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + } } else $thirdparty = $mysoc; @@ -170,6 +146,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $sendtocc=''; $sendtobcc=''; $sendtoid = array(); + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $sendtouserid=array(); + } // Define $sendto $receiver=$_POST['receiver']; @@ -191,7 +170,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party { - $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; + $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } elseif ($val) // Id du contact { @@ -200,6 +179,18 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $receiveruser=$_POST['receiveruser']; + if (is_array($receiveruser) && count($receiveruser)>0) + { + $fuserdest = new User($db); + foreach($receiveruser as $key=>$val) + { + $tmparray[] = $fuserdest->user_get_property($key,'email'); + $sendtouserid[] = $key; + } + } + } $sendto=implode(',',$tmparray); // Define $sendtocc @@ -221,7 +212,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party { - $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; + $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } elseif ($val) // Id du contact { @@ -230,6 +221,19 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $receiveruser=$_POST['receiveccruser']; + + if (is_array($receiveruser) && count($receiveruser)>0) + { + $fuserdest = new User($db); + foreach($receiveruser as $key=>$val) + { + $tmparray[] = $fuserdest->user_get_property($key,'email'); + $sendtouserid[] = $key; + } + } + } $sendtocc=implode(',',$tmparray); if (dol_strlen($sendto)) @@ -245,13 +249,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $fromtype = GETPOST('fromtype','alpha'); if ($fromtype === 'robot') { - $from = $conf->global->MAIN_MAIL_EMAIL_FROM .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; + $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; } elseif ($fromtype === 'user') { - $from = $user->getFullName($langs) .' <'.$user->email.'>'; + $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>'; } elseif ($fromtype === 'company') { - $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { $tmp=explode(',', $user->email_aliases); @@ -267,14 +271,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $obj = $db->fetch_object($resql); if ($obj) { - $from = $obj->label.' <'.$obj->email.'>'; + $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; } } else { - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>'; } - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>'; $message = GETPOST('message','none'); $subject = GETPOST('subject','none'); @@ -343,9 +347,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (!$folder) $folder = "Sent"; // Default Sent folder $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password); - if (FALSE === $mailboxconfig->mbox) + if (false === $mailboxconfig->mbox) { - $info = FALSE; + $info = false; $err = $langs->trans('Error3_Imap_Connection_Error'); setEventMessages($err,$mailboxconfig->element, null, 'errors'); } @@ -430,6 +434,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (is_array($attachedfiles) && count($attachedfiles)>0) { $object->attachedfiles = $attachedfiles; } + if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $object->sendtouserid = $sendtouserid; + } // Call of triggers if (! empty($trigger_name)) @@ -448,10 +455,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - $moreparam=''; - if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); - exit; + $moreparam=''; + if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); + exit; } else { diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index eadce1dc74c..03ff1491e49 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -31,13 +31,13 @@ if ($action == 'update' && is_array($arrayofparameters)) { $db->begin(); - $ok=True; + $ok=true; foreach($arrayofparameters as $key => $val) { $result=dolibarr_set_const($db,$key,GETPOST($key, 'alpha'),'chaine',0,'',$conf->entity); if ($result < 0) { - $ok=False; + $ok=false; break; } } diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 612f38bb05b..f6bd5b5214a 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -26,8 +26,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; @@ -70,7 +68,7 @@ if ($boxorder && $zone != '' && $userid > 0) dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG); $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); - if ($result > 0) + if ($result > 0) { $langs->load("boxes"); if (! GETPOST('closing')) diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index f79753260d7..9e9f8a0d799 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -26,7 +26,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index 1c7c7a56e4b..b03b9f128cf 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -23,10 +23,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index f8a636e52a5..908c1ef9f11 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -25,7 +25,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); include '../../main.inc.php'; diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index 6eb4d5836b8..9405aa26cf1 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -21,16 +21,10 @@ * \brief File to return Ajax response on file upload */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) require '../../main.inc.php'; diff --git a/htdocs/core/ajax/getaccountcurrency.php b/htdocs/core/ajax/getaccountcurrency.php index 40e52672c0e..2289d8e1c0f 100644 --- a/htdocs/core/ajax/getaccountcurrency.php +++ b/htdocs/core/ajax/getaccountcurrency.php @@ -22,10 +22,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 7e9e541c768..099f66ba3de 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -22,10 +22,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php index d4a101fb497..577f659b2cc 100644 --- a/htdocs/core/ajax/price.php +++ b/htdocs/core/ajax/price.php @@ -22,10 +22,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require('../../main.inc.php'); diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 4fe31ee7ae8..98f18df8a68 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -28,7 +28,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 61c2dca675b..7070d1a8799 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -22,10 +22,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index cc7335618d0..fa1ce2103d4 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -27,7 +27,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); require '../../main.inc.php'; diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 1bc527ff555..57483848c4e 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -27,10 +27,9 @@ if (! isset($usedbyinclude) || empty($usedbyinclude)) { if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal - //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); - if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); - if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); - if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); + if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); + if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN','1'); $res=@include '../../main.inc.php'; diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php index ac9691bfa25..3826e521d06 100644 --- a/htdocs/core/ajax/vatrates.php +++ b/htdocs/core/ajax/vatrates.php @@ -22,10 +22,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 936d269f82a..a8dc7f1231d 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -85,7 +85,7 @@ class box_contacts extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; + $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; $sql.= " ORDER BY sp.tms DESC"; diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index d665d70da56..abbdc7b7c71 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -222,13 +222,14 @@ class box_graph_invoices_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.='
'; if ($shownb && $showtot) diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index efd7de41e5a..53d9ce08059 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -219,13 +219,14 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.='
'; if ($shownb && $showtot) diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 699f2db902b..05a0ff498ec 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -218,13 +218,14 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.='
'; if ($shownb && $showtot) diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index f49f38c1228..e88ed46be72 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -217,13 +217,14 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.='
'; if ($shownb && $showtot) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 69a09e8aad2..39a7a3984d2 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -338,6 +338,7 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire)) { @@ -355,7 +356,7 @@ class box_graph_product_distribution extends ModeleBoxes } $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.='
'; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 50e3cbe9bf8..bddf4a27e64 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -219,13 +219,14 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfProposalsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfProposalsByMonthHT"); $stringtoshow.='
'; $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.='
'; if ($shownb && $showtot) diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index dc20e9b9665..895f411e3d6 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -1,5 +1,4 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012 Raphaël Doursenaud @@ -83,7 +82,7 @@ class box_supplier_orders extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql.= " s.code_client, s.code_fournisseur,"; $sql.= " s.logo,"; - $sql.= " c.ref, c.tms, c.rowid, c.date_commande,"; + $sql.= " c.rowid, c.ref, c.tms, c.date_commande,"; $sql.= " c.total_ht,"; $sql.= " c.tva as total_tva,"; $sql.= " c.total_ttc,"; @@ -110,7 +109,7 @@ class box_supplier_orders extends ModeleBoxes $date=$db->jdate($objp->date_commande); $datem=$db->jdate($objp->tms); - $supplierorderstatic->id = $objp->id; + $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; $thirdpartytmp->id = $objp->socid; diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 74f0ffc9d9d..61af58a4b8b 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -261,17 +261,17 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" { $sublink=''; if (! empty($head['sublink'])) $sublink.= ''; - if (! empty($head['subpicto'])) $sublink.= img_picto($head['subtext'], $head['subpicto'], 'class="'.(empty($head['subclass'])?'':$head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); + if (! empty($head['subpicto'])) $sublink.= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium '.(empty($head['subclass'])?'':$head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); if (! empty($head['sublink'])) $sublink.= ''; $out.= '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''; if ($user->societe_id == 0) @@ -1916,7 +1913,7 @@ else print '
'; // Si pas encore active @@ -1972,7 +1969,7 @@ else } } - print '
'.$langs->trans("DateServiceActivate").''; print $form->select_date($dateactstart,'',$usehm,$usehm,'',"active",1,0,1); print '
'.$langs->trans("Comment").''; print '   '; @@ -2029,7 +2026,7 @@ else $now=dol_now(); if ($dateactend > $now) $dateactend=$now; - print '
'; + print '
'; if ($objp->statut >= 4) { if ($objp->statut == 4) @@ -2042,7 +2039,7 @@ else print ''; print '
'.$langs->trans("Comment").''; print '   '; @@ -2082,8 +2079,6 @@ else // Form to add new line if ($action != 'editline') { - $var = true; - $forcetoshowtitlelines=1; // Add free products/services @@ -2136,7 +2131,7 @@ else else print ''; } - if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) + if (! empty($conf->facture->enabled) && $object->statut > 0) { $langs->load("bills"); if ($user->rights->facture->creer) print ''; @@ -2205,7 +2200,6 @@ else $genallowed = $user->rights->contrat->lire; $delallowed = $user->rights->contrat->creer; - $var = true; print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 689b0465fd4..1bb17eb4352 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -182,7 +182,7 @@ class Contracts extends DolibarrApi * @param array $request_data Request data * @return int ID of contrat */ - function post($request_data = NULL) + function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401, "Insuffisant rights"); @@ -247,7 +247,7 @@ class Contracts extends DolibarrApi * * @return int */ - function postLine($id, $request_data = NULL) { + function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401); } @@ -300,7 +300,7 @@ class Contracts extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = NULL) { + function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401); } @@ -359,7 +359,7 @@ class Contracts extends DolibarrApi * * @return object */ - function activateLine($id, $lineid, $datestart, $dateend = NULL, $comment = NULL) { + function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401); } @@ -396,7 +396,7 @@ class Contracts extends DolibarrApi * * @return object */ - function unactivateLine($id, $lineid, $datestart, $comment = NULL) { + function unactivateLine($id, $lineid, $datestart, $comment = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401); } @@ -470,7 +470,7 @@ class Contracts extends DolibarrApi * * @return int */ - function put($id, $request_data = NULL) { + function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401); } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 215dc185ac4..8e6f6af33ce 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -237,7 +237,13 @@ class Contrat extends CommonObject */ function active_line($user, $line_id, $date, $date_end='', $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } @@ -252,7 +258,13 @@ class Contrat extends CommonObject */ function close_line($user, $line_id, $date_end, $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } @@ -767,17 +779,7 @@ class Contrat extends CommonObject $line->fk_user_cloture = $objp->fk_user_cloture; $line->fk_unit = $objp->fk_unit; - $line->ref = $objp->product_ref; // deprecated - if (empty($objp->fk_product)) - { - $line->label = ''; // deprecated - $line->libelle = $objp->description; // deprecated - } - else - { - $line->label = $objp->product_label; // deprecated - $line->libelle = $objp->product_label; // deprecated - } + $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; // Ref product $line->product_desc = $objp->product_desc; // Description product $line->product_label = $objp->product_label; // Label product @@ -2459,12 +2461,15 @@ class ContratLigne extends CommonObjectLine var $fk_contrat; var $fk_product; var $statut; // 0 inactive, 4 active, 5 closed - var $type; // 0 for product, 1 for service + var $type; // 0 for product, 1 for service + /** + * @var string + * @deprecated + */ var $label; /** * @var string - * @deprecated Use $label instead - * @see label + * @deprecated */ public $libelle; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 4bc2747a829..53125f3063b 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -181,7 +181,7 @@ if ($object->id) print ''; print ''; - print ''; + print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize,1,1).'
'; print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index b1755b7f7ec..61d62896cf1 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2018 Ferran Marcet * * 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 @@ -301,6 +301,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); @@ -372,7 +377,9 @@ $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; if ($user->rights->contrat->creer) { - $newcardbutton=''.$langs->trans('NewContractSubscription').''; + $newcardbutton=''.$langs->trans('NewContractSubscription'); + $newcardbutton.= ''; + $newcardbutton.= ''; } print '
'; @@ -512,11 +519,11 @@ if (! empty($arrayfields['c.date_contrat']['checked'])) // Date contract print '
'; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; //print ' '.$langs->trans('Year').': '; $syear = $year; - print $formother->selectyear($syear,'year',1, 20, 5, 0, 0, '', 'widthauto'); + print $formother->selectyear($syear,'year',1, 20, 5); print '
'; print $contractstatic->getNomUrl(1,16); print ''; print $obj->qty; print ''; + print ''; print price($obj->total_ht); print ''; + print ''; print price($obj->total_tva); print ''; + print ''; print price2num($obj->tva_tx).'%'; print ''; + print ''; print price($obj->subprice); print ''; - print ($obj->date_ouverture_prevue?dol_print_date($db->jdate($obj->date_ouverture_prevue)):' '); + print ($obj->date_ouverture_prevue?dol_print_date($db->jdate($obj->date_ouverture_prevue), 'dayhour'):' '); if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) print ' '.img_picto($langs->trans("Late"),"warning"); else print '    '; print ''.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture)):' ').''.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour'):' ').''.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite)):' '); + print ''.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour'):' '); if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) { $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24; @@ -634,10 +663,13 @@ while ($i < min($num,$limit)) } else print '    '; print ''.dol_print_date($db->jdate($obj->date_cloture)).''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''; @@ -690,6 +723,25 @@ while ($i < min($num,$limit)) print "
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
'; $out.=$sublink; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - $out.= img_picto($langs->trans("MoveBox",$this->box_id),'grip_title','class="boxhandle hideonsmartphone cursormove"'); - $out.= img_picto($langs->trans("CloseBox",$this->box_id),'close_title','class="boxclose cursorpointer" rel="x:y" id="imgclose'.$this->box_id.'"'); + $out.= img_picto($langs->trans("MoveBox",$this->box_id),'grip_title','class="opacitymedium boxhandle hideonsmartphone cursormove"'); + $out.= img_picto($langs->trans("CloseBox",$this->box_id),'close_title','class="opacitymedium boxclose cursorpointer" rel="x:y" id="imgclose'.$this->box_id.'"'); $label=$head['text']; //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; - if (! empty($head['graph'])) $label.=' '; + if (! empty($head['graph'])) $label.=' '; $out.= ''; $out.= '
'; } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index af3dce343f4..3bccc54204f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -775,9 +775,6 @@ class CMailFile if (! empty($this->error) || ! $result) { dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res=false; - } else { - $this->error = $langs->trans("SentXXXmessages", $result); - $this->errors[] = $langs->trans("SentXXXmessages", $result); } } else @@ -1158,7 +1155,7 @@ class CMailFile $out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; $out.= "Content-Type: " . $mimetype_list[$i] . "; name=\"".$filename_list[$i]."\"".$this->eol; $out.= "Content-Transfer-Encoding: base64".$this->eol; - $out.= "Content-Description: File Attachment".$this->eol; + $out.= "Content-Description: ".$filename_list[$i].$this->eol; $out.= $this->eol; $out.= $encoded; $out.= $this->eol; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 4d45f5aabbb..d3d77640540 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -376,7 +376,7 @@ abstract class CommonDocGenerator $array_key.'_payment_mode_code'=>$object->mode_reglement_code, $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), $array_key.'_payment_term_code'=>$object->cond_reglement_code, - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement), + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):($object->cond_reglement_doc?$object->cond_reglement_doc:$object->cond_reglement)), $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), $array_key.'_total_vat_locale'=>(! empty($object->total_vat)?price($object->total_vat, 0, $outputlangs):price($object->total_tva, 0, $outputlangs)), diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 88ef341cb04..4c236324373 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel - * Copyright (C) 2011-2014 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2012 Cedric Salvador @@ -13,7 +13,7 @@ * Copyright (C) 2016 Bahfir abbes * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017 Nicolas ZABOURI - * Copyright (C) 2017 Rui Strecht + * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -448,7 +448,7 @@ abstract class CommonObject * * @param int $withcountry 1=Add country into address string * @param string $sep Separator to use to build string - * @param int $withregion 1=Add region into address string + * @param int $withregion 1=Add region into address string * @return string Full address string */ function getFullAddress($withcountry=0,$sep="\n",$withregion=0) @@ -599,7 +599,7 @@ abstract class CommonObject if (empty($this->last_main_doc)) { - return ''; // No known last doc + return ''; // No way to known which document name to use } include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; @@ -717,7 +717,7 @@ abstract class CommonObject } else { - // On recherche id type_contact + // We look for id type_contact $sql = "SELECT tc.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE tc.element='".$this->db->escape($this->element)."'"; @@ -741,7 +741,7 @@ abstract class CommonObject $datecreate = dol_now(); - // Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error + // Socpeople must have already been added by some trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error $TListeContacts=$this->liste_contact(-1, $source); $already_added=false; if(!empty($TListeContacts)) { @@ -757,7 +757,7 @@ abstract class CommonObject $this->db->begin(); - // Insertion dans la base + // Insert into database $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; @@ -832,7 +832,7 @@ abstract class CommonObject */ function update_contact($rowid, $statut, $type_contact_id=0, $fk_socpeople=0) { - // Insertion dans la base + // Insert into database $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; $sql.= " statut = ".$statut; if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'"; @@ -1116,7 +1116,7 @@ abstract class CommonObject $sql.= " WHERE ec.element_id = ".$id; $sql.= " AND ec.fk_socpeople = c.rowid"; if ($source == 'internal') $sql.= " AND c.entity IN (0,".$conf->entity.")"; - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")"; + if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('socpeople').")"; $sql.= " AND ec.fk_c_type_contact = tc.rowid"; $sql.= " AND tc.element = '".$element."'"; $sql.= " AND tc.source = '".$source."'"; @@ -1408,18 +1408,19 @@ abstract class CommonObject * Setter generic. Update a specific field into database. * Warning: Trigger is run only if param trigkey is provided. * - * @param string $field Field to update - * @param mixed $value New value - * @param string $table To force other table element or element line (should not be used) - * @param int $id To force other object id (should not be used) - * @param string $format Data format ('text', 'date'). 'text' is used if not defined - * @param string $id_field To force rowid field name. 'rowid' is used if not defined - * @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none' - * @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY') - * @return int <0 if KO, >0 if OK + * @param string $field Field to update + * @param mixed $value New value + * @param string $table To force other table element or element line (should not be used) + * @param int $id To force other object id (should not be used) + * @param string $format Data format ('text', 'date'). 'text' is used if not defined + * @param string $id_field To force rowid field name. 'rowid' is used if not defined + * @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none' + * @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY') + * @param string $fk_user_field Name of field to save user id making change + * @return int <0 if KO, >0 if OK * @see updateExtraField */ - function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='') + function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='', $fk_user_field='fk_user_modif') { global $user,$langs,$conf; @@ -1428,24 +1429,26 @@ abstract class CommonObject if (empty($format)) $format='text'; if (empty($id_field)) $id_field='rowid'; - $fk_user_field = 'fk_user_modif'; - $error=0; $this->db->begin(); // Special case if ($table == 'product' && $field == 'note_private') $field='note'; - if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { - $fk_user_field = 'fk_user_mod'; - } + if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) $fk_user_field = 'fk_user_mod'; $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; + if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); - if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; - elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; + + if ($fk_user_field) + { + if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; + elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; + } + $sql.= " WHERE ".$id_field." = ".$id; dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG); @@ -2787,11 +2790,12 @@ abstract class CommonObject * @param int $targetid Object target id (if not defined, id of object) * @param string $targettype Object target type (if not defined, elemennt name of object) * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided - * @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type. - * @return int <0 if KO, >0 if OK + * @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type. + * @param string $orderby SQL 'ORDER BY' clause + * @return int <0 if KO, >0 if OK * @see add_object_linked, updateObjectLinked, deleteObjectLinked */ - function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1) + function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1,$orderby='sourcetype') { global $conf; @@ -2847,7 +2851,7 @@ abstract class CommonObject $sql.= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')"; $sql.= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')"; } - $sql .= ' ORDER BY sourcetype'; + $sql .= ' ORDER BY '.$orderby; dol_syslog(get_class($this)."::fetchObjectLink", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3590,12 +3594,12 @@ abstract class CommonObject * @param Societe $buyer Object thirdparty who buy * @return void */ - function formAddObjectLine($dateSelector,$seller,$buyer) + function formAddObjectLine($dateSelector, $seller, $buyer) { global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; - //Line extrafield + // Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafieldsline = new ExtraFields($this->db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); @@ -3673,7 +3677,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3712,7 +3716,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; @@ -3919,23 +3923,26 @@ abstract class CommonObject $var = true; $i = 0; - foreach ($this->lines as $line) + if (! empty($this->lines)) { - if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) + foreach ($this->lines as $line) { - if (empty($line->fk_parent_line)) + if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) { - $parameters=array('line'=>$line,'var'=>$var,'i'=>$i); - $action=''; - $hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($line->fk_parent_line)) + { + $parameters=array('line'=>$line,'var'=>$var,'i'=>$i); + $action=''; + $hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + } + } + else + { + $this->printOriginLine($line, $var, $restrictlist); } - } - else - { - $this->printOriginLine($line, $var, $restrictlist); - } - $i++; + $i++; + } } } @@ -4380,6 +4387,9 @@ abstract class CommonObject $ecmfile->gen_or_uploaded = 'generated'; $ecmfile->description = ''; // indexed content $ecmfile->keyword = ''; // keyword content + $ecmfile->src_object_type = $this->table_element; + $ecmfile->src_object_id = $this->id; + $result = $ecmfile->create($user); if ($result < 0) { @@ -4556,6 +4566,8 @@ abstract class CommonObject return 0; } + $this->array_options=array(); + if (! is_array($optionsArray)) { // If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. @@ -4597,7 +4609,7 @@ abstract class CommonObject $sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields"; $sql.= " WHERE fk_object = ".$rowid; - dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); + //dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose $resql=$this->db->query($sql); if ($resql) { @@ -4789,6 +4801,10 @@ abstract class CommonObject $new_array_options[$key] = $this->db->idate($this->array_options[$key]); break; case 'datetime': + // If data is a string instead of a timestamp, we convert it + if (! is_int($this->array_options[$key])) { + $this->array_options[$key] = strtotime($this->array_options[$key]); + } $new_array_options[$key] = $this->db->idate($this->array_options[$key]); break; case 'link': @@ -4895,14 +4911,14 @@ abstract class CommonObject } /** - * Update an exta field value for the current object. + * Update an extra field value for the current object. * Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * * @param string $key Key of the extrafield (without starting 'options_') * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) * @param User $userused Object user * @return int -1=error, O=did nothing, 1=OK - * @see setValueFrom + * @see setValueFrom, insertExtraFields */ function updateExtraField($key, $trigger, $userused) { @@ -5014,7 +5030,7 @@ abstract class CommonObject * @param array $val Array of properties for field to show * @param string $key Key of attribute * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) - * @param string $moreparam To add more parametes on html input tag + * @param string $moreparam To add more parameters on html input tag * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string|int $showsize Value for css to define size. May also be a numeric. @@ -5042,11 +5058,11 @@ abstract class CommonObject $type = 'varchar'; // convert varchar(xx) int varchar $size = $reg[1]; } - elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar + elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) into varchar + elseif (preg_match('/double/', $type)) $type = 'double'; // convert double(xx) into double if (is_array($val['arrayofkeyval'])) $type='select'; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link'; - //$elementtype=$this->attribute_elementtype[$key]; // seems to not be used $default=$val['default']; $computed=$val['computed']; $unique=$val['unique']; @@ -5069,7 +5085,7 @@ abstract class CommonObject else return ''; } - // Use in priorit showsize from parameters, then $val['css'] then autodefine + // Use in priority showsize from parameters, then $val['css'] then autodefine if (empty($showsize) && ! empty($val['css'])) { $showsize = $val['css']; @@ -5117,7 +5133,6 @@ abstract class CommonObject } } //var_dump($showsize.' '.$size); - if (in_array($type,array('date','datetime'))) { $tmp=explode(',',$size); @@ -5540,6 +5555,41 @@ abstract class CommonObject // If prefix is 'search_', field is used as a filter, we use a common text field. $out=''; } + elseif ($type == 'array') + { + $newval = $val; + $newval['type'] = 'varchar(256)'; + + $out=''; + + $inputs = array(); + if(! empty($value)) { + foreach($value as $option) { + $out.= ' '; + $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'
'; + } + } + + $out.= ''; + + $newInput = ' '; + $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; + + if(! empty($conf->use_javascript_ajax)) { + $out.= ' + '; + } + } if (!empty($hidden)) { $out=''; } @@ -5589,7 +5639,6 @@ abstract class CommonObject if (is_array($val['arrayofkeyval'])) $type='select'; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link'; - //$elementtype=$this->attribute_elementtype[$key]; // seems to not be used $default=$val['default']; $computed=$val['computed']; $unique=$val['unique']; @@ -5664,11 +5713,19 @@ abstract class CommonObject elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value=$this->getLibStatut(3); elseif ($type == 'date') { - $value=dol_print_date($value,'day'); + if(! empty($value)) { + $value=dol_print_date($value,'day'); + } else { + $value=''; + } } elseif ($type == 'datetime') { - $value=dol_print_date($value,'dayhour'); + if(! empty($value)) { + $value=dol_print_date($value,'dayhour'); + } else { + $value=''; + } } elseif ($type == 'double') { @@ -5904,6 +5961,10 @@ abstract class CommonObject { $value=preg_replace('/./i','*',$value); } + elseif ($type == 'array') + { + $value = implode('
', $value); + } //print $type.'-'.$size; $out=$value; @@ -5929,17 +5990,29 @@ abstract class CommonObject $out = ''; - if (count($extrafields->attribute_label) > 0) + if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) { $out .= "\n"; $out .= ' '; $out .= "\n"; $e = 0; - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label) { - if (empty($extrafields->attribute_list[$key])) continue; // 0 = Never visible field - if (($mode == 'create' || $mode == 'edit') && abs($extrafields->attribute_list[$key]) != 1 && abs($extrafields->attribute_list[$key]) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + $enabled = 1; + if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key])) + { + $enabled = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1); + } + + $perms = 1; + if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) + { + $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1); + } + + if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + if (empty($perms)) continue; // Load language if required if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); @@ -5970,18 +6043,18 @@ abstract class CommonObject } else { $value = $this->array_options["options_" . $key]; // No GET, no POST, no default value, so we take value of object. } + //var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value); break; } - //var_dump($value); - if ($extrafields->attribute_type[$key] == 'separate') + if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { - $out .= $extrafields->showSeparator($key); + $out .= $extrafields->showSeparator($key, $this); } else { $csstyle=''; - $class=(!empty($extrafields->attribute_hidden[$key]) ? 'hideobject ' : ''); + $class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); if (is_array($params) && count($params)>0) { if (array_key_exists('style',$params)) { $csstyle=$params['style']; @@ -5997,27 +6070,27 @@ abstract class CommonObject $out .= ''; - if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } } - if($action == 'selectlines'){ $colspan++; } + if ($action == 'selectlines') { $colspan++; } // Convert date into timestamp format (value in memory must be a timestamp) - if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) + if (in_array($extrafields->attributes[$this->table_element]['type'][$key],array('date','datetime'))) { - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]); + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]); } // Convert float submited string into real php numeric (value in memory must be a php numeric) - if (in_array($extrafields->attribute_type[$key],array('price','double'))) + if (in_array($extrafields->attributes[$this->table_element]['type'][$key],array('price','double'))) { - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix,'int',3)):$this->array_options['options_'.$key]; + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)):$this->array_options['options_'.$key]; } $labeltoshow = $langs->trans($label); - if($extrafields->attribute_required[$key]) + if ($extrafields->attributes[$this->table_element]['required'][$key]) { $labeltoshow = ''.$labeltoshow.''; } @@ -6571,7 +6644,7 @@ abstract class CommonObject { if(empty($this->{$field})) { - $queryarray[$field] = NULL; + $queryarray[$field] = null; } else { @@ -6580,7 +6653,14 @@ abstract class CommonObject } else if($this->isArray($info)) { - $queryarray[$field] = serialize($this->{$field}); + if(! empty($this->{$field})) { + if(! is_array($this->{$field})) { + $this->{$field} = array($this->{$field}); + } + $queryarray[$field] = serialize($this->{$field}); + } else { + $queryarray[$field] = null; + } } else if($this->isInt($info)) { @@ -6624,9 +6704,13 @@ abstract class CommonObject } elseif($this->isArray($info)) { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); + if(! empty($obj->{$field})) { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); + } else { + $this->{$field} = array(); + } } elseif($this->isInt($info)) { @@ -6714,7 +6798,7 @@ abstract class CommonObject if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); - if ($this->fields[$key]['notnull'] == 1 && ! isset($values[$key])) + if ($this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default'])) { $error++; $this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']); @@ -6784,14 +6868,16 @@ abstract class CommonObject */ public function fetchCommon($id, $ref = null, $morewhere = '') { - if (empty($id) && empty($ref)) return false; + if (empty($id) && empty($ref) && empty($morewhere)) return -1; $sql = 'SELECT '.$this->getFieldList(); $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - if (!empty($id)) $sql.= ' WHERE rowid = '.$id; - else $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); - if ($morewhere) $sql.=$morewhere; + if (!empty($id)) $sql.= ' WHERE rowid = '.$id; + elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); + else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare + if ($morewhere) $sql.= $morewhere; + $sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record $res = $this->db->query($sql); if ($res) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index c4ccd6fe982..0ee73799bcb 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -97,7 +97,7 @@ class Conf // First level object // TODO Remove this part. $this->expedition_bon = new stdClass(); - $this->livraison_bon = new stdClass(); + $this->livraison_bon = new stdClass(); $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); @@ -107,12 +107,13 @@ class Conf $this->propal = new stdClass(); $this->facture = new stdClass(); $this->contrat = new stdClass(); - $this->usergroup = new stdClass(); + $this->usergroup = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); + $this->expensereport = new stdClass(); + $this->productbatch = new stdClass(); } @@ -346,6 +347,9 @@ class Conf $this->fournisseur->facture=new stdClass(); $this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture"; $this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp"; + $this->supplierproposal=new stdClass(); + $this->supplierproposal->dir_output=$rootfordata."/supplier_proposal"; + $this->supplierproposal->dir_temp=$rootfordata."/supplier_proposal/temp"; $this->fournisseur->payment=new stdClass(); $this->fournisseur->payment->dir_output =$rootfordata."/fournisseur/payment"; $this->fournisseur->payment->dir_temp =$rootfordata."/fournisseur/payment/temp"; @@ -361,6 +365,9 @@ class Conf $this->supplier_invoice->enabled=1; $this->supplier_invoice->dir_output=$rootfordata."/fournisseur/facture"; $this->supplier_invoice->dir_temp=$rootfordata."/fournisseur/facture/temp"; + $this->supplierproposal=new stdClass(); + $this->supplierproposal->dir_output=$rootfordata."/supplier_proposal"; + $this->supplierproposal->dir_temp=$rootfordata."/supplier_proposal/temp"; } } @@ -375,6 +382,10 @@ class Conf $this->service->dir_output=$rootfordata."/produit"; $this->service->dir_temp =$rootfordata."/produit/temp"; + // Module productbatch + $this->productbatch->multidir_output=array($this->entity => $rootfordata."/produitlot"); + $this->productbatch->multidir_temp =array($this->entity => $rootfordata."/produitlot/temp"); + // Module contrat $this->contrat->dir_output=$rootfordata."/contracts"; $this->contrat->dir_temp =$rootfordata."/contracts/temp"; @@ -505,7 +516,7 @@ class Conf // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. - // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list + // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list if (! empty($this->modules_parts['moduleforexternal'])) foreach($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL.=",$key"; diff --git a/htdocs/core/class/cookie.class.php b/htdocs/core/class/cookie.class.php deleted file mode 100644 index 1d28861a44e..00000000000 --- a/htdocs/core/class/cookie.class.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/class/cookie.class.php - * \ingroup core - * \brief File of class to manage cookies - */ - - -/** - * Class to manage cookies. - * This class is used by external module multicompany but will be removed soon only and must not be used by - * - * @deprecated PHP already provide function to read/store a cookie. No need to use a dedicated class. Also storing sensitive information into cookie is forbidden, so encryption is useless. - * If a data is sensitive, it must be stored into database (if we need a long term retention) or into session. - */ -class DolCookie -{ - private $_myKey; - private $_iv; - - var $myCookie; - var $myValue; - var $myExpire; - var $myPath; - var $myDomain; - var $mySecure; - var $cookie; - - /** - * Constructor - * - * @param string $key Personnal key - * @deprecated - */ - function __construct($key = '') - { - $this->_myKey = hash('sha256', $key, TRUE); - $this->_iv = md5(md5($this->_myKey)); - $this->cookie = ""; - $this->myCookie = ""; - $this->myValue = ""; - } - - - /** - * Encrypt en create the cookie - * - * @return void - */ - private function _cryptCookie() - { - if (!empty($this->_myKey) && !empty($this->_iv)) - { - $valuecrypt = base64_encode($this->myValue); - $this->cookie = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->_myKey, $valuecrypt, MCRYPT_MODE_CBC, $this->_iv)); - } - else - { - $this->cookie = $this->myValue; - } - - setcookie($this->myCookie, $this->cookie, $this->myExpire, $this->myPath, $this->myDomain, $this->mySecure); - } - - /** - * Decrypt the cookie - * - * @return string - */ - private function _decryptCookie() - { - if (!empty($this->_myKey) && !empty($this->_iv)) - { - $this->cookie = $_COOKIE[$this->myCookie]; - $this->myValue = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->_myKey, base64_decode($this->cookie), MCRYPT_MODE_CBC, $this->_iv)); - - return(base64_decode($this->myValue)); - } - else - { - return($_COOKIE[$this->myCookie]); - } - } - - /** - * Set and create the cookie - * - * @param string $cookie Cookie name - * @param string $value Cookie value - * @param integer $expire Expiration - * @param string $path Path of cookie - * @param string $domain Domain name - * @param int $secure 0 or 1 - * @return void - */ - public function setCookie($cookie, $value, $expire=0, $path="/", $domain="", $secure=0) - { - $this->myCookie = $cookie; - $this->myValue = $value; - $this->myExpire = $expire; - $this->myPath = $path; - $this->myDomain = $domain; - $this->mySecure = $secure; - - //print 'key='.$this->myKey.' name='.$this->myCookie.' value='.$this->myValue.' expire='.$this->myExpire; - - $this->_cryptCookie(); - } - - /** - * Get the cookie - * - * @param string $cookie Cookie name - * @return string Decrypted value - */ - public function getCookie($cookie) - { - $this->myCookie = $cookie; - - $decryptValue = $this->_decryptCookie(); - - return $decryptValue; - } - -} - diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index aa500ab64df..860d89afea8 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -153,7 +153,7 @@ class DolEditor { global $conf,$langs; - $fullpage=False; + $fullpage=false; if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) { $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index ba7a67be3cb..3ad22f87c03 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -674,7 +674,7 @@ class DolGraph $group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values $group->legend->setSpace(0); $group->legend->setPadding(2,2,2,2); - $group->legend->setPosition(NULL,0.1); + $group->legend->setPosition(null, 0.1); $group->legend->setBackgroundColor($colorsemitrans); if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid); @@ -734,7 +734,7 @@ class DolGraph $plot->barShadow->setSize($this->SetShading); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(160, 160, 160, 50)); - $plot->barShadow->smooth(TRUE); + $plot->barShadow->smooth(true); //$plot->setSize(1, 0.96); //$plot->setCenter(0.5, 0.52); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index bf9bcf587f8..62fd4335315 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -39,38 +39,50 @@ class ExtraFields var $db; // type of element (for what object is the extrafield) + // @deprecated var $attribute_elementtype; - // Array with type of the extra field + // @deprecated var $attribute_type; // Array with label of extra field + // @deprecated var $attribute_label; // Array with size of extra field + // @deprecated var $attribute_size; // array with list of possible values for some types of extra fields + // @deprecated var $attribute_choice; // Array to store compute formula for computed fields + // @deprecated var $attribute_computed; // Array to store default value + // @deprecated var $attribute_default; // Array to store if attribute is unique or not + // @deprecated var $attribute_unique; // Array to store if attribute is required or not + // @deprecated var $attribute_required; // Array to store parameters of attribute (used in select type) + // @deprecated var $attribute_param; // Array to store position of attribute + // @deprecated var $attribute_pos; // Array to store if attribute is editable regardless of the document status + // @deprecated var $attribute_alwayseditable; // Array to store permission to check + // @deprecated var $attribute_perms; // Array to store language file to translate label of values + // @deprecated var $attribute_langfile; // Array to store if field is visible by default on list + // @deprecated var $attribute_list; - // Array to store if extra field is hidden - var $attribute_hidden; // warning, do not rely on this. If your module need a hidden data, it must use its own table. // New array to store extrafields definition var $attributes; @@ -126,7 +138,6 @@ class ExtraFields $this->attribute_perms = array(); $this->attribute_langfile = array(); $this->attribute_list = array(); - $this->attribute_hidden = array(); } /** @@ -137,14 +148,14 @@ class ExtraFields * @param int $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price','phone','mail','password','url','select','checkbox','separate',...) * @param int $pos Position of attribute * @param string $size Size/length of attribute - * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) + * @param string $elementtype Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not * @param string $default_value Defaulted value (In database. use the default_value feature for default value on screen. Example: '', '0', 'null', 'avalue') * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibilty (0=never visible, 1=visible on list+forms, 2=list onyl, 3=form only) + * @param string $list Visibilty ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string') * @param int $notused Deprecated. * @param string $computed Computed value * @param string $entity Entity of extrafields (for multicompany modules) @@ -152,7 +163,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $computed='', $entity='', $langfile='', $enabled='1') + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $computed='', $entity='', $langfile='', $enabled='1') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -198,11 +209,11 @@ class ExtraFields * @param string $default_value Default value for field (in database) * @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option')) * @param string $perms Permission - * @param int $list Into list view by default + * @param string $list Into list view by default * @param string $computed Computed value * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0, $computed='') + private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list='0', $computed='') { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; @@ -288,7 +299,7 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibily + * @param string $list Visibily * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -297,7 +308,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') { global $conf,$user; @@ -306,7 +317,7 @@ class ExtraFields // Clean parameters if (empty($pos)) $pos=0; - if (empty($list)) $list=0; + if (empty($list)) $list='0'; if (empty($required)) $required=0; if (empty($unique)) $unique=0; if (empty($alwayseditable)) $alwayseditable=0; @@ -361,7 +372,7 @@ class ExtraFields $sql.= " ".$alwayseditable.","; $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; - $sql.= " ".$list.","; + $sql.= " '".$this->db->escape($list)."',"; $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; @@ -496,7 +507,7 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibility + * @param string $list Visibility * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -605,7 +616,7 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visiblity + * @param string $list Visiblity * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -614,7 +625,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') { global $conf, $user; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled); @@ -624,7 +635,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; if (empty($pos)) $pos=0; - if (empty($list)) $list=0; + if (empty($list)) $list='0'; if (empty($required)) $required=0; if (empty($unique)) $unique=0; if (empty($alwayseditable)) $alwayseditable=0; @@ -688,7 +699,7 @@ class ExtraFields $sql.= " ".$pos.","; $sql.= " '".$this->db->escape($alwayseditable)."',"; $sql.= " '".$this->db->escape($params)."',"; - $sql.= " ".$list.", "; + $sql.= " '".$this->db->escape($list)."', "; $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; @@ -729,7 +740,7 @@ class ExtraFields { global $conf; - if (empty($elementtype) ) return array(); + if (empty($elementtype)) return array(); if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; @@ -758,10 +769,10 @@ class ExtraFields // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; - if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; + if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element $sql.= " ORDER BY pos"; $resql=$this->db->query($sql); @@ -812,6 +823,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); + $this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled; $this->attributes[$tab->elementtype]['loaded']=1; } @@ -832,16 +844,17 @@ class ExtraFields * Return HTML string to put an input field into a page * Code very similar with showInputField of common object * - * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) - * @param string $moreparam To add more parametes on html input tag - * @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names) - * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) - * @param int $objectid Current object id + * @param string $key Key of attribute + * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string $moreparam To add more parametes on html input tag + * @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names) + * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) + * @param int $objectid Current object id + * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data * @return string */ - function showInputField($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss='', $objectid=0) + function showInputField($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss='', $objectid=0, $extrafieldsobjectkey='') { global $conf,$langs,$form; @@ -855,18 +868,36 @@ class ExtraFields $keyprefix = $keyprefix.'options_'; // Because we work on extrafields - $label=$this->attribute_label[$key]; - $type =$this->attribute_type[$key]; - $size =$this->attribute_size[$key]; - $elementtype=$this->attribute_elementtype[$key]; // Seems not used - $default=$this->attribute_default[$key]; - $computed=$this->attribute_computed[$key]; - $unique=$this->attribute_unique[$key]; - $required=$this->attribute_required[$key]; - $param=$this->attribute_param[$key]; - $langfile=$this->attribute_langfile[$key]; - $list=$this->attribute_list[$key]; - $hidden=$this->attribute_hidden[$key]; + if (! empty($extrafieldsobjectkey)) + { + $label=$this->attributes[$extrafieldsobjectkey]['label'][$key]; + $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; + $size=$this->attributes[$extrafieldsobjectkey]['size'][$key]; + $default=$this->attributes[$extrafieldsobjectkey]['default'][$key]; + $computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key]; + $unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key]; + $required=$this->attributes[$extrafieldsobjectkey]['required'][$key]; + $param=$this->attributes[$extrafieldsobjectkey]['param'][$key]; + $perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); + $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; + $list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); + $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + } + else // Old usage + { + $label=$this->attribute_label[$key]; + $type =$this->attribute_type[$key]; + $size =$this->attribute_size[$key]; + $elementtype=$this->attribute_elementtype[$key]; // Seems not used + $default=$this->attribute_default[$key]; + $computed=$this->attribute_computed[$key]; + $unique=$this->attribute_unique[$key]; + $required=$this->attribute_required[$key]; + $param=$this->attribute_param[$key]; + $langfile=$this->attribute_langfile[$key]; + $list=$this->attribute_list[$key]; + $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + } if ($computed) { @@ -1008,7 +1039,10 @@ class ExtraFields $out.=''; } $out.=''; } @@ -1063,6 +1097,10 @@ class ExtraFields $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { + // can use curent entity filter + if (strpos($InfoFieldList[4], '$ENTITY$')!==false) { + $InfoFieldList[4]=str_replace('$ENTITY$',$conf->entity,$InfoFieldList[4]); + } // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); @@ -1371,7 +1409,7 @@ class ExtraFields * @param string $key Key of attribute * @param string $value Value to show * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data + * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data * @return string Formated value */ function showOutputField($key, $value, $moreparam='', $extrafieldsobjectkey='') @@ -1380,7 +1418,6 @@ class ExtraFields if (! empty($extrafieldsobjectkey)) { - $elementtype=$this->attributes[$extrafieldsobjectkey]['elementtype'][$key]; // seems not used $label=$this->attributes[$extrafieldsobjectkey]['label'][$key]; $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; $size=$this->attributes[$extrafieldsobjectkey]['size'][$key]; @@ -1389,14 +1426,13 @@ class ExtraFields $unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key]; $required=$this->attributes[$extrafieldsobjectkey]['required'][$key]; $param=$this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms=$this->attributes[$extrafieldsobjectkey]['perms'][$key]; + $perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list=$this->attributes[$extrafieldsobjectkey]['list'][$key]; - $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); + $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else // Old usage { - $elementtype=$this->attribute_elementtype[$key]; // seems not used $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; $size=$this->attribute_size[$key]; @@ -1405,10 +1441,10 @@ class ExtraFields $unique=$this->attribute_unique[$key]; $required=$this->attribute_required[$key]; $param=$this->attribute_param[$key]; - $perms=$this->attribute_perms[$key]; + $perms=dol_eval($this->attribute_perms[$key], 1); $langfile=$this->attribute_langfile[$key]; - $list=$this->attribute_list[$key]; - $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $list=dol_eval($this->attribute_list[$key], 1); + $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. @@ -1468,7 +1504,8 @@ class ExtraFields } elseif ($type == 'select') { - $value=$param['options'][$value]; + if ($langfile && $param['options'][$value]) $value=$langs->trans($param['options'][$value]); + else $value=$param['options'][$value]; } elseif ($type == 'sellist') { @@ -1739,28 +1776,35 @@ class ExtraFields * Return HTML string to print separator extrafield * * @param string $key Key of attribute - * @return string + * @param string $object Object + * @return string HTML code with line for separator */ - function showSeparator($key) + function showSeparator($key, $object) { - $out = ''.$this->attribute_label[$key].''; + global $langs; + + $out = ''; + $out.= $langs->trans($this->attributes[$object->table_element]['label'][$key]); + $out.= ''; return $out; } /** * Fill array_options property of object by extrafields value (using for data sent by forms) * - * @param array $extralabels $array of extrafields + * @param array $extralabels $array of extrafields (@deprecated) * @param object $object Object * @param string $onlykey Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset. * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) */ - function setOptionalsFromPost($extralabels,&$object,$onlykey='') + function setOptionalsFromPost($extralabels, &$object, $onlykey='') { global $_POST, $langs; $nofillrequired='';// For error when required field left blank $error_field_required = array(); + if (is_array($this->attributes[$object->table_element]['label'])) $extralabels=$this->attributes[$object->table_element]['label']; + if (is_array($extralabels)) { // Get extra fields @@ -1768,11 +1812,27 @@ class ExtraFields { if (! empty($onlykey) && $key != $onlykey) continue; - $key_type = $this->attribute_type[$key]; - if ($this->attribute_required[$key] && empty($_POST["options_".$key])) // Check if empty without GETPOST, value can be alpha, int, array, etc... + $key_type = $this->attributes[$object->table_element]['type'][$key]; + if ($key_type == 'separate') continue; + + $enabled = 1; + if (isset($this->attributes[$object->table_element]['list'][$key])) { + $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1); + } + $perms = 1; + if (isset($this->attributes[$object->table_element]['perms'][$key])) + { + $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1); + } + if (empty($enabled)) continue; + if (empty($perms)) continue; + + if ($this->attributes[$object->table_element]['required'][$key] && empty($_POST["options_".$key])) // Check if empty without GETPOST, value can be alpha, int, array, etc... + { + //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; $nofillrequired++; - $error_field_required[] = $value; + $error_field_required[] = $langs->transnoentitiesnoconv($value); } if (in_array($key_type,array('date'))) @@ -1798,13 +1858,14 @@ class ExtraFields } else if (in_array($key_type,array('price','double'))) { - $value_arr=GETPOST("options_".$key); + $value_arr=GETPOST("options_".$key, 'alpha'); $value_key=price2num($value_arr); } else { $value_key=GETPOST("options_".$key); } + $object->array_options["options_".$key]=$value_key; } @@ -1825,7 +1886,7 @@ class ExtraFields /** * return array_options array of data of extrafields value of object sent by a search form * - * @param array $extralabels $array of extrafields + * @param array $extralabels $array of extrafields (@deprecated) * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @return array|int array_options set or 0 if no value @@ -1834,13 +1895,15 @@ class ExtraFields { global $_POST; + if (is_array($this->attributes[$object->table_element]['label'])) $extralabels=$this->attributes[$object->table_element]['label']; + $array_options = array(); if (is_array($extralabels)) { // Get extra fields foreach ($extralabels as $key => $value) { - $key_type = $this->attribute_type[$key]; + $key_type = $this->attributes[$object->table_element]['type'][$key]; if (in_array($key_type,array('date','datetime'))) { diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index e25709fd303..c3a40599877 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -94,6 +94,9 @@ class FileUpload elseif ($element == 'product') { $dir_output = $conf->product->multidir_output[$conf->entity]; } + elseif ($element == 'productbatch') { + $dir_output = $conf->productbatch->multidir_output[$conf->entity]; + } elseif ($element == 'action') { $pathname = 'comm/action'; $filename='actioncomm'; $dir_output=$conf->agenda->dir_output; @@ -222,7 +225,7 @@ class FileUpload * getFileObject * * @param string $file_name Filename - * @return stdClass|NULL + * @return stdClass|null */ protected function getFileObject($file_name) { diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 8cc2c62bee7..cd33f1d8d02 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -80,28 +80,31 @@ class HookManager $this->contextarray=array_unique(array_merge($arraycontext,$this->contextarray)); // All contexts are concatenated - foreach($conf->modules_parts['hooks'] as $module => $hooks) + foreach($conf->modules_parts['hooks'] as $module => $hooks) // Loop on each module that brings hooks { - if ($conf->$module->enabled) + if (empty($conf->$module->enabled)) continue; + + //dol_syslog(get_class($this).'::initHooks module='.$module.' arraycontext='.join(',',$arraycontext)); + foreach($arraycontext as $context) { - foreach($arraycontext as $context) + if (is_array($hooks)) $arrayhooks=$hooks; // New system + else $arrayhooks=explode(':',$hooks); // Old system (for backward compatibility) + + if (in_array($context, $arrayhooks) || in_array('all', $arrayhooks)) // We instantiate action class only if initialized hook is handled by module { - if (is_array($hooks)) $arrayhooks=$hooks; // New system - else $arrayhooks=explode(':',$hooks); // Old system (for backward compatibility) - if (in_array($context,$arrayhooks) || in_array('all',$arrayhooks)) // We instantiate action class only if hook is required + // Include actions class overwriting hooks + if (! is_object($this->hooks[$context][$module])) // If set, class was already loaded { $path = '/'.$module.'/class/'; $actionfile = 'actions_'.$module.'.class.php'; - $pathroot = ''; - // Include actions class overwriting hooks - dol_syslog('Loading hook:' . $actionfile, LOG_INFO); + dol_syslog(get_class($this).'::initHooks Loading hook class for context '.$context.": ".$actionfile, LOG_INFO); $resaction=dol_include_once($path.$actionfile); if ($resaction) { - $controlclassname = 'Actions'.ucfirst($module); - $actionInstance = new $controlclassname($this->db); - $this->hooks[$context][$module] = $actionInstance; + $controlclassname = 'Actions'.ucfirst($module); + $actionInstance = new $controlclassname($this->db); + $this->hooks[$context][$module] = $actionInstance; } } } @@ -117,7 +120,7 @@ class HookManager * @param array $parameters Array of parameters * @param Object $object Object to use hooks on * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * $this->error or this->errors are also defined by class called by this function if error. @@ -179,9 +182,11 @@ class HookManager 'printTabsHead', 'printObjectLine', 'printObjectSubLine', + 'restrictedArea', 'sendMail', 'sendMailAfter', - 'showLinkToObjectBlock' + 'showLinkToObjectBlock', + 'setContentSecurityPolicy' ) )) $hooktype='addreplace'; @@ -213,20 +218,19 @@ class HookManager $this->resNbOfHooks++; - dol_syslog(get_class($this).'::executeHooks a qualified hook was found for method='.$method.' module='.$module." action=".$action." context=".$context); - $modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method to avoid running twice // Clean class (an error may have been set from a previous call of another method for same module/hook) $actionclassinstance->error=0; $actionclassinstance->errors=array(); + dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", action=".$action." context=".$context, LOG_DEBUG); + // Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; $parameters['currentcontext'] = $context; // Hooks that must return int (hooks with type 'addreplace') if ($hooktype == 'addreplace') { - dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); $resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c7fa142daf1..642fe099593 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -16,6 +16,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -642,16 +643,17 @@ class Form /** * Return combo list of activated countries, into language of user * - * @param string $selected Id or Code or Label of preselected country - * @param string $htmlname Name of html select object - * @param string $htmloption Options html on select object - * @param integer $maxlength Max length for labels (0=no limit) - * @param string $morecss More css class - * @param string $usecodeaskey 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key - * @param int $showempty Show empty choice - * @return string HTML string with select + * @param string $selected Id or Code or Label of preselected country + * @param string $htmlname Name of html select object + * @param string $htmloption Options html on select object + * @param integer $maxlength Max length for labels (0=no limit) + * @param string $morecss More css class + * @param string $usecodeaskey 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key + * @param int $showempty Show empty choice + * @param int $disablefavorites Disable favorites + * @return string HTML string with select */ - function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1) + function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1, $disablefavorites=0) { global $conf,$langs; @@ -692,13 +694,14 @@ class Form $i++; } - array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); + if (empty($disablefavorites)) array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); + else $countryArray = dol_sort_array($countryArray, 'label'); foreach ($countryArray as $row) { if (empty($showempty) && empty($row['rowid'])) continue; - if ($row['favorite'] && $row['code_iso']) $atleastonefavorite++; + if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) $atleastonefavorite++; if (empty($row['favorite']) && $atleastonefavorite) { $atleastonefavorite=0; @@ -1330,7 +1333,7 @@ class Form if ($showsoc > 0) $sql.= " , s.nom as company"; $sql.= " FROM ".MAIN_DB_PREFIX ."socpeople as sp"; if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; + $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid; if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0"; $sql.= " ORDER BY sp.lastname ASC"; @@ -2901,7 +2904,7 @@ class Form dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); - print ''; if ($addempty) print ''; foreach($this->cache_availability as $id => $arrayavailability) { @@ -3469,8 +3472,8 @@ class Form if ($selected) { require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; $bankstatic=new Account($this->db); - $bankstatic->fetch($selected); - print $bankstatic->getNomUrl(1); + $result = $bankstatic->fetch($selected); + if ($result) print $bankstatic->getNomUrl(1); } else { print " "; } @@ -4772,10 +4775,10 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date (emptydate must be 0). + * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name - * @param int $h 1=Show also hours (-1 has same effect, but hour and minutes are prefilled with 23:59 if $set_time = -1) - * @param int $m 1=Show also minutes + * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty + * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty * @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only * @param string $form_name Not used * @param int $d 1=Show days, month, years @@ -4810,7 +4813,7 @@ class Form } // Analysis of the pre-selection date - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) // deprecated usage { // Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' $syear = (! empty($reg[1])?$reg[1]:''); @@ -4848,6 +4851,8 @@ class Form $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_MIN; $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_SEC; } + if ($h == 3) $shour = ''; + if ($m == 3) $smin = ''; // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' $usecalendar='combo'; @@ -5335,7 +5340,8 @@ class Form $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t"; if ($objecttmp->ismultientitymanaged == 2) if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE t.entity IN (".getEntity($objecttmp->table_element).")"; + $sql.= " WHERE 1=1"; + if(! empty($objecttmp->ismultientitymanaged)) $sql.= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->societe_id)) { if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->societe_id; @@ -5536,7 +5542,7 @@ class Form /** - * Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL. + * Return a HTML select string, built from an array of key+value, but content returned into select come from an Ajax call of an URL. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * * @param string $htmlname Name of html select area @@ -5551,7 +5557,7 @@ class Form * @param string $placeholder String to use as placeholder * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string - * @see ajax_combobox in ajax.lib.php + * @see selectArrayFilter, ajax_combobox in ajax.lib.php */ static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { @@ -5612,7 +5618,7 @@ class Form /* Code to execute a GET when we select a value */ $(".'.$htmlname.'").change(function() { var selected = $(".'.$htmlname.'").val(); - console.log("We select "+selected) + console.log("We select in selectArrayAjax the entry "+selected) $(".'.$htmlname.'").val(""); /* reset visible combo value */ $.each( saveRemoteData, function( key, value ) { if (key == selected) @@ -5638,7 +5644,7 @@ class Form } /** - * Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL. + * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * * @param string $htmlname Name of html select area @@ -5653,7 +5659,7 @@ class Form * @param string $placeholder String to use as placeholder * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string - * @see ajax_combobox in ajax.lib.php + * @see selectArrayAjax, ajax_combobox in ajax.lib.php */ static function selectArrayFilter($htmlname, $array, $id='', $moreparam='', $disableFiltering=0, $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { @@ -5702,8 +5708,9 @@ class Form var urlBase = data.url; var separ = urlBase.indexOf("?") >= 0 ? "&" : "?"; - - saveRemoteData[data.id].url = urlBase + separ + "sall=" + params.term;'; + /* console.log("params.term="+params.term); */ + /* console.log("params.term encoded="+encodeURIComponent(params.term)); */ + saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term);'; } if(! $disableFiltering) { @@ -5907,7 +5914,7 @@ class Form -
+