Merge branch 'develop' into patch-modulebuilder-supportsellist

This commit is contained in:
delcroix Patrick 2018-05-22 22:24:20 +02:00 committed by GitHub
commit c85d216f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3910 changed files with 217779 additions and 47998 deletions

0
.gitignore vendored Executable file → Normal file
View File

View File

@ -3,7 +3,7 @@
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/
# We use dist: precise to have php 5.3 available # We use dist: precise to have php 5.3 available
dist: precise dist: trusty
sudo: required sudo: required
language: php language: php
@ -31,7 +31,6 @@ addons:
- pgloader - pgloader
php: php:
- '5.3'
- '5.4' - '5.4'
- '5.5' - '5.5'
- '5.6' - '5.6'
@ -64,8 +63,6 @@ matrix:
- php: nightly - php: nightly
# We exclude some combinations not usefull to save Travis CPU # We exclude some combinations not usefull to save Travis CPU
exclude: exclude:
- php: '5.4'
env: DB=postgresql
- php: '5.5' - php: '5.5'
env: DB=postgresql env: DB=postgresql
- php: '5.6' - php: '5.6'
@ -123,7 +120,7 @@ install:
- | - |
echo "Installing PHP Unit" 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 composer -n require phpunit/phpunit ^4
fi fi
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then
@ -145,6 +142,7 @@ install:
echo echo
before_script: before_script:
- | - |
echo Start travis echo Start travis
@ -162,7 +160,7 @@ before_script:
echo echo
echo "Set timezone" echo "Set timezone"
echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini 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 if [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then
#echo #echo
#echo "Enabling APC for PHP <= 5.4" #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! # Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6!
@ -176,22 +174,27 @@ before_script:
echo echo
- | - |
if [ "$DEBUG" = true ]; then echo "Versions information"
echo "Debugging informations"
# Check PHP # Check PHP
php -i echo "PHP version"
php -i | head -
# Check PHP CodeSniffer installation # Check PHP CodeSniffer installation
echo "PHPCS version"
which phpcs which phpcs
phpcs --version phpcs --version | head -
phpcs -i phpcs -i | head -
# Check PHPUnit installation # Check PHPUnit installation
echo "PHPUnit version"
which phpunit which phpunit
phpunit --version phpunit --version | head -
# Check MySQL # Check Apache version
mysql --version echo "Apache version"
mysql -e "SELECT VERSION();" apache2 -v | head -
# Check MariaDb
echo "MariaDb version"
mysql --version | head -
mysql -e "SELECT VERSION();" | head -
echo echo
fi
- | - |
echo "Setting up database" echo "Setting up database"
@ -239,41 +242,41 @@ before_script:
echo "first line" > documents/dolibarr.log echo "first line" > documents/dolibarr.log
echo 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 # enable php-fpm
cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - 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 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 # 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 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 fi
if [ "$DEBUG" = true ]; then - sudo a2enmod rewrite actions fastcgi alias
cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
fi - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
sudo a2enmod rewrite actions fastcgi alias - sudo chown -R travis:travis /var/lib/apache2/fastcgi
echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
if [ "$DEBUG" = true ]; then # configure apache virtual hosts for precise
cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini #- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default
fi #- sudo cat /etc/apache2/sites-available/default
~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm # configure apache virtual hosts for trusty
# configure apache virtual hosts - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf
sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/default - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default - sudo cat /etc/apache2/sites-available/000-default.conf
if [ "$DEBUG" = true ]; then - sudo service apache2 restart
sudo cat /etc/apache2/sites-available/default
fi
sudo service apache2 restart
echo
script: script:
- | - |
echo "Checking webserver availability" echo "Checking webserver availability by a wget -O - http://127.0.0.1"
# Ensure we catch errors # Ensure we catch errors
set -e set -e
wget http://127.0.0.1 # The wget should return a page with line '<meta name="generator" content="Dolibarr installer">
if [ "$DEBUG" = true ]; then wget -O - http://127.0.0.1 > test.html
cat index.html head test.html
fi
set +e set +e
echo echo
@ -328,7 +331,7 @@ script:
php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log
php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log
php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log
php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log php upgrade2.php 7.0.0 8.0.0 MAIN_MODULE_TICKETSUP > $TRAVIS_BUILD_DIR/upgrade700800-2.log
php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log
cd - cd -
set +e set +e
@ -341,7 +344,6 @@ script:
- | - |
echo "Unit testing" 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. # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file.
set -e set -e
phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php

View File

@ -20,6 +20,12 @@ source_file = htdocs/langs/en_US/agenda.lang
source_lang = en_US source_lang = en_US
type = MOZILLAPROPERTIES type = MOZILLAPROPERTIES
[dolibarr.assets]
file_filter = htdocs/langs/<lang>/assets.lang
source_file = htdocs/langs/en_US/assets.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.banks] [dolibarr.banks]
file_filter = htdocs/langs/<lang>/banks.lang file_filter = htdocs/langs/<lang>/banks.lang
source_file = htdocs/langs/en_US/banks.lang source_file = htdocs/langs/en_US/banks.lang
@ -152,12 +158,6 @@ source_file = htdocs/langs/en_US/hrm.lang
source_lang = en_US source_lang = en_US
type = MOZILLAPROPERTIES type = MOZILLAPROPERTIES
[dolibarr.incoterm]
file_filter = htdocs/langs/<lang>/incoterm.lang
source_file = htdocs/langs/en_US/incoterm.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.install] [dolibarr.install]
file_filter = htdocs/langs/<lang>/install.lang file_filter = htdocs/langs/<lang>/install.lang
source_file = htdocs/langs/en_US/install.lang source_file = htdocs/langs/en_US/install.lang
@ -356,6 +356,12 @@ source_file = htdocs/langs/en_US/supplier_proposal.lang
source_lang = en_US source_lang = en_US
type = MOZILLAPROPERTIES type = MOZILLAPROPERTIES
[dolibarr.ticketsup]
file_filter = htdocs/langs/<lang>/ticketsup.lang
source_file = htdocs/langs/en_US/ticketsup.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.trips] [dolibarr.trips]
file_filter = htdocs/langs/<lang>/trips.lang file_filter = htdocs/langs/<lang>/trips.lang
source_file = htdocs/langs/en_US/trips.lang source_file = htdocs/langs/en_US/trips.lang

84
CODE_OF_CONDUCT.md Normal file
View File

@ -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/)

216
ChangeLog
View File

@ -8,12 +8,178 @@ English Dolibarr ChangeLog
WARNING: WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: 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 * Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from
'doaction' into 'sendMail'. 'doaction' into 'sendMail'.
* Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and * Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and
CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE
* Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is * Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is
a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required. a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required.
* PHP 5.3 is no more supported. Minimum PHP is now 5.4+
* Remove the old deprecated code of doActions and getInstanceDao in canvas. The doActions of standard hooks are
already available and are better.
* 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
FIX: #8219
FIX: #8232
FIX: #8269
FIX: #8277
FIX: #8285 Extrafields now reported by /api/index.php/agendaevents/{id}
FIX: #8289 add a configuration for stock calculation
FIX: Activate all also if there are inactive services
FIX: add planned delivery to order exports
FIX: approval date was not visible if leave was canceled after
FIX: avoid "Array" on screen
FIX: Avoid empty value to fk_multicurrency attribute
FIX: Bad var for substitution of free text
FIX: Can't activate tasks on projects configuration
FIX: Can use odx templates that does not include lines tags
FIX: check shipping on delete order
FIX: check verif exped on delete order
FIX: comment on tasks
FIX: country must not be mandatory for accounting report groups
FIX: css
FIX: Delete tasks on project delete will now trigger TASK_DELETE
FIX: Do not lose filter when editing comment of a time spent in task view
FIX: duplicate confirm message. Missing reposition class
FIX: Duplicate product_type asignement on order addline
FIX: email use the validate user instead of approver in holiday approval
FIX: Error management in leave request
FIX: for nondisplay of fk_element 's id in REST API response
FIX: Generic substitution of constant disabled for sensitive constant
FIX: if we make a mistake with situation_percent, now we can correct it. before situation_final was always set to 1 and no way to go back
FIX: Import process must stop after ending line nb to import
FIX: Infinite loop on deletion of temp file when there is symbolic links
FIX: Input of holiday for subordinates was ko
FIX: invoice creation fails when next date not defined
FIX: Label of event show twice
FIX: letter for month March
FIX: Look and feel v7
FIX: Make a redirect after the remove_file action to avoid deletion done
FIX: migration script for product photo
FIX: missing email of customer in stripe info payments
FIX: missing object entity in fetch
FIX: Missing restore_lastsearch_values
FIX: multicompany compatibility and fix reports
FIX: natural search double quote
FIX: navigation and filters on holiday list
FIX: Parameter must be an array or an object that implements Countable
FIX: Payment mode not correctly set in donation and document
FIX: Permission in list of holiday
FIX: Properties updated if update successfull.
FIX: reverse field to have object loaded in doaction
FIX: Saving wrong localtax on order addline
FIX: Search criteria on vat
FIX: security report by DIGITEMIS CYBERSECURITY & PRIVACY
FIX: show status on societe banner
FIX: solve column mismatch in user card with multicompany transverse mode + code cleanup
FIX: Subscription events not recorded into agenda
FIX: Subscription not correctly log in blockedlog
FIX: Temporary dir for mail files must be cleaned at beginning of form
FIX: Trad and creation date in subscription create
FIX: translation of holiday types
FIX: Unknown column 'pl.amount_requested' in compta/prelevement/factures.php
FIX: Useless clean of tree
FIX: Use of undefined constant _ROWS_2
FIX: warning when adding ECM files using old photo path
***** ChangeLog for 7.0.0 compared to 6.0.5 ***** ***** ChangeLog for 7.0.0 compared to 6.0.5 *****
@ -303,6 +469,56 @@ Following changes may create regressions for some external modules, but were nec
multicompany module to a version that support Dolibarr v7, everything should work as expected. multicompany module to a version that support Dolibarr v7, everything should work as expected.
***** 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
FIX: #8151
FIX: #8200
FIX: add planned delivery to order exports
FIX: a discount is a percent, not an amount, so we use vatrate not price
FIX: Avoid empty value to fk_multicurrency attribute
FIX: Bad localtaxes assignment in cashdesk
FIX: check shipping on delete order
FIX: check verif exped on delete order
FIX: creer into lire
FIX: Delete tasks on project delete will now trigger TASK_DELETE
FIX: Global on $user parameter reset the variable
FIX: if we make a mistake with situation_percent, now we can correct…
FIX: if we make a mistake with situation_percent, now we can correct it. before situation_final was always set to 1 and no way to go back
FIX: Import process must stop after ending line nb to import
FIX: migration script for product photo
FIX: natural search double quote
FIX: reverse field to have object loaded in doaction
FIX: Saving wrong localtax on order addline
FIX: show status on societe banner
FIX: solve column mismatch in user card's usergroup list + code cleanup
FIX: solve column mismatch in user card with multicompany transverse mode + code cleanup
FIX: unset categorie
FIX: update_extras on fourn card
FIX: warning when adding ECM files using old photo path
FIX: Withdrawals lines not filter by company name and not respect dropdown limit lines by page
NEW: Add sale representative einstein_pdf_modules
NEW_einstein_pdf_modules
NEW: field commerciaux and categ export CustomersInvoicesAndPayments
***** ChangeLog for 6.0.5 compared to 6.0.4 ***** ***** ChangeLog for 6.0.5 compared to 6.0.4 *****
FIX: security vulnerability reported by ADLab of Venustech FIX: security vulnerability reported by ADLab of Venustech
CVE-2017-17897, CVE-2017-17898, CVE-2017-17899, CVE-2017-17900 CVE-2017-17897, CVE-2017-17898, CVE-2017-17899, CVE-2017-17900

View File

@ -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). 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)].
<a href="https://github.com/Dolibarr/dolibarr/graphs/contributors"><img src="https://opencollective.com/dolibarr/contributors.svg?width=890&button=false" /></a>
## CREDITS ## CREDITS

View File

@ -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). 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: 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 ## 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)].
<a href="https://github.com/Dolibarr/dolibarr/graphs/contributors"><img src="https://opencollective.com/dolibarr/contributors.svg?width=890&button=false" /></a>
## CREDITS ## CREDITS
@ -199,3 +200,8 @@ Follow Dolibarr project on:
- [LinkedIn](https://www.linkedin.com/company/association-dolibarr) - [LinkedIn](https://www.linkedin.com/company/association-dolibarr)
- [YouTube](https://www.youtube.com/user/DolibarrERPCRM) - [YouTube](https://www.youtube.com/user/DolibarrERPCRM)
- [GitHub](https://github.com/Dolibarr/dolibarr) - [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)]

View File

@ -28,9 +28,9 @@ OutputBaseFilename=__FILENAMEEXEDOLIWAMP__
SourceDir=..\..\.. SourceDir=..\..\..
AppId=doliwamp AppId=doliwamp
AppPublisher=NLTechno AppPublisher=NLTechno
AppPublisherURL=http://www.nltechno.com AppPublisherURL=https://www.nltechno.com
AppSupportURL=http://www.dolibarr.org AppSupportURL=https://www.dolibarr.org
AppUpdatesURL=http://www.dolibarr.org AppUpdatesURL=https://www.dolibarr.org
AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares. AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares.
AppCopyright=Copyright (C) 2008-2017 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) AppCopyright=Copyright (C) 2008-2017 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre)
DefaultDirName=c:\dolibarr DefaultDirName=c:\dolibarr
@ -102,7 +102,7 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi
; Put here path of Wampserver applications ; Put here path of Wampserver applications
; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45
; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45
; Value ???: apache 2.4.19, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) ; Value OK: apache 2.4.19, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe)
Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange"
Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log"
Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log"

View File

@ -17,7 +17,7 @@
*/ */
/** /**
* \file build/generate_filecheck_xml.php * \file build/generate_filelist_xml.php
* \ingroup dev * \ingroup dev
* \brief This script create a xml checksum file * \brief This script create a xml checksum file
*/ */
@ -45,7 +45,7 @@ $includeconstants=array();
if (empty($argv[1])) if (empty($argv[1]))
{ {
print "Usage: ".$script_file." release=x.y.z[-...] [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"; 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; exit -1;
} }
@ -68,21 +68,52 @@ while ($i < $argc)
$i++; $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' || $tmpver[0] == 'autostable')
{
$release=DOL_VERSION;
if ($tmpver[1] && $tmpver[0] == 'auto') $release.='-'.$tmpver[1];
}
if (empty($includecustom)) if (empty($includecustom))
{ {
if (DOL_VERSION != $release) $tmpverbis=explode('-', $release, 2);
if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable')
{ {
print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$release.')'."\n"; if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto')
print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; {
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; exit -1;
} }
} }
else 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)) 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 '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=x.y.z[-...] [includecustom=1]\n"; print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
exit -1; exit -1;
} }
} }

View File

@ -388,7 +388,7 @@ if ($nboftargetok) {
#----------------------- #-----------------------
if ($CHOOSEDTARGET{'-CHKSUM'}) if ($CHOOSEDTARGET{'-CHKSUM'})
{ {
print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filecheck_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filelist_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n";
$ret=`php $SOURCE/build/generate_filelist_xml.php release=$MAJOR.$MINOR.$BUILD`; $ret=`php $SOURCE/build/generate_filelist_xml.php release=$MAJOR.$MINOR.$BUILD`;
print $ret."\n"; print $ret."\n";
# Copy to final dir # Copy to final dir
@ -466,10 +466,12 @@ if ($nboftargetok) {
$ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.deb`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.deb`;
$ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.dsc`; $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.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-*.deb`;
$ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.rpm`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.rpm`;
$ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar`; $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.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-*.tgz`;
$ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.xz`;
$ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.zip`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.zip`;
@ -849,6 +851,8 @@ if ($nboftargetok) {
unlink("$NEWDESTI/${FILENAMEDEB}.changes"); unlink("$NEWDESTI/${FILENAMEDEB}.changes");
print "Remove target ${FILENAMEDEB}.debian.tar.gz...\n"; print "Remove target ${FILENAMEDEB}.debian.tar.gz...\n";
unlink("$NEWDESTI/${FILENAMEDEB}.debian.tar.gz"); 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"; print "Remove target ${FILENAMEDEBNATIVE}.orig.tar.gz...\n";
unlink("$NEWDESTI/${FILENAMEDEBNATIVE}.orig.tar.gz"); unlink("$NEWDESTI/${FILENAMEDEBNATIVE}.orig.tar.gz");
@ -1024,7 +1028,7 @@ if ($nboftargetok) {
$ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`;
$ret=`mv $BUILDROOT/*.dsc "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.dsc "$NEWDESTI/"`;
$ret=`mv $BUILDROOT/*.orig.tar.gz "$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/"`; $ret=`mv $BUILDROOT/*.changes "$NEWDESTI/"`;
next; 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}_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}_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}.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_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/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'Dolibarr installer for Windows (DoliWamp)',
"$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM', "$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}_all.deb"=>'package_debian-ubuntu',
"$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'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}.dsc"=>'package_debian-ubuntu',
"$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.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_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu',
"$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows', "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows',
"$DESTI/standard/$FILENAMETGZ.tgz"=>'standard', "$DESTI/standard/$FILENAMETGZ.tgz"=>'standard',

View File

@ -1,7 +1,7 @@
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# \file dolibarr.pl # \file dolibarr.pl
# \brief Dolibarr script install for Virtualmin Pro # \brief Dolibarr script install for Virtualmin Pro
# \author (c)2009-2017 Regis Houssin <regis.houssin@capnetworks.com> # \author (c)2009-2018 Regis Houssin <regis.houssin@inodbox.com>
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -30,7 +30,7 @@ return "Regis Houssin";
# script_dolibarr_versions() # script_dolibarr_versions()
sub script_dolibarr_versions sub script_dolibarr_versions
{ {
return ( "5.0.4", "4.0.6", "3.9.4" ); return ( "7.0.0", "6.0.5", "5.0.7" );
} }
sub script_dolibarr_release sub script_dolibarr_release
@ -386,6 +386,8 @@ sub script_dolibarr_check_latest
{ {
local ($ver) = @_; local ($ver) = @_;
local @vers = &osdn_package_versions("dolibarr", local @vers = &osdn_package_versions("dolibarr",
$ver >= 7.0 ? "dolibarr\\-(7\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 6.0 ? "dolibarr\\-(6\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 5.0 ? "dolibarr\\-(5\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 5.0 ? "dolibarr\\-(5\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 4.0 ? "dolibarr\\-(4\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 4.0 ? "dolibarr\\-(4\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 3.9 ? "dolibarr\\-(3\\.9\\.[0-9\\.]+)\\.tgz" : $ver >= 3.9 ? "dolibarr\\-(3\\.9\\.[0-9\\.]+)\\.tgz" :

View File

@ -160,6 +160,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/adherents
%_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/admin
%_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/api
%_datadir/dolibarr/htdocs/asset
%_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/asterisk
%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/barcode
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
@ -176,6 +177,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/core
%_datadir/dolibarr/htdocs/cron %_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/custom
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expedition

View File

@ -240,6 +240,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/adherents
%_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/admin
%_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/api
%_datadir/dolibarr/htdocs/asset
%_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/asterisk
%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/barcode
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
@ -256,6 +257,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/core
%_datadir/dolibarr/htdocs/cron %_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/custom
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expedition

View File

@ -157,6 +157,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/adherents
%_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/admin
%_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/api
%_datadir/dolibarr/htdocs/asset
%_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/asterisk
%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/barcode
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
@ -173,6 +174,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/core
%_datadir/dolibarr/htdocs/cron %_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/custom
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expedition

View File

@ -168,6 +168,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/adherents
%_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/admin
%_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/api
%_datadir/dolibarr/htdocs/asset
%_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/asterisk
%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/barcode
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
@ -184,6 +185,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/core
%_datadir/dolibarr/htdocs/cron %_datadir/dolibarr/htdocs/cron
%_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/custom
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expedition

View File

@ -1,11 +1,10 @@
<VirtualHost *:80> <VirtualHost *:80>
DocumentRoot %TRAVIS_BUILD_DIR%/htdocs DocumentRoot %TRAVIS_BUILD_DIR%/htdocs
<Directory "%TRAVIS_BUILD_DIR%/htdocs"> <Directory "%TRAVIS_BUILD_DIR%/htdocs/">
Options FollowSymLinks MultiViews ExecCGI Options FollowSymLinks MultiViews ExecCGI
AllowOverride All AllowOverride All
Order deny,allow Require all granted
Allow from all
</Directory> </Directory>
# Wire up Apache to use Travis CI's php-fpm. # Wire up Apache to use Travis CI's php-fpm.
@ -14,5 +13,9 @@
Action php5-fcgi /php5-fcgi Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/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 FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule> </IfModule>
</VirtualHost> </VirtualHost>

View File

@ -90,6 +90,14 @@ var vTmpNode=this.newNode(vTmpCell, 'div', null, '');
vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']); vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']);
vTmpNode.setAttribute('href',vTaskList[i].getLink()); vTmpNode.setAttribute('href',vTaskList[i].getLink());
* Replace '% Comp.' to have a smaller text column header
'comp':'% Comp.'
with
'comp':'%'
JCROP: JCROP:
------ ------

File diff suppressed because one or more lines are too long

View File

@ -92,7 +92,7 @@ if ($connection)
{ {
if (! @ssh2_auth_password($connection, $login, $password)) if (! @ssh2_auth_password($connection, $login, $password))
{ {
dol_syslog("Could not authenticate with username ".$login." . and password ".$password,LOG_ERR); dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password),LOG_ERR);
exit(-5); exit(-5);
} }
else else

View File

@ -138,9 +138,7 @@
<rule ref="Generic.NamingConventions.ConstructorName" /> <rule ref="Generic.NamingConventions.ConstructorName" />
<!-- Check if we use PHP4 constructor instead of __construct() --> <!-- Check if we use PHP4 constructor instead of __construct() -->
<rule ref="Generic.NamingConventions.ConstructorName.OldStyle"> <rule ref="Generic.NamingConventions.ConstructorName.OldStyle" />
<severity>0</severity>
</rule>
<rule ref="Generic.NamingConventions.UpperCaseConstantName" /> <rule ref="Generic.NamingConventions.UpperCaseConstantName" />
@ -156,8 +154,8 @@
<!-- Warning when using @ before functions --> <!-- Warning when using @ before functions -->
<!-- <rule ref="Generic.PHP.NoSilencedErrors" /> --> <!-- <rule ref="Generic.PHP.NoSilencedErrors" /> -->
<!-- Say if null, true, false must be uppercase --> <!-- Say if null, true, false must be uppercase (Rule 2.5 of PSR2 https://www.php-fig.org/psr/psr-2/) -->
<!-- <rule ref="Generic.PHP.UpperCaseConstant" /> --> <rule ref="Generic.PHP.LowerCaseConstant" />
<rule ref="Generic.Strings.UnnecessaryStringConcat" /> <rule ref="Generic.Strings.UnnecessaryStringConcat" />

View File

@ -1,7 +1,13 @@
#!/bin/sh #!/bin/sh
FROM=2016-01-01 if [ "x$1" = "x" ]; then
TO=2016-12-31 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" 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 git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l

View File

@ -1,10 +1,11 @@
#/bin/bash #/bin/bash
Releases=("3.8" "3.9" "4.0" "5.0", "develop") Releases=("3.8" "3.9" "4.0" "5.0" "6.0" " 7.0" "develop")
Dates=("2010-01-01", "2011-01-01", "2012-01-01", "2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01") 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" let "counter = 1"
for i in "${Releases[@]}" for i in "${Releases[@]}"
do 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]} git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]}
echo -n "Total $i: " echo -n "Total $i: "
git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l

View File

@ -101,7 +101,7 @@ $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks //set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
//set image scale factor //set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

View File

@ -76,7 +76,7 @@ $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks //set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
//set image scale factor //set image scale factor
//$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,18 +28,14 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
// Langs $langs->loadLangs(array("compta","bills","admin","accountancy","salaries"));
$langs->load("compta");
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
$langs->load("salaries");
$mesg = ''; $mesg = '';
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
$cancel = GETPOST('cancel','alpha'); $cancel = GETPOST('cancel','alpha');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'accountingaccountlist'; // To manage different context of search
$search_account = GETPOST("search_account"); $search_account = GETPOST("search_account");
$search_label = GETPOST("search_label"); $search_label = GETPOST("search_label");
@ -74,8 +70,6 @@ $arrayfields=array(
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
// Initialize technical object to manage context to save list fields
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'accountingaccountlist';
/* /*
@ -176,12 +170,11 @@ $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 = "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 .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $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"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf->entity;
// Dirty hack wainting that foreign key account_parent is an integer to be compared correctly with rowid 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;
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)"; else $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 = CAST(aa.account_parent AS UNSIGNED)";
$sql .= " WHERE asy.rowid = " . $pcgver; $sql .= " WHERE asy.rowid = " . $pcgver;
//print $sql;
if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account);
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
if (strlen(trim($search_accountparent))) $sql .= natural_search("aa.account_parent", $search_accountparent); if (strlen(trim($search_accountparent))) $sql .= natural_search("aa.account_parent", $search_accountparent);
@ -195,6 +188,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $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); $sql .= $db->plimit($limit + 1, $offset);
@ -227,9 +225,11 @@ if ($resql)
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$htmlbuttonadd = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>'; $newcardbutton = '<a class="butActionNew" href="./card.php?action=create">' . $langs->trans("Addanaccount");
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
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 // Box to select active chart of account
print $langs->trans("Selectchartofaccounts") . " : "; print $langs->trans("Selectchartofaccounts") . " : ";
@ -257,7 +257,7 @@ if ($resql)
else dol_print_error($db); else dol_print_error($db);
print "</select>"; print "</select>";
print ajax_combobox("chartofaccounts"); print ajax_combobox("chartofaccounts");
print '<input type="submit" class="button" name="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">'; print '<input type="submit" class="button" name="change_chart" tabindex="-1" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
print '<br>'; print '<br>';
print '<br>'; print '<br>';
@ -276,7 +276,7 @@ if ($resql)
if (! empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="' . $search_pcgtype . '"></td>'; if (! empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="' . $search_pcgtype . '"></td>';
if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>'; if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
if (! empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; if (! empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
print '<td align="right" colspan="2" class="liste_titre">'; print '<td align="right" class="liste_titre">';
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
@ -310,7 +310,7 @@ if ($resql)
if (! empty($arrayfields['aa.account_number']['checked'])) if (! empty($arrayfields['aa.account_number']['checked']))
{ {
print "<td>"; print "<td>";
print $accountstatic->getNomUrl(1); print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1);
print "</td>\n"; print "</td>\n";
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com> * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
@ -45,7 +45,7 @@ $langs->loadLangs(array("errors","admin","companies","resource","holiday","compt
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int'); $id=31;
$rowid=GETPOST('rowid','alpha'); $rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha'); $code=GETPOST('code','alpha');
@ -58,8 +58,8 @@ $listoffset=GETPOST('listoffset');
$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
$active = 1; $active = 1;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'aZ09comma');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'aZ09comma');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page ; $offset = $listlimit * $page ;
@ -84,59 +84,48 @@ $hookmanager->initHooks(array('admin'));
$tabname=array(); $tabname=array();
$tabname[31]= MAIN_DB_PREFIX."accounting_system"; $tabname[31]= MAIN_DB_PREFIX."accounting_system";
$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
// Dictionary labels // Dictionary labels
$tablib=array(); $tablib=array();
$tablib[31]= "Pcg_version"; $tablib[31]= "Pcg_version";
$tablib[32]= "DictionaryAccountancyCategory";
// Requests to extract data // Requests to extract data
$tabsql=array(); $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[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 // Criteria to sort dictionaries
$tabsqlsort=array(); $tabsqlsort=array();
$tabsqlsort[31]="pcg_version ASC"; $tabsqlsort[31]="pcg_version ASC";
$tabsqlsort[32]="position ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire // Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array(); $tabfield=array();
$tabfield[31]= "pcg_version,label,country_id,country"; $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 // Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array(); $tabfieldvalue=array();
$tabfieldvalue[31]= "pcg_version,label,country"; $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 // Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array(); $tabfieldinsert=array();
$tabfieldinsert[31]= "pcg_version,label,fk_country"; $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 // Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on // Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array(); $tabrowid=array();
$tabrowid[31]= ""; $tabrowid[31]= "";
$tabrowid[32]= "";
// Condition to show dictionary in setup page // Condition to show dictionary in setup page
$tabcond=array(); $tabcond=array();
$tabcond[31]= ! empty($conf->accounting->enabled); $tabcond[31]= ! empty($conf->accounting->enabled);
$tabcond[32]= ! empty($conf->accounting->enabled);
// List of help for fields // List of help for fields
$tabhelp=array(); $tabhelp=array();
$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); $tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET) // List of check for fields (NOT USED YET)
$tabfieldcheck=array(); $tabfieldcheck=array();
$tabfieldcheck[31] = array(); $tabfieldcheck[31] = array();
$tabfieldcheck[32] = array();
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
@ -484,7 +473,7 @@ print "<br>\n";
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') 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); //var_dump($elementList);
@ -503,24 +492,9 @@ if ($id)
$sql.= " c.rowid = ".$search_country_id; $sql.= " c.rowid = ".$search_country_id;
} }
if ($sortfield)
{
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code'; if ($sortfield == 'country') $sortfield='country_code';
$sql.= " ORDER BY ".$sortfield; $sql.=$db->order($sortfield,$sortorder);
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->plimit($listlimit+1,$offset); $sql.=$db->plimit($listlimit+1,$offset);
//print $sql; //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 $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; $error=$hookmanager->error; $errors=$hookmanager->errors;
if ($id == 3) unset($fieldlist[2]);
if (empty($reshook)) 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 '<td colspan="3" align="right">'; print '<td colspan="3" align="right">';
if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit')
{
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
}
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
@ -683,7 +645,6 @@ if ($id)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$var=true;
$param = '&id='.$id; $param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
@ -880,7 +841,7 @@ if ($id)
$valuetoshow=price($valuetoshow); $valuetoshow=price($valuetoshow);
} }
else if ($fieldlist[$field]=='libelle_facture') { else if ($fieldlist[$field]=='libelle_facture') {
$langs->load("bills"); $langs->loadLangs(array("bills"));
$key=$langs->trans("PaymentCondition".strtoupper($obj->code)); $key=$langs->trans("PaymentCondition".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
$valuetoshow=nl2br($valuetoshow); $valuetoshow=nl2br($valuetoshow);
@ -890,7 +851,7 @@ if ($id)
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { 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)); $key=$langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
@ -915,17 +876,17 @@ if ($id)
$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $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') { 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)); $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]}); $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') { 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)); $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { 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)); $key=$langs->trans("PaymentType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $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]}); $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') { 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); $key=$langs->trans($obj->code);
$valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]}; $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]};
} }
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { 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)); $key=$langs->trans("SendingMethod".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $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') 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)); $key = $langs->trans(strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
} }
@ -961,11 +922,11 @@ if ($id)
$valuetoshow = $langs->getCurrencySymbol($obj->code,1); $valuetoshow = $langs->getCurrencySymbol($obj->code,1);
} }
else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { 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]}); $valuetoshow=$langs->trans($obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { 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]}); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]});
} }
else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format'))
@ -1013,13 +974,7 @@ if ($id)
// Active // Active
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
else
{
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
else print $langs->trans("AlwaysActive"); else print $langs->trans("AlwaysActive");
}
print "</td>"; print "</td>";
// Modify link // Modify link
@ -1068,7 +1023,6 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
global $form; global $form;
global $region_id; global $region_id;
global $elementList,$sourceList; global $elementList,$sourceList;
global $bc;
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
@ -1168,16 +1122,11 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
} }
elseif (in_array($fieldlist[$field], array('content'))) elseif (in_array($fieldlist[$field], array('content')))
{ {
if ($tabname == MAIN_DB_PREFIX.'c_email_templates') print '<td>';
{
print '<td colspan="4"></td></tr><tr class="pair nohover"><td colspan="5">'; // To create an artificial CR for the current tr we are on
}
else print '<td>';
if ($context != 'hide') if ($context != 'hide')
{ {
//print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>'; //print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
$okforextended=true; $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%'); $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); print $doleditor->Create(1);
} }

View File

@ -31,9 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$error = 0; $error = 0;
// Langs $langs->loadLangs(array("bills","accountancy"));
$langs->load("bills");
$langs->load("accountancy");
$mesg = ''; $mesg = '';
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
@ -188,12 +186,10 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
} }
} }
/* /*
* View * View
*/ */
$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card');
$helpurl = '';
llxheader('', $title, $helpurl);
$form = new Form($db); $form = new Form($db);
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
@ -201,6 +197,11 @@ $formaccounting = new FormAccounting($db);
$accountsystem = new AccountancySystem($db); $accountsystem = new AccountancySystem($db);
$accountsystem->fetch($conf->global->CHARTOFACCOUNTS); $accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card');
$helpurl = '';
llxheader('', $title, $helpurl);
// Create mode // Create mode
if ($action == 'create') { if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAccountingAccount')); print load_fiche_titre($langs->trans('NewAccountingAccount'));
@ -330,7 +331,7 @@ else if ($id > 0 || $ref) {
print '</form>'; print '</form>';
} else { } else {
// View mode // View mode
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr'); dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');

View File

@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$error = 0; $error = 0;
$langs->load("bills"); $langs->loadLangs(array("bills","accountancy"));
$langs->load("accountancy");
$mesg = ''; $mesg = '';
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
@ -53,6 +52,11 @@ if (empty($user->rights->accounting->chartofaccount))
$accountingcategory = new AccountancyCategory($db); $accountingcategory = new AccountancyCategory($db);
/*
* Actions
*/
// si ajout de comptes // si ajout de comptes
if (! empty($selectcpt)) { if (! empty($selectcpt)) {
$cpts = array (); $cpts = array ();
@ -66,7 +70,7 @@ if (! empty($selectcpt)) {
if ($return<0) { if ($return<0) {
setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors'); setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
} else { } else {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
} }
} }
if ($action == 'delete') { if ($action == 'delete') {
@ -83,12 +87,13 @@ if ($action == 'delete') {
/* /*
* View * View
*/ */
$form = new Form($db); $form = new Form($db);
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
llxheader('', $langs->trans('AccountingCategory')); llxheader('', $langs->trans('AccountingCategory'));
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?search_country_id='.$mysoc->country_id.'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
print load_fiche_titre($langs->trans('AccountingCategory'), $linkback); print load_fiche_titre($langs->trans('AccountingCategory'), $linkback);
@ -99,13 +104,15 @@ print '<input type="hidden" name="action" value="display">';
dol_fiche_head(); dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Category
// Select the category
print '<tr><td class="titlefield">' . $langs->trans("AccountingCategory") . '</td>'; print '<tr><td class="titlefield">' . $langs->trans("AccountingCategory") . '</td>';
print '<td>'; print '<td>';
$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1); $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1);
print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">'; print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">';
print '</td></tr>'; print '</td></tr>';
// Select the accounts
if (! empty($cat_id)) if (! empty($cat_id))
{ {
$return = $accountingcategory->getAccountsWithNoCategory($cat_id); $return = $accountingcategory->getAccountsWithNoCategory($cat_id);
@ -153,7 +160,7 @@ if ($action == 'display' || $action == 'delete') {
print "</tr>\n"; print "</tr>\n";
if (! empty($cat_id)) { if (! empty($cat_id)) {
$return = $accountingcategory->display($cat_id); $return = $accountingcategory->display($cat_id); // This load ->lines_display
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $accountingcategory->errors, 'errors'); setEventMessages(null, $accountingcategory->errors, 'errors');
} }

View File

@ -54,8 +54,8 @@ $listoffset=GETPOST('listoffset');
$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
$active = 1; $active = 1;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'aZ09comma');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'aZ09comma');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page ; $offset = $listlimit * $page ;
@ -152,7 +152,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
{ {
if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'formula' && empty($_POST['formula'])) continue;
if ($value == 'range_account' && empty($_POST['range_account'])) continue; if ($value == 'range_account' && empty($_POST['range_account'])) continue;
if ($value == 'country') continue; // country_id required but not country if ($value == 'country' || $value == 'country_id') continue;
if (! isset($_POST[$value]) || $_POST[$value]=='') if (! isset($_POST[$value]) || $_POST[$value]=='')
{ {
$ok=0; $ok=0;
@ -175,16 +175,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$ok=0; $ok=0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
} }
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
{
$ok = 0;
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/
} }
if (isset($_POST["country"]) && ($_POST["country"] <= 0)) if (! is_numeric(GETPOST('position','alpha')))
{ {
$langs->loadLangs(array("errors"));
$ok=0; $ok=0;
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors'); setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors');
} }
// Clean some parameters // Clean some parameters
@ -193,7 +189,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd')) if ($ok && GETPOST('actionadd','alpha'))
{ {
if ($tabrowid[$id]) if ($tabrowid[$id])
{ {
@ -214,15 +210,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) $sql.= $tabrowid[$id].",";
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id]; $sql.= $tabfieldinsert[$id];
$sql.=",active)"; $sql.=",active)";
$sql.= " VALUES("; $sql.= " VALUES(";
// List of values // List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) $sql.= $newid.",";
$sql.= $newid.",";
$i=0; $i=0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value)
{ {
@ -306,7 +300,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol="rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
@ -330,10 +324,10 @@ if ($action == $acts[0])
else { $rowidcol="rowid"; } else { $rowidcol="rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
} }
elseif ($code) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -350,10 +344,10 @@ if ($action == $acts[1])
else { $rowidcol="rowid"; } else { $rowidcol="rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
} }
elseif ($code) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -370,10 +364,10 @@ if ($action == 'activate_favorite')
else { $rowidcol="rowid"; } else { $rowidcol="rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
} }
elseif ($code) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$code."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -390,10 +384,10 @@ if ($action == 'disable_favorite')
else { $rowidcol="rowid"; } else { $rowidcol="rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
} }
elseif ($code) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$code."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -440,27 +434,12 @@ if ($id)
{ {
if (preg_match('/ WHERE /',$sql)) $sql.= " AND "; if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
else $sql.=" WHERE "; else $sql.=" WHERE ";
$sql.= " c.rowid = ".$search_country_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 sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code'; if ($sortfield == 'country') $sortfield='country_code';
$sql.= " ORDER BY ".$sortfield; $sql.=$db->order($sortfield,$sortorder);
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->plimit($listlimit+1,$offset); $sql.=$db->plimit($listlimit+1,$offset);
//print $sql; //print $sql;
@ -477,7 +456,6 @@ if ($id)
if ($tabname[$id]) if ($tabname[$id])
{ {
$alabelisused=0; $alabelisused=0;
$var=false;
$fieldlist=explode(',',$tabfield[$id]); $fieldlist=explode(',',$tabfield[$id]);
@ -571,7 +549,6 @@ if ($id)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$var=true;
$param = '&id='.$id; $param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
@ -741,7 +718,7 @@ if ($id)
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { 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)); $key=$langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
} }
@ -799,7 +776,7 @@ if ($id)
print '<td class="center">'; print '<td class="center">';
if (empty($obj->formula)) if (empty($obj->formula))
{ {
print '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories.php?action=display&account_category='.$obj->rowid.'">'; print '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.'">';
print $langs->trans("ListOfAccounts"); print $langs->trans("ListOfAccounts");
print '</a>'; print '</a>';
} }

View File

@ -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/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("compta"); $langs->loadLangs(array("compta","bills","admin","accountancy","salaries","loan"));
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
$langs->load("salaries");
$langs->load("loan");
// Security check // Security check
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))

View File

@ -28,15 +28,11 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
$langs->load("compta"); $langs->loadLangs(array("compta","bills","admin","accountancy"));
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
// Security access // Security access
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))

View File

@ -39,8 +39,7 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield="f.rowid"; // Set here default search field if (! $sortfield) $sortfield="f.rowid"; // Set here default search field
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
$langs->load("admin"); $langs->loadLangs(array("admin","compta"));
$langs->load("compta");
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
@ -95,6 +94,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);

View File

@ -26,8 +26,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
$langs->load("admin"); $langs->loadLangs(array("admin","compta"));
$langs->load("compta");
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)

View File

@ -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/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
$langs->load("admin"); $langs->loadLangs(array("admin","compta"));
$langs->load("compta");
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)

View File

@ -24,16 +24,12 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// langs // Load traductions files requiredby by page
$langs->load("compta"); $langs->loadLangs(array("compta","bills","accountancy"));
$langs->load("bills");
$langs->load("main");
$langs->load("accountancy");
// Security check // Security check
if (! $user->admin) if (! $user->admin)
@ -141,7 +137,6 @@ if ($result) {
$form = new Form($db); $form = new Form($db);
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$var = true;
while ( $i < min($num_lines, $limit) ) { while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@ -27,16 +27,12 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Setup page to configure accounting expert module * \brief Setup page to configure accounting expert module
*/ */
require '../../main.inc.php';
// Class require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$langs->load("compta"); $langs->loadLangs(array("compta","bills","admin","accountancy"));
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
// Security access // Security access
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))
@ -65,26 +61,8 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' :
if ($action == 'update') { if ($action == 'update') {
$error = 0; $error = 0;
$accounting_modes = array ( if (! $error)
'RECETTES-DEPENSES', {
'CREANCES-DETTES'
);
$accounting_mode = GETPOST('accounting_mode', 'alpha');
if (in_array($accounting_mode, $accounting_modes)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
foreach ($list as $constname) foreach ($list as $constname)
{ {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
@ -93,11 +71,13 @@ if ($action == 'update') {
$error++; $error++;
} }
} }
if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if (! $error) { if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }

View File

@ -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.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
$langs->load("admin"); $langs->loadLangs(array("admin","compta","accountancy"));
$langs->load("compta");
$langs->load("accountancy");
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int'); $id=35;
$rowid=GETPOST('rowid','alpha'); $rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha'); $code=GETPOST('code','alpha');
@ -135,6 +133,7 @@ $elementList = array();
'3' => $langs->trans('AccountingJournalType3'), '3' => $langs->trans('AccountingJournalType3'),
'4' => $langs->trans('AccountingJournalType4'), '4' => $langs->trans('AccountingJournalType4'),
'5' => $langs->trans('AccountingJournalType5'), '5' => $langs->trans('AccountingJournalType5'),
'8' => $langs->trans('AccountingJournalType8'),
'9' => $langs->trans('AccountingJournalType9') '9' => $langs->trans('AccountingJournalType9')
); );
@ -400,24 +399,9 @@ if ($id)
$sql=$tabsql[$id]; $sql=$tabsql[$id];
$sql.= " WHERE a.entity = ".$conf->entity; $sql.= " WHERE a.entity = ".$conf->entity;
if ($sortfield)
{
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code'; if ($sortfield == 'country') $sortfield='country_code';
$sql.= " ORDER BY ".$sortfield; $sql.=$db->order($sortfield,$sortorder);
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->plimit($listlimit+1,$offset); $sql.=$db->plimit($listlimit+1,$offset);
$fieldlist=explode(',',$tabfield[$id]); $fieldlist=explode(',',$tabfield[$id]);
@ -433,7 +417,6 @@ if ($id)
if ($tabname[$id]) if ($tabname[$id])
{ {
$alabelisused=0; $alabelisused=0;
$var=false;
$fieldlist=explode(',',$tabfield[$id]); $fieldlist=explode(',',$tabfield[$id]);
@ -513,7 +496,6 @@ if ($id)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$var=true;
$param = '&id='.$id; $param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
@ -618,6 +600,7 @@ if ($id)
if (empty($reshook)) if (empty($reshook))
{ {
$langs->load("accountancy");
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
@ -628,9 +611,11 @@ if ($id)
$valuetoshow=$langs->trans('All'); $valuetoshow=$langs->trans('All');
} }
else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$langs->load("accountancy");
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature)); $key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]});
}
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$valuetoshow=$langs->trans($obj->label);
} }
$class='tddict'; $class='tddict';
@ -657,13 +642,7 @@ if ($id)
// Active // Active
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
else
{
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
else print $langs->trans("AlwaysActive"); else print $langs->trans("AlwaysActive");
}
print "</td>"; print "</td>";
// Modify link // Modify link

View File

@ -26,7 +26,6 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.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 . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
// Langs // Load traductions files requiredby by page
$langs->load("companies"); $langs->loadLangs(array("companies","compta","accountancy","products"));
$langs->load("compta");
$langs->load("main");
$langs->load("accountancy");
$langs->load("products");
// Security check // Security check
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
@ -261,7 +256,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
} }
}
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
@ -272,8 +273,8 @@ if ($result)
$i = 0; $i = 0;
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref); if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param.="&search_desc=".urlencode($search_label); if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc); if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
@ -300,10 +301,10 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>'; print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr ' . $bc[false] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>'; print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
print '<td>'.$langs->trans('OptionModeProductSellDesc'); print '<td>'.$langs->trans('OptionModeProductSellDesc');
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr ' . $bc[true] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>'; print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n"; print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
print "</table>\n"; print "</table>\n";
@ -328,9 +329,9 @@ if ($result)
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
// On sell // On sell
print '<td class="liste_titre"></td>'; if ($accounting_product_mode == 'ACCOUNTANCY_SELL') print '<td class="liste_titre"></td>';
// On buy // On buy
print '<td class="liste_titre"></td>'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print '<td class="liste_titre"></td>';
// Current account // Current account
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_current_account" value="' . dol_escape_htmltag($search_current_account) . '">'; print '<input type="text" class="flat" size="6" name="search_current_account" value="' . dol_escape_htmltag($search_current_account) . '">';
@ -348,11 +349,9 @@ if ($result)
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, 'align="center"', $sortfield, $sortorder); if ($accounting_product_mode == 'ACCOUNTANCY_SELL') print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, 'align="center"', $sortfield, $sortorder); if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, 'align="center"', $sortfield, $sortorder);
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') $fieldtosortaccount="p.accountancy_code_buy";
$fieldtosortaccount="p.accountancy_code_buy";
}
else $fieldtosortaccount="p.accountancy_code_sell"; else $fieldtosortaccount="p.accountancy_code_sell";
print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AssignDedicatedAccountingAccount"); print_liste_field_titre("AssignDedicatedAccountingAccount");
@ -362,7 +361,6 @@ if ($result)
$product_static = new Product($db); $product_static = new Product($db);
$var = true;
$i=0; $i=0;
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
@ -410,8 +408,10 @@ if ($result)
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>'; print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
} }
if ($accounting_product_mode == 'ACCOUNTANCY_SELL')
print '<td align="center">'.$product_static->getLibStatut(3, 0).'</td>'; print '<td align="center">'.$product_static->getLibStatut(3, 0).'</td>';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY')
print '<td align="center">'.$product_static->getLibStatut(3, 1).'</td>'; print '<td align="center">'.$product_static->getLibStatut(3, 1).'</td>';
// Current accounting account // Current accounting account

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2016-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -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'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
// Langs // Langs
$langs->load("accountancy"); $langs->loadLangs(array("accountancy"));
$page = GETPOST("page"); $page = GETPOST("page");
$sortorder = GETPOST("sortorder"); $sortorder = GETPOST("sortorder");
@ -138,8 +138,7 @@ if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = 'balance'; $filename = 'balance';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
$result = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); $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 $object->get_compte_desc($line->numero_compte) . $sep;
print price($line->debit) . $sep; print price($line->debit) . $sep;
print price($line->credit) . $sep; print price($line->credit) . $sep;
print price($line->debit) . $sep;
print price($line->credit - $line->debit) . $sep; print price($line->credit - $line->debit) . $sep;
print "\n"; print "\n";
} }
@ -188,7 +186,7 @@ else {
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
$button = '<input type="submit" name="exportcsv" class="butAction" value="' . $langs->trans("Export") . ' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />'; $button = '<input type="submit" name="exportcsv" class="butActionNew" value="' . $langs->trans("Export") . ' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button);
$moreforfilter = ''; $moreforfilter = '';
@ -254,8 +252,8 @@ else {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Permet d'afficher le compte comptable // 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 // Affiche un Sous-Total par compte comptable
if ($displayed_account != "") { if ($displayed_account != "") {
print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">' . price($sous_total_debit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit - $sous_total_debit) . '</td>'; print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">' . price($sous_total_debit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit - $sous_total_debit) . '</td>';
@ -263,9 +261,9 @@ else {
print '</tr>'; print '</tr>';
} }
// Affiche le compte comptable en d<EFBFBD>but de ligne // Affiche le compte comptable en debut de ligne
print "<tr>"; print "<tr>";
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">' . $root_account_description . '</td>'; print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">' . $line->numero_compte . ($root_account_description ? ' - ' . $root_account_description : '') . '</td>';
print '</tr>'; print '</tr>';
$displayed_account = $root_account_description; $displayed_account = $root_account_description;

View File

@ -26,16 +26,11 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs // Load traductions files requiredby by page
$langs->load("main"); $langs->loadLangs(array("bills","compta","accountancy","other"));
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("accountancy");
// Filter // Filter
$year = GETPOST("year",'int'); $year = GETPOST("year",'int');
@ -75,8 +70,6 @@ if ($result) {
$y = $year_current; $y = $year_current;
$var = true;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width=150>' . $langs->trans("Label") . '</td><td align="center">' . $langs->trans("JanuaryMin") . '</td><td align="center">' . $langs->trans("FebruaryMin") . '</td><td align="center">' . $langs->trans("MarchMin") . '</td><td align="center">' . $langs->trans("AprilMin") . '</td><td align="center">' . $langs->trans("MayMin") . '</td><td align="center">' . $langs->trans("JuneMin") . '</td><td align="center">' . $langs->trans("JulyMin") . '</td><td align="center">' . $langs->trans("AugustMin") . '</td><td align="center">' . $langs->trans("SeptemberMin") . '</td><td align="center">' . $langs->trans("OctoberMin") . '</td><td align="center">' . $langs->trans("NovemberMin") . '</td><td align="center">' . $langs->trans("DecemberMin") . '</td><td align="center"><b>Total</b></td></tr>'; print '<tr class="liste_titre"><td width=150>' . $langs->trans("Label") . '</td><td align="center">' . $langs->trans("JanuaryMin") . '</td><td align="center">' . $langs->trans("FebruaryMin") . '</td><td align="center">' . $langs->trans("MarchMin") . '</td><td align="center">' . $langs->trans("AprilMin") . '</td><td align="center">' . $langs->trans("MayMin") . '</td><td align="center">' . $langs->trans("JuneMin") . '</td><td align="center">' . $langs->trans("JulyMin") . '</td><td align="center">' . $langs->trans("AugustMin") . '</td><td align="center">' . $langs->trans("SeptemberMin") . '</td><td align="center">' . $langs->trans("OctoberMin") . '</td><td align="center">' . $langs->trans("NovemberMin") . '</td><td align="center">' . $langs->trans("DecemberMin") . '</td><td align="center"><b>Total</b></td></tr>';
@ -108,7 +101,7 @@ if ($resql) {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<tr><td width="14%">' . length_accountg($row[0]) . '</td>'; print '<tr class="oddeven"><td width="14%">' . length_accountg($row[0]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[1]) . '</td>'; print '<td align="right" width="6.5%">' . price($row[1]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[2]) . '</td>'; print '<td align="right" width="6.5%">' . price($row[2]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[3]) . '</td>'; print '<td align="right" width="6.5%">' . price($row[3]) . '</td>';

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2017 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -32,30 +32,30 @@ 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 . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
$langs->load("accountancy"); $langs->loadLangs(array("accountancy", "bills", "compta"));
$langs->load("bills");
$langs->load("compta"); $action = GETPOST('action','aZ09');
$id = GETPOST('id', 'int'); // id of record
$mode = GETPOST('mode','aZ09'); // '' or 'tmp'
$piece_num = GETPOST("piece_num",'int'); // id of transaction (several lines share the same transaction id)
// Security check // Security check
$id = GETPOST('id', 'int');
if ($user->societe_id > 0) { if ($user->societe_id > 0) {
accessforbidden(); accessforbidden();
} }
$action = GETPOST('action','aZ09');
$mode = GETPOST('mode','aZ09'); // '' or 'tmp'
$piece_num = GETPOST("piece_num");
$mesg = ''; $mesg = '';
$account_number = GETPOST('account_number'); $account_number = GETPOST('account_number','alphanohtml');
$subledger_account = GETPOST('subledger_account'); $subledger_account = GETPOST('subledger_account','alphanohtml');
if ($subledger_account == - 1) { if ($subledger_account == - 1) {
$subledger_account = null; $subledger_account = null;
} }
$label_compte = GETPOST('label_compte'); $label_compte = GETPOST('label_compte','alphanohtml');
$label_operation= GETPOST('label_operation'); $label_operation= GETPOST('label_operation','alphanohtml');
$debit = price2num(GETPOST('debit')); $debit = price2num(GETPOST('debit','alpha'));
$credit = price2num(GETPOST('credit')); $credit = price2num(GETPOST('credit','alpha'));
$save = GETPOST('save','alpha'); $save = GETPOST('save','alpha');
if (! empty($save)) $action = 'add'; if (! empty($save)) $action = 'add';
@ -87,36 +87,36 @@ if ($action == "confirm_update") {
if (! $error) 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) { if ($result < 0) {
$error++; $error++;
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
$book->numero_compte = $account_number; $object->numero_compte = $account_number;
$book->subledger_account = $subledger_account; $object->subledger_account = $subledger_account;
$book->label_compte = $label_compte; $object->label_compte = $label_compte;
$book->label_operation= $label_operation; $object->label_operation= $label_operation;
$book->debit = $debit; $object->debit = $debit;
$book->credit = $credit; $object->credit = $credit;
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$book->montant = $debit; $object->montant = $debit;
$book->sens = 'D'; $object->sens = 'D';
} }
if (floatval($credit) != 0.0) { if (floatval($credit) != 0.0) {
$book->montant = $credit; $object->montant = $credit;
$book->sens = 'C'; $object->sens = 'C';
} }
$result = $book->update($user, false, $mode); $result = $object->update($user, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp')
{ {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$debit = 0; $debit = 0;
@ -145,39 +145,39 @@ else if ($action == "add") {
} }
if (! $error) { if (! $error) {
$book = new BookKeeping($db); $object = new BookKeeping($db);
$book->numero_compte = $account_number; $object->numero_compte = $account_number;
$book->subledger_account = $subledger_account; $object->subledger_account = $subledger_account;
$book->label_compte = $label_compte; $object->label_compte = $label_compte;
$book->label_operation= $label_operation; $object->label_operation= $label_operation;
$book->debit = $debit; $object->debit = $debit;
$book->credit = $credit; $object->credit = $credit;
$book->doc_date = GETPOST('doc_date'); $object->doc_date = GETPOST('doc_date','alpha');
$book->doc_type = GETPOST('doc_type'); $object->doc_type = GETPOST('doc_type','alpha');
$book->piece_num = $piece_num; $object->piece_num = $piece_num;
$book->doc_ref = GETPOST('doc_ref'); $object->doc_ref = GETPOST('doc_ref','alpha');
$book->code_journal = GETPOST('code_journal'); $object->code_journal = GETPOST('code_journal','alpha');
$book->fk_doc = GETPOST('fk_doc'); $object->fk_doc = GETPOST('fk_doc','alpha');
$book->fk_docdet = GETPOST('fk_docdet'); $object->fk_docdet = GETPOST('fk_docdet','alpha');
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$book->montant = $debit; $object->montant = $debit;
$book->sens = 'D'; $object->sens = 'D';
} }
if (floatval($credit) != 0.0) { if (floatval($credit) != 0.0) {
$book->montant = $credit; $object->montant = $credit;
$book->sens = 'C'; $object->sens = 'C';
} }
$result = $book->createStd($user, false, $mode); $result = $object->createStd($user, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp')
{ {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$debit = 0; $debit = 0;
@ -189,17 +189,17 @@ else if ($action == "add") {
} }
else if ($action == "confirm_delete") { else if ($action == "confirm_delete") {
$book = new BookKeeping($db); $object = new BookKeeping($db);
$result = $book->fetch($id, null, $mode); $result = $object->fetch($id, null, $mode);
$piece_num = $book->piece_num; $piece_num = $object->piece_num;
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
$result = $book->delete($user, false, $mode); $result = $object->delete($user, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
$action = ''; $action = '';
@ -208,9 +208,9 @@ else if ($action == "confirm_delete") {
else if ($action == "confirm_create") { else if ($action == "confirm_create") {
$error = 0; $error = 0;
$book = new BookKeeping($db); $object = new BookKeeping($db);
if (! GETPOST('code_journal') || GETPOST('code_journal') == '-1') { if (! GETPOST('code_journal','alpha') || GETPOST('code_journal','alpha') == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors');
$action='create'; $action='create';
$error++; $error++;
@ -223,29 +223,29 @@ else if ($action == "confirm_create") {
if (! $error) if (! $error)
{ {
$book->label_compte = ''; $object->label_compte = '';
$book->debit = 0; $object->debit = 0;
$book->credit = 0; $object->credit = 0;
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); $object->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'); $object->doc_type = GETPOST('doc_type','alpha');
$book->piece_num = GETPOST('next_num_mvt'); $object->piece_num = GETPOST('next_num_mvt','alpha');
$book->doc_ref = GETPOST('doc_ref'); $object->doc_ref = GETPOST('doc_ref','alpha');
$book->code_journal = GETPOST('code_journal'); $object->code_journal = GETPOST('code_journal','alpha');
$book->fk_doc = 0; $object->fk_doc = 0;
$book->fk_docdet = 0; $object->fk_docdet = 0;
$book->montant = 0; $object->montant = 0;
$result = $book->createStd($user,0, $mode); $result = $object->createStd($user,0, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp')
{ {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = 'update'; $action = 'update';
$id=$book->id; $id=$object->id;
$piece_num = $book->piece_num; $piece_num = $object->piece_num;
} }
} }
} }
@ -258,35 +258,35 @@ if ($action == 'setdate') {
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp')
{ {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = ''; $action = '';
} }
} }
if ($action == 'setjournal') { if ($action == 'setjournal') {
$journaldoc = trim(GETPOST('code_journal')); $journaldoc = trim(GETPOST('code_journal','alpha'));
$result = $object->updateByMvt($piece_num, 'code_journal', $journaldoc, $mode); $result = $object->updateByMvt($piece_num, 'code_journal', $journaldoc, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp')
{ {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = ''; $action = '';
} }
} }
if ($action == 'setdocref') { if ($action == 'setdocref') {
$refdoc = trim(GETPOST('doc_ref')); $refdoc = trim(GETPOST('doc_ref','alpha'));
$result = $object->updateByMvt($piece_num,'doc_ref',$refdoc,$mode); $result = $object->updateByMvt($piece_num,'doc_ref',$refdoc,$mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp')
{ {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = ''; $action = '';
} }
@ -324,8 +324,8 @@ if ($action == 'create')
{ {
print load_fiche_titre($langs->trans("CreateMvts")); print load_fiche_titre($langs->trans("CreateMvts"));
$book = new BookKeeping($db); $object = new BookKeeping($db);
$next_num_mvt = $book->getNextNumMvt('_tmp'); $next_num_mvt = $object->getNextNumMvt('_tmp');
if (empty($next_num_mvt)) if (empty($next_num_mvt))
{ {
@ -340,13 +340,14 @@ if ($action == 'create')
dol_fiche_head(); dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>';
/*print '<tr>';
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>'; print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>';
print '<td>' . $next_num_mvt . '</td>'; print '<td>' . $next_num_mvt . '</td>';
print '</tr>'; print '</tr>';*/
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">' . $langs->trans("Docdate") . '</td>'; print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("Docdate") . '</td>';
print '<td>'; print '<td>';
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>'; print '</td>';
@ -358,7 +359,7 @@ if ($action == 'create')
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Docref") . '</td>'; print '<td>' . $langs->trans("Piece") . '</td>';
print '<td><input type="text" class="minwidth200" name="doc_ref" value=""/></td>'; print '<td><input type="text" class="minwidth200" name="doc_ref" value=""/></td>';
print '</tr>'; print '</tr>';
@ -381,28 +382,28 @@ if ($action == 'create')
print '</form>'; print '</form>';
} else { } else {
$book = new BookKeeping($db); $object = new BookKeeping($db);
$result = $book->fetchPerMvt($piece_num, $mode); $result = $object->fetchPerMvt($piece_num, $mode);
if ($result < 0) { 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 = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">' . $langs->trans('BackToList') . '</a>'; $backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">' . $langs->trans('BackToList') . '</a>';
print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
$head=array(); $head=array();
$h=0; $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][1] = $langs->trans("Transaction");
$head[$h][2] = 'transaction'; $head[$h][2] = 'transaction';
$h++; $h++;
dol_fiche_head($head, 'transaction', '', -1); dol_fiche_head($head, 'transaction', '', -1);
//dol_banner_tab($book, '', $backlink); //dol_banner_tab($object, '', $backlink);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
@ -413,7 +414,7 @@ if ($action == 'create')
// Account movement // Account movement
print '<tr>'; print '<tr>';
print '<td class="titlefield">' . $langs->trans("NumMvts") . '</td>'; print '<td class="titlefield">' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $book->piece_num . '</td>'; print '<td>' . $object->piece_num . '</td>';
print '</tr>'; print '</tr>';
// Date // Date
@ -422,19 +423,19 @@ if ($action == 'create')
print $langs->trans('Docdate'); print $langs->trans('Docdate');
print '</td>'; print '</td>';
if ($action != 'editdate') if ($action != 'editdate')
print '<td><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;piece_num='. $book->piece_num .'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;piece_num='. $object->piece_num .'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editdate') { if ($action == 'editdate') {
print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">'; print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setdate">'; print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
$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 '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>'; print '</form>';
} else { } else {
print $book->doc_date ? dol_print_date($book->doc_date, 'day') : '&nbsp;'; print $object->doc_date ? dol_print_date($object->doc_date, 'day') : '&nbsp;';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -445,19 +446,19 @@ if ($action == 'create')
print $langs->trans('Codejournal'); print $langs->trans('Codejournal');
print '</td>'; print '</td>';
if ($action != 'editjournal') if ($action != 'editjournal')
print '<td><a href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$book->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$object->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editjournal') { if ($action == 'editjournal') {
print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">'; print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setjournal">'; print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
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 '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>'; print '</form>';
} else { } else {
print $book->code_journal ; print $object->code_journal ;
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -465,22 +466,22 @@ if ($action == 'create')
// Ref document // Ref document
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Docref'); print $langs->trans('Piece');
print '</td>'; print '</td>';
if ($action != 'editdocref') if ($action != 'editdocref')
print '<td><a href="'.$_SERVER["PHP_SELF"].'?action=editdocref&amp;piece_num='.$book->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdocref&amp;piece_num='.$object->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editdocref') { if ($action == 'editdocref') {
print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">'; print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setdocref">'; print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="text" size="20" name="doc_ref" value="'.$book->doc_ref.'">'; print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">';
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>'; print '</form>';
} else { } else {
print $book->doc_ref ; print $object->doc_ref ;
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -495,11 +496,11 @@ if ($action == 'create')
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
// Doc type // Doc type
if(! empty($book->doc_type)) if(! empty($object->doc_type))
{ {
print '<tr>'; print '<tr>';
print '<td class="titlefield">' . $langs->trans("Doctype") . '</td>'; print '<td class="titlefield">' . $langs->trans("Doctype") . '</td>';
print '<td>' . $book->doc_type . '</td>'; print '<td>' . $object->doc_type . '</td>';
print '</tr>'; print '</tr>';
} }
@ -507,7 +508,7 @@ if ($action == 'create')
print '<tr>'; print '<tr>';
print '<td class="titlefield">' . $langs->trans("DateCreation") . '</td>'; print '<td class="titlefield">' . $langs->trans("DateCreation") . '</td>';
print '<td>'; print '<td>';
print $book->date_creation ? dol_print_date($book->date_creation, 'day') : '&nbsp;'; print $object->date_creation ? dol_print_date($object->date_creation, 'day') : '&nbsp;';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -516,7 +517,7 @@ if ($action == 'create')
print '<tr>'; print '<tr>';
print '<td class="titlefield">' . $langs->trans("Status") . '</td>'; print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>'; print '<td>';
if (empty($book->validated)) { if (empty($object->validated)) {
print '<a href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>'; print '</a>';
@ -533,11 +534,11 @@ if ($action == 'create')
/* /*
print '<tr>'; print '<tr>';
print '<td class="titlefield">' . $langs->trans("Control") . '</td>'; print '<td class="titlefield">' . $langs->trans("Control") . '</td>';
if ($book->doc_type == 'customer_invoice') if ($object->doc_type == 'customer_invoice')
{ {
$sqlmid = 'SELECT rowid as ref'; $sqlmid = 'SELECT rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; $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); dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
@ -560,24 +561,24 @@ if ($action == 'create')
print '<br>'; print '<br>';
$result = $book->fetchAllPerMvt($piece_num, $mode); $result = $object->fetchAllPerMvt($piece_num, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">'; print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n"; print '<input type="hidden" name="doc_date" value="' . $object->doc_date . '">' . "\n";
print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n"; print '<input type="hidden" name="doc_type" value="' . $object->doc_type . '">' . "\n";
print '<input type="hidden" name="doc_ref" value="' . $book->doc_ref . '">' . "\n"; print '<input type="hidden" name="doc_ref" value="' . $object->doc_ref . '">' . "\n";
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n"; print '<input type="hidden" name="code_journal" value="' . $object->code_journal . '">' . "\n";
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n"; print '<input type="hidden" name="fk_doc" value="' . $object->fk_doc . '">' . "\n";
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n"; print '<input type="hidden" name="fk_docdet" value="' . $object->fk_docdet . '">' . "\n";
print '<input type="hidden" name="mode" value="' . $mode . '">' . "\n"; print '<input type="hidden" name="mode" value="' . $mode . '">' . "\n";
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
if (count($book->linesmvt) > 0) { if (count($object->linesmvt) > 0) {
$total_debit = 0; $total_debit = 0;
$total_credit = 0; $total_credit = 0;
@ -594,7 +595,7 @@ if ($action == 'create')
print "</tr>\n"; print "</tr>\n";
foreach ( $book->linesmvt as $line ) { foreach ($object->linesmvt as $line) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
@ -616,7 +617,7 @@ if ($action == 'create')
} }
print '</td>'; print '</td>';
print '<td><input type="text" class="minwidth100" name="label_compte" value="' . $line->label_compte . '"/></td>'; print '<td><input type="text" class="minwidth100" name="label_compte" value="' . $line->label_compte . '"/></td>';
print '<td><input type="text" class="minwidth300" name="label_operation" value="' . $line->label_operation. '"/></td>'; print '<td><input type="text" class="minwidth200" name="label_operation" value="' . $line->label_operation. '"/></td>';
print '<td align="right"><input type="text" size="6" class="right" name="debit" value="' . price($line->debit) . '"/></td>'; print '<td align="right"><input type="text" size="6" class="right" name="debit" value="' . price($line->debit) . '"/></td>';
print '<td align="right"><input type="text" size="6" class="right" name="credit" value="' . price($line->credit) . '"/></td>'; print '<td align="right"><input type="text" size="6" class="right" name="credit" value="' . price($line->credit) . '"/></td>';
print '<td>'; print '<td>';
@ -653,7 +654,7 @@ if ($action == 'create')
if ($total_debit != $total_credit) 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') { if ($action == "" || $action == 'add') {
@ -673,10 +674,10 @@ if ($action == 'create')
print '<input type="text" name="subledger_account" value="">'; print '<input type="text" name="subledger_account" value="">';
} }
print '</td>'; print '</td>';
print '<td><input type="text" class="minwidth100" name="label_compte" value="' . $line->label_compte . '"/></td>'; print '<td><input type="text" class="minwidth100" name="label_compte" value=""/></td>';
print '<td><input type="text" class="minwidth300" name="label_operation" value="' . $line->label_operation. '"/></td>'; print '<td><input type="text" class="minwidth200" name="label_operation" value=""/></td>';
print '<td align="right"><input type="text" size="6" class="right" name="debit" value="' . ($debit ? price($debit) : '') . '"/></td>'; print '<td align="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
print '<td align="right"><input type="text" size="6" class="right" name="credit" value="' . ($credit ? price($credit) : '') . '"/></td>'; print '<td align="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';
print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>'; print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>';
print '</tr>'; print '</tr>';
} }
@ -689,11 +690,11 @@ if ($action == 'create')
print '<div class="center">'; print '<div class="center">';
if ($total_debit == $total_credit) if ($total_debit == $total_credit)
{ {
print '<a class="button" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '&action=valid">'.$langs->trans("ValidTransaction").'</a>'; print '<a class="button" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '&action=valid">'.$langs->trans("ValidTransaction").'</a>';
} }
else else
{ {
print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $credit, $debit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">'; print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">';
} }
print ' &nbsp; '; print ' &nbsp; ';

View File

@ -32,15 +32,14 @@ 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/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs $langs->loadLangs(array("accountancy"));
$langs->load("accountancy");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_doc_type = GETPOST("search_doc_type"); $search_doc_type = GETPOST("search_doc_type");
$search_doc_ref = GETPOST("search_doc_ref"); $search_doc_ref = GETPOST("search_doc_ref");
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); $search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int')); $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int'));
$search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); $search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int'));
@ -75,6 +74,8 @@ if ($search_accountancy_aux_code_end == - 1) {
} }
$search_mvt_label = GETPOST('search_mvt_label', 'alpha'); $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
// Load variable for pagination // Load variable for pagination
@ -98,7 +99,7 @@ $form = new Form($db);
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int')) if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int'))
{ {
if (empty($search_date_start) && empty($search_date_end)) if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values'))
{ {
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; $query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
@ -181,12 +182,12 @@ $filter = array ();
if (! empty($search_date_start)) { if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start; $filter['t.doc_date>='] = $search_date_start;
$tmp=dol_getdate($search_date_start); $tmp=dol_getdate($search_date_start);
$param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year']; $param .= '&search_date_startmonth=' . $tmp['mon'] . '&search_date_startday=' . $tmp['mday'] . '&search_date_startyear=' . $tmp['year'];
} }
if (! empty($search_date_end)) { if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end; $filter['t.doc_date<='] = $search_date_end;
$tmp=dol_getdate($search_date_end); $tmp=dol_getdate($search_date_end);
$param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year']; $param .= '&search_date_endmonth=' . $tmp['mon'] . '&search_date_endday=' . $tmp['mday'] . '&search_date_endyear=' . $tmp['year'];
} }
if (! empty($search_doc_date)) { if (! empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date; $filter['t.doc_date'] = $search_doc_date;
@ -195,51 +196,51 @@ if (! empty($search_doc_date)) {
} }
if (! empty($search_doc_type)) { if (! empty($search_doc_type)) {
$filter['t.doc_type'] = $search_doc_type; $filter['t.doc_type'] = $search_doc_type;
$param .= '&search_doc_type=' . $search_doc_type; $param .= '&search_doc_type=' . urlencode($search_doc_type);
} }
if (! empty($search_doc_ref)) { if (! empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref; $filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref=' . $search_doc_ref; $param .= '&search_doc_ref=' . urlencode($search_doc_ref);
} }
if (! empty($search_accountancy_code)) { if (! empty($search_accountancy_code)) {
$filter['t.numero_compte'] = $search_accountancy_code; $filter['t.numero_compte'] = $search_accountancy_code;
$param .= '&search_accountancy_code=' . $search_accountancy_code; $param .= '&search_accountancy_code=' . urlencode($search_accountancy_code);
} }
if (! empty($search_accountancy_code_start)) { if (! empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start; $filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start=' . $search_accountancy_code_start; $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
} }
if (! empty($search_accountancy_code_end)) { if (! empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end; $filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
} }
if (! empty($search_accountancy_aux_code)) { if (! empty($search_accountancy_aux_code)) {
$filter['t.subledger_account'] = $search_accountancy_aux_code; $filter['t.subledger_account'] = $search_accountancy_aux_code;
$param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; $param .= '&search_accountancy_aux_code=' . urlencode($search_accountancy_aux_code);
} }
if (! empty($search_accountancy_aux_code_start)) { if (! empty($search_accountancy_aux_code_start)) {
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start; $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
$param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; $param .= '&search_accountancy_aux_code_start=' . urlencode($search_accountancy_aux_code_start);
} }
if (! empty($search_accountancy_aux_code_end)) { if (! empty($search_accountancy_aux_code_end)) {
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end; $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; $param .= '&search_accountancy_aux_code_end=' . urlencode($search_accountancy_aux_code_end);
} }
if (! empty($search_mvt_label)) { if (! empty($search_mvt_label)) {
$filter['t.label_operation'] = $search_mvt_label; $filter['t.label_operation'] = $search_mvt_label;
$param .= '&search_mvt_label=' . $search_mvt_label; $param .= '&search_mvt_label=' . urlencode($search_mvt_label);
} }
if (! empty($search_direction)) { if (! empty($search_direction)) {
$filter['t.sens'] = $search_direction; $filter['t.sens'] = $search_direction;
$param .= '&search_direction=' . $search_direction; $param .= '&search_direction=' . urlencode($search_direction);
} }
if (! empty($search_ledger_code)) { if (! empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code; $filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code=' . $search_ledger_code; $param .= '&search_ledger_code=' . urlencode($search_ledger_code);
} }
if (! empty($search_mvt_num)) { if (! empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num; $filter['t.piece_num'] = $search_mvt_num;
$param .= '&search_mvt_num=' . $search_mvt_num; $param .= '&search_mvt_num=' . urlencode($search_mvt_num);
} }
if (! empty($search_date_creation_start)) { if (! empty($search_date_creation_start)) {
$filter['t.date_creation>='] = $search_date_creation_start; $filter['t.date_creation>='] = $search_date_creation_start;
@ -263,13 +264,14 @@ if (! empty($search_date_modification_end)) {
} }
if (! empty($search_debit)) { if (! empty($search_debit)) {
$filter['t.debit'] = $search_debit; $filter['t.debit'] = $search_debit;
$param .= '&search_debit=' . $search_debit; $param .= '&search_debit=' . urlencode($search_debit);
} }
if (! empty($search_credit)) { if (! empty($search_credit)) {
$filter['t.credit'] = $search_credit; $filter['t.credit'] = $search_credit;
$param .= '&search_credit=' . $search_credit; $param .= '&search_credit=' . urlencode($search_credit);
} }
if ($action == 'delbookkeeping') { if ($action == 'delbookkeeping') {
$import_key = GETPOST('importkey', 'alpha'); $import_key = GETPOST('importkey', 'alpha');
@ -435,10 +437,12 @@ else $button.= $langs->trans("ExportList");
$button.= '</a>'; $button.= '</a>';
$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param.'">' . $langs->trans("GroupByAccountAccounting") . '</a>'; $groupby = ' <a class="nohover marginrightonly" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param.'">' . $langs->trans("GroupByAccountAccounting") . '</a>';
$addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>'; $newcardbutton = '<a class="butActionNew" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt");
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
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; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
@ -460,11 +464,11 @@ if (! empty($arrayfields['t.doc_date']['checked']))
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From') . ' '; print $langs->trans('From') . ' ';
print $form->select_date($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1); print $form->select_date($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to') . ' '; print $langs->trans('to') . ' ';
print $form->select_date($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1); print $form->select_date($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} }
@ -612,7 +616,12 @@ if ($num > 0)
// Piece number // Piece number
if (! empty($arrayfields['t.piece_num']['checked'])) if (! empty($arrayfields['t.piece_num']['checked']))
{ {
print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->piece_num . '</a></td>'; print '<td>';
$object->id = $line->id;
$object->piece_num = $line->piece_num;
print $object->getNomUrl(1,'',0,'',1);
//print '<a href="./card.php?piece_num=' . $line->piece_num . '&save_lastsearch_values=1">' . $line->piece_num . '</a>';
print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -694,7 +703,7 @@ if ($num > 0)
} }
// Action column // Action column
print '<td align="center">'; print '<td align="center" class="nowraponall">';
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a>&nbsp;'; print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a>&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>'; print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>';
print '</td>'; print '</td>';
@ -732,7 +741,7 @@ print '</div>';
// TODO Replace this with mass delete action // TODO Replace this with mass delete action
print '<div class="tabsAction tabsActionNoBottom">' . "\n"; print '<div class="tabsAction tabsActionNoBottom">' . "\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DelBookKeeping") . '</a>'; print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DeleteMvt") . '</a>';
print '</div>'; print '</div>';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr> /* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,35 +26,38 @@
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.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.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs $langs->loadLangs(array("accountancy"));
$langs->load("accountancy");
$page = GETPOST("page"); $page = GETPOST("page");
$sortorder = GETPOST("sortorder"); $sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield"); $sortfield = GETPOST("sortfield");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); $search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code = GETPOST("search_accountancy_code");
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
if ($search_accountancy_code_start == - 1) { if ($search_accountancy_code_start == - 1) {
$search_accountancy_code_start = ''; $search_accountancy_code_start = '';
} }
$search_label_account = GETPOST('search_label_account', 'alpha'); $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
$search_mvt_label = GETPOST('search_mvt_label', '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_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
@ -96,63 +99,86 @@ if (empty($search_date_start) && empty($search_date_end)) {
$object = new BookKeeping($db); $object = new BookKeeping($db);
$options = '';
$filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('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_operation'] = $search_label_account;
$options .= '&search_label_account=' . urlencode($search_label_account);
}
if (! empty($search_mvt_label)) {
$filter['t.label_operation'] = $search_mvt_label;
$options .= '&search_mvt_label=' . urlencode($search_mvt_label);
}
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 * 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 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_doc_date = '';
$search_accountancy_code = ''; $search_accountancy_code = '';
$search_accountancy_code_start = ''; $search_accountancy_code_start = '';
$search_accountancy_code_end = '';
$search_label_account = ''; $search_label_account = '';
$search_mvt_label = ''; $search_doc_ref = '';
$search_label_operation = '';
$search_direction = ''; $search_direction = '';
$search_ledger_code = ''; $search_ledger_code = '';
$search_date_start='';
$search_date_end='';
$search_date_startyear='';
$search_date_startmonth='';
$search_date_startday='';
$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') { if ($action == 'delmouvconfirm') {
$mvt_num = GETPOST('mvt_num', 'int'); $mvt_num = GETPOST('mvt_num', 'int');
@ -176,7 +202,7 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$form = new Form($db); $form = new Form($db);
$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting"); $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting"));
llxHeader('', $title_page); llxHeader('', $title_page);
@ -226,17 +252,17 @@ if ($action == 'delbookkeepingyear') {
} }
$param=$options;
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
$viewflat = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param.'">' . $langs->trans("ViewFlatList") . '</a>'; $viewflat = ' <a class="nohover marginrightonly" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param.'">' . $langs->trans("ViewFlatList") . '</a>';
$addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>'; $newcardbutton = '<a class="butActionNew" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt");
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$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 // Reverse sort order
if ( preg_match('/^asc/i', $sortorder) ) if ( preg_match('/^asc/i', $sortorder) )
@ -247,20 +273,29 @@ else
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre">' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . '</td>'; print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
print '</div>';
print '</td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre" align="center">';
print $langs->trans('From') . ': '; print $langs->trans('From') . ': ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print $form->select_date($search_date_start, 'search_date_start', 0, 0, 1);
print '<br>'; print '<br>';
print $langs->trans('to') . ': '; print $langs->trans('to') . ': ';
print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print $form->select_date($search_date_end, 'search_date_end', 0, 0, 1);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/></td>'; print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="' . dol_escape_htmltag($search_doc_ref) . '"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_account" value="' . $search_label_account . '"/></td>'; print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="' . dol_escape_htmltag($search_label_operation) . '"/></td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
print '<td class="liste_titre" align="center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>'; print '<td class="liste_titre" align="center"><input type="text" name="search_ledger_code" size="3" value="' . dol_escape_htmltag($search_ledger_code) . '"></td>';
print '<td class="liste_titre" align="right" colspan="2">'; print '<td class="liste_titre" align="right" colspan="2">';
$searchpicto=$form->showFilterAndCheckAddButtons(0); $searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
@ -268,14 +303,14 @@ print '</td>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF']); 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("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Docref", $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $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("Label");
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $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", "", $options, '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", "", $options, 'align="center"', $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"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
print '</tr>'; print '</tr>';
@ -343,10 +378,15 @@ while ($i < min($num, $limit))
print '<td align="right">' . ($line->debit ? price($line->debit) :''). '</td>'; print '<td align="right">' . ($line->debit ? price($line->debit) :''). '</td>';
print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>'; print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>';
print '<td align="center">' . $line->code_journal . '</td>';
$accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('',$line->code_journal);
$journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal);
print '<td align="center">' . $journaltoshow . '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;'; print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $options . '&page=' . $page . '">' . img_delete() . '</a>'; print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -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 . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$langs->loadLangs(array("compta"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
@ -141,7 +143,6 @@ if ($object->check_codeclient() != 0)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$langs->load('compta');
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);

View File

@ -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 . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$langs->loadLangs(array("compta"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
@ -157,7 +159,6 @@ if ($object->check_codefournisseur() != 0)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$langs->load('compta');
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer); print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer);

View File

@ -357,13 +357,14 @@ class AccountancyCategory // extends CommonObject
* Function to select all accounting accounts from an accounting category * Function to select all accounting accounts from an accounting category
* *
* @param int $id Id * @param int $id Id
*
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function display($id) { public function display($id) {
global $conf;
$sql = "SELECT t.rowid, t.account_number, t.label"; $sql = "SELECT t.rowid, t.account_number, t.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = " . $id; $sql .= " WHERE t.fk_accounting_category = " . $id;
$sql .= " AND t.entity = " . $conf->entity;
$this->lines_display = array(); $this->lines_display = array();
@ -401,13 +402,14 @@ class AccountancyCategory // extends CommonObject
$sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " WHERE t.numero_compte NOT IN (";
$sql .= " SELECT t.account_number"; $sql .= " SELECT t.account_number";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $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 .= " AND t.numero_compte IN (";
$sql .= " SELECT DISTINCT aa.account_number"; $sql .= " SELECT DISTINCT aa.account_number";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $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 .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref";
$sql .= " ORDER BY t.numero_compte"; $sql .= " ORDER BY t.numero_compte";
@ -449,6 +451,7 @@ class AccountancyCategory // extends CommonObject
$sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $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 aa.account_number, aa.label"; $sql .= " GROUP BY aa.account_number, aa.label";
$sql .= " ORDER BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label";
@ -493,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 .= " 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 asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " AND aa.entity = " . $conf->entity;
$this->db->begin(); $this->db->begin();
@ -580,31 +584,27 @@ class AccountancyCategory // extends CommonObject
* *
* @return array Result in table * @return array Result in table
*/ */
public function getCatsCpts() { public function getCatsCpts()
global $mysoc; {
global $mysoc,$conf;
$sql = ""; $sql = "";
if (empty($mysoc->country_id) && empty($mysoc->country_code)) { if (empty($mysoc->country_id)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
exit(); exit();
} }
if (! empty($mysoc->country_id)) {
$sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat";
$sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid ";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
$sql .= " WHERE c.active = 1"; $sql .= " WHERE c.active = 1";
$sql .= " AND c.fk_country = " . $mysoc->country_id . ")"; $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 cat.rowid = t.fk_accounting_category";
$sql .= " AND t.entity = " . $conf->entity;
$sql .= " ORDER BY cat.position ASC"; $sql .= " ORDER BY cat.position ASC";
} else {
$sql = "SELECT c.rowid, c.code, c.label, c.category_type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c, " . MAIN_DB_PREFIX . "c_country as co";
$sql .= " WHERE c.active = 1 AND c.fk_country = co.rowid";
$sql .= " AND co.code = '" . $mysoc->country_code . "'";
$sql .= " ORDER BY c.position ASC";
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -685,35 +685,27 @@ class AccountancyCategory // extends CommonObject
} }
/** /**
* Return list of personalized groups * Return list of personalized groups that are active
* *
* @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups * @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups
* @return array Array of groups * @return array Array of groups
*/ */
public function getCats($categorytype=-1) public function getCats($categorytype=-1)
{ {
global $db, $langs, $user, $mysoc; global $db, $langs, $user, $mysoc, $conf;
if (empty($mysoc->country_id) && empty($mysoc->country_code)) { if (empty($mysoc->country_id)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
exit(); exit();
} }
if (! empty($mysoc->country_id)) {
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; $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 .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
$sql .= " WHERE c.active = 1 "; $sql .= " WHERE c.active = 1 ";
$sql .= " AND c.entity = " . $conf->entity;
if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; if ($categorytype >= 0) $sql.=" AND c.category_type = 1";
$sql .= " AND c.fk_country = " . $mysoc->country_id; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)";
$sql .= " ORDER BY c.position ASC"; $sql .= " ORDER BY c.position ASC";
} else { // Note: this should not happen
$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, " . MAIN_DB_PREFIX . "c_country as co";
$sql .= " WHERE c.active = 1 AND c.fk_country = co.rowid";
if ($categorytype >= 0) $sql.=" AND c.category_type = 1";
$sql .= " AND co.code = '" . $mysoc->country_code . "'";
$sql .= " ORDER BY c.position ASC";
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {

View File

@ -5,7 +5,7 @@
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr> * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2016-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com> * Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
* Copyright (C) 2017 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2017 Frédéric France <frederic.france@netlogic.fr>
@ -177,7 +177,7 @@ class AccountancyExport
*/ */
public static function downloadFile() { public static function downloadFile() {
global $conf; global $conf;
$journal = 'bookkepping'; $filename = 'general_ledger';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
} }

View File

@ -84,7 +84,8 @@ class AccountingAccount extends CommonObject
* @param int $limittocurrentchart 1=Do not load record if it is into another accounting system * @param int $limittocurrentchart 1=Do not load record if it is into another accounting system
* @return int <0 if KO, 0 if not found, Id of record if OK and found * @return int <0 if KO, 0 if not found, Id of record if OK and found
*/ */
function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) { function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0)
{
global $conf; global $conf;
if ($rowid || $account_number) { if ($rowid || $account_number) {
@ -96,10 +97,10 @@ class AccountingAccount extends CommonObject
if ($rowid) { if ($rowid) {
$sql .= " a.rowid = '" . $rowid . "'"; $sql .= " a.rowid = '" . $rowid . "'";
} elseif ($account_number) { } elseif ($account_number) {
$sql .= " a.account_number = '" . $account_number . "'"; $sql .= " a.account_number = '" . $this->db->escape($account_number) . "'";
} }
if (! empty($limittocurrentchart)) { if (! empty($limittocurrentchart)) {
$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')';
} }
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
@ -203,7 +204,7 @@ class AccountingAccount extends CommonObject
$sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'"); $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'");
$sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'"); $sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'");
$sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); $sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
$sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'"); $sql .= ", " . (empty($this->account_category) ? '0' : $this->db->escape($this->account_category));
$sql .= ", " . $user->id; $sql .= ", " . $user->id;
$sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active)); $sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
$sql .= ")"; $sql .= ")";
@ -274,7 +275,7 @@ class AccountingAccount extends CommonObject
$sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'";
$sql .= " , account_parent = '" . $this->db->escape($this->account_parent) . "'"; $sql .= " , account_parent = '" . $this->db->escape($this->account_parent) . "'";
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
$sql .= " , fk_accounting_category = '" . $this->db->escape($this->account_category) . "'"; $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : $this->db->escape($this->account_category));
$sql .= " , fk_user_modif = " . $user->id; $sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = " . $this->active; $sql .= " , active = " . $this->active;
$sql .= " WHERE rowid = " . $this->id; $sql .= " WHERE rowid = " . $this->id;
@ -389,9 +390,10 @@ class AccountingAccount extends CommonObject
* @param int $nourl 1=Disable url * @param int $nourl 1=Disable url
* @param string $moretitle Add more text to title tooltip * @param string $moretitle Add more text to title tooltip
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL * @return string String with URL
*/ */
function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0) function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0, $save_lastsearch_value=-1)
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -402,6 +404,11 @@ class AccountingAccount extends CommonObject
$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
$picto = 'billr'; $picto = 'billr';
$label=''; $label='';
@ -560,7 +567,7 @@ class AccountingAccount extends CommonObject
function LibStatut($statut,$mode=0) function LibStatut($statut,$mode=0)
{ {
global $langs; global $langs;
$langs->load('users'); $langs->loadLangs(array("users"));
if ($mode == 0) if ($mode == 0)
{ {

View File

@ -36,7 +36,7 @@ class AccountingJournal extends CommonObject
public $code; public $code;
public $label; public $label;
public $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 4:expense-report, 9: has-new public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
public $active; public $active;
public $lines; public $lines;
@ -256,7 +256,7 @@ class AccountingJournal extends CommonObject
{ {
global $langs; global $langs;
$langs->load("accountancy"); $langs->loadLangs(array("accountancy"));
if ($mode == 0) if ($mode == 0)
{ {

View File

@ -170,7 +170,7 @@ class BookKeeping extends CommonObject
// Check parameters // Check parameters
if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') 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'))) if (in_array($this->doc_type, array('bank', 'expense_report')))
{ {
$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type);
@ -246,9 +246,6 @@ class BookKeeping extends CommonObject
} }
$now = dol_now(); $now = dol_now();
if (empty($this->date_create)) {
$this->date_create = $now;
}
$sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " (";
$sql .= "doc_date"; $sql .= "doc_date";
@ -291,7 +288,7 @@ class BookKeeping extends CommonObject
$sql .= "," . $this->montant; $sql .= "," . $this->montant;
$sql .= ",'" . $this->db->escape($this->sens) . "'"; $sql .= ",'" . $this->db->escape($this->sens) . "'";
$sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; $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->code_journal) . "'";
$sql .= ",'" . $this->db->escape($this->journal_label) . "'"; $sql .= ",'" . $this->db->escape($this->journal_label) . "'";
$sql .= "," . $this->db->escape($this->piece_num); $sql .= "," . $this->db->escape($this->piece_num);
@ -354,6 +351,67 @@ class BookKeeping extends CommonObject
} }
} }
/**
* Return a link to the object card (with optionaly the picto)
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to ('nolink', ...)
* @param int $notooltip 1=Disable tooltip
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
{
global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("Transaction") . '</u>';
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->piece_num;
$url = DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$this->piece_num;
if ($option != 'nolink')
{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowTransaction");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->piece_num;
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
return $result;
}
/** /**
* Create object into database * Create object into database
* *
@ -435,9 +493,6 @@ class BookKeeping extends CommonObject
$this->credit = price2num($this->credit, 'MT'); $this->credit = price2num($this->credit, 'MT');
$now = dol_now(); $now = dol_now();
if (empty($this->date_create)) {
$this->date_create = $now;
}
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
@ -484,7 +539,7 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ','; $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ',';
$sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ','; $sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ',';
$sql .= ' ' . $user->id . ','; $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->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
$sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ',';
$sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).',';
@ -501,7 +556,7 @@ class BookKeeping extends CommonObject
} }
if (! $error) { if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element . $mode);
if (! $notrigger) { if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
@ -676,12 +731,12 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=' . $value; $sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} elseif ($key == 't.label_operation') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} else { } else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere[] = natural_search($key, $value, 0, 1);
} }
} }
} }
@ -804,13 +859,14 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.tms>=' || $key == 't.tms<=') { } elseif ($key == 't.tms>=' || $key == 't.tms<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} else { } else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere[] = natural_search($key, $value, 0, 1);
} }
} }
} }
$sql.= ' WHERE 1 = 1'; $sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
} }
@ -1101,7 +1157,7 @@ class BookKeeping extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab";
$sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'"); $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$this->db->escape($value)."'");
$sql .= ' WHERE ab.piece_num=' . $piece_num ; $sql .= ' WHERE ab.piece_num=' . $piece_num ;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1184,7 +1240,7 @@ class BookKeeping extends CommonObject
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "DELETE"; $sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE import_key = '" . $importkey . "'"; $sql .= " WHERE import_key = '" . $this->db->escape($importkey) . "'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1222,7 +1278,7 @@ class BookKeeping extends CommonObject
$sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql.= " WHERE 1 = 1"; $sql.= " WHERE 1 = 1";
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; if (! empty($journal)) $sql.= " AND code_journal = '".$this->db->escape($journal)."'";
$sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1254,7 +1310,7 @@ class BookKeeping extends CommonObject
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "DELETE"; $sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . (int) $piecenum;
$sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -24,13 +24,10 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs $langs->loadLangs(array("bills","accountancy"));
$langs->load("bills");
$langs->load("accountancy");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');

View File

@ -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'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
// Langs // Langs
$langs->load("compta"); $langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
// Security check // Security check
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
@ -47,15 +43,24 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
// Filter
$year = GETPOST("year",'int'); $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
if ($year == 0) { if (GETPOST("year",'int')) $year_start = GETPOST("year",'int');
$year_current = strftime("%Y", time()); else
$year_start = $year_current; {
} else { $year_start = dol_print_date(dol_now(), '%Y');
$year_current = $year; if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_start = $year;
} }
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
$year_current = $year_start;
// Validate History // Validate History
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
@ -108,30 +113,6 @@ if ($action == 'validatehistory') {
$db->commit(); $db->commit();
setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
} }
} elseif ($action == 'cleanaccountancycode') {
$error = 0;
$db->begin();
// Now clean
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sql1.= " SET fk_code_ventilation = 0";
$sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f";
$sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
$sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
$sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")";
$sql1.=")";
dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
} else {
$db->commit();
setEventMessage($langs->trans('Done'), 'mesgs');
}
} }
@ -144,6 +125,7 @@ llxHeader('', $langs->trans("CustomersVentilation"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>'; $textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>'; $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
// Clean database // Clean database
@ -170,54 +152,39 @@ print $langs->trans("DescVentilCustomer") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>'; print '<br>';
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " , " . MAIN_DB_PREFIX . "facture as f";
$sql .= " WHERE fd.fk_code_ventilation = 0";
$sql .= " AND f.rowid = fd.fk_facture";
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
}
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/customer/index.php');
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_row($result);
$nbfac = $row[0];
$db->free($result);
}
$y = $year_current; $y = $year_current;
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; $buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); //print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; $sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND f.fk_statut > 0";
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
@ -262,32 +229,39 @@ if ($resql) {
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
print '<br>'; print '<br>';
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; $sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else { } else {
@ -339,26 +313,32 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_fiche_titre($langs->trans("OtherInfo"), '', ''); print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>'; print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
for($i = 1; $i <= 12; $i ++) { 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) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else { } else {
@ -392,20 +372,25 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>'; print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else { } else {

View File

@ -27,7 +27,6 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.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 . '/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/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs $langs->loadLangs(array("bills","compta","accountancy","productbatch"));
$langs->load("bills");
$langs->load("compta");
$langs->load("main");
$langs->load("accountancy");
$langs->load("productbatch");
$account_parent = GETPOST('account_parent'); $account_parent = GETPOST('account_parent');
$changeaccount = GETPOST('changeaccount'); $changeaccount = GETPOST('changeaccount');
@ -110,10 +104,18 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
if (is_array($changeaccount) && count($changeaccount) > 0) { if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0; $error = 0;
if (! (GETPOST('account_parent','int') >= 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
}
if (! $error)
{
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l";
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1);
@ -133,6 +135,8 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$account_parent = ''; // Protection to avoid to mass apply it a second time $account_parent = ''; // Protection to avoid to mass apply it a second time
} }
}
/* /*
* View * View
@ -163,11 +167,15 @@ print '<script type="text/javascript">
/* /*
* Customer Invoice lines * Customer Invoice lines
*/ */
$sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.datef, f.ref_client,"; $sql = "SELECT f.rowid as facid, f.facnumber as ref, f.type, f.datef, f.ref_client,";
$sql.= " fd.rowid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,"; $sql.= " fd.rowid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
$sql .= " fd.situation_percent, co.label as country, s.tva_intra"; $sql.= " fd.situation_percent,";
$sql.= " co.label as country, s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
@ -234,6 +242,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -272,7 +285,7 @@ if ($result) {
print $langs->trans("DescVentilDoneCustomer") . '<br>'; print $langs->trans("DescVentilDoneCustomer") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formaccounting->select_account($account_parent, 'account_parent', 1); print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>'; print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
$moreforfilter = ''; $moreforfilter = '';
@ -281,11 +294,11 @@ if ($result) {
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
$formother->select_year($search_year,'search_year',1, 20, 5); $formother->select_year($search_year,'search_year',1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
@ -293,9 +306,9 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>'; print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tavintra" value="' . dol_escape_htmltag($search_tavintra) . '"></td>';
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre" align="center">';
$searchpicto=$form->showFilterButtons(); $searchpicto=$form->showFilterButtons();
print $searchpicto; print $searchpicto;
@ -310,9 +323,9 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
$clickpicto=$form->showCheckAddButtons(); $clickpicto=$form->showCheckAddButtons();
print_liste_field_titre($clickpicto, '', '', '', '', 'align="center"'); print_liste_field_titre($clickpicto, '', '', '', '', 'align="center"');
print "</tr>\n"; print "</tr>\n";
@ -323,16 +336,18 @@ if ($result) {
while ( $objp = $db->fetch_object($result) ) { while ( $objp = $db->fetch_object($result) ) {
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte; $codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte;
$facture_static->ref = $objp->facnumber; $facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid; $facture_static->id = $objp->facid;
$facture_static->type = $objp->ftype;
$product_static->ref = $objp->product_ref; $product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id; $product_static->id = $objp->product_id;
$product_static->type = $objp->product_type; $product_static->type = $objp->type;
$product_static->label = $objp->product_label; $product_static->label = $objp->product_label;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>'; print '<td>' . $objp->rowid . '</td>';
// Ref Invoice // Ref Invoice
@ -347,7 +362,7 @@ if ($result) {
if ($objp->product_label) print '<br>'.$objp->product_label; if ($objp->product_label) print '<br>'.$objp->product_label;
print '</td>'; print '</td>';
print '<td>'; print '<td class="tdoverflowonsmartphone">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description); print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
@ -355,16 +370,17 @@ if ($result) {
print '<td align="right">' . price($objp->total_ht) . '</td>'; print '<td align="right">' . price($objp->total_ht) . '</td>';
print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>'; print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td align="center">'; print '<td align="center">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')).'">'; print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')).'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
print '</td>'; print '</td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>'; print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print "</tr>"; print "</tr>";

View File

@ -27,7 +27,6 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.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 . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
@ -36,13 +35,8 @@ 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/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs // Load traductions files requiredby by page
$langs->load("compta"); $langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$langs->load("productbatch");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha'); $massaction=GETPOST('massaction','alpha');
@ -55,8 +49,8 @@ $mesCasesCochees = GETPOST('toselect', 'array');
// Search Getpost // Search Getpost
$search_lineid = GETPOST('search_lineid', 'int'); $search_lineid = GETPOST('search_lineid', 'int');
$search_invoice = GETPOST('search_invoice', 'alpha');
$search_ref = GETPOST('search_ref', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha');
$search_invoice = GETPOST('search_invoice', 'alpha');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha');
@ -65,6 +59,8 @@ $search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day","int"); $search_day=GETPOST("search_day","int");
$search_month=GETPOST("search_month","int"); $search_month=GETPOST("search_month","int");
$search_year=GETPOST("search_year","int"); $search_year=GETPOST("search_year","int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha');
@ -103,7 +99,7 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
/* /*
* Action * Actions
*/ */
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
@ -129,6 +125,8 @@ if (empty($reshook))
$search_day = ''; $search_day = '';
$search_month = ''; $search_month = '';
$search_year = ''; $search_year = '';
$search_country = '';
$search_tvaintra = '';
} }
// Mass actions // Mass actions
@ -209,14 +207,17 @@ if (empty($chartaccountcode))
} }
// Customer Invoice lines // Customer Invoice lines
$sql = "SELECT f.rowid as facid, f.facnumber, f.datef, f.type as ftype,"; $sql = "SELECT f.rowid as facid, f.facnumber as ref, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql.= " aa.rowid as aarowid"; $sql.= " aa.rowid as aarowid,";
$sql.= " co.label as country, s.tva_intra";
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
@ -262,6 +263,12 @@ else if ($search_year > 0)
{ {
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
} }
if (strlen(trim($search_country))) {
$sql .= natural_search("co.label", $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else { } else {
@ -282,6 +289,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -306,6 +318,8 @@ if ($result) {
if ($search_desc) $param.='&search_desc='.urlencode($search_desc); if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_amount) $param.='&search_amount='.urlencode($search_amount); if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
if ($search_vat) $param.='&search_vat='.urlencode($search_vat); if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
if ($search_country) $param .= "&search_country=" . urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
@ -344,9 +358,9 @@ if ($result) {
// We add search filter // We add search filter
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year,'search_year',1, 20, 5); $formother->select_year($search_year,'search_year',1, 20, 5);
@ -356,6 +370,8 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td align="center" class="liste_titre">'; print '<td align="center" class="liste_titre">';
@ -373,6 +389,8 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"'); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"');
print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"'); print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"');
$checkpicto=''; $checkpicto='';
@ -382,9 +400,7 @@ if ($result) {
$facture_static = new Facture($db); $facture_static = new Facture($db);
$product_static = new Product($db); $product_static = new Product($db);
$form = new Form($db);
$var = true;
while ( $i < min($num_lines, $limit) ) { while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
@ -397,7 +413,7 @@ if ($result) {
$product_static->type = $objp->type; $product_static->type = $objp->type;
$product_static->label = $objp->product_label; $product_static->label = $objp->product_label;
$facture_static->ref = $objp->facnumber; $facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid; $facture_static->id = $objp->facid;
$facture_static->type = $objp->ftype; $facture_static->type = $objp->ftype;
@ -461,6 +477,10 @@ if ($result) {
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
print '</td>'; print '</td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
// Current account // Current account
print '<td align="center" style="' . $code_sell_p_notset . '">'; print '<td align="center" style="' . $code_sell_p_notset . '">';
print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown")); print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));

View File

@ -28,14 +28,10 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs $langs->loadLangs(array("bills","accountancy","trips"));
$langs->load("bills");
$langs->load("accountancy");
$langs->load("trips");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');

View File

@ -27,13 +27,10 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
// Langs // Langs
$langs->load("compta"); $langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
// Security check // Security check
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
@ -44,20 +41,29 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
// Filter $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$year = GETPOST('year', 'int'); if (GETPOST("year",'int')) $year_start = GETPOST("year",'int');
if ($year == 0) { else
$year_current = strftime("%Y", time()); {
$year_start = $year_current; $year_start = dol_print_date(dol_now(), '%Y');
} else { if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_current = $year;
$year_start = $year;
} }
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
$year_current = $year_start;
// Validate History // Validate History
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
/* /*
* Actions * Actions
*/ */
@ -104,32 +110,9 @@ if ($action == 'validatehistory') {
$db->commit(); $db->commit();
setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
} }
} elseif ($action == 'cleanaccountancycode') {
$error = 0;
$db->begin();
// Now clean
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1.= " SET fk_code_ventilation = 0";
$sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql1.= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
$sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
$sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")";
$sql1.=")";
dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
} else {
$db->commit();
setEventMessage($langs->trans('Done'), 'mesgs');
}
} }
/* /*
* View * View
*/ */
@ -141,10 +124,6 @@ $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur
print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . "&nbsp;" . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy'); print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . "&nbsp;" . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
print $langs->trans("DescVentilExpenseReport") . '<br>';
print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>';
// Clean database // Clean database
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
@ -165,37 +144,44 @@ if (! $resql1) {
} }
// End clean database // End clean database
print $langs->trans("DescVentilExpenseReport") . '<br>';
print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>';
$y = $year_current; $y = $year_current;
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; $buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
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 '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(erd.total_ht) as total"; $sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
@ -238,7 +224,9 @@ print '</div>';
print '<br>'; print '<br>';
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, '');
print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -246,22 +234,26 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(erd.total_ht),2) as total"; $sql .= " ROUND(SUM(erd.total_ht),2) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
@ -280,6 +272,7 @@ if ($resql) {
} }
else print length_accountg($row[0]); else print length_accountg($row[0]);
print '</td>'; print '</td>';
print '<td align="left">'; print '<td align="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind')
{ {
@ -303,31 +296,36 @@ print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
{ {
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_fiche_titre($langs->trans("OtherInfo"), '', ''); print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>'; print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; $sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(erd.total_ht) as total"; $sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/expensereport/index.php'); dol_syslog('htdocs/accountancy/expensereport/index.php');

View File

@ -26,7 +26,6 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
@ -34,16 +33,9 @@ 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/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs $langs->loadLangs(array("compta","bills","other","accountancy","trips","productbatch"));
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$langs->load("trips");
$langs->load("productbatch");
$account_parent = GETPOST('account_parent'); $account_parent = GETPOST('account_parent','int');
$changeaccount = GETPOST('changeaccount'); $changeaccount = GETPOST('changeaccount');
// Search Getpost // Search Getpost
$search_expensereport = GETPOST('search_expensereport', 'alpha'); $search_expensereport = GETPOST('search_expensereport', 'alpha');
@ -103,10 +95,18 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
if (is_array($changeaccount) && count($changeaccount) > 0) { if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0; $error = 0;
if (! (GETPOST('account_parent','int') >= 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
}
$db->begin(); $db->begin();
if (! $error)
{
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= " SET erd.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0');
$sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1);
@ -125,6 +125,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$account_parent = ''; // Protection to avoid to mass apply it a second time $account_parent = ''; // Protection to avoid to mass apply it a second time
} }
}
/* /*
@ -164,10 +165,10 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql .= " , " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " , " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " , " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " , " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut >= 5 AND erd.fk_code_ventilation <> 0 "; $sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <> 0 ";
$sql .= " AND aa.rowid = erd.fk_code_ventilation"; $sql .= " AND aa.rowid = erd.fk_code_ventilation";
if (strlen(trim($search_expensereport))) { if (strlen(trim($search_expensereport))) {
$sql .= " AND er.ref like '%" . $search_expensereport . "%'"; $sql .= natural_search("er.ref", $search_expensereport);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= natural_search("f.label", $search_label); $sql .= natural_search("f.label", $search_label);
@ -207,6 +208,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -246,7 +252,7 @@ if ($result) {
print $langs->trans("DescVentilDoneExpenseReport") . '<br>'; print $langs->trans("DescVentilDoneExpenseReport") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>'; print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
$moreforfilter = ''; $moreforfilter = '';

View File

@ -27,7 +27,6 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
@ -35,14 +34,8 @@ 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/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs // Load traductions files requiredby by page
$langs->load("compta"); $langs->loadLangs(array("bills","compta","accountancy","other","trips","productbatch"));
$langs->load("bills");
$langs->load("other");
$langs->load("trips");
$langs->load("main");
$langs->load("accountancy");
$langs->load("productbatch");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha'); $massaction=GETPOST('massaction','alpha');
@ -201,7 +194,7 @@ $sql.= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport"; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
$sql.= " WHERE er.fk_statut > 4 AND erd.fk_code_ventilation <= 0"; $sql.= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
// Add search filter like // Add search filter like
if (strlen(trim($search_expensereport))) { if (strlen(trim($search_expensereport))) {
$sql .= natural_search("er.ref",$search_expensereport); $sql .= natural_search("er.ref",$search_expensereport);
@ -244,6 +237,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -345,7 +343,6 @@ if ($result) {
$expensereport_static = new ExpenseReport($db); $expensereport_static = new ExpenseReport($db);
$form = new Form($db); $form = new Form($db);
$var = true;
while ( $i < min($num_lines, $limit) ) { while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);

View File

@ -26,26 +26,12 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs $langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict"));
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
$langs->load("admin");
$langs->load("dict");
$langs->load("bills");
$langs->load("accountancy");
$langs->load("compta");
$langs->load("banks");
$langs->load("loans");
/* /*
* Actions * Actions
*/ */
@ -63,6 +49,8 @@ print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy'
$step = 0; $step = 0;
if ($conf->accounting->enabled)
{
print $langs->trans("AccountancyAreaDescIntro")."<br>\n"; print $langs->trans("AccountancyAreaDescIntro")."<br>\n";
print "<br>\n";print "<br>\n"; print "<br>\n";print "<br>\n";
@ -168,6 +156,11 @@ print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64+$step))."<br>\n"; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64+$step))."<br>\n";
print "<br>\n"; print "<br>\n";
}
else
{
print $langs->trans("Module10Desc")."<br>\n";
}
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -104,8 +104,8 @@ $idpays = $mysoc->country_id;
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop_company,"; $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop_user,"; $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, bu2.type as typeop_user,";
$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier"; $sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
@ -212,6 +212,7 @@ if ($result) {
'id' => $obj->socid, 'id' => $obj->socid,
'name' => $obj->name, 'name' => $obj->name,
'code_compta' => $compta_soc, 'code_compta' => $compta_soc,
'email' => $obj->email
); );
// Set accountancy code for user // Set accountancy code for user
@ -222,7 +223,8 @@ if ($result) {
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
'lastname' => $obj->lastname, 'lastname' => $obj->lastname,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'accountancy_code' => $compta_user, 'email' => $obj->useremail,
'accountancy_code' => $compta_user
); );
// Variable bookkeeping ($obj->rowid is Bank Id) // Variable bookkeeping ($obj->rowid is Bank Id)
@ -237,7 +239,7 @@ if ($result) {
} else { } else {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
} }
$links = $object->get_url($obj->rowid); $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
//var_dump($i); //var_dump($i);
//var_dump($tabpay); //var_dump($tabpay);
@ -282,11 +284,15 @@ if ($result) {
} else if ($links[$key]['type'] == 'company') { } else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id']; $societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label']; $societestatic->name = $links[$key]['label'];
$societestatic->email = $tabcompany[$obj->rowid]['email'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
if ($compta_soc) $tabtp[$obj->rowid][$compta_soc] += $obj->amount; if ($compta_soc) $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
} else if ($links[$key]['type'] == 'user') { } else if ($links[$key]['type'] == 'user') {
$userstatic->id = $links[$key]['url_id']; $userstatic->id = $links[$key]['url_id'];
$userstatic->name = $links[$key]['label']; $userstatic->name = $links[$key]['label'];
$userstatic->email = $tabuser[$obj->rowid]['email'];
$userstatic->firstname = $tabuser[$obj->rowid]['firstname'];
$userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30);
else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment.
if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount; if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount;
@ -341,7 +347,7 @@ if ($result) {
$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
} else if ($links[$key]['type'] == 'payment_expensereport') { } else if ($links[$key]['type'] == 'payment_expensereport') {
$paymentexpensereportstatic->id = $links[$key]['url_id']; $paymentexpensereportstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id;
} else if ($links[$key]['type'] == 'payment_various') { } else if ($links[$key]['type'] == 'payment_various') {
$paymentvariousstatic->id = $links[$key]['url_id']; $paymentvariousstatic->id = $links[$key]['url_id'];
@ -696,6 +702,7 @@ if (! $error && $action == 'writebookkeeping') {
if ($action == 'exportcsv') { // ISO and not UTF8 ! if ($action == 'exportcsv') { // ISO and not UTF8 !
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$filename = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
// CSV header line // CSV header line
@ -825,7 +832,7 @@ if (empty($action) || $action == 'view') {
//$description = $langs->trans("DescFinanceJournal") . '<br>'; //$description = $langs->trans("DescFinanceJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;

View File

@ -140,9 +140,9 @@ if ($result) {
$compta_fees = $obj->compte; $compta_fees = $obj->compte;
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
$compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); $compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); $compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva // Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
@ -412,9 +412,10 @@ $form = new Form($db);
$userstatic = new User($db); $userstatic = new User($db);
// Export // Export
/*if ($action == 'exportcsv') { /*if ($action == 'exportcsv') { // ISO and not UTF8 !
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$filename = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
// Model Cegid Expert Export // Model Cegid Expert Export
@ -531,7 +532,7 @@ if (empty($action) || $action == 'view') {
$builddate=dol_now(); $builddate=dol_now();
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;

View File

@ -575,9 +575,10 @@ if ($action == 'writebookkeeping') {
$form = new Form($db); $form = new Form($db);
// Export // Export
if ($action == 'exportcsv') { if ($action == 'exportcsv') { // ISO and not UTF8 !
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$filename = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Fournisseur($db); $companystatic = new Fournisseur($db);
@ -627,8 +628,8 @@ if ($action == 'exportcsv') {
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
print '"' . $journal . '"' ; print '"' . $journal . '"' ;
@ -694,7 +695,7 @@ if ($action == 'exportcsv') {
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . ' NPR"' . $sep; print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . ' NPR"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
@ -723,7 +724,7 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
} }
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;

View File

@ -171,7 +171,8 @@ if ($result) {
$line->fetch($obj->fdid); $line->fetch($obj->fdid);
// Situation invoices handling // Situation invoices handling
$prev_progress = $line->get_prev_progress($obj->fdid); $prev_progress = $line->get_prev_progress($obj->rowid);
if ($obj->type == Facture::TYPE_SITUATION) { if ($obj->type == Facture::TYPE_SITUATION) {
// Avoid divide by 0 // Avoid divide by 0
if ($obj->situation_percent == 0) { if ($obj->situation_percent == 0) {
@ -527,10 +528,10 @@ if ($action == 'writebookkeeping') {
$form = new Form($db); $form = new Form($db);
// Export // Export
if ($action == 'exportcsv') { if ($action == 'exportcsv') { // ISO and not UTF8 !
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$filename = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Client($db); $companystatic = new Client($db);
@ -578,8 +579,8 @@ if ($action == 'exportcsv') {
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . $journal . '"'; print '"' . $journal . '"';
@ -653,7 +654,7 @@ if (empty($action) || $action == 'view') {
else else
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;

View File

@ -28,13 +28,10 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs $langs->loadLangs(array("bills","accountancy"));
$langs->load("bills");
$langs->load("accountancy");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');

View File

@ -30,11 +30,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
// Langs // Langs
$langs->load("compta"); $langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
// Security check // Security check
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
@ -45,20 +41,30 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
// Filter
$year = GETPOST("year",'int'); $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
if ($year == 0) { if (GETPOST("year",'int')) $year_start = GETPOST("year",'int');
$year_current = strftime("%Y", time()); else
$year_start = $year_current; {
} else { $year_start = dol_print_date(dol_now(), '%Y');
$year_current = $year; if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_start = $year;
} }
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
$year_current = $year_start;
// Validate History // Validate History
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
/* /*
* Actions * Actions
*/ */
@ -105,31 +111,9 @@ if ($action == 'validatehistory') {
$db->commit(); $db->commit();
setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
} }
} elseif ($action == 'cleanaccountancycode') {
$error = 0;
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1.= " SET fk_code_ventilation = 0";
$sql1.= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
$sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
$sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")";
$sql1.= ")";
dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
} else {
$db->commit();
setEventMessage($langs->trans('Done'), 'mesgs');
}
} }
/* /*
* View * View
*/ */
@ -141,10 +125,6 @@ $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur
print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy'); print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
print $langs->trans("DescVentilSupplier") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>';
// Clean database // Clean database
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
@ -165,35 +145,42 @@ if (! $resql1) {
} }
// End clean database // End clean database
print $langs->trans("DescVentilSupplier") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>';
$y = $year_current; $y = $year_current;
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; $buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
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 '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND ff.fk_statut > 0"; $sql .= " AND ff.fk_statut > 0";
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
@ -238,28 +225,33 @@ print '</div>';
print '<br>'; print '<br>';
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND ff.fk_statut > 0"; $sql .= " AND ff.fk_statut > 0";
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
@ -307,25 +299,30 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_fiche_titre($langs->trans("OtherInfo"), '', ''); print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
//print_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>'; print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; $sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND ff.fk_statut > 0"; $sql .= " AND ff.fk_statut > 0";
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
@ -335,8 +332,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr><td>' . $row[0] . '</td>'; print '<tr><td>' . $row[0] . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td align="right">' . price($row[$i]) . '</td>'; print '<td align="right">' . price($row[$i]) . '</td>';
@ -344,7 +339,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<td align="right"><b>' . price($row[13]) . '</b></td>'; print '<td align="right"><b>' . price($row[13]) . '</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error

View File

@ -26,22 +26,16 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; 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/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs $langs->loadLangs(array("compta","bills","other","accountancy","productbatch"));
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$langs->load("productbatch");
$account_parent = GETPOST('account_parent'); $account_parent = GETPOST('account_parent');
$changeaccount = GETPOST('changeaccount'); $changeaccount = GETPOST('changeaccount');
@ -111,10 +105,19 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
if (is_array($changeaccount) && count($changeaccount) > 0) { if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0; $error = 0;
if (! (GETPOST('account_parent','int') >= 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
}
if (! $error)
{
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1); dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1);
@ -133,6 +136,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$account_parent = ''; // Protection to avoid to mass apply it a second time $account_parent = ''; // Protection to avoid to mass apply it a second time
} }
}
/* /*
@ -164,10 +168,13 @@ print '<script type="text/javascript">
/* /*
* Supplier Invoice lines * Supplier Invoice lines
*/ */
$sql = "SELECT f.rowid as facid, f.ref as facnumber, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,"; $sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,"; $sql.= " l.rowid, l.fk_product, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
$sql.= " aa.label, aa.account_number, "; $sql.= " aa.label, aa.account_number, ";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, co.label as country, s.tva_intra"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, co.label as country, s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = l.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
@ -221,6 +228,11 @@ if (strlen(trim($search_tvaintra))) {
} }
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
@ -229,11 +241,16 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/supplier/lines.php::list'); dol_syslog('accountancy/supplier/lines.php');
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
@ -264,12 +281,12 @@ if ($result) {
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print $langs->trans("DescVentilDoneSupplier") . '<br>'; print $langs->trans("DescVentilDoneSupplier") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formaccounting->select_account($account_parent, 'account_parent', 1); print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>'; print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
$moreforfilter = ''; $moreforfilter = '';
@ -277,8 +294,9 @@ if ($result) {
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// We add search filter
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
@ -291,9 +309,9 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tavintra" value="' . dol_escape_htmltag($search_tavintra) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre" align="center">';
$searchpicto=$form->showFilterButtons(); $searchpicto=$form->showFilterButtons();
print $searchpicto; print $searchpicto;
@ -310,22 +328,22 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
$checkpicto=$form->showCheckAddButtons(); $checkpicto=$form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"');
print "</tr>\n"; print "</tr>\n";
$facturefournisseur_static = new FactureFournisseur($db); $facturefournisseur_static = new FactureFournisseur($db);
$product_static = new Product($db); $product_static = new ProductFournisseur($db);
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label; $codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label;
$facturefournisseur_static->ref = $objp->facnumber; $facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid; $facturefournisseur_static->id = $objp->facid;
$product_static->ref = $objp->product_ref; $product_static->ref = $objp->product_ref;
@ -335,24 +353,26 @@ if ($result) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>'; print '<td>' . $objp->rowid . '</td>';
// Ref Invoice // Ref Invoice
print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>'; print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
print '<td>'; print '<td class="tdoverflowonsmartphone">';
print $objp->invoice_label; print $objp->invoice_label;
print '</td>'; print '</td>';
print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>'; print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
// Ref Product // Ref product
print '<td>'; print '<td>';
if ($product_static->id) if ($product_static->id)
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
if ($objp->product_label) print '<br>'.$objp->product_label; if ($objp->product_label) print '<br>'.$objp->product_label;
print '</td>'; print '</td>';
// Description
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
@ -361,18 +381,20 @@ if ($result) {
print '<td align="right">' . price($objp->total_ht) . '</td>'; print '<td align="right">' . price($objp->total_ht) . '</td>';
print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>'; print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td align="center">'; print '<td align="center">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')) . '">'; print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')) . '">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>'; print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print "</tr>"; print '</tr>';
$i ++; $i ++;
} }
print "</table>"; print '</table>';
print "</div>"; print "</div>";
if ($nbtotalofrecords > $limit) { if ($nbtotalofrecords > $limit) {

View File

@ -27,7 +27,6 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
@ -36,13 +35,8 @@ 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/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Langs // Load traductions files requiredby by page
$langs->load("compta"); $langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$langs->load("productbatch");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha'); $massaction=GETPOST('massaction','alpha');
@ -65,6 +59,8 @@ $search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day","int"); $search_day=GETPOST("search_day","int");
$search_month=GETPOST("search_month","int"); $search_month=GETPOST("search_month","int");
$search_year=GETPOST("search_year","int"); $search_year=GETPOST("search_year","int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha');
@ -104,7 +100,7 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
/* /*
* Action * Actions
*/ */
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
@ -130,6 +126,8 @@ if (empty($reshook))
$search_day = ''; $search_day = '';
$search_month = ''; $search_month = '';
$search_year = ''; $search_year = '';
$search_country = '';
$search_tvaintra = '';
} }
// Mass actions // Mass actions
@ -213,11 +211,14 @@ if (empty($chartaccountcode))
$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
$sql.= " aa.rowid as aarowid"; $sql.= " aa.rowid as aarowid,";
$sql.= " co.label as country, s.tva_intra";
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
@ -246,7 +247,10 @@ if (strlen(trim($search_account))) {
$sql .= natural_search("aa.account_number", $search_account); $sql .= natural_search("aa.account_number", $search_account);
} }
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx",$search_vat,1); $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
} }
if ($search_month > 0) if ($search_month > 0)
{ {
@ -261,6 +265,9 @@ else if ($search_year > 0)
{ {
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
} }
if (strlen(trim($search_country))) {
$sql .= natural_search("co.label", $search_country);
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")";
} else { } else {
@ -281,12 +288,18 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/supplier/list.php'); dol_syslog('accountancy/supplier/list.php');
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num_lines = $db->num_rows($result); $num_lines = $db->num_rows($result);
$i = 0; $i = 0;
@ -305,6 +318,8 @@ if ($result) {
if ($search_desc) $param.='&search_desc='.urlencode($search_desc); if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_amount) $param.='&search_amount='.urlencode($search_amount); if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
if ($search_vat) $param.='&search_vat='.urlencode($search_vat); if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
if ($search_country) $param .= "&search_country=" . urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
@ -343,26 +358,28 @@ if ($result) {
// We add search filter // We add search filter
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year,'search_year',1, 20, 5); $formother->select_year($search_year,'search_year',1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td align="center" class="liste_titre">'; print '<td align="center" class="liste_titre">';
$searchpicto=$form->showFilterButtons(); $searchpicto=$form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print '</tr>'; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
@ -374,6 +391,8 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"'); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"');
print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"'); print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"');
$checkpicto=''; $checkpicto='';
@ -383,9 +402,7 @@ if ($result) {
$facturefourn_static = new FactureFournisseur($db); $facturefourn_static = new FactureFournisseur($db);
$productfourn_static = new ProductFournisseur($db); $productfourn_static = new ProductFournisseur($db);
$form = new Form($db);
$var = true;
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
@ -468,6 +485,9 @@ if ($result) {
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
print '</td>'; print '</td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
// Current account // Current account
print '<td align="center" style="' . $code_buy_p_notset . '">'; print '<td align="center" style="' . $code_buy_p_notset . '">';
print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown")); print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown"));

View File

@ -23,15 +23,15 @@ if (empty($conf) || ! is_object($conf))
exit; exit;
} }
$code = $conf->global->MAIN_INFO_ACCOUNTANT_CODE;
$prefix = $conf->global->ACCOUNTING_EXPORT_PREFIX_SPEC; $prefix = $conf->global->ACCOUNTING_EXPORT_PREFIX_SPEC;
$format = $conf->global->ACCOUNTING_EXPORT_FORMAT; $format = $conf->global->ACCOUNTING_EXPORT_FORMAT;
$nodateexport = $conf->global->ACCOUNTING_EXPORT_NO_DATE_IN_FILENAME; $nodateexport = $conf->global->ACCOUNTING_EXPORT_NO_DATE_IN_FILENAME;
$date_export = dol_print_date($now, '%Y%m%d%H%M%S'); $date_export = "_" . dol_print_date(dol_now(), '%Y%m%d%H%M%S');
header('Content-Type: text/csv'); header('Content-Type: text/csv');
$filename = ($prefix?$prefix . "_":""). "journal_" . $journal . ($nodateexport?"":$date_export) . "." . $format; $completefilename = ($code?$code . "_":"") . ($prefix?$prefix . "_":"") . $filename . ($nodateexport?"":$date_export) . "." . $format;
header('Content-Disposition: attachment;filename=' . $filename); header('Content-Disposition: attachment;filename=' . $completefilename);

View File

@ -39,7 +39,7 @@ $langs->load("members");
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();
$type=array('yesno','texte','chaine'); $oldtypetonewone=array('texte'=>'text','chaine'=>'string'); // old type to new ones
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
@ -53,20 +53,7 @@ if ($action == 'updateall')
{ {
$db->begin(); $db->begin();
$res1=$res2=$res3=$res4=$res5=$res6=0; $res1=$res2=$res3=$res4=$res5=$res6=0;
$res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); $res1=dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
$res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
// Use vat for invoice creation
if ($conf->facture->enabled)
{
$res4=dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res5=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{
$res6=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
}
}
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
{ {
setEventMessages('ErrorFailedToSaveDate', null, 'errors'); setEventMessages('ErrorFailedToSaveDate', null, 'errors');
@ -82,19 +69,16 @@ if ($action == 'updateall')
// Action mise a jour ou ajout d'une constante // Action mise a jour ou ajout d'une constante
if ($action == 'update' || $action == 'add') if ($action == 'update' || $action == 'add')
{ {
$constlineid = GETPOST('rowid','int');
$constname=GETPOST('constname','alpha'); $constname=GETPOST('constname','alpha');
$constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE' || $constname=='ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue=''; $constvalue=(GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue'));
if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice $consttype=(GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
{ $constnote=(GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote'));
if ($constvalue) $constvalue=0;
else $constvalue=1;
}
$consttype=GETPOST('consttype','alpha'); $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
$constnote=GETPOST('constnote');
$res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity); $res=dolibarr_set_const($db,$constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
@ -157,24 +141,16 @@ print '<input type="hidden" name="action" value="updateall">';
* Editing global variables not related to a specific theme * Editing global variables not related to a specific theme
*/ */
$constantes=array( $constantes=array(
'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT', 'ADHERENT_MAIL_FROM'=>'string',
'ADHERENT_AUTOREGISTER_NOTIF_MAIL', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
'ADHERENT_AUTOREGISTER_MAIL_SUBJECT', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
'ADHERENT_AUTOREGISTER_MAIL', 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
'ADHERENT_MAIL_VALID_SUBJECT', 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
'ADHERENT_MAIL_VALID', 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
'ADHERENT_MAIL_COTIS_SUBJECT', 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
'ADHERENT_MAIL_COTIS', 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
'ADHERENT_MAIL_RESIL_SUBJECT',
'ADHERENT_MAIL_RESIL',
'ADHERENT_MAIL_FROM',
); );
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext.='__YEAR__, __MONTH__, __DAY__';
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; $helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; $helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';

View File

@ -241,7 +241,13 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC))
} else { } else {
$entity_qr=''; $entity_qr='';
} }
print '<a target="_blank" href="'.DOL_URL_ROOT.'/public/members/new.php'.$entity_qr.'">'.DOL_MAIN_URL_ROOT.'/public/members/new.php'.$entity_qr.'</a>';
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
print '<a target="_blank" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.$urlwithroot.'/public/members/new.php'.$entity_qr.'</a>';
} }

View File

@ -148,10 +148,12 @@ if ($object->id > 0)
//print '</div>'; //print '</div>';
$createbutton = ''; $newcardbutton = '';
if (! empty($conf->agenda->enabled)) if (! empty($conf->agenda->enabled))
{ {
$createbutton.='<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction").'</a>'; $newcardbutton.='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction");
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
} }
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
@ -162,7 +164,7 @@ if ($object->id > 0)
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $createbutton, '', 0, 1, 1); print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
// List of all actions // List of all actions
$filters=array(); $filters=array();

View File

@ -47,34 +47,6 @@ abstract class ActionsAdherentCardCommon
var $errors=array(); var $errors=array();
/**
* Instantiation of DAO class. Init ->object
*
* @return int 0
* @deprecated Using getInstanceDao should not be used.
*/
private function getInstanceDao()
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
if (! is_object($this->object))
{
$modelclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/dao_'.$this->targetmodule.'_'.$this->canvas.'.class.php');
if (file_exists($modelclassfile))
{
// Include dataservice class (model)
$ret = require_once $modelclassfile;
if ($ret)
{
// Instantiate dataservice class (model)
$modelclassname = 'Dao'.ucfirst($this->targetmodule).ucfirst($this->canvas);
$this->object = new $modelclassname($this->db);
}
}
}
return 0;
}
/** /**
* Get object * Get object
* *
@ -97,141 +69,6 @@ abstract class ActionsAdherentCardCommon
//} //}
} }
/**
* doActions of a canvas is not the doActions of the hook
* @deprecated Use the doActions of hooks instead of this.
*
* @param string $action Type of action
* @param int $id Id of object
* @return void
*/
function doActions(&$action, $id)
{
global $conf, $user, $langs;
// Creation utilisateur depuis Adherent
if ($action == 'confirm_create_user' && GETPOST("confirm") == 'yes')
{
// Recuperation adherent actuel
$result = $this->object->fetch($id);
if ($result > 0)
{
$this->db->begin();
// Creation user
$nuser = new User($this->db);
$result=$nuser->create_from_member($this->object,GETPOST("login"));
if ($result > 0)
{
$result2=$nuser->setPassword($user,GETPOST("password"),0,1,1);
if ($result2)
{
$this->db->commit();
}
else
{
$this->db->rollback();
}
}
else
{
$this->errors[]=$nuser->error;
$this->db->rollback();
}
}
else
{
$this->errors=$this->object->errors;
}
}
// Creation adherent
if ($action == 'add')
{
$this->assign_post();
if (! $_POST["name"])
{
array_push($this->errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
$action = 'create';
}
if ($_POST["name"])
{
$id = $this->object->create($user);
if ($id > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
$this->errors=$this->object->errors;
$action = 'create';
}
}
}
if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes')
{
$result=$this->object->fetch($id);
$this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"];
$result = $this->object->delete(0, $user, 0);
if ($result > 0)
{
header("Location: list.php");
exit;
}
else
{
$this->errors=$this->object->errors;
}
}
if ($action == 'update')
{
if ($_POST["cancel"])
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$this->object->id);
exit;
}
if (empty($_POST["name"]))
{
$this->error=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
$action = 'edit';
}
if (empty($this->error))
{
$this->object->fetch($_POST["adherentid"]);
$this->object->oldcopy = clone $this->object;
$this->assign_post();
$result = $this->object->update($_POST["adherentid"], $user);
if ($result > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$this->object->id);
exit;
}
else
{
$this->errors=$this->object->errors;
$action = 'edit';
}
}
}
}
/** /**
* Set content of ->tpl array, to use into template * Set content of ->tpl array, to use into template
* *

View File

@ -2,9 +2,9 @@
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2016 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2012-2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -41,11 +41,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$langs->load("companies"); // Load traductions files requiredby by page
$langs->load("bills"); $langs->loadLangs(array("companies","bills","members","users","other"));
$langs->load("members");
$langs->load("users");
$langs->load('other');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$cancel=GETPOST('cancel','alpha'); $cancel=GETPOST('cancel','alpha');
@ -238,21 +235,6 @@ if (empty($reshook))
} }
} }
/*
if ($action == 'confirm_sendinfo' && $confirm == 'yes')
{
if ($object->email)
{
$from=$conf->email_from;
if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM;
$result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent"));
$langs->load("mails");
setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs');
}
}*/
if ($action == 'update' && ! $cancel && $user->rights->adherent->creer) if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -298,38 +280,38 @@ if (empty($reshook))
$object->oldcopy = clone $object; $object->oldcopy = clone $object;
// Change values // Change values
$object->civility_id = trim($_POST["civility_id"]); $object->civility_id = trim(GETPOST("civility_id",'alpha'));
$object->firstname = trim($_POST["firstname"]); $object->firstname = trim(GETPOST("firstname",'alpha'));
$object->lastname = trim($_POST["lastname"]); $object->lastname = trim(GETPOST("lastname",'alpha'));
$object->login = trim($_POST["login"]); $object->login = trim(GETPOST("login",'alpha'));
$object->pass = trim($_POST["pass"]); $object->pass = trim(GETPOST("pass",'alpha'));
$object->societe = trim($_POST["societe"]); $object->societe = trim(GETPOST("societe",'alpha'));
$object->company = trim($_POST["societe"]); $object->company = trim(GETPOST("societe",'alpha'));
$object->address = trim($_POST["address"]); $object->address = trim(GETPOST("address",'alpha'));
$object->zip = trim($_POST["zipcode"]); $object->zip = trim(GETPOST("zipcode",'alpha'));
$object->town = trim($_POST["town"]); $object->town = trim(GETPOST("town",'alpha'));
$object->state_id = $_POST["state_id"]; $object->state_id = GETPOST("state_id",'int');
$object->country_id = $_POST["country_id"]; $object->country_id = GETPOST("country_id",'int');
$object->phone = trim($_POST["phone"]); $object->phone = trim(GETPOST("phone",'alpha'));
$object->phone_perso = trim($_POST["phone_perso"]); $object->phone_perso = trim(GETPOST("phone_perso",'alpha'));
$object->phone_mobile= trim($_POST["phone_mobile"]); $object->phone_mobile= trim(GETPOST("phone_mobile",'alpha'));
$object->email = trim($_POST["member_email"]); $object->email = preg_replace('/\s+/', '', GETPOST("member_email",'alpha'));
$object->skype = trim($_POST["skype"]); $object->skype = trim(GETPOST("skype",'alpha'));
$object->birth = $birthdate; $object->birth = $birthdate;
$object->typeid = $_POST["typeid"]; $object->typeid = GETPOST("typeid",'int');
//$object->note = trim($_POST["comment"]); //$object->note = trim(GETPOST("comment","alpha"));
$object->morphy = $_POST["morphy"]; $object->morphy = GETPOST("morphy",'alpha');
if (GETPOST('deletephoto')) $object->photo=''; if (GETPOST('deletephoto','alpha')) $object->photo='';
elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
// Get status and public property // Get status and public property
$object->statut = $_POST["statut"]; $object->statut = GETPOST("statut",'alpha');
$object->public = $_POST["public"]; $object->public = GETPOST("public",'alpha');
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -445,32 +427,32 @@ if (empty($reshook))
$datesubscription=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $datesubscription=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
} }
$typeid=$_POST["typeid"]; $typeid=GETPOST("typeid",'int');
$civility_id=$_POST["civility_id"]; $civility_id=GETPOST("civility_id",'int');
$lastname=$_POST["lastname"]; $lastname=GETPOST("lastname",'alpha');
$firstname=$_POST["firstname"]; $firstname=GETPOST("firstname",'alpha');
$societe=$_POST["societe"]; $societe=GETPOST("societe",'alpha');
$address=$_POST["address"]; $address=GETPOST("address",'alpha');
$zip=$_POST["zipcode"]; $zip=GETPOST("zipcode",'alpha');
$town=$_POST["town"]; $town=GETPOST("town",'alpha');
$state_id=$_POST["state_id"]; $state_id=GETPOST("state_id",'int');
$country_id=$_POST["country_id"]; $country_id=GETPOST("country_id",'int');
$phone=$_POST["phone"]; $phone=GETPOST("phone",'alpha');
$phone_perso=$_POST["phone_perso"]; $phone_perso=GETPOST("phone_perso",'alpha');
$phone_mobile=$_POST["phone_mobile"]; $phone_mobile=GETPOST("phone_mobile",'alpha');
$skype=$_POST["member_skype"]; $skype=GETPOST("member_skype",'alpha');
$email=$_POST["member_email"]; $email=preg_replace('/\s+/', '', GETPOST("member_email",'alpha'));
$login=$_POST["member_login"]; $login=GETPOST("member_login",'alpha');
$pass=$_POST["password"]; $pass=GETPOST("password",'alpha');
$photo=$_POST["photo"]; $photo=GETPOST("photo",'alpha');
//$comment=$_POST["comment"]; //$comment=GETPOST("comment",'none');
$morphy=$_POST["morphy"]; $morphy=GETPOST("morphy",'alpha');
$subscription=$_POST["subscription"]; $subscription=GETPOST("subscription",'alpha');
$public=$_POST["public"]; $public=GETPOST("public",'alpha');
$userid=$_POST["userid"]; $userid=GETPOST("userid",'int');
$socid=$_POST["socid"]; $socid=GETPOST("socid",'int');
$object->civility_id = $civility_id; $object->civility_id = $civility_id;
$object->firstname = $firstname; $object->firstname = $firstname;
@ -630,7 +612,34 @@ if (empty($reshook))
// Send confirmation email (according to parameters of member type. Otherwise generic) // Send confirmation email (according to parameters of member type. Otherwise generic)
if ($object->email && GETPOST("send_mail")) if ($object->email && GETPOST("send_mail"))
{ {
$result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); $subject = '';
$msg= '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
// Get email content fro mtemplae
$arraydefaultmessage=null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, 2);
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
@ -674,7 +683,34 @@ if (empty($reshook))
{ {
if ($object->email && GETPOST("send_mail")) if ($object->email && GETPOST("send_mail"))
{ {
$result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); $subject = '';
$msg= '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
// Get email content fro mtemplae
$arraydefaultmessage=null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1);
} }
if ($result < 0) if ($result < 0)
{ {
@ -962,13 +998,7 @@ else
} }
// Other attributes // Other attributes
$parameters=array(); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
$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))
{
print $object->showOptionals($extrafields,'edit');
}
print '<tbody>'; print '<tbody>';
print "</table>\n"; print "</table>\n";
@ -1093,14 +1123,14 @@ else
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale"); $morphys["mor"] = $langs->trans("Morale");
print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy",'alpha'):$object->morphy));
print "</td></tr>"; print "</td></tr>";
// Type // Type
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
{ {
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->typeid)); print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid")?GETPOST("typeid",'int'):$object->typeid));
} }
else else
{ {
@ -1238,13 +1268,7 @@ else
print '</td></tr>'; print '</td></tr>';
// Other attributes // Other attributes
$parameters=array(); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
$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))
{
print $object->showOptionals($extrafields,'edit',$parameters);
}
print '</table>'; print '</table>';
@ -1339,7 +1363,7 @@ else
array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
); );
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 'yes');
} }
// Confirm validate member // Confirm validate member
@ -1350,10 +1374,34 @@ else
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($object->typeid); $adht->fetch($object->typeid);
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT); $subject = '';
$texttosend=$object->makeSubstitution($adht->getMailOnValid()); $msg= '';
$tmp=$langs->trans("SendAnEMailToMember"); // Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
$arraydefaultmessage=null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
$tmp=$langs->trans("SendingAnEMailToMember");
$tmp.='<br>'.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, '; $tmp.='<br>'.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
$tmp.='<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>'; $tmp.='<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>';
$helpcontent=''; $helpcontent='';
@ -1375,15 +1423,9 @@ else
if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) { if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
$formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
} }
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1,1); print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220);
} }
// Confirm send card by mail
/*if ($action == 'sendinfo')
{
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
}*/
// Confirm terminate // Confirm terminate
if ($action == 'resign') if ($action == 'resign')
{ {
@ -1392,10 +1434,34 @@ else
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($object->typeid); $adht->fetch($object->typeid);
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT); $subject = '';
$texttosend=$object->makeSubstitution($adht->getMailOnResiliate()); $msg= '';
$tmp=$langs->trans("SendAnEMailToMember"); // Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
// Get email content fro mtemplae
$arraydefaultmessage=null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
$tmp=$langs->trans("SendingAnEMailToMember");
$tmp.='<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, '; $tmp.='<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
$tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)'; $tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
$helpcontent=''; $helpcontent='';
@ -1412,7 +1478,7 @@ else
$formquestion=array(); $formquestion=array();
if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false')); if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1); print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resign", $formquestion, 'no', 1, 220);
} }
// Confirm remove member // Confirm remove member
@ -1420,7 +1486,7 @@ else
{ {
$formquestion=array(); $formquestion=array();
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1); print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1);
} }
// Confirm add in spip // Confirm add in spip
@ -1623,11 +1689,11 @@ else
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
if (empty($reshook)) { if (empty($reshook)) {
if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty') if ($action != 'editlogin' && $action != 'editthirdparty')
{ {
// Send // Send
if ($object->statut == 1) { if ($object->statut == 1) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>';
} }
// Send card by email // Send card by email

View File

@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php';
$langs->load("members"); $langs->loadLangs(array("members","errors"));
$langs->load("errors");
// Choix de l'annee d'impression ou annee courante. // Choix de l'annee d'impression ou annee courante.
$now = dol_now(); $now = dol_now();
$year=dol_print_date($now,'%Y'); $year=dol_print_date($now,'%Y');
$month=dol_print_date($now,'%m'); $month=dol_print_date($now,'%m');
$day=dol_print_date($now,'%d'); $day=dol_print_date($now,'%d');
$foruserid=GETPOST('foruserid'); $foruserid=GETPOST('foruserid','alphanohtml');
$foruserlogin=GETPOST('foruserlogin'); $foruserlogin=GETPOST('foruserlogin','alphanohtml');
$mode=GETPOST('mode'); $mode=GETPOST('mode','aZ09');
$model=GETPOST("model"); // Doc template to use for business cards $model=GETPOST("model",'aZ09'); // Doc template to use for business cards
$modellabel=GETPOST("modellabel"); // Doc template to use for address sheet $modellabel=GETPOST("modellabel",'aZ09'); // Doc template to use for address sheet
$mesg=''; $mesg='';
$adherentstatic=new Adherent($db); $adherentstatic=new Adherent($db);
$object=new Adherent($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels // fetch optionals attributes and labels
@ -70,11 +70,11 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
$sql.= " t.libelle as type,"; $sql.= " t.libelle as type,";
$sql.= " c.code as country_code, c.label as country"; $sql.= " c.code as country_code, c.label as country";
// Add fields from extrafields // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) if (! empty($extrafields->attributes[$object->table_element]['label']))
$sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
$sql.= " AND d.entity IN (".getEntity('adherent').")"; $sql.= " AND d.entity IN (".getEntity('adherent').")";
if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid; if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
@ -98,10 +98,10 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
$adherentstatic->firstname=$objp->firstname; $adherentstatic->firstname=$objp->firstname;
// format extrafiled so they can be parsed in function complete_substitutions_array // format extrafiled so they can be parsed in function complete_substitutions_array
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']))
{ {
$adherentstatic->array_options = array(); $adherentstatic->array_options = array();
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{ {
$tmpkey='options_'.$key; $tmpkey='options_'.$key;
if (!empty($objp->$tmpkey)) if (!empty($objp->$tmpkey))

View File

@ -147,9 +147,11 @@ class Adherent extends CommonObject
if ($msgishtml == -1) if ($msgishtml == -1)
{ {
$msgishtml = 0; $msgishtml = 0;
if (dol_textishtml($text,1)) $msgishtml = 1; if (dol_textishtml($text,0)) $msgishtml = 1;
} }
dol_syslog('send_an_email msgishtml='.$msgishtml);
$texttosend=$this->makeSubstitution($text); $texttosend=$this->makeSubstitution($text);
$subjecttosend=$this->makeSubstitution($subject); $subjecttosend=$this->makeSubstitution($subject);
if ($msgishtml) $texttosend=dol_htmlentitiesbr($texttosend); if ($msgishtml) $texttosend=dol_htmlentitiesbr($texttosend);
@ -439,8 +441,8 @@ class Adherent extends CommonObject
$sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null");
$sql.= ", public = '".$this->db->escape($this->public)."'"; $sql.= ", public = '".$this->db->escape($this->public)."'";
$sql.= ", statut = ".$this->statut; $sql.= ", statut = ".$this->db->escape($this->statut);
$sql.= ", fk_adherent_type = ".$this->typeid; $sql.= ", fk_adherent_type = ".$this->db->escape($this->typeid);
$sql.= ", morphy = '".$this->db->escape($this->morphy)."'"; $sql.= ", morphy = '".$this->db->escape($this->morphy)."'";
$sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null"); $sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null");
if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
@ -461,14 +463,7 @@ class Adherent extends CommonObject
$action='update'; $action='update';
// Actions on extra fields (by external module) // Actions on extra fields
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('memberdao'));
$parameters=array('id'=>$this->id);
$action='';
$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 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();
@ -477,8 +472,6 @@ class Adherent extends CommonObject
$error++; $error++;
} }
} }
}
else if ($reshook < 0) $error++;
// Update password // Update password
if (! $error && $this->pass) if (! $error && $this->pass)
@ -1051,9 +1044,11 @@ class Adherent extends CommonObject
* @param string $ref To load member from its ref * @param string $ref To load member from its ref
* @param int $fk_soc To load member from its link to third party * @param int $fk_soc To load member from its link to third party
* @param string $ref_ext External reference * @param string $ref_ext External reference
* @param bool $fetch_optionals To load optionals (extrafields)
* @param bool $fetch_subscriptions To load member subscriptions
* @return int >0 if OK, 0 if not found, <0 if KO * @return int >0 if OK, 0 if not found, <0 if KO
*/ */
function fetch($rowid,$ref='',$fk_soc='',$ref_ext='') function fetch($rowid,$ref='',$fk_soc='',$ref_ext='',$fetch_optionals=true,$fetch_subscriptions=true)
{ {
global $langs; global $langs;
@ -1158,10 +1153,14 @@ class Adherent extends CommonObject
// Retreive all extrafield // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
if ($fetch_optionals) {
$this->fetch_optionals(); $this->fetch_optionals();
}
// Load other properties // Load other properties
if ($fetch_subscriptions) {
$result=$this->fetch_subscriptions(); $result=$this->fetch_subscriptions();
}
return $this->id; return $this->id;
} }
@ -1331,7 +1330,7 @@ class Adherent extends CommonObject
* Do complementary actions after subscription recording. * Do complementary actions after subscription recording.
* *
* @param int $subscriptionid Id of created subscription * @param int $subscriptionid Id of created subscription
* @param string $option Which action ('bankdirect', 'invoiceonly', ...) * @param string $option Which action ('bankdirect', 'bankviainvoice', 'invoiceonly', ...)
* @param int $accountid Id bank account * @param int $accountid Id bank account
* @param int $datesubscription Date of subscription * @param int $datesubscription Date of subscription
* @param int $paymentdate Date of payment * @param int $paymentdate Date of payment
@ -1341,7 +1340,7 @@ class Adherent extends CommonObject
* @param string $num_chq Numero cheque (if Id bank account provided) * @param string $num_chq Numero cheque (if Id bank account provided)
* @param string $emetteur_nom Name of cheque writer * @param string $emetteur_nom Name of cheque writer
* @param string $emetteur_banque Name of bank of cheque * @param string $emetteur_banque Name of bank of cheque
* @param string $autocreatethirdparty Auto create new thirdparty if member not linked to a thirdparty. * @param string $autocreatethirdparty Auto create new thirdparty if member not linked to a thirdparty and we request an option that generate invoice.
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom='', $emetteur_banque='', $autocreatethirdparty=0) function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom='', $emetteur_banque='', $autocreatethirdparty=0)
@ -1352,6 +1351,8 @@ class Adherent extends CommonObject
$this->invoice = null; // This will contains invoice if an invoice is created $this->invoice = null; // This will contains invoice if an invoice is created
dol_syslog("subscriptionComplementaryActions subscriptionid=".$subscriptionid." option=".$option." accountid=".$accountid." datesubscription=".$datesubscription." paymentdate=".$paymentdate." label=".$label." amount=".$amount." num_chq=".$num_chq." autocreatethirdparty=".$autocreatethirdparty);
// Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect' // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect'
if ($option == 'bankdirect' && $accountid) if ($option == 'bankdirect' && $accountid)
{ {
@ -1407,7 +1408,7 @@ class Adherent extends CommonObject
if (! $error) if (! $error)
{ {
if (! ($this->fk_soc > 0)) if (! ($this->fk_soc > 0)) // If not yet linked to a company
{ {
if ($autocreatethirdparty) if ($autocreatethirdparty)
{ {
@ -1429,8 +1430,8 @@ class Adherent extends CommonObject
$result=$customer->create_from_member($this, $companyname, $companyalias); $result=$customer->create_from_member($this, $companyname, $companyalias);
if ($result < 0) if ($result < 0)
{ {
$this->error = $company->error; $this->error = $customer->error;
$this->errors = $company->errors; $this->errors = $customer->errors;
$error++; $error++;
} }
else else
@ -1509,7 +1510,7 @@ class Adherent extends CommonObject
$vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription); $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription);
} }
//print xx".$vattouse." - ".$mysoc." - ".$customer;exit; //print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
$result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datesubscription,$datesubend,0,0,'','TTC',$amount,1); $result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datesubscription,'',0,0,'','TTC',$amount,1);
if ($result <= 0) if ($result <= 0)
{ {
$this->error=$invoice->error; $this->error=$invoice->error;
@ -1577,7 +1578,7 @@ class Adherent extends CommonObject
} }
} }
if (! $error) if (! $error && !empty($bank_line_id))
{ {
// Update fk_bank into subscription table // Update fk_bank into subscription table
$sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id;
@ -1602,8 +1603,9 @@ class Adherent extends CommonObject
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $lang_id=GETPOST('lang_id');
$newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($lang_id))
$newlang = $lang_id;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $customer->default_lang; $newlang = $customer->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
@ -1613,7 +1615,7 @@ class Adherent extends CommonObject
// Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $invoice->generateDocument($invoice->modelpdf, $outputlangs);
} }
} }
@ -1667,6 +1669,8 @@ class Adherent extends CommonObject
if ($result < 0) { $error++; $this->db->rollback(); return -1; } if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers // End call triggers
$this->datevalid = $now;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -1891,6 +1895,8 @@ class Adherent extends CommonObject
$label.= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; $label.= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
if (! empty($this->firstname) || ! empty($this->lastname)) if (! empty($this->firstname) || ! empty($this->lastname))
$label.= '<br><b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs); $label.= '<br><b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs);
if (! empty($this->societe))
$label.= '<br><b>' . $langs->trans('Company') . ':</b> ' . $this->societe;
$label.='</div>'; $label.='</div>';
$url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id; $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id;
@ -2308,8 +2314,8 @@ class Adherent extends CommonObject
if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note_private; if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = $this->note_public; if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2);
if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap'); if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap');
if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap'); if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
@ -2491,4 +2497,134 @@ class Adherent extends CommonObject
return $this->datefin < ($now - $conf->adherent->subscription->warning_delay); return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
} }
/**
* Send reminders by emails before subscription end
* CAN BE A CRON TASK
*
* @param int $daysbeforeend Nb of days before end of subscription (negative number = after subscription)
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
*/
public function sendReminderForExpiredSubscription($daysbeforeend=10)
{
global $conf, $langs, $mysoc, $user;
$error = 0;
$this->output = '';
$this->error='';
$blockingerrormsg = '';
/*if (empty($conf->global->MEMBER_REMINDER_EMAIL))
{
$langs->load("agenda");
$this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Adherent"));
return 0;
}*/
$now = dol_now();
dol_syslog(__METHOD__, LOG_DEBUG);
$tmp=dol_getdate($now);
$datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), -1 * $daysbeforeend, 'd');
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent';
$sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'";
$resql = $this->db->query($sql);
if ($resql)
{
$num_rows = $this->db->num_rows($resql);
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$adherent = new Adherent($this->db);
$formmail=new FormMail($db);
$i=0;
$nbok = 0;
$nbko = 0;
while ($i < $num_rows)
{
$obj = $this->db->fetch_object($resql);
$adherent->fetch($obj->rowid);
if (empty($adherent->email))
{
$nbko++;
}
else
{
$adherent->fetch_thirdparty();
// Send reminder email
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
$arraydefaultmessage=null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $adherent);
//if (is_array($adherent->thirdparty)) $substitutionarraycomp = ...
complete_substitutions_array($substitutionarray, $outputlangs, $adherent);
$subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
$msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
$from = $conf->global->ADHERENT_MAIL_FROM;
$to = $adherent->email;
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
$result = $cmail->sendfile();
if (! $result)
{
$error++;
$this->error = $cmail->error;
$this->errors += $cmail->errors;
$nbko++;
}
else
{
$nbok++;
}
}
else
{
$blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding";
$nbko++;
break;
}
}
$i++;
}
}
else
{
$this->error = $this->db->lasterror();
return 1;
}
if ($blockingerrormsg)
{
$this->error = $blockingerrormsg;
return 1;
}
else
{
$this->output = 'Found '.($nbok + $nbko).' members to send reminder to.';
$this->output.= ' Send email successfuly to '.$nbok.' members';
if ($nbko) $this->output.= ' - Canceled for '.$nbko.' member (no email or email sending error)';
}
return 0;
}
} }

View File

@ -45,12 +45,6 @@ class AdherentType extends CommonObject
public $libelle; public $libelle;
/** @var string Label */ /** @var string Label */
public $label; public $label;
/**
* @var bool
* @deprecated Use subscription
* @see subscription
*/
public $cotisation;
/** /**
* @var int Subsription required (0 or 1) * @var int Subsription required (0 or 1)
* @since 5.0 * @since 5.0
@ -177,12 +171,7 @@ class AdherentType extends CommonObject
{ {
$action='update'; $action='update';
// Actions on extra fields (by external module or standard code) // Actions on extra fields
$hookmanager->initHooks(array('membertypedao'));
$parameters=array('membertype'=>$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 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();
@ -191,8 +180,6 @@ class AdherentType extends CommonObject
$error++; $error++;
} }
} }
}
else if ($reshook < 0) $error++;
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
@ -265,7 +252,7 @@ class AdherentType extends CommonObject
{ {
$sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = ".$rowid; $sql .= " WHERE d.rowid = ".(int) $rowid;
dol_syslog("Adherent_type::fetch", LOG_DEBUG); dol_syslog("Adherent_type::fetch", LOG_DEBUG);
@ -338,7 +325,9 @@ class AdherentType extends CommonObject
* Return array of Member objects for member type this->id (or all if this->id not defined) * Return array of Member objects for member type this->id (or all if this->id not defined)
* *
* @param string $excludefilter Filter to exclude * @param string $excludefilter Filter to exclude
* @param int $mode 0=Return array of member instance, 1=Return array of members id only * @param int $mode 0=Return array of member instance
* 1=Return array of member instance without extra data
* 2=Return array of members id only
* @return mixed Array of members or -1 on error * @return mixed Array of members or -1 on error
*/ */
function listMembersForMemberType($excludefilter='', $mode=0) function listMembersForMemberType($excludefilter='', $mode=0)
@ -361,10 +350,14 @@ class AdherentType extends CommonObject
{ {
if (! array_key_exists($obj->rowid, $ret)) if (! array_key_exists($obj->rowid, $ret))
{ {
if ($mode != 1) if ($mode < 2)
{ {
$memberstatic=new Adherent($this->db); $memberstatic=new Adherent($this->db);
if ($mode == 1) {
$memberstatic->fetch($obj->rowid,'','','',false, false);
} else {
$memberstatic->fetch($obj->rowid); $memberstatic->fetch($obj->rowid);
}
$ret[$obj->rowid]=$memberstatic; $ret[$obj->rowid]=$memberstatic;
} }
else $ret[$obj->rowid]=$obj->rowid; else $ret[$obj->rowid]=$obj->rowid;
@ -456,14 +449,14 @@ class AdherentType extends CommonObject
// Champs // Champs
if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = $this->note; if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
{ {
$valueofldapfield=array(); $valueofldapfield=array();
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database. foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database.
{ {
$member=new Adherent($this->db); $member=new Adherent($this->db);
$member->fetch($val->id); $member->fetch($val->id,'','','',false,false);
$info2 = $member->_load_ldap_info(); $info2 = $member->_load_ldap_info();
$valueofldapfield[] = $member->_load_ldap_dn($info2); $valueofldapfield[] = $member->_load_ldap_dn($info2);
} }
@ -505,7 +498,7 @@ class AdherentType extends CommonObject
/** /**
* getMailOnValid * getMailOnValid
* *
* @return string Return mail model * @return string Return mail content of type or empty
*/ */
function getMailOnValid() function getMailOnValid()
{ {
@ -515,16 +508,14 @@ class AdherentType extends CommonObject
{ {
return $this->mail_valid; return $this->mail_valid;
} }
else
{ return '';
return $conf->global->ADHERENT_MAIL_VALID;
}
} }
/** /**
* getMailOnSubscription * getMailOnSubscription
* *
* @return string Return mail model * @return string Return mail content of type or empty
*/ */
function getMailOnSubscription() function getMailOnSubscription()
{ {
@ -535,16 +526,14 @@ class AdherentType extends CommonObject
{ {
return $this->mail_subscription; return $this->mail_subscription;
} }
else
{ return '';
return $conf->global->ADHERENT_MAIL_COTIS;
}
} }
/** /**
* getMailOnResiliate * getMailOnResiliate
* *
* @return string Return mail model * @return string Return mail model content of type or empty
*/ */
function getMailOnResiliate() function getMailOnResiliate()
{ {
@ -555,10 +544,8 @@ class AdherentType extends CommonObject
{ {
return $this->mail_resiliate; return $this->mail_resiliate;
} }
else
{ return '';
return $conf->global->ADHERENT_MAIL_RESIL;
}
} }
} }

View File

@ -275,8 +275,6 @@ class MembersTypes extends DolibarrApi
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->cotisation);
unset($object->array_options); unset($object->array_options);
unset($object->linkedObjectsIds); unset($object->linkedObjectsIds);
unset($object->context); unset($object->context);

View File

@ -144,7 +144,7 @@ if ($id > 0)
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
//Total taille //Total taille
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>';
print '</table>'; print '</table>';

View File

@ -48,9 +48,6 @@ $subscriptionstatic=new Subscription($db);
print load_fiche_titre($langs->trans("MembersArea")); print load_fiche_titre($langs->trans("MembersArea"));
$var=True;
$Adherents=array(); $Adherents=array();
$AdherentsAValider=array(); $AdherentsAValider=array();
$MemberUpToDate=array(); $MemberUpToDate=array();
@ -255,7 +252,6 @@ print '<th align="right">'.$langs->trans("AmountTotal").'</th>';
print '<th align="right">'.$langs->trans("AmountAverage").'</th>'; print '<th align="right">'.$langs->trans("AmountAverage").'</th>';
print "</tr>\n"; print "</tr>\n";
$var=true;
krsort($Total); krsort($Total);
foreach ($Total as $key=>$value) foreach ($Total as $key=>$value)
{ {

View File

@ -42,23 +42,23 @@ $toselect = GETPOST('toselect', 'array');
// Security check // Security check
$result=restrictedArea($user,'adherent'); $result=restrictedArea($user,'adherent');
$filter=GETPOST("filter"); $filter=GETPOST("filter",'alpha');
$statut=GETPOST("statut"); $statut=GETPOST("statut",'intcomma');
$search=GETPOST("search"); $search=GETPOST("search",'alpha');
$search_ref=GETPOST("search_ref"); $search_ref=GETPOST("search_ref",'alpha');
$search_lastname=GETPOST("search_lastname"); $search_lastname=GETPOST("search_lastname",'alpha');
$search_firstname=GETPOST("search_firstname"); $search_firstname=GETPOST("search_firstname",'alpha');
$search_login=GETPOST("search_login"); $search_login=GETPOST("search_login",'alpha');
$search_address=GETPOST("search_address"); $search_address=GETPOST("search_address",'alpha');
$search_zip=GETPOST("search_zip"); $search_zip=GETPOST("search_zip",'alpha');
$search_town=GETPOST("search_town"); $search_town=GETPOST("search_town",'alpha');
$search_state=GETPOST("search_state"); $search_state=GETPOST("search_state",'alpha');
$search_country=GETPOST("search_country"); $search_country=GETPOST("search_country",'alpha');
$search_phone=GETPOST("search_phone"); $search_phone=GETPOST("search_phone",'alpha');
$search_phone_perso=GETPOST("search_phone_perso"); $search_phone_perso=GETPOST("search_phone_perso",'alpha');
$search_phone_mobile=GETPOST("search_phone_mobile"); $search_phone_mobile=GETPOST("search_phone_mobile",'alpha');
$search_type=GETPOST("search_type"); $search_type=GETPOST("search_type",'alpha');
$search_email=GETPOST("search_email"); $search_email=GETPOST("search_email",'alpha');
$search_categ = GETPOST("search_categ",'int'); $search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int'); $catid = GETPOST("catid",'int');
$optioncss = GETPOST('optioncss','alpha'); $optioncss = GETPOST('optioncss','alpha');
@ -79,6 +79,7 @@ if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); }
if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); }
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Adherent($db);
$hookmanager->initHooks(array('memberlist')); $hookmanager->initHooks(array('memberlist'));
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -261,6 +262,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) $nbtotalofrecords = $db->num_rows($resql); if ($resql) $nbtotalofrecords = $db->num_rows($resql);
else dol_print_error($db); 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 limit // Add limit
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);
@ -288,7 +294,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) &&
llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros'); llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$titre=$langs->trans("MembersList"); $titre=$langs->trans("MembersList");
if (isset($_GET["statut"])) if (GETPOSTISSET("statut"))
{ {
if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); } if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); } if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); }
@ -344,6 +350,14 @@ if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs-
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
$newcardbutton='';
if ($user->rights->adherent->creer)
{
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/adherents/card.php?action=create">'.$langs->trans('NewMember');
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -354,7 +368,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
$topicmail="Information"; $topicmail="Information";
$modelmail="member"; $modelmail="member";
@ -593,7 +607,6 @@ while ($i < min($num, $limit))
$memberstatic->ref=$obj->rowid; $memberstatic->ref=$obj->rowid;
$memberstatic->lastname=$obj->lastname; $memberstatic->lastname=$obj->lastname;
$memberstatic->firstname=$obj->firstname; $memberstatic->firstname=$obj->firstname;
$memberstatic->societe=$obj->company;
$memberstatic->statut=$obj->statut; $memberstatic->statut=$obj->statut;
$memberstatic->datefin= $datefin; $memberstatic->datefin= $datefin;
$memberstatic->socid = $obj->fk_soc; $memberstatic->socid = $obj->fk_soc;
@ -605,6 +618,7 @@ while ($i < min($num, $limit))
} else { } else {
$companyname=$obj->company; $companyname=$obj->company;
} }
$memberstatic->societe = $companyname;
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@ -213,7 +213,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs // Show graphs
print '<table class="border" width="100%"><tr valign="top"><td align="center">'; print '<table class="border" width="100%"><tr class="pair nohover"><td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { else {
print $px1->show(); print $px1->show();

View File

@ -349,8 +349,32 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
// Send confirmation Email // Send confirmation Email
if ($object->email && $sendalsoemail) if ($object->email && $sendalsoemail)
{ {
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); $subject = '';
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); $msg= '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
// Get email content fro mtemplae
$arraydefaultmessage=null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
// Attach a file ? // Attach a file ?
$file=''; $file='';
@ -1018,8 +1042,33 @@ if ($rowid > 0)
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($object->typeid); $adht->fetch($object->typeid);
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); // Send subscription email
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); $subject = '';
$msg= '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "members"));
// Get email content fro mtemplae
$arraydefaultmessage=null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
$tmp='<input name="sendmail" type="checkbox"'.(GETPOST('sendmail','alpha')?' checked':(! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>'; $tmp='<input name="sendmail" type="checkbox"'.(GETPOST('sendmail','alpha')?' checked':(! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>';
$helpcontent=''; $helpcontent='';

View File

@ -145,6 +145,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
} }
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);
@ -181,6 +186,14 @@ if ($result)
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
$newcardbutton='';
if ($user->rights->adherent->cotisation->creer)
{
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/adherents/list.php?status=-1,1">'.$langs->trans('NewSubscription');
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -191,7 +204,7 @@ if ($result)
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
$topicmail="Information"; $topicmail="Information";
$modelmail="subscription"; $modelmail="subscription";

View File

@ -36,13 +36,12 @@ $langs = $GLOBALS['langs'];
$linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("members"); $langs->load("members");
$var=true;
$total=0; $total=0;
foreach($linkedObjectBlock as $key => $objectlink) foreach($linkedObjectBlock as $key => $objectlink)
{ {
?> ?>
<tr <?php echo $GLOBALS['bc'][$var]; ?> > <tr class="oddeven" >
<td><?php echo $langs->trans("Subscription"); ?></td> <td><?php echo $langs->trans("Subscription"); ?></td>
<td><?php echo $objectlink->getNomUrl(1); ?></td> <td><?php echo $objectlink->getNomUrl(1); ?></td>
<td align="center"></td> <td align="center"></td>
@ -53,7 +52,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->amount); echo price($objectlink->amount);
} ?></td> } ?></td>
<td align="right"></td> <td align="right"></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td> <td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>
<?php <?php
} }

View File

@ -228,6 +228,14 @@ if (! $rowid && $action != 'create' && $action != 'edit')
$param = ''; $param = '';
$newcardbutton='';
if ($user->rights->adherent->configurer)
{
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/adherents/type.php?action=create">'.$langs->trans('NewMemberType');
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -237,7 +245,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
$moreforfilter = ''; $moreforfilter = '';
@ -332,7 +340,7 @@ if ($action == 'create')
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');
} }
@ -479,6 +487,9 @@ if ($rowid > 0)
{ {
$sql.=" AND datefin < '".$db->idate($now)."'"; $sql.=" AND datefin < '".$db->idate($now)."'";
} }
$sql.= " ".$db->order($sortfield,$sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@ -486,9 +497,13 @@ if ($rowid > 0)
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) $nbtotalofrecords = $db->num_rows($result); if ($resql) $nbtotalofrecords = $db->num_rows($result);
else dol_print_error($db); 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); $sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
@ -730,7 +745,7 @@ if ($rowid > 0)
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');
} }
@ -738,7 +753,7 @@ if ($rowid > 0)
print '</table>'; print '</table>';
// Extra field // Extra field
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook))
{ {
print '<br><br><table class="border" width="100%">'; print '<br><br><table class="border" width="100%">';
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)

View File

@ -63,7 +63,7 @@ if (empty($reshook))
if ($result > 0) if ($result > 0)
{ {
$object->listMembersForMemberType(); $object->listMembersForMemberType('', 1);
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info); $dn = $object->_load_ldap_dn($info);

251
htdocs/admin/accountant.php Normal file
View File

@ -0,0 +1,251 @@
<?php
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/accountant.php
* \ingroup accountant
* \brief Setup page to configure accountant / auditor
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$action=GETPOST('action','aZ09');
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'adminaccoutant'; // To manage different context of search
$langs->load("admin");
$langs->load("companies");
if (! $user->admin) accessforbidden();
$error=0;
/*
* Actions
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ( ($action == 'update' && ! GETPOST("cancel",'alpha'))
|| ($action == 'updateedit') )
{
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", GETPOST('country_id','int'), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_WEB", GETPOST("web",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note",'none'),'chaine',0,'',$conf->entity);
if ($action != 'updateedit' && ! $error)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
}
/*
* View
*/
$help_url='';
llxHeader('',$langs->trans("CompanyFoundation"),$help_url);
print load_fiche_titre($langs->trans("CompanyFoundation"),'','title_setup');
$head = company_admin_prepare_head();
dol_fiche_head($head, 'accountant', $langs->trans("Company"), -1, 'company');
$form=new Form($db);
$formother=new FormOther($db);
$formcompany=new FormCompany($db);
$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
print $langs->trans("AccountantDesc")."<br>\n";
print "<br>\n";
if ($action == 'edit' || $action == 'updateedit')
{
/**
* Edit parameters
*/
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
document.form_index.action.value="updateedit";
document.form_index.submit();
});
});';
print '</script>'."\n";
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
// Name
print '<tr class="oddeven"><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_NAME?$conf->global->MAIN_INFO_ACCOUNTANT_NAME: GETPOST("nom",'nohtml')) . '" autofocus="autofocus"></td></tr>'."\n";
// Address
print '<tr class="oddeven"><td><label for="address">'.$langs->trans("CompanyAddress").'</label></td><td>';
print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS?$conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS: GETPOST("address",'nohtml')) . '</textarea></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="zipcode">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input class="minwidth100" name="zipcode" id="zipcode" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_ZIP?$conf->global->MAIN_INFO_ACCOUNTANT_ZIP: GETPOST("zipcode",'alpha')) . '"></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="town">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="town" class="minwidth100" id="town" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_TOWN?$conf->global->MAIN_INFO_ACCOUNTANT_TOWN: GETPOST("town",'nohtml')) . '"></td></tr>'."\n";
// Country
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
//if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization
print $form->select_country($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
$formcompany->select_departement($conf->global->MAIN_INFO_ACCOUNTANT_STATE, $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'state_id');
print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
print '<input name="tel" id="phone" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_PHONE . '"></td></tr>';
print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
print '<input name="fax" id="fax" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_FAX . '"></td></tr>';
print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
print '<input name="mail" id="email" class="minwidth200" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_MAIL . '"></td></tr>';
print '</td></tr>'."\n";
// Web
print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
print '<input name="web" id="web" class="minwidth300" value="'. $conf->global->MAIN_INFO_ACCOUNTANT_WEB . '"></td></tr>';
print '</td></tr>'."\n";
// Code
print '<tr class="oddeven"><td><label for="code">'.$langs->trans("AccountantFileNumber").'</label></td><td>';
print '<input name="code" id="code" class="minwidth100" value="'. ($conf->global->MAIN_INFO_ACCOUNTANT_CODE?$conf->global->MAIN_INFO_ACCOUNTANT_CODE: GETPOST("code",'nohtml')) . '" autofocus="autofocus"></td></tr>'."\n";
// Note
print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(GETPOST('note','none') ? GETPOST('note','none') : $conf->global->MAIN_INFO_ACCOUNTANT_NOTE).'</textarea></td></tr>';
print '</td></tr>';
print '</table>';
print '<br><div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '<br>';
print '</form>';
}
else
{
/*
* Show parameters
*/
// Actions buttons
//print '<div class="tabsAction">';
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
//print '</div><br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("CompanyInfo").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven"><td class="titlefield wordbreak">'.$langs->trans("CompanyName").'</td><td>';
print $conf->global->MAIN_INFO_ACCOUNTANT_NAME;
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CompanyAddress").'</td><td>' . nl2br(empty($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS) . '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CompanyZip").'</td><td>' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_ZIP)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ZIP) . '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CompanyTown").'</td><td>' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_TOWN)?'':$conf->global->MAIN_INFO_ACCOUNTANT_TOWN) . '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CompanyCountry").'</td><td>';
if (! empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY))
{
$code = getCountry($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 2);
$img=picto_from_langcode($code);
print $img?$img.' ':'';
print getCountry($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY,1);
}
print '</td></tr>';
if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print '<tr class="oddeven"><td>'.$langs->trans("Region-State").'</td><td>';
else print '<tr class="oddeven"><td>'.$langs->trans("State").'</td><td>';
if (! empty($conf->global->MAIN_INFO_ACCOUNTANT_STATE)) print getState($conf->global->MAIN_INFO_ACCOUNTANT_STATE,$conf->global->MAIN_SHOW_STATE_CODE,0,$conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
else print '&nbsp;';
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("Phone").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_PHONE,$mysoc->country_code) . '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("Fax").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_FAX,$mysoc->country_code) . '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("Mail").'</td><td>' . dol_print_email($conf->global->MAIN_INFO_ACCOUNTANT_MAIL,0,0,0,80) . '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("Web").'</td><td>' . dol_print_url($conf->global->MAIN_INFO_ACCOUNTANT_WEB,'_blank',80) . '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("AccountantFileNumber").'</td><td>' . $conf->global->MAIN_INFO_ACCOUNTANT_CODE . '</td></tr>';
print '<tr class="oddeven"><td class="tdtop">'.$langs->trans("Note").'</td><td>' . (! empty($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) ? nl2br($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) : '') . '</td></tr>';
print '</table>';
print "</div>";
print '</form>';
// Actions buttons
print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a></div>';
print '</div>';
}
llxFooter();
$db->close();

View File

@ -75,6 +75,12 @@ else
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{ {
$search_event = ''; $search_event = '';
$action = '';
}
if (GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') ||GETPOST('button_search','alpha')) // To avoid the save when we click on search
{
$action = '';
} }
if ($action == "save" && empty($cancel)) if ($action == "save" && empty($cancel))
@ -106,34 +112,6 @@ if ($action == "save" && empty($cancel))
} }
} }
if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
$value=(GETPOST($code) ? GETPOST($code) : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}
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);
}
}
/** /**

View File

@ -148,7 +148,6 @@ print "<br>\n";
$selectedvalue=$conf->global->AGENDA_DISABLE_EXT; $selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
$var=true;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
@ -202,7 +201,6 @@ print '<td align="right">'.$langs->trans("Color").'</td>';
print "</tr>"; print "</tr>";
$i=1; $i=1;
$var=true;
while ($i <= $MAXAGENDA) while ($i <= $MAXAGENDA)
{ {
$key=$i; $key=$i;

View File

@ -52,10 +52,10 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_(.*)/',$action,$reg)) if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{ {
$code=$reg[1]; $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) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{ {
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
@ -67,7 +67,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]; $code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0)

View File

@ -29,9 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$langs->load("admin"); $langs->loadLangs(array("admin","other","agenda"));
$langs->load("other");
$langs->load("agenda");
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
@ -47,10 +45,10 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_(.*)/',$action,$reg)) if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{ {
$code=$reg[1]; $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) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{ {
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
@ -62,7 +60,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]; $code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0)
@ -173,8 +171,6 @@ llxHeader();
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
print "<br>\n";

View File

@ -32,9 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$langs->load("admin"); $langs->loadLangs(array("admin","other","agenda"));
$langs->load("other");
$langs->load("agenda");
$def = array(); $def = array();
$actionsave=GETPOST('save','alpha'); $actionsave=GETPOST('save','alpha');

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2014 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,11 +31,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$langs->load("admin"); // Load traductions files requiredby by page
$langs->load("companies"); $langs->loadLangs(array("admin","companies","bills","other","banks"));
$langs->load("bills");
$langs->load("other");
$langs->load("banks");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
@ -178,10 +175,6 @@ print load_fiche_titre($langs->trans("BankSetupModule"), $linkback,
$head = bank_admin_prepare_head(null); $head = bank_admin_prepare_head(null);
dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account');
$var = true;
$var = !$var;
//Show bank account order //Show bank account order
print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print load_fiche_titre($langs->trans("BankOrderShow"), '', '');
@ -201,12 +194,10 @@ $bankorder[1][0] = $langs->trans("BankOrderES");
$bankorder[1][1] = $langs->trans("BankOrderESDesc"); $bankorder[1][1] = $langs->trans("BankOrderESDesc");
$bankorder[1][2] = 'BankCode DeskCode BankAccountNumberKey BankAccountNumber'; $bankorder[1][2] = 'BankCode DeskCode BankAccountNumberKey BankAccountNumber';
$var = true;
$i = 0; $i = 0;
$nbofbank = count($bankorder); $nbofbank = count($bankorder);
while ($i < $nbofbank) { while ($i < $nbofbank) {
$var = !$var;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>' . $bankorder[$i][0] . "</td><td>\n"; print '<td>' . $bankorder[$i][0] . "</td><td>\n";
@ -238,7 +229,6 @@ while ($i < $nbofbank) {
print '</table>' . "\n"; print '</table>' . "\n";
print '<br><br>'; print '<br><br>';
@ -430,7 +420,8 @@ if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) {
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} }
else { else
{
print '<td align="center">' . "\n"; print '<td align="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setreportlastnumreleve">' . img_picto($langs->trans("Disabled"), print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setreportlastnumreleve">' . img_picto($langs->trans("Disabled"),
'switch_off') . '</a>'; 'switch_off') . '</a>';

View File

@ -157,7 +157,6 @@ foreach($dirbarcode as $reldir)
/* /*
* CHOIX ENCODAGE * CHOIX ENCODAGE
*/ */
$var=true;
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'',''); print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'','');
@ -185,7 +184,6 @@ if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$var=true;
while ($i < $num) while ($i < $num)
{ {
@ -277,7 +275,6 @@ print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"update\">"; print "<input type=\"hidden\" name=\"action\" value=\"update\">";
$var=true;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>'; print '<td>'.$langs->trans("Parameter").'</td>';

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2014 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,11 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
$langs->load("admin"); // Load traductions files requiredby by page
$langs->load("companies"); $langs->loadLangs(array("admin","companies","bills","other","banks"));
$langs->load("bills");
$langs->load("other");
$langs->load("banks");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
@ -133,8 +130,6 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
$var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
@ -166,7 +161,6 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled()) if ($module->isEnabled())
{ {
$var = !$var;
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name); print (empty($module->name)?$name:$module->name);
print "</td><td>\n"; print "</td><td>\n";
@ -254,9 +248,6 @@ print '<td>'.$langs->trans("Parameters").'</td>';
print '<td align="center" width="60">&nbsp;</td>'; print '<td align="center" width="60">&nbsp;</td>';
print '<td width="80">&nbsp;</td>'; print '<td width="80">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$var=true;
$var=! $var;
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");

View File

@ -72,8 +72,6 @@ print '<form method="post" action="clicktodial.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setvalue">'; print '<input type="hidden" name="action" value="setvalue">';
$var=true;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("Name").'</td>';

View File

@ -286,7 +286,6 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
$var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -406,7 +405,6 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$var=true;
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('','/doc') as $valdir) foreach (array('','/doc') as $valdir)
@ -537,7 +535,6 @@ print '<td>'.$langs->trans("Parameter").'</td>';
print '<td align="center" width="60">'.$langs->trans("Value").'</td>'; print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print "<td>&nbsp;</td>\n"; print "<td>&nbsp;</td>\n";
print "</tr>\n"; print "</tr>\n";
$var=true;
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
@ -545,7 +542,6 @@ $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>'; $htmltext.='</i>';
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">'; print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';

View File

@ -1,10 +1,11 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2017 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2017 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -37,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$action=GETPOST('action','aZ09'); $action=GETPOST('action','aZ09');
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'admincompany'; // To manage different context of search
$langs->load("admin"); $langs->load("admin");
$langs->load("companies"); $langs->load("companies");
@ -46,8 +48,7 @@ if (! $user->admin) accessforbidden();
$error=0; $error=0;
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$contextpage=array('admincompany','globaladmin'); $hookmanager->initHooks(array('admincompany','globaladmin'));
$hookmanager->initHooks($contextpage);
/* /*
* Actions * Actions
@ -74,11 +75,12 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha'))
} }
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("address",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'aZ09'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail",'alpha'),'chaine',0,'',$conf->entity);
@ -154,26 +156,27 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha'))
} }
} }
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object",'nohtml'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'int'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'aZ09'),'chaine',0,'',$conf->entity);
// Local taxes // Local taxes
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", GETPOST("optionlocaltax1",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", GETPOST("optionlocaltax1",'aZ09'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", GETPOST("optionlocaltax2",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", GETPOST("optionlocaltax2",'aZ09'),'chaine',0,'',$conf->entity);
if($_POST["optionlocaltax1"]=="localtax1on") if($_POST["optionlocaltax1"]=="localtax1on")
{ {
@ -183,9 +186,9 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha'))
} }
else else
{ {
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1','alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1','aZ09'),'chaine',0,'',$conf->entity);
} }
dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1",'aZ09'),'chaine',0,'',$conf->entity);
} }
if($_POST["optionlocaltax2"]=="localtax2on") if($_POST["optionlocaltax2"]=="localtax2on")
{ {
@ -195,9 +198,9 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha'))
} }
else else
{ {
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2','alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2','aZ09'),'chaine',0,'',$conf->entity);
} }
dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2",'aZ09'),'chaine',0,'',$conf->entity);
} }
if ($action != 'updateedit' && ! $error) if ($action != 'updateedit' && ! $error)
@ -293,6 +296,10 @@ $countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst")
print load_fiche_titre($langs->trans("CompanyFoundation"),'','title_setup'); print load_fiche_titre($langs->trans("CompanyFoundation"),'','title_setup');
$head = company_admin_prepare_head();
dol_fiche_head($head, 'company', $langs->trans("Company"), -1, 'company');
print $langs->trans("CompanyFundationDesc")."<br>\n"; print $langs->trans("CompanyFundationDesc")."<br>\n";
print "<br>\n"; print "<br>\n";
@ -324,16 +331,16 @@ if ($action == 'edit' || $action == 'updateedit')
// Addresse // Addresse
print '<tr class="oddeven"><td><label for="address">'.$langs->trans("CompanyAddress").'</label></td><td>'; print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADDRESS?$conf->global->MAIN_INFO_SOCIETE_ADDRESS: GETPOST("address",'nohtml')) . '</textarea></td></tr>'."\n"; print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADDRESS?$conf->global->MAIN_INFO_SOCIETE_ADDRESS: GETPOST("MAIN_INFO_SOCIETE_ADDRESS",'nohtml')) . '</textarea></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="zipcode">'.$langs->trans("CompanyZip").'</label></td><td>'; print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input class="minwidth100" name="zipcode" id="zipcode" value="'. ($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP: GETPOST("zipcode",'alpha')) . '"></td></tr>'."\n"; print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'. ($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP: GETPOST("MAIN_INFO_SOCIETE_ZIP",'alpha')) . '"></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="town">'.$langs->trans("CompanyTown").'</label></td><td>'; print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="town" class="minwidth100" id="town" value="'. ($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN: GETPOST("town",'nohtml')) . '"></td></tr>'."\n"; print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'. ($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN: GETPOST("MAIN_INFO_SOCIETE_TOWN",'nohtml')) . '"></td></tr>'."\n";
// Country // Country
@ -409,7 +416,7 @@ if ($action == 'edit' || $action == 'updateedit')
// IDs of the company (country-specific) // IDs of the company (country-specific)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
$langs->load("companies"); $langs->load("companies");
@ -418,6 +425,13 @@ if ($action == 'edit' || $action == 'updateedit')
print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>'; print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="' . $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '"></td></tr>'; print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="' . $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '"></td></tr>';
// GDPR contact
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
print '</td><td>';
print '<input name="MAIN_INFO_GDPR" id="director" class="minwidth500" value="' . $conf->global->MAIN_INFO_GDPR . '"></td></tr>';
// Capital // Capital
print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>'; print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
@ -562,7 +576,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>'; print '<td width="140">'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
@ -595,7 +609,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>'; print '<td width="140">'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>';
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
@ -726,8 +740,9 @@ else
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("State").'</td><td>'; if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print '<tr class="oddeven"><td>'.$langs->trans("Region-State").'</td><td>';
if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) print getState($conf->global->MAIN_INFO_SOCIETE_STATE); else print '<tr class="oddeven"><td>'.$langs->trans("State").'</td><td>';
if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) print getState($conf->global->MAIN_INFO_SOCIETE_STATE,$conf->global->MAIN_SHOW_STATE_CODE,0,$conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
@ -808,6 +823,11 @@ else
print '<tr class="oddeven"><td>'.$langs->trans("ManagingDirectors").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("ManagingDirectors").'</td><td>';
print $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '</td></tr>'; print $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '</td></tr>';
// GDPR Contact
print '<tr class="oddeven"><td>'.$langs->trans("GDPRContact").'</td><td>';
print $conf->global->MAIN_INFO_GDPR . '</td></tr>';
// Capital // Capital
print '<tr class="oddeven"><td>'.$langs->trans("Capital").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("Capital").'</td><td>';
@ -1131,8 +1151,6 @@ else
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a></div>';
print '</div>'; print '</div>';
print '<br>';
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> /* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,9 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
$langs->load("admin"); // Load traductions files requiredby by page
$langs->load("errors"); $langs->loadLangs(array("admin","errors","contracts"));
$langs->load("contracts");
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
@ -220,7 +219,6 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
$var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -339,7 +337,6 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$var=true;
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
foreach (array('','/doc') as $valdir) foreach (array('','/doc') as $valdir)
@ -377,7 +374,6 @@ foreach ($dirmodels as $reldir)
if ($modulequalified) if ($modulequalified)
{ {
$var = !$var;
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name); print (empty($module->name)?$name:$module->name);
print "</td><td>\n"; print "</td><td>\n";
@ -472,7 +468,6 @@ print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>'; print '<td>'.$langs->trans("Parameter").'</td>';
print '<td align="center" width="60">'.$langs->trans("Value").'</td>'; print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true;
$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
@ -480,7 +475,6 @@ $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>'; $htmltext.='</i>';
$var=! $var;
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
print '<br>'; print '<br>';

142
htdocs/admin/dav.php Normal file
View File

@ -0,0 +1,142 @@
<?php
/* Copyright (C) 2008-2018 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/dav.php
* \ingroup dav
* \brief Page to setup DAV server
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
$langs->loadLangs(array("admin","other","agenda"));
if (!$user->admin)
accessforbidden();
// Parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$arrayofparameters=array('DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200'));
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
/*
* View
*/
llxHeader('', $langs->trans("DAVSetup"), $wikihelp);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("DAVSetup"),$linkback,'title_setup');
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$head=dav_admin_prepare_head();
dol_fiche_head($head, 'webdav', '', -1, 'action');
if ($action == 'edit')
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
{
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
}
print '</table>';
print '<br><div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print '</form>';
print '<br>';
}
else
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
{
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip'));
print '</td><td>' . $conf->global->$key . '</td></tr>';
}
print '</table>';
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';
}
dol_fiche_end();
/*print '<div class="center">';
print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
print "</div>";
*/
print "</form>\n";
clearstatcache();
print $langs->trans("WebDAVSetupDesc")."<br>\n";
print "<br>";
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Show message
$message='';
$url='<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV',$url);
$message.='<br>';
print $message;
llxFooter();
$db->close();

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