Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into develop

This commit is contained in:
fappels 2017-07-09 08:19:45 +02:00
commit 71fd9d324c
1486 changed files with 46120 additions and 84222 deletions

View File

@ -2,6 +2,7 @@
# from Dolibarr GitHub repository. # from Dolibarr GitHub repository.
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/
dist: precise
sudo: required sudo: required
language: php language: php
@ -10,22 +11,28 @@ php:
- '5.3' - '5.3'
- '5.4' - '5.4'
- '5.5' - '5.5'
- '5.6' - '5.6.29'
- '7.0' - '7.0'
- '7.1' - '7.1'
- nightly - nightly
addons: addons:
mariadb: '10.0' mariadb: '10.0'
# FIXME: find a way to import a MySQL dump into PostgreSQL postgresql: '9.3'
#postgresql: '9.3'
apt: apt:
sources:
# To use the last version of pgloader, we add repo of postgresql
- postgresql
- sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
- key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
packages: packages:
# We need a webserver to test the webservices # We need a webserver to test the webservices
# Let's install Apache with. # Let's install Apache with.
- apache2 - apache2
# mod_php is not supported by Travis. Add fcgi. We install FPM later on. # mod_php is not supported by Travis. Add fcgi. We install FPM later on.
- libapache2-mod-fastcgi - libapache2-mod-fastcgi
# We need pgloader for import mysql database into pgsql
- pgloader
# Start on every boot # Start on every boot
services: services:
@ -39,8 +46,7 @@ env:
# MariaDB overrides MySQL installation so it's not possible to test both yet # MariaDB overrides MySQL installation so it's not possible to test both yet
#- DB=mysql #- DB=mysql
- DB=mariadb - DB=mariadb
# FIXME: find a way to import a MySQL dump into PostgreSQL - DB=postgresql
#- DB=postgresql
# TODO # TODO
#- DB=sqlite #- DB=sqlite
# See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP
@ -53,7 +59,6 @@ matrix:
allow_failures: allow_failures:
- php: 7.1 - php: 7.1
- php: nightly - php: nightly
# FIXME
#- env: DB=postgresql #- env: DB=postgresql
# TODO # TODO
#- env: DB=sqlite #- env: DB=sqlite
@ -77,6 +82,13 @@ before_install:
phpenv config-rm xdebug.ini phpenv config-rm xdebug.ini
echo echo
- |
if [ "$DB" = 'postgresql' ]; then
echo "Check pgloader version"
pgloader --version
echo
fi
install: install:
- | - |
echo "Updating Composer" echo "Updating Composer"
@ -132,10 +144,10 @@ before_script:
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.3' ] || [ "$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!
echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini #echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
echo echo
echo "Enabling Memcached for PHP <= 5.4" echo "Enabling Memcached for PHP <= 5.4"
# Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1 and nightly! # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1 and nightly!
@ -164,16 +176,19 @@ before_script:
- | - |
echo "Setting up database" echo "Setting up database"
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then
echo "MySQL" echo "MySQL"
mysql -e 'DROP DATABASE IF EXISTS travis;' mysql -e 'DROP DATABASE IF EXISTS travis;'
mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
mysql -e 'FLUSH PRIVILEGES;'
mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
fi fi
# FIXME: find a way to import a MySQL dump into PostgreSQL if [ "$DB" = 'postgresql' ]; then
#if [ "$DB" = 'postgresql' ]; then
#pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
#fi #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr
pgloader mysql://root@127.0.0.1/travis postgresql:///travis
fi
# TODO: SQLite # TODO: SQLite
echo echo
@ -190,10 +205,9 @@ before_script:
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then
echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE
fi fi
# FIXME if [ "$DB" = 'postgresql' ]; then
#if [ "$DB" = 'postgresql' ]; then echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE
# echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE fi
#fi
# TODO: SQLite # TODO: SQLite
echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE
cat $CONF_FILE cat $CONF_FILE
@ -252,8 +266,6 @@ script:
set +e set +e
echo echo
# TODO: dev/* checks
- | - |
echo "Checking coding style" echo "Checking coding style"
# Ensure we catch errors # Ensure we catch errors
@ -267,8 +279,6 @@ script:
# TODO: Check CSS (csslint?) # TODO: Check CSS (csslint?)
# TODO: check SQL syntax (pgsanity?)
- | - |
echo "Upgrading Dolibarr" echo "Upgrading Dolibarr"
# Ensure we catch errors # Ensure we catch errors

View File

@ -224,13 +224,13 @@ source_file = htdocs/langs/en_US/members.lang
source_lang = en_US source_lang = en_US
type = MOZILLAPROPERTIES type = MOZILLAPROPERTIES
[dolibarr.members] [dolibarr.modulebuilder]
file_filter = htdocs/langs/<lang>/modulebuilder.lang file_filter = htdocs/langs/<lang>/modulebuilder.lang
source_file = htdocs/langs/en_US/modulebuilder.lang source_file = htdocs/langs/en_US/modulebuilder.lang
source_lang = en_US source_lang = en_US
type = MOZILLAPROPERTIES type = MOZILLAPROPERTIES
[dolibarr.members] [dolibarr.multicurrency]
file_filter = htdocs/langs/<lang>/multicurrency.lang file_filter = htdocs/langs/<lang>/multicurrency.lang
source_file = htdocs/langs/en_US/multicurrency.lang source_file = htdocs/langs/en_US/multicurrency.lang
source_lang = en_US source_lang = en_US

View File

@ -6,6 +6,8 @@ English Dolibarr ChangeLog
For developers: For developers:
NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... NEW: Add a lot of API REST: dictionaryevents, memberstypes, ...
NEW: Big refactorization of multicompany transverse mode.
NEW: getEntity function use true $shared value by default.
WARNING: WARNING:
@ -15,12 +17,64 @@ Following changes may create regression for some external modules, but were nece
* The page societe/soc.php was renamed into societe/card.php to match page naming conventions. * The page societe/soc.php was renamed into societe/card.php to match page naming conventions.
* The page compta/facture.php was renamed into compta/facture/card.php to match page naming conventions. * The page compta/facture.php was renamed into compta/facture/card.php to match page naming conventions.
* The signature of method ->delete() of class Product and PriceExpression was changed from * The signature of method ->delete() of class Product and PriceExpression was changed from
->delete($id, notrigger) to ->delete(User, notrigger) to match standard dev rules. ->delete(id, notrigger) to ->delete(User, notrigger) to match standard dev rules.
* The signature of method ->delete() of class Adherent was changed from
->delete(id) to ->delete(id, User, notrigger) to match standard dev rules.
* Removed CommonObject::displayMarginInfos (was deprecated in 3.8). Use same method into * Removed CommonObject::displayMarginInfos (was deprecated in 3.8). Use same method into
html.formmargin.class.php html.formmargin.class.php
* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. * Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used.
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still * Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
exists, but if an external module need action on it, it must provides itself its trigger file. exists, but if an external module need action on it, it must provides itself its trigger file.
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
* The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output
content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow
hook specifications so you must return output into "resprint".
***** ChangeLog for 5.0.4 compared to 5.0.3 *****
FIX: #5640 Prices of a predefined product/service were incorrect under certain circumstances
FIX: #6541 since 4.0.4 to 5.0.0 autofill zip/town not working
FIX: #6880 #6925
FIX: #6885
FIX: #6926
FIX: #7003
FIX: #7012
FIX: #7040
FIX: #7048 #6075
FIX: Can set supplier invoice to billed.
FIX: Can't create invoice if PO disapproved
FIX: contratligne update
FIX: CVE-2017-7886
FIX: default param
FIX: Line of invoices not inserted when using POS module and VAT NPR.
FIX: origin & originid on supplierproposal
FIX: Redirect to payment page from member subscription page failed if a unique security key was defined.
FIX: REST api to get project when user has permission to read all.
FIX: situation_progress param default value must be 100 and not 0
FIX: SQL injection on user/index.php parameter search_statut.
FIX: vat code not saved during product creation.
FIX: Warnings
***** ChangeLog for 5.0.3 compared to 5.0.2 *****
FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty
FIX: #6813
FIX: 6863
FIX: #6877
FIX: #6881
FIX: Better sanitizing of search all parameter.
FIX: Correction with author and validator user on orders
FIX: dialog window with md theme must not be hidden by left menu part.
FIX: doactions hook missing in invoice model page
FIX: Fullname when member is a moral entity with no name.
FIX: Link to files on bank account tab broken with multicompany FIX: Link to preview on thirdparty broken with multicompany
FIX: New vat code not correctly implemented if "1 price per customer".
FIX: Pagination of invoices
FIX: pagination on resources
FIX: REST API not possible to add agendaevents
FIX: situation invoice broken due to the all percent application form inside addline form
FIX: SQL injection on user/index.php parameter search_statut.
FIX: XSS
***** ChangeLog for 5.0.2 compared to 5.0.1 ***** ***** ChangeLog for 5.0.2 compared to 5.0.1 *****
FIX: #6468 + Fix missing translation FIX: #6468 + Fix missing translation
@ -234,7 +288,29 @@ Dolibarr better:
- Method commande->set_availability(user, availability_id) removed from commande class, use method commande->availability(availability_id, notrigger). - Method commande->set_availability(user, availability_id) removed from commande class, use method commande->availability(availability_id, notrigger).
Dolibarr 5.0 was frozen before PHP 7.1 was released. Unit tests are successful on PHP 7.1 but we don't have enough Dolibarr 5.0 was frozen before PHP 7.1 was released. Unit tests are successful on PHP 7.1 but we don't have enough
feedback to confirm all application is compatible. Current officiel supported PHP versions are PHP 5.3 to 7.0. feedback to confirm whole application is compatible. Current officiel supported PHP versions are PHP 5.3 to 7.0.
***** ChangeLog for 4.0.6 to 4.0.5 *****
FIX: #6613 Default subject for Supplier proposal emails is filled with a non-existing key
FIX: #6623 User card shows "Return to list" link even if the user has no rights to list users
FIX: #6636 Complete fix
FIX: #6669 User with no permission to edit customer invoices can see a edit button in project entry
FIX: #6671 Cannot remove thirdparty type with "#" in its name
FIX: #6673 Missing "nature" table header in thirdparty list
FIX: #6675 Restricted user with no agenda permissions can see a button to create appointment in thirdparty contact list
FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty
FIX: #6679 User with restricted supplier invoice permissions can edit project, payment conditions, payment mode
FIX: #6680 User with restricted supplier invoice permissions sees "reopen" button even if he has no permission to do it
FIX: #6813
FIX: Correction with author and validator user on orders
FIX: doactions hook missing in invoice model page
FIX: dont get empty "Incoterms : - " string if no incoterm
FIX: dont lose supplier ref if no supplier price in database
FIX: forgotten parameter for right multicompany use
FIX: global $dateSelector isn't the good one, then date selector on objectline_create tpl was hidden
FIX: limit+1 dosn't show Total line
FIX: supplier order line were always created with rang = 0
***** ChangeLog for 4.0.5 to 4.0.4 ***** ***** ChangeLog for 4.0.5 to 4.0.4 *****

View File

@ -98,34 +98,58 @@ Voir fichier ChangeLog.
- Rapports - Rapports
- Imports/Exports des données - Imports/Exports des données
- Connectivité LDAP - Connectivité LDAP
- De nombreuses autres fonctionnalités issues de modules officiels ou non (AWStats, Bittorrent, Gravatar, Google, Webcalendar...) - Intégratn de ClickToDial
- Intégration RSS
- Intégation Skype
- Intégration de système de paiements (Paypal, Strip, Paybox...)
- … - …
### Divers: ### Divers:
- Application multi-utilisateurs avec différents niveaux de permissions par module. - Multi-langue.
- Multi-utilisateurs avec différents niveaux de permissions par module.
- Multi-devise.
- Peux être multi-société par ajout du module externe multi-société. - Peux être multi-société par ajout du module externe multi-société.
- Peux-être multi-devise par ajout du module externe multi-devise.
- Plusieurs gestionnaires de menus (possibilité de différencier les menus pour les utilisateurs internes ou externes comme les clients ou fournisseurs).
- Application simple à utiliser.
- Plusieurs thèmes visuels. - Plusieurs thèmes visuels.
- Code simple et facilement personnalisable. - Application simple à utiliser.
- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur http://wiki.dolibarr.org/index.php/Prérequis). - Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur https://wiki.dolibarr.org/index.php/Prérequis).
- Compatible avec toutes les offres Cloud du marché respectant les prérequis de base de données et PHP. - Compatible avec toutes les offres Cloud du marché respectant les prérequis de base de données et PHP.
- Export PDF de tous les éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) - Code simple et facilement personnalisable (pas de framework lourd; mécanisme de hook et triggers).
- APIs.
- Génération PDF et ODT des éléments (factures, propositions commerciales, commandes, bons expéditions, etc...)
- …
### Extension
Dolibarr peut aussi être étendu à volonté avec l'ajout de module/applications externes développées par des développeus tiers, disponible sur [DoliStore](https://www.dolistore.com).
## CE QUE DOLIBARR NE PEUT PAS FAIRE (TACHES A FAIRE) ## CE QUE DOLIBARR NE PEUT PAS (ENCORE) FAIRE
Voici un liste de fonctionnalites pas encore gérées par Dolibarr: Voici un liste de fonctionnalites pas encore gérées par Dolibarr:
- Pas encore de compta analytique double-partie (uniquement gestion de trésorerie).
- Dolibarr ne gère qu'une seule monnaie à la fois (mono-devise).
- Dolibarr ne contient pas de module de Gestion de la paie. - Dolibarr ne contient pas de module de Gestion de la paie.
- Les tâches du module de gestion de projets n'ont pas de dépendance entre elle. - Les tâches du module de gestion de projets n'ont pas de dépendances entre elle.
- Dolibarr ne contient pas de Webmail. - Dolibarr n'embarque pas de Webmail intégré nativement.
- Dolibarr ne fait pas le café (pas encore). - Dolibarr ne fait pas le café (pas encore).
## DOCUMENTATION
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
Voir le fichier [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)
## CREDITS
Dolibarr est le résultat du travail de nombreux contributeurs depuis des années et utilise des librairies d'autres contributeurs.
Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT)
## ACTUALITES ET RESEAUX SOCIAUX ## ACTUALITES ET RESEAUX SOCIAUX
Suivez le projet Dolibarr project sur les réseaux francophones Suivez le projet Dolibarr project sur les réseaux francophones

View File

@ -12,6 +12,7 @@ You can use it as a standalone application or as a web application to be able to
![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x400.png) ![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x400.png)
## LICENSE ## LICENSE
Dolibarr is released 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 (GPL-3+). Dolibarr is released 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 (GPL-3+).
@ -20,6 +21,7 @@ See the [COPYING](https://github.com/Dolibarr/dolibarr/blob/develop/COPYING) fil
Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list. Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list.
## INSTALLING ## INSTALLING
### Download ### Download
@ -67,6 +69,7 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql)
- Follow the installer instructions - Follow the installer instructions
## UPGRADING ## UPGRADING
- Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package.
@ -75,13 +78,15 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql)
*Note: migration process can safely be done multiple times by calling the page /install/index.php* *Note: migration process can safely be done multiple times by calling the page /install/index.php*
## WHAT'S NEW ## WHAT'S NEW
See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file. See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file.
## FEATURES ## FEATURES
### Main modules (all optional) ### Main application/modules (all optional)
- Customers, Prospects and/or Suppliers directory - Customers, Prospects and/or Suppliers directory
- Products and/or Services catalog - Products and/or Services catalog
@ -107,7 +112,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- Point of Sale - Point of Sale
- … - …
### Other modules ### Other application/modules
- Bookmarks management - Bookmarks management
- Donations management - Donations management
@ -120,56 +125,63 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
- ClickToDial integration - ClickToDial integration
- RSS integration - RSS integration
- Skype integration - Skype integration
- Payment platforms integration (PayBox, PayPal) - Payment platforms integration (PayPal, Stripe, Paybox...)
- … - …
### Other general features ### Other general features
- Multi-Users and groups with finely grained rights
- Localization in most major languages - Localization in most major languages.
- Can manage several companies by adding external module multi-company. - Multi-Users and groups with finely grained rights.
- Can manage several currencies by adding external module multi-currency. - Multi-currency.
- Very user friendly and easy to use - Multi-company by adding of an external module.
- Very user friendly and easy to use.
- Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one)
- Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](http://wiki.dolibarr.org/index.php/Prerequisite)) - Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite))
- Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. - Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites.
- An easy to understand, maintain and code interfaces with your own information system (PHP with no heavy framework; trigger and hook architecture) - APIs.
- An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture)
- Support for country specific features: - Support for country specific features:
- Spanish Tax RE and ISPF - Spanish Tax RE and ISPF
- French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM)
- Canadian double taxes (federal/province) and other countries using cumulative VAT - Canadian double taxes (federal/province) and other countries using cumulative VAT
- Tunisian tax stamp - Tunisian tax stamp
- Argentina invoice numbering using A,B,C...
- Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE)
- PDF or ODT generation for invoice, proposals, orders... - PDF or ODT generation for invoice, proposals, orders...
- … - …
### Extending ### Extending
Dolibarr can be extended with a lot of other external 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 ## FUTURE
These are features that Dolibarr does **not** yet fully support: These are features that Dolibarr does **not** yet fully support:
- Double-entry bookkeeping yet (only bank and treasury management)
- Tasks dependencies in projects - Tasks dependencies in projects
- Payroll module - Payroll module
- Webmail - No native embedded Webmail
- Dolibarr can't do coffee (yet) - Dolibarr can't do coffee (yet)
## DOCUMENTATION ## DOCUMENTATION
Administrator, user, developer and translator's documentations are available along with other community resources on the [Wiki](https://wiki.dolibarr.org). Administrator, user, developer and translator's documentations are available along with other community resources on the [Wiki](https://wiki.dolibarr.org).
## CONTRIBUTING ## CONTRIBUTING
See file [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) See file [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)
## CREDITS ## CREDITS
Dolibarr is the work of many contributors over the years and uses some fine libraries. Dolibarr is the work of many contributors over the years and uses some fine libraries.
See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file.
## NEWS AND SOCIAL NETWORKS ## NEWS AND SOCIAL NETWORKS
Follow Dolibarr project on: Follow Dolibarr project on:

View File

@ -174,7 +174,7 @@ or
Puis pour se connecter et préparer l'environnement Puis pour se connecter et préparer l'environnement
> schroot -c name_of_chroot (exemple schroot -c unstable-amd64-sbuild) > schroot -c name_of_chroot (exemple schroot -c unstable-amd64-sbuild)
> cat /etc/debian_chroot to check which debian branch we are into > cat /etc/debian_chroot to check which debian branch we are into
> apt-get install vi dialog > apt-get install vim dialog
> vi /usr/sbin/policy-rc.d and replace return code 101 (not allowed) into 0 (ok) > vi /usr/sbin/policy-rc.d and replace return code 101 (not allowed) into 0 (ok)
> apt-get update > apt-get update
> apt-get upgrade > apt-get upgrade
@ -444,3 +444,4 @@ Note that package 3.5.7 contains not only fixed for bugs reported to debian. It
so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935. so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935.
After discussion with ..., it appears that security holes are enough to request this unblock request." After discussion with ..., it appears that security holes are enough to request this unblock request."
Note: If there is a response to ask more information, don't forget to remove the tag during answer.

View File

@ -4,7 +4,14 @@ dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jsgantt/*
dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/* dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/*
# Those are false positives, the files are their own sources since # Those are false positives, the files are their own sources since
# they are not minified # they are not minified
source-is-missing htdocs/includes/jsgantt/jsgantt.js * source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/a11yhelp/dialogs/lang/*.js
source-is-missing htdocs/includes/jquery/plugins/colorpicker/jquery.colorpicker.js * source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/specialchar/dialogs/lang/*.js
source-is-missing htdocs/includes/jquery/plugins/select2/select2.js * source-is-missing htdocs/includes/ckeditor/ckeditor/lang/*.js
source-is-missing htdocs/includes/jquery/plugins/select2/select2_locale_ar.js * source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/dialogs/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/filter/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/templates/templates/default.js
source-is-missing htdocs/includes/restler/framework/Luracast/Restler/explorer/lib/*.js
# Those are false positives, the files are their own sources since
# they are data files
source-is-missing htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json

View File

@ -5,7 +5,7 @@
// during install process to be used. // during install process to be used.
// //
// //
$force_install_noedit=2; $force_install_noedit=2; // 1=To block vars specific to distrib, 2 to block all technical parameters
$force_install_message='KeepDefaultValuesWamp'; $force_install_message='KeepDefaultValuesWamp';
$force_install_main_data_root='WAMPROOT/dolibarr_documents'; $force_install_main_data_root='WAMPROOT/dolibarr_documents';
$force_install_type='mysqli'; $force_install_type='mysqli';

View File

@ -86,8 +86,8 @@ else
} }
print "Release : ".$release."\n"; print "Release : ".$release."\n";
print "Include custom : ".$includecustom."\n"; print "Include custom in signature : ".$includecustom."\n";
print "Include constants: "; print "Include constants in signature : ";
foreach ($includeconstants as $countrycode => $tmp) foreach ($includeconstants as $countrycode => $tmp)
{ {
foreach($tmp as $constname => $constvalue) foreach($tmp as $constname => $constvalue)

View File

@ -14,7 +14,7 @@
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
use Cwd; use Cwd;
use Term::ANSIColor;
# Change this to defined target for option 98 and 99 # Change this to defined target for option 98 and 99
$PROJECT="dolibarr"; $PROJECT="dolibarr";
@ -313,6 +313,75 @@ foreach my $target (sort keys %CHOOSEDTARGET) {
print "\n"; print "\n";
#print join(',',sort keys %CHOOSEDTARGET)."\n";
# Check if there is at least one target to build
#----------------------------------------------
$nboftargetok=0;
$nboftargetneedbuildroot=0;
$nbofpublishneedtag=0;
$nbofpublishneedchangelog=0;
foreach my $target (sort keys %CHOOSEDTARGET) {
if ($target eq '-CHKSUM') { $nbofpublishneedchangelog++; }
if ($CHOOSEDTARGET{$target} < 0) { next; }
if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP' && $target ne '-CHKSUM')
{
$nboftargetneedbuildroot++;
}
$nboftargetok++;
}
foreach my $target (sort keys %CHOOSEDPUBLISH) {
if ($CHOOSEDPUBLISH{$target} < 0) { next; }
if ($target eq 'ASSO') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; }
if ($target eq 'SF') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; }
$nboftargetok++;
}
if ($nboftargetok) {
# Check Changelog
#----------------
if ($nbofpublishneedchangelog)
{
# Test that the ChangeLog is ok
$TMPBUILDTOCHECKCHANGELOG=$BUILD;
$TMPBUILDTOCHECKCHANGELOG =~ s/\-rc\d*//;
$TMPBUILDTOCHECKCHANGELOG =~ s/\-beta\d*//;
print "\nCheck if ChangeLog is ok for version $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG\n";
$ret=`grep "ChangeLog for $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG" "$SOURCE/ChangeLog" 2>&1`;
if (! $ret)
{
print color("yellow"), "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n", color('reset');
}
else
{
print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog. But you can regenerate it with command:'\n";
}
if (! $BUILD || $BUILD eq '0-rc') # For a major version
{
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
}
else # For a maintenance release
{
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
}
print "\n";
if (! $ret)
{
print "\nPress F to force and continue anyway (or other key to stop)... ";
my $WAITKEY=<STDIN>;
chomp($WAITKEY);
if ($WAITKEY ne 'F')
{
print "Canceled.\n";
exit;
}
}
}
# Build xml check file # Build xml check file
#----------------------- #-----------------------
if ($CHOOSEDTARGET{'-CHKSUM'}) if ($CHOOSEDTARGET{'-CHKSUM'})
@ -327,31 +396,6 @@ if ($CHOOSEDTARGET{'-CHKSUM'})
copy "$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml", "$NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"; copy "$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml", "$NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml";
} }
#print join(',',sort keys %CHOOSEDTARGET)."\n";
# Check if there is at least one target to build
#----------------------------------------------
$nboftargetok=0;
$nboftargetneedbuildroot=0;
$nbofpublishneedtag=0;
foreach my $target (sort keys %CHOOSEDTARGET) {
if ($CHOOSEDTARGET{$target} < 0) { next; }
if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP' && $target ne '-CHKSUM')
{
$nboftargetneedbuildroot++;
}
$nboftargetok++;
}
foreach my $target (sort keys %CHOOSEDPUBLISH) {
if ($CHOOSEDPUBLISH{$target} < 0) { next; }
if ($target eq 'ASSO') { $nbofpublishneedtag++; }
if ($target eq 'SF') { $nbofpublishneedtag++; }
$nboftargetok++;
}
if ($nboftargetok) {
# Update GIT tag if required # Update GIT tag if required
#--------------------------- #---------------------------
if ($nbofpublishneedtag) if ($nbofpublishneedtag)
@ -360,34 +404,6 @@ if ($nboftargetok) {
$olddir=getcwd(); $olddir=getcwd();
chdir("$SOURCE"); chdir("$SOURCE");
# Test that the ChangeLog is ok
$TMPBUILDTOCHECKCHANGELOG=$BUILD;
$TMPBUILDTOCHECKCHANGELOG =~ s/\-rc\d*//;
$TMPBUILDTOCHECKCHANGELOG =~ s/\-beta\d*//;
print "Check if ChangeLog is ok for version $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG\n";
$ret=`grep "ChangeLog for $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG" "$SOURCE/ChangeLog" 2>&1`;
if (! $ret)
{
print "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n";
}
else
{
print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog. But you can regenerate it with commande:'\n";
}
if (! $BUILD || $BUILD eq '0-rc') # For a major version
{
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
}
else # For a maintenance release
{
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
}
print "\n";
if (! $ret)
{
exit;
}
print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n"; print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n";
$ret=`git tag -a -m "$MAJOR.$MINOR.$BUILD" "$MAJOR.$MINOR.$BUILD" 2>&1`; $ret=`git tag -a -m "$MAJOR.$MINOR.$BUILD" "$MAJOR.$MINOR.$BUILD" 2>&1`;
if ($ret =~ /(already exists|existe déjà)/) if ($ret =~ /(already exists|existe déjà)/)
@ -517,6 +533,7 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimed*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimed*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimod*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimod*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/factory*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/factory*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/forceproject*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/lead*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/lead*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/management*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/management*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/multicompany*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/multicompany*`;
@ -574,7 +591,7 @@ if ($nboftargetok) {
print "Remove subdir of custom dir\n"; print "Remove subdir of custom dir\n";
print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n";
$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep dir $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs but not files
} }
# Build package for each target # Build package for each target
@ -955,13 +972,12 @@ if ($nboftargetok) {
$ret=`$cmd`; $ret=`$cmd`;
$ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/modMyModule.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_api_class.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject_api_class.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_card.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_class.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_card.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_list.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_list.php`;
$ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_script.php`; $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/scripts/myobject.php`;
$ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_webservice_server.php`;
$cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.php' -type f -exec chmod 755 {} \\; "; $cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.php' -type f -exec chmod 755 {} \\; ";
$ret=`$cmd`; $ret=`$cmd`;
$cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.sh' -type f -exec chmod 755 {} \\; "; $cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.sh' -type f -exec chmod 755 {} \\; ";

View File

@ -194,6 +194,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin %_datadir/dolibarr/htdocs/margin
%_datadir/dolibarr/htdocs/modulebuilder
%_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/multicurrency
%_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/opensurvey
%_datadir/dolibarr/htdocs/paybox %_datadir/dolibarr/htdocs/paybox
@ -209,6 +210,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/theme
%_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/webservices
%_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/websites
%_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.ico

View File

@ -274,6 +274,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin %_datadir/dolibarr/htdocs/margin
%_datadir/dolibarr/htdocs/modulebuilder
%_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/multicurrency
%_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/opensurvey
%_datadir/dolibarr/htdocs/paybox %_datadir/dolibarr/htdocs/paybox
@ -289,6 +290,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/theme
%_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/webservices
%_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/websites
%_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.ico

View File

@ -190,6 +190,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin %_datadir/dolibarr/htdocs/margin
%_datadir/dolibarr/htdocs/modulebuilder
%_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/multicurrency
%_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/opensurvey
%_datadir/dolibarr/htdocs/paybox %_datadir/dolibarr/htdocs/paybox
@ -205,6 +206,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/theme
%_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/webservices
%_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/websites
%_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.ico

View File

@ -202,6 +202,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin %_datadir/dolibarr/htdocs/margin
%_datadir/dolibarr/htdocs/modulebuilder
%_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/multicurrency
%_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/opensurvey
%_datadir/dolibarr/htdocs/paybox %_datadir/dolibarr/htdocs/paybox
@ -217,6 +218,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/support
%_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/theme
%_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/user
%_datadir/dolibarr/htdocs/variants
%_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/webservices
%_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/websites
%_datadir/dolibarr/htdocs/*.ico %_datadir/dolibarr/htdocs/*.ico

View File

@ -1,7 +1,7 @@
<?php <?php
$force_install_packager='rpmfedora'; $force_install_packager='rpmfedora';
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters $force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
$force_install_message='KeepDefaultValuesDeb'; $force_install_message='KeepDefaultValuesDeb';
$force_install_main_data_root='/var/lib/dolibarr/documents'; $force_install_main_data_root='/var/lib/dolibarr/documents';
$force_install_type='mysqli'; $force_install_type='mysqli';

View File

@ -1,7 +1,7 @@
<?php <?php
$force_install_packager='rpmgeneric'; $force_install_packager='rpmgeneric';
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters $force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
$force_install_message='KeepDefaultValuesDeb'; $force_install_message='KeepDefaultValuesDeb';
$force_install_main_data_root='/var/lib/dolibarr/documents'; $force_install_main_data_root='/var/lib/dolibarr/documents';
$force_install_type='mysqli'; $force_install_type='mysqli';

View File

@ -1,7 +1,7 @@
<?php <?php
$force_install_packager='rpmmandriva'; $force_install_packager='rpmmandriva';
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters $force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
$force_install_message='KeepDefaultValuesDeb'; $force_install_message='KeepDefaultValuesDeb';
$force_install_main_data_root='/var/lib/dolibarr/documents'; $force_install_main_data_root='/var/lib/dolibarr/documents';
$force_install_type='mysqli'; $force_install_type='mysqli';

View File

@ -1,7 +1,7 @@
<?php <?php
$force_install_packager='rpmopensuse'; $force_install_packager='rpmopensuse';
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters $force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
$force_install_message='KeepDefaultValuesDeb'; $force_install_message='KeepDefaultValuesDeb';
$force_install_main_data_root='/var/lib/dolibarr/documents'; $force_install_main_data_root='/var/lib/dolibarr/documents';
$force_install_type='mysqli'; $force_install_type='mysqli';

View File

@ -155,7 +155,7 @@ fi
#echo "mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile" #echo "mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile"
#mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile #mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
#echo "drop old table" #echo "drop old table"
echo "drop table llx_accounting_account;" | mysql -P$port -u$admin $passwd $base echo "drop table if exists llx_accounting_account;" | mysql -P$port -u$admin $passwd $base
echo "mysql -P$port -u$admin -p***** $base < $mydir/$dumpfile" echo "mysql -P$port -u$admin -p***** $base < $mydir/$dumpfile"
mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
export res=$? export res=$?

View File

@ -528,7 +528,7 @@ CREATE TABLE `llx_bank` (
LOCK TABLES `llx_bank` WRITE; LOCK TABLES `llx_bank` WRITE;
/*!40000 ALTER TABLE `llx_bank` DISABLE KEYS */; /*!40000 ALTER TABLE `llx_bank` DISABLE KEYS */;
INSERT INTO `llx_bank` VALUES (1,'2010-07-08 23:56:14','2013-03-07 21:28:51','2010-07-08','2010-07-08',2000.00000000,'(Initial balance)',1,NULL,1,'SOLD','201210',NULL,1,NULL,0,NULL,NULL,NULL),(2,'2010-07-09 00:00:24','0000-00-00 00:00:00','2010-07-09','2010-07-09',500.00000000,'(Initial balance)',2,NULL,NULL,'SOLD',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(3,'2010-07-10 13:33:42','0000-00-00 00:00:00','2010-07-10','2010-07-10',0.00000000,'(Solde initial)',3,NULL,NULL,'SOLD',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(4,'2010-07-10 14:59:41','0000-00-00 00:00:00','2010-07-10','2010-07-10',0.02000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,'Client salon invidivdu',NULL),(5,'2011-07-18 20:50:24','0000-00-00 00:00:00','2011-07-08','2011-07-08',20.00000000,'(CustomerInvoicePayment)',1,1,NULL,'CB','201107',NULL,1,NULL,0,NULL,NULL,NULL),(6,'2011-07-18 20:50:47','0000-00-00 00:00:00','2011-07-08','2011-07-08',10.00000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(8,'2011-08-01 03:34:11','2013-03-07 21:28:51','2011-08-01','2011-08-01',5.63000000,'(CustomerInvoicePayment)',1,1,1,'CB','201210',NULL,1,NULL,0,NULL,NULL,NULL),(12,'2011-08-05 23:11:37','2013-03-07 21:33:57','2011-08-05','2011-08-05',-10.00000000,'(SocialContributionPayment)',1,1,1,'VIR','201210',NULL,1,NULL,0,NULL,NULL,NULL),(13,'2011-08-06 20:33:54','0000-00-00 00:00:00','2011-08-06','2011-08-06',5.98000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(14,'2011-08-08 02:53:40','0000-00-00 00:00:00','2011-08-08','2011-08-08',26.10000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(15,'2011-08-08 02:55:58','2013-03-07 21:39:20','2011-08-08','2011-08-08',26.96000000,'(CustomerInvoicePayment)',1,1,1,'TIP','201211',NULL,1,NULL,0,NULL,NULL,NULL),(16,'2012-12-09 15:28:44','2012-12-09 14:28:44','2012-12-09','2012-12-09',2.00000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(17,'2012-12-09 15:28:53','2012-12-09 14:33:07','2012-12-09','2012-12-09',-2.00000000,'(CustomerInvoicePaymentBack)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(18,'2012-12-09 17:35:55','2012-12-09 16:35:55','2012-12-09','2012-12-09',-2.00000000,'(CustomerInvoicePaymentBack)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(19,'2012-12-09 17:37:02','2012-12-09 16:37:02','2012-12-09','2012-12-09',2.00000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(20,'2012-12-09 18:35:07','2012-12-09 17:35:07','2012-12-09','2012-12-09',-2.00000000,'(CustomerInvoicePaymentBack)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(21,'2012-12-12 18:54:33','2013-03-07 21:28:51','2012-12-12','2012-12-12',1.00000000,'(CustomerInvoicePayment)',1,1,1,'TIP','201210',NULL,1,NULL,0,NULL,NULL,NULL),(22,'2013-03-06 16:48:16','2013-03-06 15:48:16','2013-03-06','2013-03-06',20.00000000,'(SubscriptionPayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(23,'2013-03-20 14:30:11','2013-03-20 13:30:11','2013-03-20','2013-03-20',10.00000000,'(SubscriptionPayment)',1,1,NULL,'VIR',NULL,NULL,0,NULL,0,NULL,NULL,NULL); INSERT INTO `llx_bank` VALUES (1,'2010-07-08 23:56:14','2013-03-07 21:28:51','2010-07-08','2010-07-08',2000.00000000,'(Initial balance)',1,NULL,1,'SOLD','201210',NULL,1,NULL,0,NULL,NULL,NULL),(2,'2010-07-09 00:00:24','2010-07-09 00:00:24','2010-07-09','2010-07-09',500.00000000,'(Initial balance)',2,NULL,NULL,'SOLD',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(3,'2010-07-10 13:33:42','2010-07-10 13:33:42','2010-07-10','2010-07-10',0.00000000,'(Solde initial)',3,NULL,NULL,'SOLD',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(4,'2010-07-10 14:59:41','2010-07-10 14:59:41','2010-07-10','2010-07-10',0.02000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,'Client salon invidivdu',NULL),(5,'2011-07-18 20:50:24','2011-07-18 20:50:24','2011-07-08','2011-07-08',20.00000000,'(CustomerInvoicePayment)',1,1,NULL,'CB','201107',NULL,1,NULL,0,NULL,NULL,NULL),(6,'2011-07-18 20:50:47','2011-07-18 20:50:47','2011-07-08','2011-07-08',10.00000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(8,'2011-08-01 03:34:11','2013-03-07 21:28:51','2011-08-01','2011-08-01',5.63000000,'(CustomerInvoicePayment)',1,1,1,'CB','201210',NULL,1,NULL,0,NULL,NULL,NULL),(12,'2011-08-05 23:11:37','2013-03-07 21:33:57','2011-08-05','2011-08-05',-10.00000000,'(SocialContributionPayment)',1,1,1,'VIR','201210',NULL,1,NULL,0,NULL,NULL,NULL),(13,'2011-08-06 20:33:54','2011-08-06 20:33:54','2011-08-06','2011-08-06',5.98000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(14,'2011-08-08 02:53:40','2011-08-08 02:53:40','2011-08-08','2011-08-08',26.10000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(15,'2011-08-08 02:55:58','2013-03-07 21:39:20','2011-08-08','2011-08-08',26.96000000,'(CustomerInvoicePayment)',1,1,1,'TIP','201211',NULL,1,NULL,0,NULL,NULL,NULL),(16,'2012-12-09 15:28:44','2012-12-09 14:28:44','2012-12-09','2012-12-09',2.00000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(17,'2012-12-09 15:28:53','2012-12-09 14:33:07','2012-12-09','2012-12-09',-2.00000000,'(CustomerInvoicePaymentBack)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(18,'2012-12-09 17:35:55','2012-12-09 16:35:55','2012-12-09','2012-12-09',-2.00000000,'(CustomerInvoicePaymentBack)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(19,'2012-12-09 17:37:02','2012-12-09 16:37:02','2012-12-09','2012-12-09',2.00000000,'(CustomerInvoicePayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(20,'2012-12-09 18:35:07','2012-12-09 17:35:07','2012-12-09','2012-12-09',-2.00000000,'(CustomerInvoicePaymentBack)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(21,'2012-12-12 18:54:33','2013-03-07 21:28:51','2012-12-12','2012-12-12',1.00000000,'(CustomerInvoicePayment)',1,1,1,'TIP','201210',NULL,1,NULL,0,NULL,NULL,NULL),(22,'2013-03-06 16:48:16','2013-03-06 15:48:16','2013-03-06','2013-03-06',20.00000000,'(SubscriptionPayment)',3,1,NULL,'LIQ',NULL,NULL,0,NULL,0,NULL,NULL,NULL),(23,'2013-03-20 14:30:11','2013-03-20 13:30:11','2013-03-20','2013-03-20',10.00000000,'(SubscriptionPayment)',1,1,NULL,'VIR',NULL,NULL,0,NULL,0,NULL,NULL,NULL);
/*!40000 ALTER TABLE `llx_bank` ENABLE KEYS */; /*!40000 ALTER TABLE `llx_bank` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
@ -4844,7 +4844,7 @@ CREATE TABLE `llx_opensurvey_sondage` (
LOCK TABLES `llx_opensurvey_sondage` WRITE; LOCK TABLES `llx_opensurvey_sondage` WRITE;
/*!40000 ALTER TABLE `llx_opensurvey_sondage` DISABLE KEYS */; /*!40000 ALTER TABLE `llx_opensurvey_sondage` DISABLE KEYS */;
INSERT INTO `llx_opensurvey_sondage` VALUES ('m4467s2mtk6khmxc','m4467s2mtk6khmxci2ysw682','fdffdshfghfj jhgjgh','aaa@aaa.com','fdfds','fdffds','2013-03-06 23:00:00','D+','1',1,'dolibarr','0000-00-00 00:00:00'); INSERT INTO `llx_opensurvey_sondage` VALUES ('m4467s2mtk6khmxc','m4467s2mtk6khmxci2ysw682','fdffdshfghfj jhgjgh','aaa@aaa.com','fdfds','fdffds','2013-03-06 23:00:00','D+','1',1,'dolibarr','2000-01-01 00:00:00');
/*!40000 ALTER TABLE `llx_opensurvey_sondage` ENABLE KEYS */; /*!40000 ALTER TABLE `llx_opensurvey_sondage` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;

View File

@ -1,4 +1,4 @@
JOURNALCODE JOURNALLIB ECRITURENUM ECRITUREDATE COMPTENUM COMPTELIB COMPAUXNUM COMPAUXLIB PIECEREF PIECEDATE ECRITURELIB DEBIT CREDIT ECRITURELET DATELET VALIDDATE MONTANTDEVISE IDEVISE JOURNALCODE JOURNALLIB ECRITURENUM ECRITUREDATE COMPTENUM COMPTELIB COMPAUXNUM COMPAUXLIB PIECEREF PIECEDATE ECRITURELIB DEBIT CREDIT ECRITURELET DATELET VALIDDATE MONTANTDEVISE IDEVISE
Banque Banque 17293 20170109 401PPRO PUBLI-PROV L08 20170109 PPRO domiciliation 1TR 187,20 0,00 20170109 Banque Banque 17293 20170109 401PPRO PUBLI-PROV L08 20170109 PPRO domiciliation 1TR 187,20 0,00 20170109
Banque Banque 17293 20170109 5121CRA CR AGRICOLE L08 20170109 PPRO domiciliation 1TR 0,00 187,20 20170109 Banque Banque 17293 20170109 5121CRA CR AGRICOLE L08 20170109 PPRO domiciliation 1TR 0,00 187,20 20170109
Banque Banque 17295 20170109 401ORPA ORANGE PARIS Report 20170109 ORPA adsl par 12 96,00 0,00 20170109 Banque Banque 17295 20170109 401ORPA ORANGE PARIS Report 20170109 ORPA adsl par 12 96,00 0,00 20170109

View File

@ -1 +1 @@
Files and tools were moved into htdocs/modulebuilder/skeletons Files and tools were moved into htdocs/modulebuilder/template

View File

@ -1,23 +0,0 @@
#!/bin/bash
# vim:ft=sh:ts=3:sts=3:sw=3:et:
###
# Strips the closing php tag `?>` and any following blank lines from the
# end of any PHP file in the current working directory and sub-directories. Files
# with non-whitespace characters following the closing tag will not be affected.
#
# Author: Bryan C. Geraghty <bryan@ravensight.org>
# Date: 2009-10-28
# Source: http://bryan.ravensight.org/2010/07/remove-php-closing-tag/
##
FILES=$(pcregrep -rnM --include='^.*\.php$' '^\?\>(?=([\s\n]+)?$(?!\n))' .);
for MATCH in $FILES;
do
FILE=`echo $MATCH | awk -F ':' '{print $1}'`;
TARGET=`echo $MATCH | awk -F ':' '{print $2}'`;
LINE_COUNT=`wc -l $FILE | awk -F " " '{print $1}'`;
echo "Removing lines ${TARGET} through ${LINE_COUNT} from file $FILE...";
sed -i "${TARGET},${LINE_COUNT}d" $FILE;
done;

View File

@ -8,7 +8,7 @@ Contact/address Contact person Partner/Contact (individual)
Financial ?? Invoicing Financial ?? Invoicing
Income / Expense ?? Profit / Loss Income / Expense ?? Profit / Loss
Balance Net profit Balance ?? Net profit
Subledger account Subledger account ??

View File

@ -310,6 +310,8 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a
if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0; if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0;
if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0; if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0;
if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0; if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0;
// modulebuilder
if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean=0;
// orders // orders
if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0; if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0;
if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0; if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0;

View File

@ -52,7 +52,7 @@ if ($user->societe_id > 0) accessforbidden();
if (! $user->rights->accounting->chartofaccount) accessforbidden(); if (! $user->rights->accounting->chartofaccount) accessforbidden();
// Load variable for pagination // Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'sortorder'); $sortorder = GETPOST("sortorder", 'sortorder');
$page = GETPOST("page", 'int'); $page = GETPOST("page", 'int');

View File

@ -8,7 +8,7 @@
* 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>
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
@ -54,6 +54,7 @@ $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$rowid=GETPOST('rowid','alpha'); $rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha');
$acts[0] = "activate"; $acts[0] = "activate";
$acts[1] = "disable"; $acts[1] = "disable";
@ -67,7 +68,7 @@ $active = 1;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; } if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $listlimit * $page ; $offset = $listlimit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -80,7 +81,7 @@ if ($user->societe_id > 0) accessforbidden();
if (! $user->rights->accounting->chartofaccount) accessforbidden(); if (! $user->rights->accounting->chartofaccount) accessforbidden();
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admin')); $hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionaries // This page is a generic page to edit dictionaries
@ -459,8 +460,8 @@ if ($action == $acts[0])
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -479,8 +480,8 @@ if ($action == $acts[1])
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -499,8 +500,8 @@ if ($action == 'activate_favorite')
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -519,8 +520,8 @@ if ($action == 'disable_favorite')
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -556,7 +557,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='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
} }
//var_dump($elementList); //var_dump($elementList);
@ -1147,7 +1148,6 @@ else
* Show list of dictionary to show * Show list of dictionary to show
*/ */
$var=true;
$lastlineisempty=false; $lastlineisempty=false;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -46,7 +46,7 @@ if ($cat_id == 0) {
} }
// Security check // Security check
if (! empty($user->rights->accountancy->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))
{ {
accessforbidden(); accessforbidden();
} }

View File

@ -8,7 +8,7 @@
* 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>
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *
@ -54,9 +54,10 @@ $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$rowid=GETPOST('rowid','alpha'); $rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha');
// Security access // Security access
if (! empty($user->rights->accountancy->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))
{ {
accessforbidden(); accessforbidden();
} }
@ -73,14 +74,14 @@ $active = 1;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; } if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $listlimit * $page ; $offset = $listlimit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$search_country_id = GETPOST('search_country_id','int'); $search_country_id = GETPOST('search_country_id','int');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admin')); $hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionaries // This page is a generic page to edit dictionaries
@ -370,8 +371,8 @@ if ($action == $acts[0])
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -390,8 +391,8 @@ if ($action == $acts[1])
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -410,8 +411,8 @@ if ($action == 'activate_favorite')
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -430,8 +431,8 @@ if ($action == 'disable_favorite')
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -461,7 +462,7 @@ print load_fiche_titre($titre,$linkback,$titlepicto);
// 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='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
} }
//var_dump($elementList); //var_dump($elementList);
@ -546,7 +547,7 @@ if ($id)
if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); } if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); }
if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); }
if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); }
if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); }
if ($valuetoshow != '') if ($valuetoshow != '')
@ -700,7 +701,7 @@ if ($id)
if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); }
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); }
if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); }
if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); }
// Affiche nom du champ // Affiche nom du champ
if ($showfield) if ($showfield)

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -23,7 +23,7 @@
*/ */
/** /**
* \file htdocs/accountancy/admin/index.php * \file htdocs/accountancy/admin/defaultaccounts.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Setup page to configure accounting expert module * \brief Setup page to configure accounting expert module
*/ */
@ -42,7 +42,7 @@ $langs->load("salaries");
$langs->load("loan"); $langs->load("loan");
// Security check // Security check
if (! empty($user->rights->accountancy->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))
{ {
accessforbidden(); accessforbidden();
} }
@ -50,10 +50,13 @@ if (! empty($user->rights->accountancy->chartofaccount))
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$list_account = array ( $list_account_main = array (
'ACCOUNTING_ACCOUNT_SUPPLIER',
'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_CUSTOMER',
'ACCOUNTING_ACCOUNT_SUPPLIER',
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
);
$list_account = array (
'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT', 'ACCOUNTING_SERVICE_BUY_ACCOUNT',
@ -94,6 +97,14 @@ if (GETPOST('change_chart'))
if ($action == 'update') { if ($action == 'update') {
$error = 0; $error = 0;
foreach ( $list_account_main as $constname ) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
foreach ( $list_account as $constname ) { foreach ( $list_account as $constname ) {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
@ -114,11 +125,11 @@ if ($action == 'update') {
* View * View
*/ */
llxHeader();
$form = new Form($db); $form = new Form($db);
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
llxHeader();
$linkback = ''; $linkback = '';
print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy'); print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy');
@ -129,7 +140,36 @@ 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="update">'; print '<input type="hidden" name="action" value="update">';
// Define Chart of accounts
// Define main accounts for thirdparty
print '<table class="noborder" width="100%">';
foreach ($list_account_main as $key) {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
$keydesc=$key.'_Desc';
$htmltext = $langs->trans($keydesc);
print '<td class="fieldrequired" width="50%">';
print $form->textwithpicto($label, $htmltext);
print '</td>';
// Value
print '<td>'; // Do not force align=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
}
print "</table>\n";
print '<br>';
// Define default accounts
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -138,7 +178,7 @@ foreach ( $list_account as $key ) {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
$label = $langs->trans($key); $label = $langs->trans($key);
print '<td>' . $label . '</td>'; print '<td width="50%">' . $label . '</td>';
// Value // Value
print '<td>'; // Do not force align=right, or it align also the content of the select box print '<td>'; // Do not force align=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -38,7 +38,7 @@ $langs->load("admin");
$langs->load("accountancy"); $langs->load("accountancy");
// Security check // Security check
if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount)) if (empty($user->admin) && empty($user->rights->accounting->chartofaccount))
{ {
accessforbidden(); accessforbidden();
} }
@ -206,7 +206,7 @@ if ($num2) {
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>'; print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n"; print "</tr>\n";
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1) if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > AccountancyExport::$EXPORT_TYPE_NORMAL)
{ {
print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>'; print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>';
} }

View File

@ -28,11 +28,11 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha'); $sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha'); $sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int'); $page = GETPOST('page','int');
if ($page == -1) { $page = 0; } if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2014-2016 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

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -39,11 +39,11 @@ $langs->load("accountancy");
if (! $user->admin) if (! $user->admin)
accessforbidden(); accessforbidden();
$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0; } if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;

View File

@ -31,6 +31,7 @@ require '../../main.inc.php';
// Class // 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';
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
@ -50,8 +51,8 @@ $action = GETPOST('action', 'alpha');
$list = array ( $list = array (
'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT' , 'ACCOUNTING_LENGTH_AACCOUNT' ,
'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
); );
@ -265,7 +266,7 @@ if (! empty($user->admin))
} }
// Param a user $user->rights->accountancy->chartofaccount can access // Param a user $user->rights->accounting->chartofaccount can access
foreach ($list as $key) foreach ($list as $key)
{ {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';

View File

@ -38,9 +38,10 @@ $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$rowid=GETPOST('rowid','alpha'); $rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha');
// Security access // Security access
if (! empty($user->rights->accountancy->chartofaccount)) if (empty($user->rights->accounting->chartofaccount))
{ {
accessforbidden(); accessforbidden();
} }
@ -57,7 +58,7 @@ $active = 1;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; } if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $listlimit * $page ; $offset = $listlimit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -66,7 +67,7 @@ if (empty($sortorder)) $sortorder='ASC';
$error = 0; $error = 0;
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admin')); $hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionaries // This page is a generic page to edit dictionaries
@ -133,6 +134,7 @@ $elementList = array();
'2' => $langs->trans('AccountingJournalType2'), '2' => $langs->trans('AccountingJournalType2'),
'3' => $langs->trans('AccountingJournalType3'), '3' => $langs->trans('AccountingJournalType3'),
'4' => $langs->trans('AccountingJournalType4'), '4' => $langs->trans('AccountingJournalType4'),
'5' => $langs->trans('AccountingJournalType5'),
'9' => $langs->trans('AccountingJournalType9') '9' => $langs->trans('AccountingJournalType9')
); );
@ -321,8 +323,8 @@ if ($action == $acts[0])
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -341,8 +343,8 @@ if ($action == $acts[1])
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
} }
elseif ($_GET["code"]) { elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -371,18 +373,11 @@ if ($id)
print load_fiche_titre($titre,$linkback,$titlepicto); print load_fiche_titre($titre,$linkback,$titlepicto);
if (empty($id))
{
print $langs->trans("DictionaryDesc");
print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
}
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='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
} }
//var_dump($elementList); //var_dump($elementList);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
@ -70,11 +70,11 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
$btn_changeaccount = GETPOST('changeaccount'); $btn_changeaccount = GETPOST('changeaccount');
$btn_changetype = GETPOST('changetype'); $btn_changetype = GETPOST('changetype');
$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0; } if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -218,7 +218,7 @@ else
{ {
$sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
} }
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= ' WHERE p.entity IN ('.getEntity('product').')';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_buy",$search_current_account); $sql .= natural_search("p.accountancy_code_buy",$search_current_account);
@ -397,7 +397,7 @@ if ($result)
// TODO ADJUST DESCRIPTION SIZE // TODO ADJUST DESCRIPTION SIZE
// print '<td align="left">' . $obj->description . '</td>'; // print '<td align="left">' . $obj->description . '</td>';
// TODO: we shoul set a user defined value to adjust user square / wide screen size // TODO: we shoul set a user defined value to adjust user square / wide screen size
$trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64; $trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
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>';
} }

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 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2016 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
@ -51,11 +51,11 @@ if ($search_accountancy_code_end == - 1) {
$search_accountancy_code_end = ''; $search_accountancy_code_end = '';
} }
if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv.x") || GETPOST("button_export_csv")) {
$action = 'export_csv'; $action = 'export_csv';
} }
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit;
$offset = $limit * $page; $offset = $limit * $page;
@ -112,7 +112,10 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
*/ */
if ($action == 'export_csv') { if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == AccountancyExport::$EXPORT_TYPE_CEGID) $sep = ";"; // For CEGID, we force separator.
$journal = 'bookkepping'; $journal = 'bookkepping';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -123,10 +126,6 @@ if ($action == 'export_csv') {
} }
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
}
print length_accountg($line->numero_compte) . $sep; print length_accountg($line->numero_compte) . $sep;
print $line->debit . $sep; print $line->debit . $sep;
print $line->credit . $sep; print $line->credit . $sep;
@ -142,7 +141,6 @@ else {
llxHeader('', $title_page); llxHeader('', $title_page);
// List // List
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
@ -156,13 +154,11 @@ else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
$button = '<input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" />'; $button = '<input type="submit" name="button_export_csv" class="butAction" 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 = '';
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
@ -200,7 +196,7 @@ else {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* *

View File

@ -1,7 +1,8 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 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-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* 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
* 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
@ -22,48 +23,49 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Page to show book-entry * \brief Page to show book-entry
*/ */
require '../../main.inc.php';
// Class require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/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 . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
// Langs
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("bank");
$langs->load("bills");
$langs->load("trips");
// Security check // Security check
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
if ($user->societe_id > 0) { if ($user->societe_id > 0) {
accessforbidden(); accessforbidden();
} }
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
$mode = GETPOST('mode','aZ09'); // '' or 'tmp'
$piece_num = GETPOST("piece_num"); $piece_num = GETPOST("piece_num");
$mesg = ''; $mesg = '';
$account_number = GETPOST('account_number'); $account_number = GETPOST('account_number');
$code_tiers = GETPOST('code_tiers'); $subledger_account = GETPOST('subledger_account');
if ($code_tiers == - 1) { if ($subledger_account == - 1) {
$code_tiers = null; $subledger_account = null;
} }
$label_compte = GETPOST('label_compte'); $label_compte = GETPOST('label_compte');
$label_operation= GETPOST('label_operation');
$debit = price2num(GETPOST('debit')); $debit = price2num(GETPOST('debit'));
$credit = price2num(GETPOST('credit')); $credit = price2num(GETPOST('credit'));
$save = GETPOST('save'); $save = GETPOST('save','alpha');
if (! empty($save)) { if (! empty($save)) $action = 'add';
$action = 'add'; $update = GETPOST('update','alpha');
} if (! empty($update)) $action = 'confirm_update';
$update = GETPOST('update');
if (! empty($update)) { $object = new BookKeeping($db);
$action = 'confirm_update';
}
/*
* Actions
*/
if ($action == "confirm_update") { if ($action == "confirm_update") {
@ -77,13 +79,14 @@ if ($action == "confirm_update") {
if (empty($error)) { if (empty($error)) {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$result = $book->fetch($id); $result = $book->fetch($id, null, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
$book->numero_compte = $account_number; $book->numero_compte = $account_number;
$book->code_tiers = $code_tiers; $book->subledger_account = $subledger_account;
$book->label_compte = $label_compte; $book->label_compte = $label_compte;
$book->label_operation= $label_operation;
$book->debit = $debit; $book->debit = $debit;
$book->credit = $credit; $book->credit = $credit;
@ -96,11 +99,18 @@ if ($action == "confirm_update") {
$book->sens = 'C'; $book->sens = 'C';
} }
$result = $book->update($user); $result = $book->update($user, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
if ($mode != '_tmp')
{
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('Saved'), null, 'mesgs');
}
$debit = 0;
$credit = 0;
$action = ''; $action = '';
} }
} }
@ -110,7 +120,7 @@ if ($action == "confirm_update") {
else if ($action == "add") { else if ($action == "add") {
$error = 0; $error = 0;
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { if (empty($debit) && empty($credit)) {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$error ++; $error ++;
} }
@ -119,8 +129,9 @@ else if ($action == "add") {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$book->numero_compte = $account_number; $book->numero_compte = $account_number;
$book->code_tiers = $code_tiers; $book->subledger_account = $subledger_account;
$book->label_compte = $label_compte; $book->label_compte = $label_compte;
$book->label_operation= $label_operation;
$book->debit = $debit; $book->debit = $debit;
$book->credit = $credit; $book->credit = $credit;
$book->doc_date = GETPOST('doc_date'); $book->doc_date = GETPOST('doc_date');
@ -141,11 +152,18 @@ else if ($action == "add") {
$book->sens = 'C'; $book->sens = 'C';
} }
$result = $book->createStd($user); $result = $book->createStd($user, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
if ($mode != '_tmp')
{
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('Saved'), null, 'mesgs');
}
$debit = 0;
$credit = 0;
$action = ''; $action = '';
} }
} }
@ -154,14 +172,13 @@ else if ($action == "add") {
else if ($action == "confirm_delete") { else if ($action == "confirm_delete") {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$result = $book->fetch($id); $result = $book->fetch($id, null, $mode);
$piece_num = $book->piece_num; $piece_num = $book->piece_num;
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
$result = $book->delete($user); $result = $book->delete($user, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} }
@ -174,6 +191,11 @@ else if ($action == "confirm_create") {
$book = new BookKeeping($db); $book = new BookKeeping($db);
if (! GETPOST('code_journal') || GETPOST('code_journal') == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors');
$action='create';
$error++;
}
if (! GETPOST('next_num_mvt')) if (! GETPOST('next_num_mvt'))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors');
@ -192,35 +214,90 @@ else if ($action == "confirm_create") {
$book->code_journal = GETPOST('code_journal'); $book->code_journal = GETPOST('code_journal');
$book->fk_doc = 0; $book->fk_doc = 0;
$book->fk_docdet = 0; $book->fk_docdet = 0;
$book->montant = 0; $book->montant = 0;
$result = $book->createStd($user); $result = $book->createStd($user,0, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
if ($mode != '_tmp')
{
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = ''; }
$action = 'update';
$id=$book->id;
$piece_num = $book->piece_num; $piece_num = $book->piece_num;
} }
} }
} }
if ($action == 'setdate') {
$datedoc = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
$result = $object->updateByMvt($piece_num,'doc_date',$db->idate($datedoc),$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
if ($mode != '_tmp')
{
setEventMessages($langs->trans('Saved'), null, 'mesgs');
}
$action = '';
}
}
if ($action == 'setjournal') {
$journaldoc = trim(GETPOST('code_journal'));
$result = $object->updateByMvt($piece_num,'code_journal',$journaldoc,$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
if ($mode != '_tmp')
{
setEventMessages($langs->trans('Saved'), null, 'mesgs');
}
$action = '';
}
}
if ($action == 'setdocref') {
$refdoc = trim(GETPOST('doc_ref'));
$result = $object->updateByMvt($piece_num,'doc_ref',$refdoc,$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
if ($mode != '_tmp')
{
setEventMessages($langs->trans('Saved'), null, 'mesgs');
}
$action = '';
}
}
// Validate transaction
if ($action == 'valid') {
$result = $object->transformTransaction(0,$piece_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
header("Location: list.php?sortfield=t.piece_num&sortorder=asc");
exit;
}
}
/* /*
* View * View
*/ */
llxHeader();
$html = new Form($db); $html = new Form($db);
$formaccountancy = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$accountjournal = new AccountingJournal($db);
/* llxHeader('', $langs->trans("CreateMvts"));
* Confirmation to delete the command
*/ // Confirmation to delete the command
if ($action == 'delete') { if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
print $formconfirm; print $formconfirm;
} }
@ -228,7 +305,8 @@ if ($action == 'create') {
print load_fiche_titre($langs->trans("CreateMvts")); print load_fiche_titre($langs->trans("CreateMvts"));
$book = new BookKeeping($db); $book = new BookKeeping($db);
$next_num_mvt = $book->getNextNumMvt(); $next_num_mvt = $book->getNextNumMvt('_tmp');
if (empty($next_num_mvt)) if (empty($next_num_mvt))
{ {
dol_print_error('', 'Failed to get next piece number'); dol_print_error('', 'Failed to get next piece number');
@ -237,6 +315,7 @@ if ($action == 'create') {
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n"; print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n"; print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
print '<input type="hidden" name="mode" value="_tmp">' . "\n";
dol_fiche_head(); dol_fiche_head();
@ -254,10 +333,9 @@ if ($action == 'create') {
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>'; print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>';
print '<td>'; print '<td>' . $formaccounting->select_journal(GETPOST('code_journal'),'code_journal',0,1,array(),1,1) . '</td>';
print $formaccountancy->select_journal('', 'code_journal', '', 0, '', 1, 1, 1, 1); print '</tr>';
print '</td></tr>';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Docref") . '</td>'; print '<td>' . $langs->trans("Docref") . '</td>';
@ -266,7 +344,7 @@ if ($action == 'create') {
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Doctype") . '</td>'; print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td><input type="text" class="minwidth200" name="doc_type" value=""/></td>'; print '<td><input type="text" class="minwidth200 name="doc_type" value=""/></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
@ -280,69 +358,175 @@ if ($action == 'create') {
print '</form>'; print '</form>';
} else { } else {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$result = $book->fetchPerMvt($piece_num); $result = $book->fetchPerMvt($piece_num, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} }
if (! empty($book->piece_num)) { if (! empty($book->piece_num)) {
print load_fiche_titre($langs->trans("UpdateMvts"), '<a href="list.php">' . $langs->trans('BackToList') . '</a>'); $backlink = '<a href="list.php">' . $langs->trans('BackToList') . '</a>';
print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
$head=array();
$h=0;
$head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$book->piece_num.($mode?'&mode='.$mode:'');
$head[$h][1] = $langs->trans("Transaction");
$head[$h][2] = 'transaction';
$h++;
dol_fiche_head($head, 'transaction', '', -1);
//dol_banner_tab($book, '', $backlink);
dol_fiche_head();
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<table class="border" width="100%">'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
print '<tr class="pair">'; // account movement
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>' . $book->piece_num . '</td>';
print '</tr>'; print '</tr>';
print '<tr class="impair">'; // date
print '<td>' . $langs->trans("Docdate") . '</td>'; print '<tr><td>';
print '<td>' . dol_print_date($book->doc_date, 'daytextshort') . '</td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Docdate');
print '</td>';
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 '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdate') {
print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
$form->select_date($book->doc_date ? $book->doc_date : - 1, 'doc_date', '', '', '', "setdate");
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $book->doc_date ? dol_print_date($book->doc_date, 'daytext') : '&nbsp;';
}
print '</td>';
print '</tr>';
//journal
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Codejournal');
print '</td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editjournal') {
print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($book->code_journal,'code_journal',0,0,array(),1,1);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $book->code_journal ;
}
print '</td>';
print '</tr>';
//docref
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Docref');
print '</td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editdocref') {
print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="text" size="20" name="doc_ref" value="'.$book->doc_ref.'">';
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $book->doc_ref ;
}
print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="pair">';
print '<td>' . $langs->trans("Codejournal") . '</td>';
print '<td>';
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch('',$book->code_journal);
print $accountingjournal->getNomUrl(0,1,1,'',1);
print '</td></tr>';
print '<tr class="impair">';
print '<td>' . $langs->trans("Docref") . '</td>';
print '<td>' . $book->doc_ref . '</td>';
print '</tr>';
$typelabel = $book->doc_type;
if ($typelabel == 'bank') {
$typelabel = $langs->trans('Bank');
}
if ($typelabel == 'customer_invoice') {
$typelabel = $langs->trans('CustomerInvoice');
}
if ($typelabel == 'supplier_invoice') {
$typelabel = $langs->trans('SupplierInvoice');
}
if ($typelabel == 'expense_report') {
$typelabel = $langs->trans('ExpenseReport');
}
print '<tr class="pair">';
print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td>' . $typelabel . '</td>';
print '</tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end(); print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Doc type
print '<tr>';
print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td>' . $book->doc_type . '</td>';
print '</tr>';
// Validate
/*
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>';
if (empty($book->validated)) {
print '<a href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
print '</td>';
print '</tr>';
*/
// check data
/*
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Control") . '</td>';
if ($book->doc_type == 'customer_invoice')
{
$sqlmid = 'SELECT rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac";
$sqlmid .= " WHERE fac.rowid=" . $book->fk_doc;
dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$invoicestatic = new Facture($db);
$invoicestatic->fetch($objmid->ref);
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
}
else dol_print_error($db);
}
print '<td>' . $ref .'</td>';
print '</tr>';
*/
print "</table>\n";
print '</div></div>';
print '</div>';
print '<div style="clear:both"></div>';
print '<br>'; print '<br>';
$result = $book->fetch_all_per_mvt($piece_num);
$result = $book->fetchAllPerMvt($piece_num, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
@ -356,8 +540,7 @@ if ($action == 'create') {
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n"; print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n";
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n"; print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n"; print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
print '<input type="hidden" name="mode" value="' . $mode . '">' . "\n";
$var=False;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
if (count($book->linesmvt) > 0) { if (count($book->linesmvt) > 0) {
@ -368,56 +551,64 @@ if ($action == 'create') {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountAccountingShort")); print_liste_field_titre($langs->trans("AccountAccountingShort"));
print_liste_field_titre($langs->trans("Code_tiers")); print_liste_field_titre($langs->trans("SubledgerAccount"));
print_liste_field_titre($langs->trans("Labelcompte")); print_liste_field_titre($langs->trans("Labelcompte"));
print_liste_field_titre($langs->trans("Label"));
print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"');
print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"');
print_liste_field_titre($langs->trans("Amount"), "", "", "", "", 'align="right"');
print_liste_field_titre($langs->trans("Sens"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Action"), "", "", "", "", 'width="60" align="center"'); print_liste_field_titre($langs->trans("Action"), "", "", "", "", 'width="60" align="center"');
print "</tr>\n"; print "</tr>\n";
foreach ( $book->linesmvt as $line ) { foreach ( $book->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;
if ($action == 'update' && $line->id == $id) { if ($action == 'update' && $line->id == $id) {
print '<td>'; print '<td>';
print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1); // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1);
}
else
{
print '<input type="text" name="subledger_account" value="'.$line->subledger_account.'">';
}
print '</td>'; print '</td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>'; print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
print '<td><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
print '<td align="right"><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>'; print '<td align="right"><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
print '<td align="right"><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>'; print '<td align="right"><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>';
print '<td align="right">' . price($line->montant) . '</td>';
print '<td align="center">' . $line->sens . '</td>';
print '<td>'; print '<td>';
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n"; print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">'; print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">';
print '</td>'; print '</td>';
} else { } else {
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($line->code_tiers) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_compte . '</td>'; print '<td>' . $line->label_compte . '</td>';
print '<td>' . $line->label_operation. '</td>';
print '<td align="right">' . price($line->debit) . '</td>'; print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>'; print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($line->montant) . '</td>';
print '<td align="center">' . $line->sens . '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="./card.php?action=update&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
print img_edit(); print img_edit();
print '</a> &nbsp;'; print '</a> &nbsp;';
print '<a href="./card.php?action=delete&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '">';
print img_delete();
print '</a>';
$actiontodelete='detele';
if ($mode == '_tmp') $actiontodelete='confirm_delete';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action='.$actiontodelete.'&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
print img_delete();
print '</a>';
print '</td>'; print '</td>';
} }
print "</tr>\n"; print "</tr>\n";
@ -434,17 +625,39 @@ if ($action == 'create') {
print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1); // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1);
}
else
{
print '<input type="text" name="subledger_account" value="">';
}
print '</td>'; print '</td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>'; print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
print '<td align="right"><input type="text" class="right maxwidth50" name="debit" value="' . price($debit) . '"/></td>'; print '<td><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
print '<td align="right"><input type="text" class="right maxwidth50" name="credit" value="' . price($credit) . '"/></td>'; print '<td align="right"><input type="text" size="6" name="debit" value="' . ($debit ? price($debit) : '') . '"/></td>';
print '<td></td>'; print '<td align="right"><input type="text" size="6" name="credit" value="' . ($credit ? price($credit) : '') . '"/></td>';
print '<td></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>';
} }
print '</table>'; print '</table>';
if ($mode=='_tmp' && $action=='')
{
print '<div class="tabsAction">';
if ($total_debit == $total_credit)
{
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '&action=valid">'.$langs->trans("ValidTransaction").'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $credit, $debit)).'">'.$langs->trans("ValidTransaction").'</a>';
}
print "</div>";
}
print '</form>'; print '</form>';
} }
} }
@ -453,5 +666,6 @@ if ($action == 'create') {
} }
} }
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -25,8 +25,7 @@
* \brief List operation of book keeping * \brief List operation of book keeping
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.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 . '/accountancy/class/accountingjournal.class.php';
@ -47,11 +46,11 @@ $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETP
$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('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('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'));
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt")) { if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
$action = 'delbookkeepingyear'; $action = 'delbookkeepingyear';
} }
if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOST("button_export_file")) {
$action = 'export_csv'; $action = 'export_file';
} }
$search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code = GETPOST("search_accountancy_code");
@ -80,7 +79,7 @@ $search_direction = GETPOST('search_direction', '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
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int'); $page = GETPOST('page','int');
@ -99,7 +98,7 @@ $formother = new FormOther($db);
$form = new Form($db); $form = new Form($db);
if ($action != 'export_csv' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction'])) { if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page)) {
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
} }
@ -171,19 +170,19 @@ if (! empty($search_accountancy_code_end)) {
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
} }
if (! empty($search_accountancy_aux_code)) { if (! empty($search_accountancy_aux_code)) {
$filter['t.code_tiers'] = $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=' . $search_accountancy_aux_code;
} }
if (! empty($search_accountancy_aux_code_start)) { if (! empty($search_accountancy_aux_code_start)) {
$filter['t.code_tiers>='] = $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=' . $search_accountancy_aux_code_start;
} }
if (! empty($search_accountancy_aux_code_end)) { if (! empty($search_accountancy_aux_code_end)) {
$filter['t.code_tiers<='] = $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=' . $search_accountancy_aux_code_end;
} }
if (! empty($search_mvt_label)) { if (! empty($search_mvt_label)) {
$filter['t.label_compte'] = $search_mvt_label; $filter['t.label_operation'] = $search_mvt_label;
$param .= '&search_mvt_label=' . $search_mvt_label; $param .= '&search_mvt_label=' . $search_mvt_label;
} }
if (! empty($search_direction)) { if (! empty($search_direction)) {
@ -261,9 +260,8 @@ if ($action == 'delmouvconfirm') {
} }
} }
if ($action == 'export_csv') { // Export into a file with format defined into setup
if ($action == 'export_file') {
include DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
@ -322,7 +320,7 @@ if ($action == 'delbookkeepingyear') {
$delyear = dol_print_date(dol_now(), '%Y'); $delyear = dol_print_date(dol_now(), '%Y');
} }
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1); $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
$form_question['delyear'] = array ( $form_question['delyear'] = array (
'name' => 'delyear', 'name' => 'delyear',
@ -333,9 +331,9 @@ if ($action == 'delbookkeepingyear') {
); );
$form_question['deljournal'] = array ( $form_question['deljournal'] = array (
'name' => 'deljournal', 'name' => 'deljournal',
'type' => 'select', 'type' => 'other', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('DelJournal'), 'label' => $langs->trans('DelJournal'),
'values' => $journal_array, 'value' => $journal_array,
'default' => $deljournal 'default' => $deljournal
); );
@ -356,16 +354,18 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
$button = '<a class="butAction" name="button_export_csv" href="'.$_SERVER["PHP_SELF"].'?action=export_csv'.($param?'&'.$param:'').'">'; $listofformat=AccountancyExport::getType();
$button = '<a class="butAction" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">';
if (count($filter)) $button.= $langs->trans("ExportFilteredList"); if (count($filter)) $button.= $langs->trans("ExportFilteredList");
else $button.= $langs->trans("ExportList"); else $button.= $langs->trans("ExportList");
$button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')';
$button.= '</a>'; $button.= '</a>';
$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">' . $langs->trans("GroupByAccountAccounting") . '</a>'; $groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">' . $langs->trans("GroupByAccountAccounting") . '</a>';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby, '', $limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby, '', $limit);
print '<div class="tabsAction">' . "\n"; print '<div class="tabsAction tabsActionNoBottom">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
print '<div class="inline-block divButAction"><a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DelBookKeeping") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DelBookKeeping") . '</a></div>';
@ -376,26 +376,53 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>'; print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">';
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, 'date_start', 0, 0, 1);
print '<br>'; print '</div>';
print '<div class="nowrap">';
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, 'date_end', 0, 0, 1);
print '</div>';
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>'; print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From'); print $langs->trans('From');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
print '<br>'; print '</div>';
print '<div class="nowrap">';
print $langs->trans('to'); print $langs->trans('to');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
print '</div>';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From'); print $langs->trans('From');
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
print '<br>'; }
else
{
print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
}
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to'); print $langs->trans('to');
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
}
else
{
print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
}
print '</div>';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>'; print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
@ -414,8 +441,8 @@ print_liste_field_titre($langs->trans("TransactionNumShort"), $_SERVER['PHP_SELF
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder);
@ -429,7 +456,6 @@ $total_debit = 0;
$total_credit = 0; $total_credit = 0;
foreach ($object->lines as $line ) { foreach ($object->lines as $line ) {
$var = ! $var;
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
@ -440,14 +466,15 @@ foreach ($object->lines as $line ) {
print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>'; print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
print '<td class="nowrap">' . $line->doc_ref . '</td>'; print '<td class="nowrap">' . $line->doc_ref . '</td>';
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($line->code_tiers) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_compte . '</td>'; print '<td>' . $line->label_operation . '</td>';
print '<td align="right">' . price($line->debit) . '</td>'; print '<td align="right">' . ($line->debit ? price($line->debit) : ''). '</td>';
print '<td align="right">' . price($line->credit) . '</td>'; print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>';
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch('',$line->code_journal); $result = $accountingjournal->fetch('',$line->code_journal);
print '<td align="center">' . $accountingjournal->getNomUrl(0,0,0,'',0) . '</td>'; $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="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;'; print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;';
@ -466,7 +493,7 @@ print '</td>';
print '<td align="right">'; print '<td align="right">';
print price($total_credit); print price($total_credit);
print '</td>'; print '</td>';
print '<td></td>'; print '<td colspan="2"></td>';
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";

View File

@ -1,9 +1,8 @@
<?php <?php
/* /* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr> largely based on the great work of : * 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-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
* 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
@ -59,7 +58,7 @@ $search_direction = GETPOST('search_direction', '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
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int'); $page = GETPOST('page','int');
@ -75,10 +74,6 @@ if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_
$object = new BookKeeping($db); $object = new BookKeeping($db);
$formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
$options = ''; $options = '';
$filter = array (); $filter = array ();
@ -104,11 +99,11 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot
$options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start; $options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
} }
if (! empty($search_label_account)) { if (! empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account; $filter['t.label_operation'] = $search_label_account;
$options .= '&amp;search_label_account=' . $search_label_account; $options .= '&amp;search_label_account=' . $search_label_account;
} }
if (! empty($search_mvt_label)) { if (! empty($search_mvt_label)) {
$filter['t.label_compte'] = $search_mvt_label; $filter['t.label_operation'] = $search_mvt_label;
$options .= '&amp;search_mvt_label=' . $search_mvt_label; $options .= '&amp;search_mvt_label=' . $search_mvt_label;
} }
if (! empty($search_direction)) { if (! empty($search_direction)) {
@ -126,7 +121,7 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot
* Action * Action
*/ */
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{ {
$search_doc_date = ''; $search_doc_date = '';
$search_accountancy_code = ''; $search_accountancy_code = '';
@ -156,6 +151,10 @@ if ($action == 'delmouvconfirm') {
* View * View
*/ */
$formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting"); $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting");
llxHeader('', $title_page); llxHeader('', $title_page);
@ -217,7 +216,7 @@ if ( preg_match('/^asc/i', $sortorder) )
else else
$sortorder = "desc"; $sortorder = "desc";
print '<div class="tabsAction">' . "\n"; print '<div class="tabsAction tabsActionNoBottom">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
print '</div>'; print '</div>';
@ -257,7 +256,6 @@ print "</tr>\n";
print '</tr>'; print '</tr>';
$var = True;
$total_debit = 0; $total_debit = 0;
$total_credit = 0; $total_credit = 0;
@ -313,14 +311,14 @@ foreach ( $object->lines as $line ) {
// Affiche un lien vers la facture client/fournisseur // Affiche un lien vers la facture client/fournisseur
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td>' . $line->label_compte . '</td>' : '<td>' . $line->label_compte . '<br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>'; print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>' . $line->label_operation . '</td>' : '<td>' . $line->label_operation . '<br /><span style="font-size:0.8em">(' . length_accounta($line->subledger_account) . ')</span></td>';
print '<td align="right">' . price($line->debit) . '</td>'; print '<td align="right">' . ($line->debit ? price($line->debit) :''). '</td>';
print '<td align="right">' . price($line->credit) . '</td>'; print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>';
print '<td align="center">' . $line->code_journal . '</td>'; print '<td align="center">' . $line->code_journal . '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="./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 . $options . '&page=' . $page . '">' . img_delete() . '</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -355,6 +353,4 @@ print "</table>";
print '</form>'; print '</form>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -37,7 +37,7 @@ $langs->load("accountancy");
$page = GETPOST("page"); $page = GETPOST("page");
$sortorder = GETPOST("sortorder"); $sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield"); $sortfield = GETPOST("sortfield");
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit;
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); $search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_doc_type = GETPOST('search_doc_type', 'alpha'); $search_doc_type = GETPOST('search_doc_type', 'alpha');
@ -52,16 +52,16 @@ $search_numero_compte_end = GETPOST('search_numero_compte_end', 'alpha');
if ($search_numero_compte_end == - 1) { if ($search_numero_compte_end == - 1) {
$search_numero_compte_end = ''; $search_numero_compte_end = '';
} }
$search_code_tiers = GETPOST('search_code_tiers', 'alpha'); $search_subledger_account = GETPOST('search_subledger_account', 'alpha');
$search_code_tiers_start = GETPOST('search_code_tiers_start', 'alpha'); $search_subledger_account_start = GETPOST('search_subledger_account_start', 'alpha');
if ($search_code_tiers_start == - 1) { if ($search_subledger_account_start == - 1) {
$search_code_tiers_start = ''; $search_subledger_account_start = '';
} }
$search_code_tiers_end = GETPOST('search_code_tiers_end', 'alpha'); $search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha');
if ($search_code_tiers_end == - 1) { if ($search_subledger_account_end == - 1) {
$search_code_tiers_end = ''; $search_subledger_account_end = '';
} }
$search_label_compte = GETPOST('search_label_compte', 'alpha'); $search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_sens = GETPOST('search_sens', 'alpha'); $search_sens = GETPOST('search_sens', 'alpha');
$search_code_journal = GETPOST('search_code_journal', 'alpha'); $search_code_journal = GETPOST('search_code_journal', 'alpha');
@ -81,16 +81,19 @@ if ($sortfield == "")
$offset = $limit * $page; $offset = $limit * $page;
llxHeader('', $langs->trans("Bookkeeping"));
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers /*
* Actions
*/
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{ {
$search_doc_type = ""; $search_doc_type = "";
$search_doc_date = ""; $search_doc_date = "";
$search_doc_ref = ""; $search_doc_ref = "";
$search_numero_compte = ""; $search_numero_compte = "";
$search_code_tiers = ""; $search_subledger_account = "";
$search_label_compte = ""; $search_label_operation = "";
$search_sens = ""; $search_sens = "";
$search_code_journal = ""; $search_code_journal = "";
} }
@ -129,21 +132,21 @@ if (! empty($search_numero_compte_end)) {
$filter['t.numero_compte<='] = $search_numero_compte_end; $filter['t.numero_compte<='] = $search_numero_compte_end;
$options .= '&amp;search_numero_compte_end=' . $search_numero_compte_end; $options .= '&amp;search_numero_compte_end=' . $search_numero_compte_end;
} }
if (! empty($search_code_tiers)) { if (! empty($search_subledger_account)) {
$filter['t.code_tiers'] = $search_code_tiers; $filter['t.subledger_account'] = $search_subledger_account;
$options .= '&amp;search_code_tiers=' . $search_code_tiers; $options .= '&amp;search_subledger_account=' . $search_subledger_account;
} }
if (! empty($search_code_tiers_start)) { if (! empty($search_subledger_account_start)) {
$filter['t.code_tiers>='] = $search_code_tiers_start; $filter['t.subledger_account>='] = $search_subledger_account_start;
$options .= '&amp;search_code_tiers_start=' . $search_code_tiers_start; $options .= '&amp;search_subledger_account_start=' . $search_subledger_account_start;
} }
if (! empty($search_code_tiers_end)) { if (! empty($search_subledger_account_end)) {
$filter['t.code_tiers<='] = $search_code_tiers_end; $filter['t.subledger_account<='] = $search_subledger_account_end;
$options .= '&amp;search_code_tiers_end=' . $search_code_tiers_end; $options .= '&amp;search_subledger_account_end=' . $search_subledger_account_end;
} }
if (! empty($search_label_compte)) { if (! empty($search_label_operation)) {
$filter['t.label_compte'] = $search_label_compte; $filter['t.label_operation'] = $search_label_operation;
$options .= '&amp;search_label_compte=' . $search_label_compte; $options .= '&amp;search_label_operation=' . $search_label_operation;
} }
if (! empty($search_sens)) { if (! empty($search_sens)) {
$filter['t.sens'] = $search_sens; $filter['t.sens'] = $search_sens;
@ -154,10 +157,13 @@ if (! empty($search_code_journal)) {
$options .= '&amp;search_code_journal=' . $search_code_journal; $options .= '&amp;search_code_journal=' . $search_code_journal;
} }
/* /*
* Mode List * Actions
*/ */
llxHeader('', $langs->trans("Bookkeeping"));
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0); $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0);
@ -188,9 +194,9 @@ print $formaccounting->select_account($search_numero_compte_end, 'search_numero_
print '</div>'; print '</div>';
print '<div class="liste_titre">'; print '<div class="liste_titre">';
print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); print $formaccounting->select_auxaccount($search_subledger_account_start, 'search_subledger_account_start', 1);
print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); print $formaccounting->select_auxaccount($search_subledger_account_end, 'search_subledger_account_end', 1);
print '</div>'; print '</div>';
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
@ -200,8 +206,8 @@ print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_t
print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder);
@ -232,11 +238,11 @@ print '<input type="text" size=6 class="flat" name="search_numero_compte" value=
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_code_tiers" value="' . $search_code_tiers . '"/>'; print '<input type="text" size=6 class="flat" name="search_subledger_account" value="' . $search_subledger_account . '"/>';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_label_compte" value="' . $search_label_compte . '"/>'; print '<input type="text" size=6 class="flat" name="search_label_operation" value="' . $search_label_operation . '"/>';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
@ -264,8 +270,6 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
$var = True;
foreach ( $object->lines as $line ) { foreach ( $object->lines as $line ) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -274,8 +278,8 @@ foreach ( $object->lines as $line ) {
print '<td align="center">' . dol_print_date($line->doc_date) . '</td>'; print '<td align="center">' . dol_print_date($line->doc_date) . '</td>';
print '<td>' . $line->doc_ref . '</td>'; print '<td>' . $line->doc_ref . '</td>';
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($line->code_tiers) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_compte . '</td>'; print '<td>' . $line->label_operation . '</td>';
print '<td align="right">' . price($line->debit) . '</td>'; print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>'; print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($line->montant) . '</td>'; print '<td align="right">' . price($line->montant) . '</td>';

View File

@ -0,0 +1,331 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.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 accounting/bookkeeping/thirdparty_lettrage.php
* \ingroup Accounting Expert
* \brief Onglet de gestion de parametrages des ventilations
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "bk.rowid";
$search_year = GETPOST ( "search_year" );
// Security check
$socid = GETPOST("socid",'int');
// if ($user->societe_id) $socid=$user->societe_id;
$object = new Societe($db);
$object->id = $socid;
$object->fetch($socid);
$form = new Form($db);
$BookKeeping = new lettering($db);
$formaccounting = new FormAccounting($db);
/*
* Action
*/
if ($action == 'lettering') {
$result = $BookKeeping->updatelettrage($_POST['ids']);
// var_dump($result);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
if ($action == 'autolettrage') {
$result = $BookKeeping->LettrageTiers($socid);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
llxHeader ( '', 'Compta - Grand Livre' );
/*
* Affichage onglets
*/
$head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
print '<table width="100%" class="border">';
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">';
$object->next_prev_filter="te.fournisseur = 1";
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
}
print '<tr>';
print '<td class="nowrap">'.$langs->trans("CustomerCode"). '</td><td colspan="3">';
print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td>';
print '</tr>';
$langs->load('compta');
print '<tr>';
print '<td>';
print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
print '</td>';
print '</tr>';
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($object->address,'gmap','thirdparty',$object->id);
print '</td></tr>';
// Zip / Town
print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>';
print '</tr>';
// Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
//$img=picto_from_langcode($object->country_code);
$img='';
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->country;
print '</td></tr>';
print '</table>';
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE (bk.code_tiers = '" . $object->code_compta . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER. "' )" ;
if (dol_strlen ( $search_year )) {
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )";
}
$sql .= " ORDER BY bk.lettering_code ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset );
// echo $sql;
// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
print '<form name="add" action="?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="action" value="lettering">';
print '<input type="hidden" name="socid" value="'.$object->id.'">';
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td></td>';
print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" );
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" );
// print_liste_field_titre ( $langs->trans ( "Numerocompte" ), "liste.php", "bk.numero_compte" );
// print_liste_field_titre ( $langs->trans ( "Code_tiers" ), "liste.php", "bk.code_tiers" );
print_liste_field_titre ( $langs->trans ( "Labelcompte" ), "liste.php", "bk_label_compte" );
print_liste_field_titre ( $langs->trans ( "Debit" ), "liste.php", "bk.debit" );
print_liste_field_titre ( $langs->trans ( "Credit" ), "liste.php", "bk.credit" );
// print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" );
// print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" );
print '<td></td>';
print '<td></td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="" method="GET">';
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
print '<td><input type="text" name="search_doc_type" value="' . $_GET ["search_doc_type"] . '"></td>';
print '<td><input type="text" name="search_year" value="' . $_GET ["search_year"] . '"></td>';
print '<td><input type="text" name="search_doc_refe" value="' . $_GET ["search_doc_ref"] . '"></td>';
// print '<td><input type="text" name="search_compte" value="' . $_GET ["search_compte"] . '"></td>';
// print '<td><input type="text" name="search_tiers" value="' . $_GET ["search_tiers"] . '"></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
// print '<td>&nbsp;</td>';
// print '<td>&nbsp;</td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</form>';
print '</tr>';
$var = false;
$debit = 0;
$credit = 0;
$solde = 0;
$tmp = '';
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
if($tmp !=$obj->lettering_code || empty($tmp) )
$tmp =$obj->lettering_code;
if($tmp !=$obj->lettering_code || empty($obj->lettering_code))
$var = ! $var;
$debit+= $obj->debit;
$credit+= $obj->credit;
$solde+=($obj->credit-$obj->debit);
print "<tr $bc[$var]>";
print '<td>' . $obj->rowid . '</td>';
if(empty($obj->lettering_code)){
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">';
print img_edit ();
print '</a>&nbsp;' . $obj->doc_type . '</td>' . "\n";
}
else
print '<td>'.$obj->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
// print '<td>' . $obj->numero_compte . '</td>';
// print '<td>' . $obj->code_tiers . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td>' . $obj->debit . '</td>';
print '<td>' . $obj->credit . '</td>';
// print '<td>' . $obj->montant . '</td>';
// print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>';
print '<td>' . round($solde, 2) . '</td>';
if(empty($obj->lettering_code)){
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
}
else
print '<td>' . $obj->lettering_code . '</td>';
print "</tr>\n";
$i ++;
}
print '<tr class="oddeven">';
print '<td colspan="4">Mouvement totaux</td>' . "\n";
print '<td></td>';
// print '<td></td>';
// print '<td></td>';
print '<td><strong>' . $debit . '</strong></td>';
print '<td><strong>' . $credit . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "<tr $bc[$var]>";
print '<td colspan="5">Solde Comptable</td>' . "\n";
// print '<td></td>';
// print '<td></td>';
print '<td></td>';
print '<td><strong>' . ($credit-$debit) . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "</table>";
print '<input class="butAction" type="submit" value="lettering">';
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
print "</form>";
$db->free($resql);
} else {
dol_print_error($db);
}
// End of page
llxFooter();
$db->close();

View File

@ -0,0 +1,335 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.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 accounting/bookkeeping/thirdparty_lettrage.php
* \ingroup Accounting Expert
* \brief Onglet de gestion de parametrages des ventilations
*/
// Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "bk.rowid";
$search_year = GETPOST ( "search_year" );
// Security check
$socid = GETPOST("socid",'int');
// if ($user->societe_id) $socid=$user->societe_id;
$object = new Societe($db);
$object->id = $socid;
$object->fetch($socid);
$form = new Form($db);
$BookKeeping = new lettering($db);
$formaccounting = new FormAccounting($db);
/*
* Action
*/
if ($action == 'lettering') {
$result = $BookKeeping->updatelettrage($_POST['ids']);
// var_dump($result);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
if ($action == 'autolettrage') {
$result = $BookKeeping->LettrageTiers($socid);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
llxHeader ( '', 'Compta - Grand Livre' );
/*
* Affichage onglets
*/
$head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
print '<table width="100%" class="border">';
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">';
$object->next_prev_filter="te.fournisseur = 1";
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
}
print '<tr>';
print '<td class="nowrap">'.$langs->trans("SupplierCode"). '</td><td colspan="3">';
print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td>';
print '</tr>';
$langs->load('compta');
print '<tr>';
print '<td>';
print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
print '</td>';
print '</tr>';
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($object->address,'gmap','thirdparty',$object->id);
print '</td></tr>';
// Zip / Town
print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>';
print '</tr>';
// Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
//$img=picto_from_langcode($object->country_code);
$img='';
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->country;
print '</td></tr>';
print '</table>';
// print_r($soc);
// exit;
// [code_compta] => 411DOUA
// [code_compta_fournisseur] => 401SUPPCODE
/*
* Mode Liste
*
*
*
*/
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE (bk.code_tiers = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER. "' )" ;
if (dol_strlen ( $search_year )) {
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )";
}
$sql .= " ORDER BY bk.lettering ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset );
// echo $sql;
// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
print '<form name="add" action="?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="action" value="lettering">';
print '<input type="hidden" name="socid" value="'.$object->id.'">';
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td></td>';
print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" );
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" );
// print_liste_field_titre ( $langs->trans ( "Numerocompte" ), "liste.php", "bk.numero_compte" );
// print_liste_field_titre ( $langs->trans ( "Code_tiers" ), "liste.php", "bk.code_tiers" );
print_liste_field_titre ( $langs->trans ( "Labelcompte" ), "liste.php", "bk_label_compte" );
print_liste_field_titre ( $langs->trans ( "Debit" ), "liste.php", "bk.debit" );
print_liste_field_titre ( $langs->trans ( "Credit" ), "liste.php", "bk.credit" );
print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" );
print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" );
print '<td></td>';
print '<td></td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="" method="GET">';
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
print '<td><input type="text" name="search_doc_type" value="' . $_GET ["search_doc_type"] . '"></td>';
print '<td><input type="text" name="search_year" value="' . $_GET ["search_year"] . '"></td>';
print '<td><input type="text" name="search_doc_refe" value="' . $_GET ["search_doc_ref"] . '"></td>';
// print '<td><input type="text" name="search_compte" value="' . $_GET ["search_compte"] . '"></td>';
// print '<td><input type="text" name="search_tiers" value="' . $_GET ["search_tiers"] . '"></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</form>';
print '</tr>';
$var = false;
$debit = 0;
$credit = 0;
$solde = 0;
$tmp = '';
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
if($tmp !=$obj->lettering || empty($tmp) )
$tmp =$obj->lettering;
if($tmp !=$obj->lettering || empty($obj->lettering))
$var = ! $var;
$debit+= $obj->debit;
$credit+= $obj->credit;
$solde+=($obj->credit-$obj->debit);
print "<tr $bc[$var]>";
print '<td>' . $obj->rowid . '</td>';
if(empty($obj->lettering)){
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">';
print img_edit ();
print '</a>&nbsp;' . $obj->doc_type . '</td>' . "\n";
}
else
print '<td>'.$obj->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
// print '<td>' . $obj->numero_compte . '</td>';
// print '<td>' . $obj->code_tiers . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td>' . $obj->debit . '</td>';
print '<td>' . $obj->credit . '</td>';
print '<td>' . $obj->montant . '</td>';
print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>';
print '<td>' . round($solde, 2) . '</td>';
if(empty($obj->lettering)){
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
}
else
print '<td>' . $obj->lettering . '</td>';
print "</tr>\n";
$i ++;
}
print '<tr class="oddeven">';
print '<td colspan="4">Mouvement totaux</td>' . "\n";
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td><strong>' . $debit . '</strong></td>';
print '<td><strong>' . $credit . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "<tr $bc[$var]>";
print '<td colspan="5">Solde Comptable</td>' . "\n";
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td><strong>' . ($credit-$debit) . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "</table>";
print '<input class="butAction" type="submit" value="lettering">';
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
print "</form>";
$db->free ( $resql );
} else {
dol_print_error ( $db );
}
// End of page
llxFooter();
$db->close();

View File

@ -92,7 +92,7 @@ class AccountancyCategory
public function getCptBK($id) { public function getCptBK($id) {
global $conf; global $conf;
$sql = "SELECT t.numero_compte, t.label_compte, t.doc_ref"; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " WHERE t.numero_compte NOT IN (";
$sql .= " SELECT t.account_number"; $sql .= " SELECT t.account_number";
@ -104,7 +104,7 @@ class AccountancyCategory
$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 .= " GROUP BY t.numero_compte, t.label_compte, 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";
$this->lines_CptBk = array (); $this->lines_CptBk = array ();
@ -332,7 +332,7 @@ class AccountancyCategory
} }
/** /**
* Function to show result of an accounting account from the general ledger with a sens and a period * Function to show result of an accounting account from the ledger with a direction and a period
* *
* @param int $cpt Id accounting account * @param int $cpt Id accounting account
* @param string $month Specifig month - Can be empty * @param string $month Specifig month - Can be empty
@ -429,4 +429,160 @@ class AccountancyCategory
return - 1; return - 1;
} }
} }
public function getCats() {
global $db, $langs, $user, $mysoc;
if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
exit();
}
if (! empty($mysoc->country_id)) {
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
$sql .= " WHERE c.active = 1 ";
$sql .= " AND c.fk_country = " . $mysoc->country_id;
$sql .= " ORDER BY c.position ASC";
} else {
$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";
$sql .= " AND co.code = '" . $mysoc->country_code . "'";
$sql .= " ORDER BY c.position ASC";
}
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$i = 0;
$obj = '';
$num = $this->db->num_rows($resql);
$data = array ();
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
$data[] = array (
'rowid' => $obj->rowid,
'code' => $obj->code,
'position' => $obj->position,
'label' => $obj->label,
'formula' => $obj->formula,
'category_type' => $obj->category_type
);
$i ++;
}
}
return $data;
} else {
$this->error = "Error " . $this->db->lasterror();
$this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR);
return - 1;
}
}
// calcule
const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/';
const PARENTHESIS_DEPTH = 10;
public function calculate($input){
if(strpos($input, '+') != null || strpos($input, '-') != null || strpos($input, '/') != null || strpos($input, '*') != null){
// Remove white spaces and invalid math chars
$input = str_replace(',', '.', $input);
$input = preg_replace('[^0-9\.\+\-\*\/\(\)]', '', $input);
// Calculate each of the parenthesis from the top
$i = 0;
while(strpos($input, '(') || strpos($input, ')')){
$input = preg_replace_callback('/\(([^\(\)]+)\)/', 'self::callback', $input);
$i++;
if($i > self::PARENTHESIS_DEPTH){
break;
}
}
// Calculate the result
if(preg_match(self::PATTERN, $input, $match)){
return $this->compute($match[0]);
}
return 0;
}
return $input;
}
private function compute($input){
$compute = create_function('', 'return '.$input.';');
return 0 + $compute();
}
private function callback($input){
if(is_numeric($input[1])){
return $input[1];
}
elseif(preg_match(self::PATTERN, $input[1], $match)){
return $this->compute($match[0]);
}
return 0;
}
/**
* get cpts of category
*
* @param int $cat_id Id accounting account category
*
* @return array Result in table
*/
public function getCptsCat($cat_id) {
global $mysoc;
$sql = "";
if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
exit();
}
$sql = "SELECT t.rowid, t.account_number, t.label as name_cpt";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = ".$cat_id;
$sql .= " ORDER BY t.account_number ";
//echo $sql;
$resql = $this->db->query($sql);
if ($resql) {
$i = 0;
$obj = '';
$num = $this->db->num_rows($resql);
$data = array ();
if ($num) {
while ( $obj = $this->db->fetch_object($resql) ) {
$name_cat = $obj->name_cat;
$data[] = array (
'id' => $obj->rowid,
'account_number' => $obj->account_number,
'name_cpt' => $obj->name_cpt,
);
$i ++;
}
}
return $data;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
return -1;
}
}
} }

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 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2016-2017 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
@ -32,14 +32,15 @@
* *
* Manage the different format accountancy export * Manage the different format accountancy export
*/ */
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
class AccountancyExport class AccountancyExport
{ {
/** /**
* * @var Type of export. Defined by $conf->global->ACCOUNTING_EXPORT_MODELCSV
* @var Type of export
*/ */
public static $EXPORT_TYPE_NORMAL = 1; public static $EXPORT_TYPE_NORMAL = 1; // Classic CSV
public static $EXPORT_TYPE_CEGID = 2; public static $EXPORT_TYPE_CEGID = 2;
public static $EXPORT_TYPE_COALA = 3; public static $EXPORT_TYPE_COALA = 3;
public static $EXPORT_TYPE_BOB50 = 4; public static $EXPORT_TYPE_BOB50 = 4;
@ -81,7 +82,7 @@ class AccountancyExport
} }
/** /**
* Get all export type are available * Array wit all export type available (key + label)
* *
* @return array of type * @return array of type
*/ */
@ -172,7 +173,7 @@ class AccountancyExport
print $date . $this->separator; print $date . $this->separator;
print $line->doc_ref . $this->separator; print $line->doc_ref . $this->separator;
print length_accountg($line->numero_compte) . $this->separator; print length_accountg($line->numero_compte) . $this->separator;
print length_accounta($line->code_tiers) . $this->separator; print length_accounta($line->subledger_account) . $this->separator;
print price($line->debit) . $this->separator; print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator; print price($line->credit) . $this->separator;
print $line->code_journal . $this->separator; print $line->code_journal . $this->separator;
@ -195,10 +196,10 @@ class AccountancyExport
print $date . $separator; print $date . $separator;
print $line->code_journal . $separator; print $line->code_journal . $separator;
print length_accountg($line->numero_compte) . $separator; print length_accountg($line->numero_compte) . $separator;
print length_accounta($line->code_tiers) . $separator; print length_accounta($line->subledger_account) . $separator;
print $line->sens . $separator; print $line->sens . $separator;
print price($line->montant) . $separator; print price($line->montant) . $separator;
print $line->label_compte . $separator; print $line->label_operation . $separator;
print $line->doc_ref; print $line->doc_ref;
print $this->end_line; print $this->end_line;
} }
@ -220,7 +221,7 @@ class AccountancyExport
print $line->piece_num . $this->separator; print $line->piece_num . $this->separator;
print length_accountg($line->numero_compte) . $this->separator; print length_accountg($line->numero_compte) . $this->separator;
print '' . $this->separator; print '' . $this->separator;
print $line->label_compte . $this->separator; print $line->label_operation . $this->separator;
print $date . $this->separator; print $date . $this->separator;
if ($line->sens=='D') { if ($line->sens=='D') {
print price($line->montant) . $this->separator; print price($line->montant) . $this->separator;
@ -230,7 +231,7 @@ class AccountancyExport
print price($line->montant) . $this->separator; print price($line->montant) . $this->separator;
} }
print $line->doc_ref . $this->separator; print $line->doc_ref . $this->separator;
print $line->label_compte . $this->separator; print $line->label_operation . $this->separator;
print $this->end_line; print $this->end_line;
} }
} }
@ -254,7 +255,7 @@ class AccountancyExport
print price($line->debit) . $this->separator; print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator; print price($line->credit) . $this->separator;
print 'E' . $this->separator; print 'E' . $this->separator;
print length_accountg($line->code_tiers) . $this->separator; print length_accountg($line->subledger_account) . $this->separator;
print $this->end_line; print $this->end_line;
} }
} }
@ -274,7 +275,7 @@ class AccountancyExport
$date = dol_print_date($line->doc_date, '%d/%m/%Y'); $date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $this->separator; print $date . $this->separator;
if (empty($line->code_tiers)) { if (empty($line->subledger_account)) {
print 'G' . $this->separator; print 'G' . $this->separator;
print length_accounta($line->numero_compte) . $this->separator; print length_accounta($line->numero_compte) . $this->separator;
} else { } else {
@ -284,12 +285,12 @@ class AccountancyExport
if (substr($line->numero_compte, 0, 3) == '401') { if (substr($line->numero_compte, 0, 3) == '401') {
print 'F' . $this->separator; print 'F' . $this->separator;
} }
print length_accountg($line->code_tiers) . $this->separator; print length_accountg($line->subledger_account) . $this->separator;
} }
print price($line->debit) . $this->separator; print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator; print price($line->credit) . $this->separator;
print dol_trunc($line->label_compte, 32) . $this->separator; print dol_trunc($line->label_operation, 32) . $this->separator;
print $this->end_line; print $this->end_line;
} }
} }
@ -307,11 +308,11 @@ class AccountancyExport
$this->end_line ="\r\n"; $this->end_line ="\r\n";
$i = 1; $i = 1;
$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
foreach ( $TData as $data ) { foreach ( $TData as $data ) {
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (! empty($data->code_tiers)) if (! empty($data->subledger_account))
$code_compta = $data->code_tiers; $code_compta = $data->subledger_account;
$Tab = array (); $Tab = array ();
$Tab['num_ecriture'] = str_pad($i, 5); $Tab['num_ecriture'] = str_pad($i, 5);
@ -320,11 +321,11 @@ class AccountancyExport
$Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
$Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_compte, 25), 25); $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_operation, 25), 25);
$Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT);
$Tab['type_montant'] = str_pad($data->sens, 1); $Tab['type_montant'] = str_pad($data->sens, 1);
$Tab['vide'] = str_repeat(' ', 18); $Tab['vide'] = str_repeat(' ', 18);
$Tab['intitule_compte'] = str_pad(self::trunc($data->label_compte, 34), 34); $Tab['intitule_compte'] = str_pad(self::trunc($data->label_operation, 34), 34);
$Tab['end'] = 'O2003'; $Tab['end'] = 'O2003';
$Tab['end_line'] = $this->end_line; $Tab['end_line'] = $this->end_line;
@ -349,8 +350,8 @@ class AccountancyExport
$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
foreach ( $TData as $data ) { foreach ( $TData as $data ) {
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (! empty($data->code_tiers)) if (! empty($data->subledger_account))
$code_compta = $data->code_tiers; $code_compta = $data->subledger_account;
$Tab = array (); $Tab = array ();
$Tab['type_ligne'] = 'M'; $Tab['type_ligne'] = 'M';
@ -359,7 +360,7 @@ class AccountancyExport
$Tab['folio'] = '000'; $Tab['folio'] = '000';
$Tab['date_ecriture'] = $date_ecriture; $Tab['date_ecriture'] = $date_ecriture;
$Tab['filler'] = ' '; $Tab['filler'] = ' ';
$Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 20), 20); $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 20), 20);
$Tab['sens'] = $data->sens; // C or D $Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+'; $Tab['signe_montant'] = '+';
$Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
@ -375,7 +376,7 @@ class AccountancyExport
$Tab['devis'] = str_pad($conf->currency, 3); $Tab['devis'] = str_pad($conf->currency, 3);
$Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
$Tab['filler3'] = str_repeat(' ', 3); $Tab['filler3'] = str_repeat(' ', 3);
$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 32), 32); $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 32), 32);
$Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
$Tab['filler4'] = str_repeat(' ', 73); $Tab['filler4'] = str_repeat(' ', 73);
@ -406,7 +407,7 @@ class AccountancyExport
print $line->code_journal . $this->separator; print $line->code_journal . $this->separator;
print length_accountg($line->numero_compte) . $this->separator; print length_accountg($line->numero_compte) . $this->separator;
print substr(length_accountg($line->numero_compte),0,2) . $this->separator; print substr(length_accountg($line->numero_compte),0,2) . $this->separator;
print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; print '"'.dol_trunc($line->label_operation,40,'right','UTF-8',1).'"' . $this->separator;
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator;
print price2num($line->montant).$this->separator; print price2num($line->montant).$this->separator;
print $line->sens.$this->separator; print $line->sens.$this->separator;
@ -437,18 +438,20 @@ class AccountancyExport
print $date . $this->separator; print $date . $this->separator;
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator;
if (empty($line->code_tiers)) { if (empty($line->subledger_account)) {
print length_accountg($line->numero_compte) . $this->separator; print length_accountg($line->numero_compte) . $this->separator;
} else { } else {
// FIXME Because the subledger_account is already an accounting account, does we really need
// to concat 4011 or 401 to it ?
if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') { if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') {
print '411' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; print '411' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator;
} }
if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') { if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') {
print '401' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; print '401' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator;
} }
} }
print length_accounta($line->code_tiers) . $this->separator; print length_accounta($line->subledger_account) . $this->separator;
print price($line->debit) . $this->separator; print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator; print price($line->credit) . $this->separator;
print price($line->montant).$this->separator; print price($line->montant).$this->separator;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>

View File

@ -33,10 +33,12 @@ class AccountingJournal extends CommonObject
var $rowid; var $rowid;
var $code; public $code;
var $label; public $label;
var $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 9: has-new public $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 4:expense-report, 9: has-new
var $active; public $active;
public $lines;
/** /**
* Constructor * Constructor
@ -62,9 +64,9 @@ class AccountingJournal extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE"; $sql .= " WHERE";
if ($rowid) { if ($rowid) {
$sql .= " rowid = '" . $rowid . "'"; $sql .= " rowid = " . (int) $rowid;
} elseif ($journal_code) { } elseif ($journal_code) {
$sql .= " code = '" . $journal_code . "'"; $sql .= " code = '" . $this->db->escape($journal_code) . "'";
} }
dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
@ -97,6 +99,74 @@ class AccountingJournal extends CommonObject
return -1; return -1;
} }
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
$sql = "SELECT rowid, code, label, nature, active";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ( $filter as $key => $value ) {
if ($key == 't.code' || $key == 't.label' || $key == 't.nature') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.rowid' || $key == 't.active') {
$sqlwhere[] = $key . '=' . $value;
}
}
}
$sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
}
if (! empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
$line = new self($this->db);
$line->id = $obj->rowid;
$line->code = $obj->code;
$line->label = $obj->label;
$line->nature = $obj->nature;
$line->active = $obj->active;
$this->lines[] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
@ -187,6 +257,7 @@ class AccountingJournal extends CommonObject
{ {
$prefix=''; $prefix='';
if ($nature == 9) return $langs->trans('AccountingJournalType9'); if ($nature == 9) return $langs->trans('AccountingJournalType9');
if ($nature == 5) return $langs->trans('AccountingJournalType5');
if ($nature == 4) return $langs->trans('AccountingJournalType4'); if ($nature == 4) return $langs->trans('AccountingJournalType4');
if ($nature == 3) return $langs->trans('AccountingJournalType3'); if ($nature == 3) return $langs->trans('AccountingJournalType3');
if ($nature == 2) return $langs->trans('AccountingJournalType2'); if ($nature == 2) return $langs->trans('AccountingJournalType2');
@ -195,6 +266,7 @@ class AccountingJournal extends CommonObject
if ($mode == 1) if ($mode == 1)
{ {
if ($nature == 9) return $langs->trans('AccountingJournalType9'); if ($nature == 9) return $langs->trans('AccountingJournalType9');
if ($nature == 5) return $langs->trans('AccountingJournalType5');
if ($nature == 4) return $langs->trans('AccountingJournalType4'); if ($nature == 4) return $langs->trans('AccountingJournalType4');
if ($nature == 3) return $langs->trans('AccountingJournalType3'); if ($nature == 3) return $langs->trans('AccountingJournalType3');
if ($nature == 2) return $langs->trans('AccountingJournalType2'); if ($nature == 2) return $langs->trans('AccountingJournalType2');

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2014-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2014-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015-2017 Florian Henry <florian.henry@open-concept.pro>
* *
* 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
@ -20,14 +20,14 @@
/** /**
* \file htdocs/accountancy/class/bookkeeping.class.php * \file htdocs/accountancy/class/bookkeeping.class.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief File of class to manage general ledger * \brief File of class to manage Ledger (General Ledger and Subledger)
*/ */
// Class // Class
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
/** /**
* Class to manage general ledger * Class to manage Ledger (General Ledger and Subledger)
*/ */
class BookKeeping extends CommonObject class BookKeeping extends CommonObject
{ {
@ -75,9 +75,12 @@ class BookKeeping extends CommonObject
public $doc_ref; public $doc_ref;
public $fk_doc; public $fk_doc;
public $fk_docdet; public $fk_docdet;
public $code_tiers; public $thirdparty_code;
public $subledger_account;
public $subledger_label;
public $numero_compte; public $numero_compte;
public $label_compte; public $label_compte;
public $label_operation;
public $debit; public $debit;
public $credit; public $credit;
public $montant; public $montant;
@ -85,11 +88,9 @@ class BookKeeping extends CommonObject
public $fk_user_author; public $fk_user_author;
public $import_key; public $import_key;
public $code_journal; public $code_journal;
public $journal_label;
public $piece_num; public $piece_num;
/**
*/
/** /**
* Constructor * Constructor
* *
@ -126,8 +127,14 @@ class BookKeeping extends CommonObject
if (isset($this->fk_docdet)) { if (isset($this->fk_docdet)) {
$this->fk_docdet = trim($this->fk_docdet); $this->fk_docdet = trim($this->fk_docdet);
} }
if (isset($this->code_tiers)) { if (isset($this->thirdparty_code)) {
$this->code_tiers = trim($this->code_tiers); $this->thirdparty_code = trim($this->thirdparty_code);
}
if (isset($this->subledger_account)) {
$this->subledger_account = trim($this->subledger_account);
}
if (isset($this->subledger_label)) {
$this->subledger_label = trim($this->subledger_label);
} }
if (isset($this->numero_compte)) { if (isset($this->numero_compte)) {
$this->numero_compte = trim($this->numero_compte); $this->numero_compte = trim($this->numero_compte);
@ -135,6 +142,9 @@ class BookKeeping extends CommonObject
if (isset($this->label_compte)) { if (isset($this->label_compte)) {
$this->label_compte = trim($this->label_compte); $this->label_compte = trim($this->label_compte);
} }
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) { if (isset($this->debit)) {
$this->debit = trim($this->debit); $this->debit = trim($this->debit);
} }
@ -156,6 +166,9 @@ class BookKeeping extends CommonObject
if (isset($this->code_journal)) { if (isset($this->code_journal)) {
$this->code_journal = trim($this->code_journal); $this->code_journal = trim($this->code_journal);
} }
if (isset($this->journal_label)) {
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
@ -172,7 +185,13 @@ class BookKeeping extends CommonObject
} }
else else
{ {
$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte);
$mesg=$this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte;
if ($this->subledger_account && $this->subledger_account != $this->numero_compte)
{
$mesg.=', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account;
}
$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg);
} }
return -1; return -1;
@ -189,7 +208,7 @@ class BookKeeping extends CommonObject
$sql .= " AND fk_doc = " . $this->fk_doc; $sql .= " AND fk_doc = " . $this->fk_doc;
$sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines
$sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'";
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -203,7 +222,7 @@ class BookKeeping extends CommonObject
$sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank'
$sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ...
$sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object
$sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum); $resqlnum = $this->db->query($sqlnum);
@ -215,7 +234,7 @@ class BookKeeping extends CommonObject
if (empty($this->piece_num)) { if (empty($this->piece_num)) {
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
$sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; $sqlnum .= " WHERE entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum); $resqlnum = $this->db->query($sqlnum);
@ -240,35 +259,43 @@ class BookKeeping extends CommonObject
$sql .= ", doc_ref"; $sql .= ", doc_ref";
$sql .= ", fk_doc"; $sql .= ", fk_doc";
$sql .= ", fk_docdet"; $sql .= ", fk_docdet";
$sql .= ", code_tiers"; $sql .= ", thirdparty_code";
$sql .= ", subledger_account";
$sql .= ", subledger_label";
$sql .= ", numero_compte"; $sql .= ", numero_compte";
$sql .= ", label_compte"; $sql .= ", label_compte";
$sql .= ", label_operation";
$sql .= ", debit"; $sql .= ", debit";
$sql .= ", credit"; $sql .= ", credit";
$sql .= ", montant"; $sql .= ", montant";
$sql .= ", sens"; $sql .= ", sens";
$sql .= ", fk_user_author"; $sql .= ", fk_user_author";
$sql .= ", import_key"; $sql .= ", date_creation";
$sql .= ", code_journal"; $sql .= ", code_journal";
$sql .= ", journal_label";
$sql .= ", piece_num"; $sql .= ", piece_num";
$sql .= ', entity'; $sql .= ', entity';
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'" . $this->db->idate($this->doc_date) . "'"; $sql .= "'" . $this->db->idate($this->doc_date) . "'";
$sql .= ",'" . $this->doc_type . "'"; $sql .= ",'" . $this->db->escape($this->doc_type) . "'";
$sql .= ",'" . $this->doc_ref . "'"; $sql .= ",'" . $this->db->escape($this->doc_ref) . "'";
$sql .= "," . $this->fk_doc; $sql .= "," . $this->fk_doc;
$sql .= "," . $this->fk_docdet; $sql .= "," . $this->fk_docdet;
$sql .= ",'" . $this->code_tiers . "'"; $sql .= ",'" . $this->db->escape($this->thirdparty_code) . "'";
$sql .= ",'" . $this->numero_compte . "'"; $sql .= ",'" . $this->db->escape($this->subledger_account) . "'";
$sql .= ",'" . $this->db->escape($this->subledger_label) . "'";
$sql .= ",'" . $this->db->escape($this->numero_compte) . "'";
$sql .= ",'" . $this->db->escape($this->label_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'";
$sql .= ",'" . $this->db->escape($this->label_operation) . "'";
$sql .= "," . $this->debit; $sql .= "," . $this->debit;
$sql .= "," . $this->credit; $sql .= "," . $this->credit;
$sql .= "," . $this->montant; $sql .= "," . $this->montant;
$sql .= ",'" . $this->sens . "'"; $sql .= ",'" . $this->db->escape($this->sens) . "'";
$sql .= ",'" . $this->fk_user_author . "'"; $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'";
$sql .= ",'" . $this->db->idate($this->date_create). "'"; $sql .= ",'" . $this->db->idate($this->date_create). "'";
$sql .= ",'" . $this->code_journal . "'"; $sql .= ",'" . $this->db->escape($this->code_journal) . "'";
$sql .= "," . $this->piece_num; $sql .= ",'" . $this->db->escape($this->journal_label) . "'";
$sql .= "," . $this->db->escape($this->piece_num);
$sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity);
$sql .= ")"; $sql .= ")";
@ -333,9 +360,10 @@ class BookKeeping extends CommonObject
* *
* @param User $user User that creates * @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @param string $mode Mode
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function createStd(User $user, $notrigger = false) { public function createStd(User $user, $notrigger = false, $mode='') {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -354,8 +382,14 @@ class BookKeeping extends CommonObject
if (isset($this->fk_docdet)) { if (isset($this->fk_docdet)) {
$this->fk_docdet = trim($this->fk_docdet); $this->fk_docdet = trim($this->fk_docdet);
} }
if (isset($this->code_tiers)) { if (isset($this->thirdparty_code)) {
$this->code_tiers = trim($this->code_tiers); $this->thirdparty_code = trim($this->thirdparty_code);
}
if (isset($this->subledger_account)) {
$this->subledger_account = trim($this->subledger_account);
}
if (isset($this->subledger_label)) {
$this->subledger_label = trim($this->subledger_label);
} }
if (isset($this->numero_compte)) { if (isset($this->numero_compte)) {
$this->numero_compte = trim($this->numero_compte); $this->numero_compte = trim($this->numero_compte);
@ -363,6 +397,9 @@ class BookKeeping extends CommonObject
if (isset($this->label_compte)) { if (isset($this->label_compte)) {
$this->label_compte = trim($this->label_compte); $this->label_compte = trim($this->label_compte);
} }
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) { if (isset($this->debit)) {
$this->debit = trim($this->debit); $this->debit = trim($this->debit);
} }
@ -384,32 +421,47 @@ class BookKeeping extends CommonObject
if (isset($this->code_journal)) { if (isset($this->code_journal)) {
$this->code_journal = trim($this->code_journal); $this->code_journal = trim($this->code_journal);
} }
if (isset($this->journal_label)) {
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
if (empty($this->debit)) $this->debit = 0; if (empty($this->debit)) $this->debit = 0;
if (empty($this->credit)) $this->credit = 0; if (empty($this->credit)) $this->credit = 0;
$this->debit = price2num($this->debit, 'MT');
$this->credit = price2num($this->credit, 'MT');
$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
// Insert request // Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.'(';
$sql .= 'doc_date,'; $sql .= 'doc_date,';
$sql .= 'doc_type,'; $sql .= 'doc_type,';
$sql .= 'doc_ref,'; $sql .= 'doc_ref,';
$sql .= 'fk_doc,'; $sql .= 'fk_doc,';
$sql .= 'fk_docdet,'; $sql .= 'fk_docdet,';
$sql .= 'code_tiers,'; $sql .= 'thirdparty_code,';
$sql .= 'subledger_account,';
$sql .= 'subledger_label,';
$sql .= 'numero_compte,'; $sql .= 'numero_compte,';
$sql .= 'label_compte,'; $sql .= 'label_compte,';
$sql .= 'label_operation,';
$sql .= 'debit,'; $sql .= 'debit,';
$sql .= 'credit,'; $sql .= 'credit,';
$sql .= 'montant,'; $sql .= 'montant,';
$sql .= 'sens,'; $sql .= 'sens,';
$sql .= 'fk_user_author,'; $sql .= 'fk_user_author,';
$sql .= 'import_key,'; $sql .= 'date_creation,';
$sql .= 'code_journal,'; $sql .= 'code_journal,';
$sql .= 'journal_label,';
$sql .= 'piece_num,'; $sql .= 'piece_num,';
$sql .= 'entity'; $sql .= 'entity';
$sql .= ') VALUES ('; $sql .= ') VALUES (';
@ -418,17 +470,21 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ',';
$sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ',';
$sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ',';
$sql .= ' ' . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ','; $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ',';
$sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ',';
$sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ',';
$sql .= ' ' . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ',';
$sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ',';
$sql .= ' ' . (! isset($this->label_operation) ? 'NULL' : "'" . $this->db->escape($this->label_operation) . "'") . ',';
$sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ',';
$sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ',';
$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 .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . "'" . $this->db->idate($this->date_create) . "',";
$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->piece_num) ? 'NULL' : $this->piece_num).','; $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 .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity);
$sql .= ')'; $sql .= ')';
@ -472,10 +528,11 @@ class BookKeeping extends CommonObject
* *
* @param int $id Id object * @param int $id Id object
* @param string $ref Ref * @param string $ref Ref
* @param string $mode Mode
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = null) { public function fetch($id, $ref = null, $mode='') {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -487,9 +544,12 @@ class BookKeeping extends CommonObject
$sql .= " t.doc_ref,"; $sql .= " t.doc_ref,";
$sql .= " t.fk_doc,"; $sql .= " t.fk_doc,";
$sql .= " t.fk_docdet,"; $sql .= " t.fk_docdet,";
$sql .= " t.code_tiers,"; $sql .= " t.thirdparty_code,";
$sql .= " t.subledger_account,";
$sql .= " t.subledger_label,";
$sql .= " t.numero_compte,"; $sql .= " t.numero_compte,";
$sql .= " t.label_compte,"; $sql .= " t.label_compte,";
$sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.montant,"; $sql .= " t.montant,";
@ -497,10 +557,11 @@ class BookKeeping extends CommonObject
$sql .= " t.fk_user_author,"; $sql .= " t.fk_user_author,";
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.code_journal,"; $sql .= " t.code_journal,";
$sql .= " t.journal_label,";
$sql .= " t.piece_num"; $sql .= " t.piece_num";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode. ' as t';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (null !== $ref) { if (null !== $ref) {
$sql .= ' AND t.ref = ' . '\'' . $ref . '\''; $sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
} else { } else {
@ -520,9 +581,12 @@ class BookKeeping extends CommonObject
$this->doc_ref = $obj->doc_ref; $this->doc_ref = $obj->doc_ref;
$this->fk_doc = $obj->fk_doc; $this->fk_doc = $obj->fk_doc;
$this->fk_docdet = $obj->fk_docdet; $this->fk_docdet = $obj->fk_docdet;
$this->code_tiers = $obj->code_tiers; $this->thirdparty_code = $obj->thirdparty_code;
$this->subledger_account = $obj->subledger_account;
$this->subledger_label = $obj->subledger_label;
$this->numero_compte = $obj->numero_compte; $this->numero_compte = $obj->numero_compte;
$this->label_compte = $obj->label_compte; $this->label_compte = $obj->label_compte;
$this->label_operation = $obj->label_operation;
$this->debit = $obj->debit; $this->debit = $obj->debit;
$this->credit = $obj->credit; $this->credit = $obj->credit;
$this->montant = $obj->montant; $this->montant = $obj->montant;
@ -530,6 +594,7 @@ class BookKeeping extends CommonObject
$this->fk_user_author = $obj->fk_user_author; $this->fk_user_author = $obj->fk_user_author;
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;
$this->code_journal = $obj->code_journal; $this->code_journal = $obj->code_journal;
$this->journal_label = $obj->journal_label;
$this->piece_num = $obj->piece_num; $this->piece_num = $obj->piece_num;
} }
$this->db->free($resql); $this->db->free($resql);
@ -547,6 +612,7 @@ class BookKeeping extends CommonObject
} }
} }
/** /**
* Load object in memory from the database * Load object in memory from the database
* *
@ -571,9 +637,12 @@ class BookKeeping extends CommonObject
$sql .= " t.doc_ref,"; $sql .= " t.doc_ref,";
$sql .= " t.fk_doc,"; $sql .= " t.fk_doc,";
$sql .= " t.fk_docdet,"; $sql .= " t.fk_docdet,";
$sql .= " t.code_tiers,"; $sql .= " t.thirdparty_code,";
$sql .= " t.subledger_account,";
$sql .= " t.subledger_label,";
$sql .= " t.numero_compte,"; $sql .= " t.numero_compte,";
$sql .= " t.label_compte,"; $sql .= " t.label_compte,";
$sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.montant,"; $sql .= " t.montant,";
@ -581,6 +650,7 @@ class BookKeeping extends CommonObject
$sql .= " t.fk_user_author,"; $sql .= " t.fk_user_author,";
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.code_journal,"; $sql .= " t.code_journal,";
$sql .= " t.journal_label,";
$sql .= " t.piece_num"; $sql .= " t.piece_num";
// Manage filter // Manage filter
$sqlwhere = array (); $sqlwhere = array ();
@ -590,13 +660,13 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value; $sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.code_tiers' || $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_compte') { } elseif ($key == 't.label_operation') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} else { } else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
@ -605,7 +675,7 @@ class BookKeeping extends CommonObject
} }
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
} }
@ -633,9 +703,12 @@ class BookKeeping extends CommonObject
$line->doc_ref = $obj->doc_ref; $line->doc_ref = $obj->doc_ref;
$line->fk_doc = $obj->fk_doc; $line->fk_doc = $obj->fk_doc;
$line->fk_docdet = $obj->fk_docdet; $line->fk_docdet = $obj->fk_docdet;
$line->code_tiers = $obj->code_tiers; $line->thirdparty_code = $obj->thirdparty_code;
$line->subledger_account = $obj->subledger_account;
$line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
@ -643,6 +716,7 @@ class BookKeeping extends CommonObject
$line->fk_user_author = $obj->fk_user_author; $line->fk_user_author = $obj->fk_user_author;
$line->import_key = $obj->import_key; $line->import_key = $obj->import_key;
$line->code_journal = $obj->code_journal; $line->code_journal = $obj->code_journal;
$line->journal_label = $obj->journal_label;
$line->piece_num = $obj->piece_num; $line->piece_num = $obj->piece_num;
$this->lines[] = $line; $this->lines[] = $line;
@ -658,7 +732,6 @@ class BookKeeping extends CommonObject
} }
} }
/** /**
* Load object in memory from the database * Load object in memory from the database
* *
@ -683,9 +756,12 @@ class BookKeeping extends CommonObject
$sql .= " t.doc_ref,"; $sql .= " t.doc_ref,";
$sql .= " t.fk_doc,"; $sql .= " t.fk_doc,";
$sql .= " t.fk_docdet,"; $sql .= " t.fk_docdet,";
$sql .= " t.code_tiers,"; $sql .= " t.thirdparty_code,";
$sql .= " t.subledger_account,";
$sql .= " t.subledger_label,";
$sql .= " t.numero_compte,"; $sql .= " t.numero_compte,";
$sql .= " t.label_compte,"; $sql .= " t.label_compte,";
$sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.montant,"; $sql .= " t.montant,";
@ -693,6 +769,7 @@ class BookKeeping extends CommonObject
$sql .= " t.fk_user_author,"; $sql .= " t.fk_user_author,";
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.code_journal,"; $sql .= " t.code_journal,";
$sql .= " t.journal_label,";
$sql .= " t.piece_num"; $sql .= " t.piece_num";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter // Manage filter
@ -703,11 +780,11 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value; $sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.code_tiers' || $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) . '%\'';
} else { } else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
@ -715,7 +792,7 @@ class BookKeeping extends CommonObject
} }
} }
$sql.= ' WHERE 1 = 1'; $sql.= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
} }
@ -742,9 +819,12 @@ class BookKeeping extends CommonObject
$line->doc_ref = $obj->doc_ref; $line->doc_ref = $obj->doc_ref;
$line->fk_doc = $obj->fk_doc; $line->fk_doc = $obj->fk_doc;
$line->fk_docdet = $obj->fk_docdet; $line->fk_docdet = $obj->fk_docdet;
$line->code_tiers = $obj->code_tiers; $line->thirdparty_code = $obj->thirdparty_code;
$line->subledger_account = $obj->subledger_account;
$line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
@ -752,6 +832,7 @@ class BookKeeping extends CommonObject
$line->fk_user_author = $obj->fk_user_author; $line->fk_user_author = $obj->fk_user_author;
$line->import_key = $obj->import_key; $line->import_key = $obj->import_key;
$line->code_journal = $obj->code_journal; $line->code_journal = $obj->code_journal;
$line->journal_label = $obj->journal_label;
$line->piece_num = $obj->piece_num; $line->piece_num = $obj->piece_num;
$this->lines[] = $line; $this->lines[] = $line;
@ -797,11 +878,13 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value; $sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} elseif ($key == 't.subledger_label') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} else { } else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
@ -809,7 +892,7 @@ class BookKeeping extends CommonObject
} }
} }
$sql.= ' WHERE 1 = 1'; $sql.= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
} }
@ -852,10 +935,10 @@ class BookKeeping extends CommonObject
* *
* @param User $user User that modifies * @param User $user User that modifies
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function update(User $user, $notrigger = false) { public function update(User $user, $notrigger = false, $mode='') {
$error = 0; $error = 0;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -873,8 +956,14 @@ class BookKeeping extends CommonObject
if (isset($this->fk_docdet)) { if (isset($this->fk_docdet)) {
$this->fk_docdet = trim($this->fk_docdet); $this->fk_docdet = trim($this->fk_docdet);
} }
if (isset($this->code_tiers)) { if (isset($this->thirdparty_code)) {
$this->code_tiers = trim($this->code_tiers); $this->thirdparty_code = trim($this->thirdparty_code);
}
if (isset($this->subledger_account)) {
$this->subledger_account = trim($this->subledger_account);
}
if (isset($this->subledger_label)) {
$this->subledger_label = trim($this->subledger_label);
} }
if (isset($this->numero_compte)) { if (isset($this->numero_compte)) {
$this->numero_compte = trim($this->numero_compte); $this->numero_compte = trim($this->numero_compte);
@ -882,6 +971,9 @@ class BookKeeping extends CommonObject
if (isset($this->label_compte)) { if (isset($this->label_compte)) {
$this->label_compte = trim($this->label_compte); $this->label_compte = trim($this->label_compte);
} }
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) { if (isset($this->debit)) {
$this->debit = trim($this->debit); $this->debit = trim($this->debit);
} }
@ -903,23 +995,32 @@ class BookKeeping extends CommonObject
if (isset($this->code_journal)) { if (isset($this->code_journal)) {
$this->code_journal = trim($this->code_journal); $this->code_journal = trim($this->code_journal);
} }
if (isset($this->journal_label)) {
$this->journal_label = trim($this->journal_label);
}
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
$this->debit = price2num($this->debit, 'MT');
$this->credit = price2num($this->credit, 'MT');
// Check parameters // Check parameters
// Put here code to add a control on parameters values // Put here code to add a control on parameters values
// Update request // Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . $mode.' SET';
$sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ','; $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ',';
$sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ','; $sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ',';
$sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ',';
$sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ','; $sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ',';
$sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ','; $sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ',';
$sql .= ' code_tiers = ' . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ','; $sql .= ' thirdparty_code = ' . (isset($this->thirdparty_code) ? "'" . $this->db->escape($this->thirdparty_code) . "'" : "null") . ',';
$sql .= ' subledger_account = ' . (isset($this->subledger_account) ? "'" . $this->db->escape($this->subledger_account) . "'" : "null") . ',';
$sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ',';
$sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ',';
$sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ',';
$sql .= ' label_operation = ' . (isset($this->label_operation) ? "'" . $this->db->escape($this->label_operation) . "'" : "null") . ',';
$sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ',';
$sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ','; $sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ',';
$sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ','; $sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ',';
@ -927,6 +1028,7 @@ class BookKeeping extends CommonObject
$sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ','; $sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ',';
$sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ','; $sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ',';
$sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ',';
$sql .= ' journal_label = ' . (isset($this->journal_label) ? "'" . $this->db->escape($this->journal_label) . "'" : "null") . ',';
$sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null");
$sql .= ' WHERE rowid=' . $this->id; $sql .= ' WHERE rowid=' . $this->id;
@ -961,15 +1063,47 @@ class BookKeeping extends CommonObject
} }
} }
/**
* Update movement
*
* @param string $piece_num Piece num
* @param string $field Field
* @param string $value Value
* @param string $mode Mode
* @return number <0 if KO, >0 if OK
*/
public function updateByMvt($piece_num='', $field='', $value='', $mode='') {
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab";
$sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'");
$sql .= ' WHERE ab.piece_num=' . $piece_num ;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/** /**
* Delete object in database * Delete object in database
* *
* @param User $user User that deletes * @param User $user User that deletes
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete(User $user, $notrigger = false) { public function delete(User $user, $notrigger = false, $mode='') {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -989,7 +1123,7 @@ class BookKeeping extends CommonObject
} }
if (! $error) { if (! $error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= ' WHERE rowid=' . $this->id; $sql .= ' WHERE rowid=' . $this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1044,9 +1178,10 @@ class BookKeeping extends CommonObject
* *
* @param string $delyear Year to delete * @param string $delyear Year to delete
* @param string $journal Journal to delete * @param string $journal Journal to delete
* @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function deleteByYearAndJournal($delyear='', $journal='') { function deleteByYearAndJournal($delyear='', $journal='', $mode='') {
global $conf; global $conf;
if (empty($delyear) && empty($journal)) if (empty($delyear) && empty($journal))
@ -1058,11 +1193,11 @@ 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.$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 = '".$journal."'";
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
@ -1083,18 +1218,19 @@ class BookKeeping extends CommonObject
* Delete bookkepping by piece number * Delete bookkepping by piece number
* *
* @param int $piecenum peicenum to delete * @param int $piecenum peicenum to delete
* @param string $mode Mode
* @return int Result * @return int Result
*/ */
function deleteMvtNum($piecenum) { function deleteMvtNum($piecenum, $mode) {
global $conf; global $conf;
$this->db->begin(); $this->db->begin();
// 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. $mode;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1175,16 +1311,20 @@ class BookKeeping extends CommonObject
$this->doc_ref = ''; $this->doc_ref = '';
$this->fk_doc = ''; $this->fk_doc = '';
$this->fk_docdet = ''; $this->fk_docdet = '';
$this->code_tiers = ''; $this->thirdparty_code = 'CU001';
$this->numero_compte = ''; $this->subledger_account = '41100001';
$this->label_compte = ''; $this->subledger_label = 'My customer company';
$this->numero_compte = '411';
$this->label_compte = 'Customer';
$this->label_operation = 'Sales of pea';
$this->debit = 99.9; $this->debit = 99.9;
$this->credit = ''; $this->credit = '';
$this->montant = ''; $this->montant = '';
$this->sens = ''; $this->sens = 'D';
$this->fk_user_author = $user->id; $this->fk_user_author = $user->id;
$this->import_key = ''; $this->import_key = '';
$this->code_journal = ''; $this->code_journal = 'VT';
$this->journal_label = 'Journal de vente';
$this->piece_num = ''; $this->piece_num = '';
} }
@ -1192,15 +1332,16 @@ class BookKeeping extends CommonObject
* Load an accounting document into memory from database * Load an accounting document into memory from database
* *
* @param int $piecenum Accounting document to get * @param int $piecenum Accounting document to get
* @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchPerMvt($piecenum) { public function fetchPerMvt($piecenum, $mode='') {
global $conf; global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1209,6 +1350,7 @@ class BookKeeping extends CommonObject
$this->piece_num = $obj->piece_num; $this->piece_num = $obj->piece_num;
$this->code_journal = $obj->code_journal; $this->code_journal = $obj->code_journal;
$this->journal_label = $obj->journal_label;
$this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_date = $this->db->jdate($obj->doc_date);
$this->doc_ref = $obj->doc_ref; $this->doc_ref = $obj->doc_ref;
$this->doc_type = $obj->doc_type; $this->doc_type = $obj->doc_type;
@ -1224,14 +1366,15 @@ class BookKeeping extends CommonObject
/** /**
* Return next number movement * Return next number movement
* *
* @param string $mode Mode
* @return string Next numero to use * @return string Next numero to use
*/ */
public function getNextNumMvt() public function getNextNumMvt($mode='')
{ {
global $conf; global $conf;
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1251,19 +1394,20 @@ class BookKeeping extends CommonObject
/** /**
* Load all informations of accountancy document * Load all informations of accountancy document
* *
* @param int $piecenum id of line to get * @param int $piecenum Id of line to get
* @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_all_per_mvt($piecenum) { function fetchAllPerMvt($piecenum, $mode='') {
global $conf; global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1280,14 +1424,18 @@ class BookKeeping extends CommonObject
$line->doc_ref = $obj->doc_ref; $line->doc_ref = $obj->doc_ref;
$line->fk_doc = $obj->fk_doc; $line->fk_doc = $obj->fk_doc;
$line->fk_docdet = $obj->fk_docdet; $line->fk_docdet = $obj->fk_docdet;
$line->code_tiers = $obj->code_tiers; $line->thirdparty_code = $obj->thirdparty_code;
$line->subledger_account = $obj->subledger_account;
$line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
$line->sens = $obj->sens; $line->sens = $obj->sens;
$line->code_journal = $obj->code_journal; $line->code_journal = $obj->code_journal;
$line->journal_label = $obj->journal_label;
$line->piece_num = $obj->piece_num; $line->piece_num = $obj->piece_num;
$this->linesmvt[] = $line; $this->linesmvt[] = $line;
@ -1311,11 +1459,11 @@ class BookKeeping extends CommonObject
global $conf; global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
@ -1335,9 +1483,12 @@ class BookKeeping extends CommonObject
$line->doc_ref = $obj->doc_ref; $line->doc_ref = $obj->doc_ref;
$line->fk_doc = $obj->fk_doc; $line->fk_doc = $obj->fk_doc;
$line->fk_docdet = $obj->fk_docdet; $line->fk_docdet = $obj->fk_docdet;
$line->code_tiers = $obj->code_tiers; $line->thirdparty_code = $obj->thirdparty_code;
$line->subledger_account = $obj->subledger_account;
$line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
@ -1357,7 +1508,92 @@ class BookKeeping extends CommonObject
} }
} }
/**
* Transform transaction
*
* @param number $direction If 0 tmp => real, if 1 real => tmp
* @param string $piece_num Piece num
* @return void
*/
public function transformTransaction($direction=0,$piece_num='') {
$this->db->begin();
if ($direction==0) {
$next_piecenum=$this->getNextNumMvt();
if ($result < 0) {
$error++;
}
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
$sql .= 'SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.'';
$sql .= ' FROM '.MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
$sql = 'DELETE FROM '.MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
}
if ($direction==1) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'_tmp(doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
$sql .= 'SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
$sql .= ' FROM '.MAIN_DB_PREFIX . $this->table_element.' WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
$sql = 'DELETE FROM '.MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
}
if (! $error) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return - 1;
}
/*
$sql = "DELETE FROM ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte";
$sql .= " AND aa.active = 1";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $pcgver;
$sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")";
$sql .= " ORDER BY account_number ASC";
*/
}
/** /**
* Return list of accounts with label by chart of accounts * Return list of accounts with label by chart of accounts
@ -1384,7 +1620,7 @@ class BookKeeping extends CommonObject
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$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 = " . $pcgver; $sql .= " AND asy.rowid = " . $pcgver;
$sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")";
$sql .= " ORDER BY account_number ASC"; $sql .= " ORDER BY account_number ASC";
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
@ -1428,7 +1664,6 @@ class BookKeeping extends CommonObject
return $out; return $out;
} }
/** /**
* Description of a root accounting account * Description of a root accounting account
* *
@ -1449,7 +1684,7 @@ class BookKeeping extends CommonObject
$sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " WHERE aa.account_number = '" . $account . "'";
$sql .= " AND parent.active = 1"; $sql .= " AND parent.active = 1";
$sql .= " AND root.active = 1"; $sql .= " AND root.active = 1";
$sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1469,7 +1704,6 @@ class BookKeeping extends CommonObject
} }
} }
/** /**
* Description of accounting account * Description of accounting account
* *
@ -1488,7 +1722,7 @@ class BookKeeping extends CommonObject
$sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND asy.rowid = " . $pcgver;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
$sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " WHERE aa.entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1508,10 +1742,8 @@ class BookKeeping extends CommonObject
return -1; return -1;
} }
} }
} }
/** /**
* Class BookKeepingLine * Class BookKeepingLine
*/ */
@ -1523,9 +1755,12 @@ class BookKeepingLine
public $doc_ref; public $doc_ref;
public $fk_doc; public $fk_doc;
public $fk_docdet; public $fk_docdet;
public $code_tiers; public $thirdparty_code;
public $subledger_account;
public $subledger_label;
public $numero_compte; public $numero_compte;
public $label_compte; public $label_compte;
public $label_operation;
public $debit; public $debit;
public $credit; public $credit;
public $montant; public $montant;
@ -1533,5 +1768,6 @@ class BookKeepingLine
public $fk_user_author; public $fk_user_author;
public $import_key; public $import_key;
public $code_journal; public $code_journal;
public $journal_label;
public $piece_num; public $piece_num;
} }

View File

@ -0,0 +1,330 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.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 2 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 accountancy/class/bookkeeping.class.php
* \ingroup Accounting Expert
* \brief Fichier de la classe des comptes comptable
*/
include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php";
include_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
/**
* Class lettering
*/
class lettering extends BookKeeping
{
/**
* lettrageTiers
*
* @param int $socid Thirdparty id
* @return void
*/
public function lettrageTiers($socid) {
$db = $this->db;
$object = new Societe($this->db);
$object->id = $socid;
$object->fetch($socid);
if( $object->code_compta == '411CUSTCODE')
$object->code_compta = '';
if( $object->code_compta_fournisseur == '401SUPPCODE')
$object->code_compta_fournisseur = '';
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.lettering_code, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE code_journal = 'BQ' AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) AND ( bk.date_lettering ='' OR bk.date_lettering IS NULL ) AND bk.lettering_code !='' ";
$sql .= " GROUP BY bk.lettering_code ";
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
$i++;
$sql = "SELECT bk.rowid ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE bk.lettering_code = '".$obj->lettering_code."' ";
$sql .= " AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) ";
// echo $sql;
$resql2 = $db->query ( $sql );
if ($resql2) {
$num2 = $db->num_rows ( $resql2 );
$i2 = 0;
$ids = array();
while ( $i2 < $num2 ) {
$obj2 = $db->fetch_object ( $resql2 );
$i2++;
$ids[] = $obj2->rowid;
}
if(count($ids) > 1 ){
$result = $this->updatelettrage($ids);
// var_dump($result);
// if( $result < 0 ){
// setEventMessages('', $BookKeeping->errors, 'errors' );
// $error++;
//
// }
}
}
}
}
/**
Prise en charge des lettering complexe avec prelevment , virement
*/
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
$sql .= " WHERE code_journal = 'BQ' AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) AND date_lettering ='' ";
$sql .= " GROUP BY bk.lettering_code ";
// echo $sql;
//
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
$ids = array();
$i++;
// print_r($obj);
if($obj->type =='payment_supplier' ) {
$ids[] = $obj->rowid;
$sql= 'SELECT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank ';
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sql.= " INNER JOIN " .MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = facf.ref) ";
// $sqlmid.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid=facf.fk_soc";
// $sqlmid.= " INNER JOIN " . MAIN_DB_PREFIX . "c_paiement as payc ON payc.id=payf.fk_paiement";
$sql .= " WHERE 1 ";
$sql .= " AND fk_paiementfourn = '".$obj->url_id."' ";
// $sql .= " AND (bk.numero_compte = '" . $object->code_compta . "' OR bk.numero_compte = '" . $object->code_compta_fournisseur . "') ";
$sql .= " AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) ";
// echo $sql;
// exit;
}
elseif($obj->type =='payment' ){
$ids[] = $obj->rowid;
$sql= 'SELECT bk.rowid,fac.facnumber , pay.fk_bank ';
$sql.= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sql.= " INNER JOIN " .MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid) ";
$sql .= " WHERE 1 ";
$sql .= " AND payfac.fk_paiement = '".$obj->url_id."' ";
$sql .= " AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) ";
// echo $sql;
}
$resql2 = $db->query ( $sql );
if ($resql2) {
$num2 = $db->num_rows ( $resql2 );
$i2 = 0;
while ( $i2 < $num2 ) {
$obj2 = $db->fetch_object ( $resql2 );
$i2++;
$ids[] = $obj2->rowid;
}
// print_r($ids);
// exit;
if(count($ids) > 1 ){
$result = $this->updatelettrage($ids);
// var_dump($result);
// if( $result < 0 ){
// setEventMessages('', $BookKeeping->errors, 'errors' );
// $error++;
//
// }
}
// exit;
}
}
}
}
public function updatelettrage($ids, $notrigger=false){
$error = 0;
$sql = "SELECT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " lettering_code != '' GROUP BY lettering_code ORDER BY lettering_code DESC limit 1; ";
// echo $sql;
$result = $this->db->query ( $sql );
if ($result) {
$obj = $this->db->fetch_object ( $result );
$lettre = (empty($obj->lettering_code)? 'AAA' : $obj->lettering_code );
if(!empty($obj->lettering_code))
$lettre++;
}
else{
$this->errors[] = 'Error'.$this->db->lasterror();;
$error++;
}
// var_dump(__line__, $error);
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " rowid IN (".implode(',', $ids).") ";
$result = $this->db->query ( $sql );
if ($result) {
$obj = $this->db->fetch_object ( $result );
// print_r($obj);
if( !(round(abs($obj->deb),2) === round(abs($obj->cred),2)) ){
// echo $sql;
// print_r($obj);
$this->errors[] = 'Total not exacts '.round(abs($obj->deb),2).' vs '. round(abs($obj->cred),2);
$error++;
}
}
else{
$this->errors[] = 'Erreur sql'.$this->db->lasterror();;
$error++;
}
// Update request
$now = dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql.= " lettering_code='".$lettre."'";
$sql.= " , date_lettering = " .$now ; // todo correct date it's false
$sql.= " WHERE rowid IN (".implode(',', $ids).") ";
// echo $sql ;
//
// var_dump(__line__, $error);
// print_r($this->errors);
// exit;
$this->db->begin();
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// var_dump(__line__, $error);
// Commit or rollback
if ($error)
{
// foreach($this->errors as $errmsg)
// {
// dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
// $this->error.=($this->error?', '.$errmsg:$errmsg);
// }
$this->db->rollback();
// echo $this->error;
// var_dump(__line__, $error);
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 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
@ -93,7 +93,7 @@ if (! empty($id)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
$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
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* *
@ -23,7 +23,7 @@
/** /**
* \file htdocs/accountancy/customer/index.php * \file htdocs/accountancy/customer/index.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Home customer ventilation * \brief Home customer journalization page
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
@ -58,7 +58,7 @@ if ($year == 0) {
} }
// Validate History // Validate History
$action = GETPOST('action','alpha'); $action = GETPOST('action','aZ09');
@ -73,7 +73,7 @@ if ($action == 'validatehistory') {
// First clean corrupted data // First clean corrupted data
$sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sqlclean .= " SET fd.fk_code_ventilation = 0"; $sqlclean .= " SET fk_code_ventilation = 0";
$sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN '; $sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sqlclean .= ' (SELECT accnt.rowid '; $sqlclean .= ' (SELECT accnt.rowid ';
$sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
@ -91,13 +91,13 @@ if ($action == 'validatehistory') {
$sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0";
} else { } else {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; $sql1 .= " SET fk_code_ventilation = accnt.rowid";
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number";
$sql1 .= " AND fd.fk_code_ventilation = 0"; $sql1 .= " AND fd.fk_code_ventilation = 0";
} }
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); dol_syslog('htdocs/accountancy/customer/index.php');
$resql1 = $db->query($sql1); $resql1 = $db->query($sql1);
if (! $resql1) { if (! $resql1) {
@ -113,7 +113,7 @@ if ($action == 'validatehistory') {
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sql1 .= " SET fd.fk_code_ventilation = 0"; $sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sql1 .= ' (SELECT accnt.rowid '; $sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
@ -137,11 +137,11 @@ if ($action == 'validatehistory') {
// Now clean // Now clean
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sql1.= " SET fd.fk_code_ventilation = 0"; $sql1.= " SET fk_code_ventilation = 0";
$sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; $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.= " 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.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
$sql1.= " AND f.entity IN (" . getEntity("accountancy", 1) . ")"; $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")";
$sql1.=")"; $sql1.=")";
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
@ -173,7 +173,7 @@ 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>';
//print '<div class="inline-block divButAction">'; //print '<div class="inline-block divButAction">';
// TODO Remove this. Should be done into the repair.php script // TODO Remove this. Should be done always or into the repair.php script.
if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>'; if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
//print '</div>'; //print '</div>';
@ -187,9 +187,9 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} else { } 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.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 $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); dol_syslog('htdocs/accountancy/customer/index.php');
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$row = $db->fetch_row($result); $row = $db->fetch_row($result);
@ -203,10 +203,6 @@ $buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' .
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>'; $buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
$var = true;
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -228,7 +224,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
$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(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$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)) {
$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 . ")";
@ -237,7 +233,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} }
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -284,7 +280,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
$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(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$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
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 {
@ -293,7 +289,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -341,7 +337,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$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
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 {
@ -351,7 +347,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
dol_syslog('htdocs/accountancy/customer/index.php'); dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
@ -361,7 +356,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>';
$i ++;
} }
$db->free($resql); $db->free($resql);
} else { } else {
@ -369,6 +363,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
} }
print "</table>\n"; print "</table>\n";
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled)) {
print "<br>\n"; print "<br>\n";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -387,14 +382,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$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
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 {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
} }
dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -55,7 +55,7 @@ $search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int'); $page = GETPOST('page', 'int');
@ -164,7 +164,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql .= " WHERE fd.fk_code_ventilation > 0 "; $sql .= " WHERE fd.fk_code_ventilation > 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 f.fk_statut > 0"; $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 . ")";
@ -201,7 +201,7 @@ if (strlen(trim($search_country))) {
if (strlen(trim($search_tvaintra))) { if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tva_intra); $sql .= natural_search("s.tva_intra", $search_tva_intra);
} }
$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 .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
@ -327,7 +327,7 @@ if ($result) {
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $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);
print '</td>'; print '</td>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -63,7 +63,7 @@ $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int'); $page = GETPOST('page','int');
@ -189,7 +189,8 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accounta
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND product_type <= 2"; $sql .= " AND product_type <= 2";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')"; $sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='' OR p.accountancy_code_sell NOT IN
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid ='" . $conf->global->CHARTOFACCOUNTS . "'))";
// Add search filter like // Add search filter like
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
@ -220,7 +221,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} else { } else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . 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 $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -375,7 +376,7 @@ if ($result) {
print '<td class="tdoverflowonsmartphone">'; print '<td class="tdoverflowonsmartphone">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $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);
print '</td>'; print '</td>';

View File

@ -96,7 +96,7 @@ if (! empty($id)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id; $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id;
$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("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);

View File

@ -69,7 +69,7 @@ if ($action == 'validatehistory') {
// First clean corrupted data // First clean corrupted data
$sqlclean = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sqlclean = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sqlclean .= " SET erd.fk_code_ventilation = 0"; $sqlclean .= " SET fk_code_ventilation = 0";
$sqlclean .= ' WHERE erd.fk_code_ventilation NOT IN '; $sqlclean .= ' WHERE erd.fk_code_ventilation NOT IN ';
$sqlclean .= ' (SELECT accnt.rowid '; $sqlclean .= ' (SELECT accnt.rowid ';
$sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
@ -93,6 +93,8 @@ if ($action == 'validatehistory') {
$sql1 .= " AND erd.fk_code_ventilation = 0"; $sql1 .= " AND erd.fk_code_ventilation = 0";
} }
dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql1 = $db->query($sql1); $resql1 = $db->query($sql1);
if (! $resql1) { if (! $resql1) {
$error ++; $error ++;
@ -107,7 +109,7 @@ if ($action == 'validatehistory') {
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 .= " SET erd.fk_code_ventilation = 0"; $sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE erd.fk_code_ventilation NOT IN '; $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN ';
$sql1 .= ' (SELECT accnt.rowid '; $sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
@ -129,12 +131,13 @@ if ($action == 'validatehistory') {
$error = 0; $error = 0;
$db->begin(); $db->begin();
// Now clean
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1.= " SET erd.fk_code_ventilation = 0"; $sql1.= " SET fk_code_ventilation = 0";
$sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er"; $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.= " 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.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
$sql1.= " AND er.entity IN (" . getEntity("accountancy", 1) . ")"; $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")";
$sql1.=")"; $sql1.=")";
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
@ -166,28 +169,25 @@ print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv
print '<br>'; print '<br>';
//print '<div class="inline-block divButAction">'; //print '<div class="inline-block divButAction">';
// TODO Remove this. Should be done always. // TODO Remove this. Should be done always or into the repair.php script.
if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>'; if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
//print '</div>'; //print '</div>';
$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>';
$y = $year_current; $y = $year_current;
$var = true; $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 '<br>';
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200" align="left">' . $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>'; print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
@ -199,14 +199,14 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
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) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(erd.total_ht),2) 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(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.fk_statut > 0 ";
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$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";
@ -240,7 +240,7 @@ print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, '
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200" align="left">' . $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>'; print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
@ -259,11 +259,11 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid =
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.fk_statut > 0 ";
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$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";
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -307,22 +307,20 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
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) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(erd.total_ht),2) 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(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.fk_statut > 0 ";
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) { while ( $row = $db->fetch_row($resql)) {
print '<tr><td>' . $row[0] . '</td>'; print '<tr><td>' . $row[0] . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td align="right">' . price($row[$i]) . '</td>'; print '<td align="right">' . price($row[$i]) . '</td>';

View File

@ -52,7 +52,7 @@ $search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int'); $page = GETPOST('page', 'int');
@ -173,7 +173,7 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')";
} }
$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 .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -287,7 +287,7 @@ if ($result) {
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->comments); print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->comments);
print '</td>'; print '</td>';

View File

@ -61,7 +61,7 @@ $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int'); $page = GETPOST('page','int');
@ -203,7 +203,7 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("erd.tva_tx",$search_vat,1); $sql .= natural_search("erd.tva_tx",$search_vat,1);
} }
$sql .= " 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 .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -323,7 +323,7 @@ if ($result) {
// Fees description -- Can be null // Fees description -- Can be null
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->comments); print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->comments);
print '</td>'; print '</td>';

View File

@ -45,10 +45,13 @@ $langs->load("compta");
$langs->load("banks"); $langs->load("banks");
$langs->load("loans"); $langs->load("loans");
/* /*
* Actions * Actions
*/ */
// None
/* /*
* View * View
@ -60,8 +63,6 @@ print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy'
$step = 0; $step = 0;
print "<br>\n";
print $langs->trans("AccountancyAreaDescIntro")."<br>\n"; print $langs->trans("AccountancyAreaDescIntro")."<br>\n";
print "<br>\n";print "<br>\n"; print "<br>\n";print "<br>\n";
@ -73,35 +74,31 @@ print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("AccountingJournals").'</strong>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("AccountingJournals").'</strong>');
print "<br>\n"; print "<br>\n";
print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").'</strong>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").'</strong>');
print "<br>\n"; print "<br>\n";
print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").'</strong>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").'</strong>');
print "<br>\n"; print "<br>\n";
print "<br>\n";
print "<br>\n";
print $langs->trans("AccountancyAreaDescActionOnceBis"); print $langs->trans("AccountancyAreaDescActionOnceBis");
print "<br>\n"; print "<br>\n";
print "<br>\n"; print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>')."<br>\n"; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>')."\n";
print "<br>\n"; print "<br>\n";
$step++; $step++;
$textlink = '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong>'; $textlink = '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink);
print "<br>\n"; print "<br>\n";
print "<br>\n";
if (! empty($conf->tax->enabled)) if (! empty($conf->tax->enabled))
{ {
$textlink = '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong>'; $textlink = '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong>';
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink);
print "<br>\n"; print "<br>\n";
print "<br>\n";
} }
/*if (! empty($conf->salaries->enabled)) /*if (! empty($conf->salaries->enabled))
{ {
@ -116,7 +113,6 @@ if (! empty($conf->expensereport->enabled)) // TODO Move this in the default ac
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong>');
print "<br>\n"; print "<br>\n";
print "<br>\n";
} }
/* /*
if (! empty($conf->loan->enabled)) if (! empty($conf->loan->enabled))
@ -124,26 +120,22 @@ if (! empty($conf->loan->enabled))
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuSpecialExpenses").'-'.$langs->transnoentitiesnoconv("Loans").'</strong> '.$langs->transnoentitiesnoconv("or").' <strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuSpecialExpenses").'-'.$langs->transnoentitiesnoconv("Loans").'</strong> '.$langs->transnoentitiesnoconv("or").' <strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
print "<br>\n"; print "<br>\n";
print "<br>\n";
} }
if (! empty($conf->don->enabled)) if (! empty($conf->don->enabled))
{ {
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDonationAccounts").'</strong>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDonationAccounts").'</strong>');
print "<br>\n"; print "<br>\n";
print "<br>\n";
}*/ }*/
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'</strong>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'</strong>');
print "<br>\n"; print "<br>\n";
print "<br>\n";
$step++; $step++;
$textlink='<strong>'.$langs->transnoentitiesnoconv("MenuBankCash").'</strong>'; $textlink='<strong>'.$langs->transnoentitiesnoconv("MenuBankCash").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink);
print "<br>\n"; print "<br>\n";
print "<br>\n";
print "<br>\n"; print "<br>\n";
@ -155,19 +147,19 @@ $step = 0;
$langs->loadLangs(array('bills', 'trips')); $langs->loadLangs(array('bills', 'trips'));
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'</strong>')."<br>\n"; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'</strong>')."\n";
print "<br>\n"; print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>')."<br>\n"; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>')."\n";
print "<br>\n"; print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong>')."<br>\n"; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong>')."\n";
print "<br>\n"; print "<br>\n";
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."<br>\n"; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
print "<br>\n"; print "<br>\n";
$step++; $step++;

View File

@ -28,8 +28,6 @@
* \brief Page with bank journal * \brief Page with bank journal
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
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/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
@ -40,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php';
@ -51,9 +50,8 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/client.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 . '/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php';
// Langs
$langs->load("companies"); $langs->load("companies");
$langs->load("other"); $langs->load("other");
$langs->load("compta"); $langs->load("compta");
@ -62,12 +60,11 @@ $langs->load('bills');
$langs->load('donations'); $langs->load('donations');
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("trips"); $langs->load("trips");
$langs->load("salaries");
$langs->load("hrm"); $langs->load("hrm");
// Old system menu
$id_bank_account = GETPOST('id_account', 'int');
// Multi journal // Multi journal
$code_journal = GETPOST('code_journal', 'alpha'); $id_journal = GETPOST('id_journal', 'int');
$date_startmonth = GETPOST('date_startmonth'); $date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday'); $date_startday = GETPOST('date_startday');
@ -75,12 +72,13 @@ $date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth'); $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$action = GETPOST('action','aZ09'); $in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now(); $now = dol_now();
$action = GETPOST('action','aZ09');
// Security check // Security check
if ($user->societe_id > 0 && empty($id_bank_account)) if ($user->societe_id > 0 && empty($id_journal))
accessforbidden(); accessforbidden();
@ -107,23 +105,24 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $mysoc->country_id;
$idpays = $p[0];
$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,"; $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,";
$sql .= " ba.courant, ba.ref as baref, ba.account_number,"; $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,"; $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,";
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as name, u.firstname as firstname, bu2.type as typeop"; $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop";
$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";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid";
$sql .= " WHERE ba.rowid=" . $id_bank_account; $sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal;
$sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy $sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
if ($in_bookkeeping == 'yes')
$sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
$sql .= " ORDER BY b.datev"; $sql .= " ORDER BY b.datev";
$object = new Account($db); $object = new Account($db);
@ -136,29 +135,20 @@ $paymentdonstatic = new PaymentDonation($db);
$paymentvatstatic = new TVA($db); $paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db); $paymentsalstatic = new PaymentSalary($db);
$paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentexpensereportstatic = new PaymentExpenseReport($db);
$paymentvariousstatic = new PaymentVarious($db);
// Get code of finance journal // Get code of finance journal
$journal = '';
$bankstatic = new Account($db);
$bankstatic->fetch($id_bank_account);
$bankstatic->rowid;
$bankstatic->number;
$bankstatic->label;
$bankstatic->fk_accountancy_journal;
$accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic = new AccountingJournal($db);
if(! empty($id_bank_account)) { $accountingjournalstatic->fetch($id_journal);
$accountingjournalstatic->fetch($bankstatic->fk_accountancy_journal);
} else {
$accountingjournalstatic->fetch('',$code_journal);
}
$journal = $accountingjournalstatic->code; $journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label;
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
// Variables // Variables
$account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
@ -200,6 +190,7 @@ if ($result) {
$tabuser[$obj->rowid] = array ( $tabuser[$obj->rowid] = array (
'id' => $obj->userid, 'id' => $obj->userid,
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
'lastname' => $obj->lastname, 'lastname' => $obj->lastname,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'accountancy_code' => $compta_user, 'accountancy_code' => $compta_user,
@ -222,7 +213,7 @@ if ($result) {
// Now loop on each link of record in bank. // Now loop on each link of record in bank.
foreach ( $links as $key => $val ) { foreach ( $links as $key => $val ) {
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert'))) // So we excluded 'company' here if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary', 'payment_various'))) // So we excluded 'company' here
{ {
// We save tabtype for a future use, to remember what kind of payment it is // We save tabtype for a future use, to remember what kind of payment it is
$tabtype[$obj->rowid] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type'];
@ -278,25 +269,36 @@ if ($result) {
} else if ($links[$key]['type'] == 'payment_donation') { } else if ($links[$key]['type'] == 'payment_donation') {
$paymentdonstatic->id = $links[$key]['url_id']; $paymentdonstatic->id = $links[$key]['url_id'];
$paymentdonstatic->fk_donation = $links[$key]['url_id']; $paymentdonstatic->fk_donation = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentDonation"); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id;
$tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount;
} else if ($links[$key]['type'] == 'payment_vat') { } else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id'];
$paymentvatstatic->label = $links[$key]['label']; $paymentvatstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentVat"); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id;
$tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount;
} else if ($links[$key]['type'] == 'payment_salary') { } else if ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label']; $paymentsalstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
// $tabtp[$obj->rowid][$account_employee] += $obj->amount; $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'];
$paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id']; $paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2);
$tabpay[$obj->rowid]["fk_expensereport"] = $paymentexpensereportstatic->id; $tabpay[$obj->rowid]["fk_expensereport"] = $paymentexpensereportstatic->id;
} else if ($links[$key]['type'] == 'payment_various') {
$paymentvariousstatic->id = $links[$key]['url_id'];
$paymentvariousstatic->ref = $links[$key]['url_id'];
$paymentvariousstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
$paymentvariousstatic->fetch($paymentvariousstatic->id);
$account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : $langs->trans("CodeNotDef"));
$tabtp[$obj->rowid][$account_various] += $obj->amount;
} else if ($links[$key]['type'] == 'banktransfert') { } else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer");
$tabtp[$obj->rowid][$account_transfer] += $obj->amount; $tabtp[$obj->rowid][$account_transfer] += $obj->amount;
@ -365,17 +367,19 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $compte->label; $bookkeeping->label_operation = $val["label"];
$bookkeeping->label_compte = $langs->trans("Bank");
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0 ? $mt : 0); $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
$bookkeeping->credit = ($mt < 0 ? - $mt : 0); $bookkeeping->credit = ($mt < 0 ? - $mt : 0);
$bookkeeping->code_journal = $journal; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_create = $now; $bookkeeping->date_create = $now;
if ($tabtype[$key] == 'payment') { if ($tabtype[$key] == 'payment') {
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac";
@ -389,7 +393,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice $bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice
} }
} else if ($tabtype[$key] == 'payment_supplier') { } else if ($tabtype[$key] == 'payment_supplier') {
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$sqlmid = 'SELECT facf.ref_supplier, facf.ref'; $sqlmid = 'SELECT facf.ref_supplier, facf.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf";
@ -403,7 +407,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice
} }
} else if ($tabtype[$key] == 'payment_expensereport') { } else if ($tabtype[$key] == 'payment_expensereport') {
$bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$sqlmid = 'SELECT e.ref'; $sqlmid = 'SELECT e.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e";
@ -415,6 +419,19 @@ if (! $error && $action == 'writebookkeeping') {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport
} }
} else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->subledger_account = '';
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment
} else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->subledger_account = '';
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
} else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment
} else if ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = '';
$bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Ref of various payment
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -448,17 +465,30 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_type = 'bank'; $bookkeeping->doc_type = 'bank';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->label_compte = $tabcompany[$key]['name']; $bookkeeping->label_operation = $tabcompany[$key]['name'];
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? - $mt : 0); $bookkeeping->debit = ($mt < 0 ? - $mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_create = $now; $bookkeeping->date_create = $now;
if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
$bookkeeping->code_tiers = ''; $sqlmid = 'SELECT ch.libelle, t.libelle as labelc';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "chargesociales ch ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paych ON paych.fk_charge=ch.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "c_chargesociales as t ON ch.fk_type=t.id";
$sqlmid .= " WHERE paych.fk_bank=" . $key;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->label_compte = $objmid->labelc;
$bookkeeping->doc_ref = $objmid->libelle ;
}
$bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice } else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
@ -472,10 +502,10 @@ if (! $error && $action == 'writebookkeeping') {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber; $bookkeeping->doc_ref = $objmid->facnumber;
} }
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->numero_compte = $k; $bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
$sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid = 'SELECT facf.ref_supplier,facf.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
@ -487,16 +517,48 @@ if (! $error && $action == 'writebookkeeping') {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
} }
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
} else if ($tabtype[$key] == 'payment_expensereport') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->label_operation = $tabuser[$key]['name'];
$sqlmid = 'SELECT e.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid";
$sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"];
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport
}
} else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat
} else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
} else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment
} else if ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Rowid of various payment
} else if ($tabtype[$key] == 'banktransfert') { } else if ($tabtype[$key] == 'banktransfert') {
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else { } else {
// FIXME Should be a temporary account ??? // Temporary account
$bookkeeping->doc_ref = $k; $bookkeeping->doc_ref = $k;
//$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
$bookkeeping->numero_compte = 'CodeNotDef';
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -525,6 +587,12 @@ if (! $error && $action == 'writebookkeeping') {
else else
{ {
$db->rollback(); $db->rollback();
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
}
} }
} }
@ -544,8 +612,7 @@ if (! $error && $action == 'writebookkeeping') {
} }
// Export // Export
/* if ($action == 'exportcsv') {
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -553,13 +620,9 @@ if ($action == 'export_csv') {
$companystatic = new Client($db); $companystatic = new Client($db);
$userstatic = new User($db); $userstatic = new User($db);
// Model Cegid Expert Export // Bank
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
{
$sep = ";";
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); $date = dol_print_date($db->jdate($val["date"]), 'day');
$reflabel = $val["ref"]; $reflabel = $val["ref"];
if ($reflabel == '(SupplierInvoicePayment)') { if ($reflabel == '(SupplierInvoicePayment)') {
@ -584,88 +647,16 @@ if ($action == 'export_csv') {
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$userstatic->id = $tabuser[$key]['id'];
$userstatic->lastname = $tabuser[$key]['lastname'];
$userstatic->firstname = $tabuser[$key]['firstname'];
// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
print $date . $sep;
print $journal . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
if ($companystatic->name == '') {
print $langs->trans('Bank')." - ". utf8_decode($val["ref"]) . $sep;
} else {
print $langs->trans("Bank") .' - '.utf8_decode($companystatic->name) . $sep;
}
print utf8_decode($reflabel) . $sep;
print "\n";
}
// Third party
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $journal . $sep;
if ($tabtype[$key] == 'payment') {
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
print length_accounta(html_entity_decode($k)) . $sep;
} else if ($tabtype[$key] == 'payment_supplier') {
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
print length_accounta(html_entity_decode($k)) . $sep;
} else {
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
}
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
if ($companystatic->name == '') {
print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep;
} else {
print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep;
}
print utf8_decode($reflabel) . $sep;
print "\n";
}
}
} else {
foreach ( $tabbq[$key] as $k => $mt ) {
print $date . $sep;
print $journal . $sep;
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . $sep;
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
if ($companystatic->name == '') {
print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep;
} else {
print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep;
}
print utf8_decode($reflabel) . $sep;
print "\n";
}
}
}
} else {
// Model Classic Export
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
// Bank // Bank
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . $journal . '"' . $sep; print '"' . $journal . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print " " . $sep;
if ($companystatic->name == '') { if ($companystatic->name == '') {
print '"' . $langs->trans('Bank') . " - " . utf8_decode($val["ref"]) . '"' . $sep; print '"' . $langs->trans('Bank') . " - " . utf8_decode($reflabel) . '"' . $sep;
} else { } else {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
} }
@ -681,9 +672,21 @@ if ($action == 'export_csv') {
print '"' . $journal . '"' . $sep; print '"' . $journal . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
if ($tabtype[$key] == 'payment_supplier') {
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
} else if($tabtype[$key] == 'payment') {
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
} else {
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
}
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
if ($companystatic->name == '') { if ($companystatic->name == '') {
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($val["ref"]) . '"' . $sep; print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep;
} else { } else {
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep; print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
} }
@ -698,8 +701,10 @@ if ($action == 'export_csv') {
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
print " " . $sep;
if ($companystatic->name == '') { if ($companystatic->name == '') {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($val["ref"]) . '"' . $sep; print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($reflabel) . '"' . $sep;
} else { } else {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
} }
@ -710,8 +715,6 @@ if ($action == 'export_csv') {
} }
} }
} }
}
*/
/* /*
@ -724,16 +727,20 @@ if (empty($action) || $action == 'view') {
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
$invoicesupplierstatic = new FactureFournisseur($db); $invoicesupplierstatic = new FactureFournisseur($db);
$expensereportstatic = new ExpenseReport($db); $expensereportstatic = new ExpenseReport($db);
$vatstatic = new Tva($db);
$donationstatic = new Don($db);
$salarystatic = new PaymentSalary($db);
$variousstatic = new PaymentVarious($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
$nom = $langs->trans("FinanceJournal") . ' - ' . $bankstatic->getNomUrl(1); $nom = $langs->trans("FinanceJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
$builddate = time(); $builddate = time();
//$description = $langs->trans("DescFinanceJournal") . '<br>'; //$description = $langs->trans("DescFinanceJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
$varlink = 'id_account=' . $id_bank_account; $varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
@ -743,8 +750,9 @@ if (empty($action) || $action == 'view') {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/ }*/
print '<div class="tabsAction">'; print '<div class="tabsAction tabsActionNoBottom">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '<input type="button" class="butAction" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
print '</div>'; print '</div>';
// TODO Avoid using js. We can use a direct link with $param // TODO Avoid using js. We can use a direct link with $param
@ -752,7 +760,7 @@ if (empty($action) || $action == 'view') {
<script type="text/javascript"> <script type="text/javascript">
function launch_export() { function launch_export() {
console.log("Set value into form and submit"); console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv"); $("div.fiche div.tabBar form input[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click(); $("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
} }
@ -806,6 +814,9 @@ if (empty($action) || $action == 'view') {
if ($reflabel == '(ExpenseReportPayment)') { if ($reflabel == '(ExpenseReportPayment)') {
$reflabel = $langs->trans('Employee'); $reflabel = $langs->trans('Employee');
} }
if ($reflabel == '(payment_salary)') {
$reflabel = $langs->trans('Employee');
}
$ref=$reflabel; $ref=$reflabel;
if ($tabtype[$key] == 'payment') if ($tabtype[$key] == 'payment')
@ -850,7 +861,62 @@ if (empty($action) || $action == 'view') {
} }
else dol_print_error($db); else dol_print_error($db);
} }
elseif ($tabtype[$key] == 'payment_vat')
{
$sqlmid = 'SELECT v.rowid as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$vatstatic->fetch($objmid->id);
$ref=$langs->trans("PaymentVat").' '.$vatstatic->getNomUrl(1);
}
else dol_print_error($db);
}
elseif ($tabtype[$key] == 'payment_donation')
{
$sqlmid = 'SELECT payd.fk_donation as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd";
$sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$donationstatic->fetch($objmid->id);
$ref=$langs->trans("Donation").' '.$donationstatic->getNomUrl(1);
}
else dol_print_error($db);
}
elseif ($tabtype[$key] == 'payment_salary')
{
$sqlmid = 'SELECT s.rowid as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s";
$sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$salarystatic->fetch($objmid->id);
$ref=$langs->trans("SalaryPayment").' '.$salarystatic->getNomUrl(1);
}
else dol_print_error($db);
}
elseif ($tabtype[$key] == 'payment_various')
{
$sqlmid = 'SELECT v.rowid as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$variousstatic->fetch($objmid->id);
$ref=$variousstatic->getNomUrl(1);
}
else dol_print_error($db);
}
/*$invoicestatic->id = $key; /*$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];
@ -871,7 +937,7 @@ if (empty($action) || $action == 'view') {
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
if ($val['soclib'] == '') { if ($val['soclib'] == '') {
print "<td>" . $bankstatic->label . " - " . $val["ref"] . "</td>"; print "<td>" . $bankstatic->label . " - " . $reflabel . "</td>";
} else { } else {
print "<td>" . $bankstatic->label . " - " . $val['soclib'] . "</td>"; print "<td>" . $bankstatic->label . " - " . $val['soclib'] . "</td>";
} }

View File

@ -3,7 +3,7 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info> * Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* 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>
* *
@ -27,17 +27,15 @@
* \brief Page with expense reports journal * \brief Page with expense reports journal
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
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/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 . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.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 . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
// Langs
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
$langs->load("other"); $langs->load("other");
@ -45,12 +43,16 @@ $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("trips"); $langs->load("trips");
$id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','aZ09');
$date_startmonth = GETPOST('date_startmonth'); $date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday'); $date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear'); $date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth'); $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now(); $now = dol_now();
@ -58,13 +60,16 @@ $now = dol_now();
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
$action = GETPOST('action','aZ09');
/* /*
* Actions * Actions
*/ */
// Get informations of journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label;
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1; $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
@ -82,31 +87,34 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $mysoc->country_id;
$idpays = $p[0];
$sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,";
$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation,"; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, ";
$sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
$sql .= " f.accountancy_code, ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
//$sql .= " ct.accountancy_code_buy as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$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 aa.rowid = erd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author"; $sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author";
$sql .= " WHERE er.fk_statut > 0"; $sql .= " WHERE er.fk_statut > 0";
$sql .= " AND erd.fk_code_ventilation > 0"; $sql .= " AND erd.fk_code_ventilation > 0";
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'";
if ($in_bookkeeping == 'yes')
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
$sql .= " ORDER BY er.date_debut"; $sql .= " ORDER BY er.date_debut";
dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql); dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
// les variables
// Variables
$account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"); $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef");
$account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
@ -124,10 +132,15 @@ if ($result) {
// Controls // Controls
$compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; $compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
$compta_fees = $obj->compte; $compta_fees = $obj->compte;
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat);
// Define array for display vat tx $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$def_tva[$obj->rowid]=price($obj->tva_tx); $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat);
// Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
}
$taber[$obj->rowid]["date"] = $db->jdate($obj->de); $taber[$obj->rowid]["date"] = $db->jdate($obj->de);
$taber[$obj->rowid]["ref"] = $obj->ref; $taber[$obj->rowid]["ref"] = $obj->ref;
@ -138,7 +151,7 @@ if ($result) {
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabuser[$obj->rowid] = array ( $tabuser[$obj->rowid] = array (
'id' => $obj->uid, 'id' => $obj->uid,
'name' => $obj->firstname.' '.$obj->lastname, 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
'user_accountancy_code' => $obj->user_accountancy_account 'user_accountancy_code' => $obj->user_accountancy_account
); );
@ -159,12 +172,12 @@ if ($action == 'writebookkeeping') {
$db->begin(); $db->begin();
// Thirdparty
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
// get compte id and label // get compte id and label
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -172,14 +185,16 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'expense_report'; $bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0; $bookkeeping->debit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -201,9 +216,9 @@ if ($action == 'writebookkeeping') {
} }
} }
// Fees
if (! $errorforline) if (! $errorforline)
{ {
// Fees
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true); $accountingaccount->fetch(null, $k, true);
@ -218,14 +233,16 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'expense_report'; $bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->subledger_label = '';
$bookkeeping->label_operation = $accountingaccount->label;
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -248,9 +265,9 @@ if ($action == 'writebookkeeping') {
} }
} }
// VAT
if (! $errorforline) if (! $errorforline)
{ {
// VAT
// var_dump($tabtva); // var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
@ -262,14 +279,16 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'expense_report'; $bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->subledger_label = '';
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -298,8 +317,13 @@ if ($action == 'writebookkeeping') {
else else
{ {
$db->rollback(); $db->rollback();
}
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
}
}
} }
if (empty($error) && count($tabpay)) { if (empty($error) && count($tabpay)) {
@ -328,7 +352,6 @@ $userstatic = new User($db);
// Export // Export
/*if ($action == 'export_csv') { /*if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -439,16 +462,18 @@ if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("ExpenseReportsJournal")); llxHeader('', $langs->trans("ExpenseReportsJournal"));
$nom = $langs->trans("ExpenseReportsJournal"); $nom = $langs->trans("ExpenseReportsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
$nomlink = ''; $nomlink = '';
$periodlink = ''; $periodlink = '';
$exportlink = ''; $exportlink = '';
$builddate = time(); $builddate = time();
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); $varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>'; print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
@ -456,7 +481,7 @@ if (empty($action) || $action == 'view') {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/ }*/
print '<div class="tabsAction">'; print '<div class="tabsAction tabsActionNoBottom">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '</div>'; print '</div>';
@ -547,7 +572,7 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "</td>"; print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>"; print "</tr>";
@ -570,7 +595,7 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("Code_tiers") . "</td>"; print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>"; print "</tr>";

View File

@ -3,7 +3,7 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info> * Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* 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>
* *
@ -27,29 +27,31 @@
* \brief Page with purchases journal * \brief Page with purchases journal
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
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/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 . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.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.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
// Langs
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
$langs->load("other"); $langs->load("other");
$langs->load("main"); $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','aZ09');
$date_startmonth = GETPOST('date_startmonth'); $date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday'); $date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear'); $date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth'); $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now(); $now = dol_now();
@ -57,13 +59,16 @@ $now = dol_now();
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
$action = GETPOST('action','aZ09');
/* /*
* Actions * Actions
*/ */
// Get informations of journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label;
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1; $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
@ -81,28 +86,31 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $mysoc->country_id;
$idpays = $p[0];
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,";
$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; $sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql .= " p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
//$sql .= " ct.accountancy_code_buy as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$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";
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " WHERE f.fk_statut > 0 "; $sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ?
$sql .= " AND fd.fk_code_ventilation > 0"; $sql .= " AND fd.fk_code_ventilation > 0";
$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
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2)"; $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")";
else } else {
$sql .= " AND f.type IN (0,1,2,3)"; $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")";
}
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
if ($in_bookkeeping == 'yes')
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
$sql .= " ORDER BY f.datef"; $sql .= " ORDER BY f.datef";
dol_syslog('accountancy/journal/purchasesjournal.php:: $sql=' . $sql); dol_syslog('accountancy/journal/purchasesjournal.php:: $sql=' . $sql);
@ -110,7 +118,7 @@ $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
// les variables // Variables
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
@ -125,7 +133,7 @@ if ($result) {
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// contrôles // Controls
$compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour;
$compta_prod = $obj->compte; $compta_prod = $obj->compte;
@ -135,10 +143,15 @@ if ($result) {
else else
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
} }
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
//Define array for display vat tx $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$def_tva[$obj->rowid]=price($obj->tva_tx); $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
}
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
@ -198,10 +211,10 @@ if ($action == 'writebookkeeping') {
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
// Thirdparty
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
// get compte id and label
if ($mt) { if ($mt) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -210,14 +223,17 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->numero_compte = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_label = ''; // TODO To complete
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount");
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0; $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -256,14 +272,17 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->code_tiers = ''; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label;
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -300,14 +319,17 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->code_tiers = ''; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -336,8 +358,13 @@ if ($action == 'writebookkeeping') {
else else
{ {
$db->rollback(); $db->rollback();
}
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
}
}
} }
if (empty($error) && count($tabpay)) { if (empty($error) && count($tabpay)) {
@ -351,7 +378,6 @@ if ($action == 'writebookkeeping') {
{ {
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
} }
$action=''; $action='';
} }
@ -362,69 +388,15 @@ if ($action == 'writebookkeeping') {
$form = new Form($db); $form = new Form($db);
$companystatic = new Fournisseur($db); $companystatic = new Fournisseur($db);
$invoicestatic = new FactureFournisseur($db);
// Export // Export
/*if ($action == 'export_csv') { if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $journal = $conf->global->ACCOUNTING_PURCHASE_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
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
foreach ( $tabfac as $key => $val ) {
$date = dol_print_date($val["date"], '%d%m%Y');
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
if ($mt) {
print $date . $sep;
print $purchase_journal . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print dol_trunc($val["description"], 32) . $sep;
print $val["ref"];
print "\n";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $purchase_journal . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print $langs->trans("VAT") . $sep;
print $val["ref"];
print "\n";
}
}
foreach ( $tabttc[$key] as $k => $mt ) {
print $date . $sep;
print $purchase_journal . $sep;
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print $companystatic->name . $sep;
print $val["ref"];
print "\n";
}
}
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Model Classic Export
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key; $invoicestatic->id = $key;
@ -445,50 +417,66 @@ $companystatic = new Fournisseur($db);
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["refsuppliersologest"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
// print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print " " . $sep;
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
print '"' . $journal_label . '"' ;
print "\n"; print "\n";
} }
} }
// VAT // VAT
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["refsuppliersologest"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
// print '"' . $langs->trans("VAT") . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep; print " " . $sep;
print '"' . $langs->trans("VAT") . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
print '"' . $journal_label . '"' ;
print "\n"; print "\n";
} }
} }
// Third party // Third party
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["refsuppliersologest"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
} print '"' . $journal_label . '"' ;
print "\n"; print "\n";
} }
} }
} }
*/
if (empty($action) || $action == 'view') { if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("PurchasesJournal")); llxHeader('', $langs->trans("PurchasesJournal"));
$nom = $langs->trans("PurchasesJournal"); $nom = $langs->trans("PurchasesJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
$nomlink = ''; $nomlink = '';
$periodlink = ''; $periodlink = '';
$exportlink = ''; $exportlink = '';
@ -501,9 +489,11 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
} }
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); $varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>'; print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
@ -511,14 +501,25 @@ if (empty($action) || $action == 'view') {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/ }*/
print '<div class="tabsAction">'; // Button to write into Ledger
if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
}
print '<div class="tabsAction tabsActionNoBottom">';
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
}
else {
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
}
print '<input type="button" class="butAction" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
print '</div>'; print '</div>';
print ' print '
<script type="text/javascript"> <script type="text/javascript">
function launch_export() { function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv"); $("div.fiche div.tabBar form input[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click(); $("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
} }
@ -537,7 +538,6 @@ if (empty($action) || $action == 'view') {
$i = 0; $i = 0;
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("JournalNum")."</td>";
print "<td></td>"; print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
@ -590,6 +590,7 @@ if (empty($action) || $action == 'view') {
print "</tr>"; print "</tr>";
} }
} }
// VAT // VAT
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
@ -605,7 +606,7 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>"; print "</tr>";
@ -628,7 +629,7 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
// print "</td><td>" . $langs->trans("ThirdParty"); // print "</td><td>" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; // print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')';
// print "</td>"; // print "</td>";

View File

@ -4,7 +4,7 @@
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.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-2016 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
@ -28,18 +28,17 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Page with sells journal * \brief Page with sells journal
*/ */
require '../../main.inc.php';
// Class require '../../main.inc.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/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 . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.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 . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
// Langs
$langs->load("commercial"); $langs->load("commercial");
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
@ -47,12 +46,16 @@ $langs->load("other");
$langs->load("main"); $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','aZ09');
$date_startmonth = GETPOST('date_startmonth'); $date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday'); $date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear'); $date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth'); $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now(); $now = dol_now();
@ -60,13 +63,17 @@ $now = dol_now();
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
$action = GETPOST('action','aZ09');
/* /*
* Actions * Actions
*/ */
// Get informations of journal
$accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label;
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1; $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
@ -84,31 +91,32 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $mysoc->country_id;
$idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
$sql .= " fd.situation_percent,ct.accountancy_code_sell as account_tva"; //$sql .= " ct.accountancy_code_sell as account_tva";
$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";
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON ((fd.vat_src_code <> '' AND fd.vat_src_code = ct.code) OR (fd.vat_src_code = '' AND fd.tva_tx = ct.taux)) AND ct.fk_pays = '" . $idpays . "'";
$sql .= " WHERE fd.fk_code_ventilation > 0"; $sql .= " WHERE fd.fk_code_ventilation > 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 f.fk_statut > 0"; // TODO Facture annulée ? $sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ?
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 {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
} }
$sql .= " AND fd.product_type IN (0,1)"; $sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
if ($in_bookkeeping == 'yes')
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
$sql .= " ORDER BY f.datef"; $sql .= " ORDER BY f.datef";
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG); dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
@ -122,14 +130,16 @@ if ($result) {
$tabcompany = array (); $tabcompany = array ();
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0;
// Variables
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
$i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// les variables // Controls
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
$compta_prod = $obj->compte; $compta_prod = $obj->compte;
@ -139,12 +149,15 @@ if ($result) {
else else
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
} }
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
$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'] : $cpttva);
//Define array for display vat tx // Define array to display all VAT rates that use this accounting account $compta_tva
$def_tva[$obj->rowid]=price($obj->tva_tx); if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
}
// Situation invoices handling // Situation invoices handling
$line = new FactureLigne($db); $line = new FactureLigne($db);
@ -226,15 +239,17 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->thirdparty_code = $companystatic->code_client;
$bookkeeping->numero_compte = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
// $bookkeeping->label_compte = $tabcompany[$key]['name']; $bookkeeping->subledger_label = ''; // TODO To complete
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount");
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0; $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
$bookkeeping->credit = ($mt < 0) ? $mt : 0; $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -271,14 +286,17 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add;
$bookkeeping->code_tiers = ''; $bookkeeping->thirdparty_code = $companystatic->code_client;
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0; $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -314,14 +332,17 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->code_tiers = ''; $bookkeeping->thirdparty_code = $companystatic->code_client;
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0; $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -350,6 +371,12 @@ if ($action == 'writebookkeeping') {
else else
{ {
$db->rollback(); $db->rollback();
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
}
} }
} }
@ -378,75 +405,17 @@ if ($action == 'writebookkeeping') {
$form = new Form($db); $form = new Form($db);
// Export // Export
/*if ($action == 'export_csv') { if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $sell_journal = $conf->global->ACCOUNTING_SELL_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);
$invoicestatic = new Facture($db);
// Model Cegid Expert Export
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$date = dol_print_date($val["date"], '%d%m%Y');
foreach ( $tabttc[$key] as $k => $mt ) {
print $date . $sep;
print $sell_journal . $sep;
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
print $val["ref"];
print "\n";
}
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount_static = new AccountingAccount($db);
if ($accountingaccount_static->fetch(null, $k, true)) {
print $date . $sep;
print $sell_journal . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep;
print $val["ref"];
print "\n";
}
}
// TVA
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $sell_journal . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
// print $langs->trans("VAT") . $sep;
print $val["ref"];
print "\n";
}
}
}
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Model Classic Export
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
@ -458,12 +427,18 @@ $form = new Form($db);
$date = dol_print_date($val["date"], 'day'); $date = dol_print_date($val["date"], 'day');
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . $sell_journal . '"' ;
print "\n"; print "\n";
} }
@ -472,40 +447,55 @@ $form = new Form($db);
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print " " . $sep;
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
print '"' . utf8_decode (dol_trunc($companystatic->name, 16) ) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $sell_journal . '"' ;
print "\n"; print "\n";
} }
} }
// VAT // VAT
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print " " . $sep;
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key]. '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ). ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $sell_journal . '"' ;
print "\n"; print "\n";
} }
} }
} }
} }
}
*/
if (empty($action) || $action == 'view') { if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("SellsJournal")); llxHeader('', $langs->trans("SellsJournal"));
$nom = $langs->trans("SellsJournal"); $nom = $langs->trans("SellsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
$nomlink = ''; $nomlink = '';
$periodlink = ''; $periodlink = '';
$exportlink = ''; $exportlink = '';
@ -516,23 +506,31 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
else else
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); $varlink = 'id_journal=' . $id_journal;
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
} else { // Button to write into Ledger
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
}*/ print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
print '<div class="tabsAction">'; print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
}
print '<div class="tabsAction tabsActionNoBottom">';
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
}
else {
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
}
print '<input type="button" class="butAction" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
print '</div>'; print '</div>';
print ' print '
<script type="text/javascript"> <script type="text/javascript">
function launch_export() { function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv"); $("div.fiche div.tabBar form input[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click(); $("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
} }
@ -555,7 +553,7 @@ if (empty($action) || $action == 'view') {
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>"; print "<td>" . $langs->trans("Label") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n"; print "</tr>\n";
@ -581,7 +579,6 @@ if (empty($action) || $action == 'view') {
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
$companystatic->client = $tabcompany[$key]['code_client'];
print "<td>"; print "<td>";
$accountoshow = length_accounta($k); $accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
@ -592,7 +589,7 @@ if (empty($action) || $action == 'view') {
// print "</td><td>" . $langs->trans("ThirdParty"); // print "</td><td>" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; // print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
print '</td>'; print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>"; print "</tr>";
@ -639,7 +636,8 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
print "</td>";
// print "<td>" . $langs->trans("VAT") . "</td>"; // print "<td>" . $langs->trans("VAT") . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro> /* Copyright (C) 2016/17 Jamal Elbaz <jamelbaz@gmail.com>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 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
@ -25,6 +25,7 @@ require '../../main.inc.php';
// Class // 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 . '/accountancy/class/accountancycategory.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
@ -41,6 +42,8 @@ $selectcpt = GETPOST('cpt_bk');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$cancel = GETPOST('cancel'); $cancel = GETPOST('cancel');
$simple_report = GETPOST('simple_report');
// Filter // Filter
$year = GETPOST('year','int'); $year = GETPOST('year','int');
@ -77,7 +80,14 @@ $form = new Form($db);
$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('ReportInOut'), $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, 'title_accountancy'); $nom = $langs->trans("ReportInOut").', '.$langs->trans("ByAccounts");
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate = time();
$description = '';
$period = $langs->trans("Detail").' '. $form->selectyesno('simple_report',$simple_report,0) . " " .$textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear ;
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
$moreforfilter=''; $moreforfilter='';
@ -108,30 +118,89 @@ foreach($months as $k => $v){
} }
print '</tr>'; print '</tr>';
$cats = $AccCat->getCatsCpts();
if ($cats < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
$catsCalcule = $AccCat->getCatsCal();
//All categories
$cats = $AccCat->getCats();
if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors); if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
$j=1; $j=1;
$sommes = array(); $sommes = array();
if (!empty($cats)) foreach($cats as $cat ){
{ if(!empty($cat['category_type'])){ // category calculed
foreach ($cats as $name_cat => $cpts)
{ $formula = $cat['formula'];
print "<tr class='liste_titre'>"; print "<tr class='liste_titre'>";
print '<td colspan="17">' . $name_cat . '</td>'; print '<td colspan="2">' . $cat['label'] . '</td>';
$vars = array();
// Previous Fiscal year (N-1)
foreach($sommes as $code => $det){
$vars[$code] = $det['NP'];
}
$result = strtr($formula, $vars);
$r = $AccCat->calculate($result);
print '<td align="right"><font color="blue">' . price($r) . '</td>';
$code = $cat['code']; // code categorie de calcule
$sommes[$code]['NP'] += $r;
// Current fiscal year (N)
if (is_array($sommes) && ! empty($sommes)){
foreach($sommes as $code => $det){
$vars[$code] = $det['N'];
}
}
$result = strtr($formula, $vars);
$r = $AccCat->calculate($result);
print '<td align="right"><font color="blue">' . price($r) . '</td>';
$sommes[$code]['N'] += $r;
// Detail by month
foreach($months as $k => $v){
foreach($sommes as $code => $det){
$vars[$code] = $det['M'][$k];
}
$result = strtr($formula, $vars);
$r = $AccCat->calculate($result);
print '<td align="right"><font color="blue">' . price($r) . '</td>';
$sommes[$code]['M'][$k] += $r;
}
print "</tr>\n"; print "</tr>\n";
$position = -1;
$code = -1;
}else{ // normal category
$totCat = array();
$totCat['M'] = array();
// get cpts of category
$cpts = $AccCat->getCptsCat($cat['rowid']);
print "<tr class='liste_titre'>";
print '<td colspan="2">' . $cat['label'] . '</td>';
foreach($cpts as $i => $cpt){ foreach($cpts as $i => $cpt){
$var = ! $var;
$position = $cpt['position']; $code = $cat['code'];
$code = $cpt['code'];
// N-1
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']); $return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
$resultNP=0; $resultNP=0;
@ -139,6 +208,7 @@ if (!empty($cats))
$resultNP=$AccCat->sdc; $resultNP=$AccCat->sdc;
} }
//N
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']); $return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
@ -146,13 +216,64 @@ if (!empty($cats))
} else { } else {
$resultN=$AccCat->sdc; $resultN=$AccCat->sdc;
} }
$totCat['NP'] += $resultNP;
$totCat['N'] += $resultN;
foreach($months as $k => $v){
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultM=0;
} else {
$resultM=$AccCat->sdc;
}
$totCat['M'][$k] += $resultM;
}
}
print '<td align="right">' . price($totCat['NP']) . '</td>';
print '<td align="right">' . price($totCat['N']) . '</td>';
foreach($totCat['M'] as $k => $v){
print '<td align="right">' . price($v) . '</td>';
}
print "</tr>\n";
foreach($cpts as $i => $cpt){
$var = ! $var;
$code = $cat['code'];
// N-1
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultNP=0;
} else {
$resultNP=$AccCat->sdc;
}
//N
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultN=0;
} else {
$resultN=$AccCat->sdc;
}
$sommes[$code]['NP'] += $resultNP; $sommes[$code]['NP'] += $resultNP;
$sommes[$code]['N'] += $resultN; $sommes[$code]['N'] += $resultN;
print '<tr class="oddeven">'; print '<tr'. $bc[$var].'>';
print '<td>' . $cpt['account_number'] . '</td>'; if ($simple_report == 'yes') {
print '<td>' . length_accountg($cpt['account_number']) . '</td>';
print '<td>' . $cpt['name_cpt'] . '</td>'; print '<td>' . $cpt['name_cpt'] . '</td>';
print '<td>' . price($resultNP) . '</td>'; print '<td align="right">' . price($resultNP) . '</td>';
print '<td>' . price($resultN) . '</td>'; print '<td align="right">' . price($resultN) . '</td>';
}
foreach($months as $k => $v){ foreach($months as $k => $v){
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']); $return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
@ -163,102 +284,15 @@ if (!empty($cats))
$resultM=$AccCat->sdc; $resultM=$AccCat->sdc;
} }
$sommes[$code]['M'][$k] += $resultM; $sommes[$code]['M'][$k] += $resultM;
if ($simple_report == 'yes') {
print '<td align="right">' . price($resultM) . '</td>'; print '<td align="right">' . price($resultM) . '</td>';
} }
}
print "</tr>\n"; print "</tr>\n";
} }
// If it's a calculated catgory
$p = $position + 1;
if(array_key_exists($p, $catsCalcule)){
$formula = $catsCalcule[$p]['formula'];
print "<tr class='liste_titre'>";
print '<td colspan="2">' . $catsCalcule[$p]['label'] . '</td>';
$vars = array();
// Previous Fiscal year (N-1)
foreach($sommes as $code => $det){
$vars[$code] = $det['NP'];
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
$code = $catsCalcule[$p]['code']; // code categorie de calcule
$sommes[$code]['NP'] += $result;
// Current fiscal year (N)
foreach($sommes as $code => $det){
$vars[$code] = $det['N'];
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
$sommes[$code]['N'] += $result;
// Detail by month
foreach($months as $k => $v){
foreach($sommes as $code => $det){
$vars[$code] = $det['M'][$k];
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
$sommes[$code]['M'][$k] += $result;
} }
//print '<td colspan="15">' . $catsCalcule[$p]['formula'] . '</td>';
print "</tr>\n";
unset($catsCalcule[$p]); // j'élimine la catégorie calculée après affichage
}
$j++;
}
// Others calculed category
foreach($catsCalcule as $p => $catc)
{
$formula = $catsCalcule[$p]['formula'];
print "<tr class='liste_titre'>";
print '<td colspan="2">' . $catsCalcule[$p]['label'] . '</td>';
$vars = array();
// Previous Fiscal year (N-1)
foreach($sommes as $code => $det){
$vars[$code] = $det['NP'];
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
$code = $catsCalcule[$p]['code']; // code categorie de calcule
$sommes[$code]['NP'] += $result;
// Current fiscal year (N)
foreach($sommes as $code => $det){
$vars[$code] = $det['N'];
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
$sommes[$code]['N'] += $result;
// Detail by month
foreach($months as $k => $v){
foreach($sommes as $code => $det){
$vars[$code] = $det['M'][$k];
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
$sommes[$code]['M'][$k] += $result;
}
//print '<td colspan="15">' . $catsCalcule[$p]['formula'] . '</td>';
print "</tr>\n";
}
} }
print "</table>"; print "</table>";

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -96,7 +96,7 @@ if (! empty($id)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
$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
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -21,12 +21,13 @@
/** /**
* \file htdocs/accountancy/supplier/index.php * \file htdocs/accountancy/supplier/index.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Home supplier ventilation * \brief Home supplier journalization page
*/ */
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 . '/fourn/class/fournisseur.facture.class.php';
// Langs // Langs
$langs->load("compta"); $langs->load("compta");
@ -55,7 +56,7 @@ if ($year == 0) {
} }
// Validate History // Validate History
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
/* /*
@ -69,7 +70,7 @@ if ($action == 'validatehistory') {
// First clean corrupted data // First clean corrupted data
$sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sqlclean .= " SET fd.fk_code_ventilation = 0"; $sqlclean .= " SET fk_code_ventilation = 0";
$sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN '; $sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sqlclean .= ' (SELECT accnt.rowid '; $sqlclean .= ' (SELECT accnt.rowid ';
$sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
@ -87,12 +88,14 @@ if ($action == 'validatehistory') {
$sql1 .= " AND " . MAIN_DB_PREFIX . "facture_fourn_det.fk_code_ventilation = 0"; $sql1 .= " AND " . MAIN_DB_PREFIX . "facture_fourn_det.fk_code_ventilation = 0";
} else { } else {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; $sql1 .= " SET fk_code_ventilation = accnt.rowid";
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number";
$sql1 .= " AND fd.fk_code_ventilation = 0"; $sql1 .= " AND fd.fk_code_ventilation = 0";
} }
dol_syslog('htdocs/accountancy/supplier/index.php');
$resql1 = $db->query($sql1); $resql1 = $db->query($sql1);
if (! $resql1) { if (! $resql1) {
$error ++; $error ++;
@ -107,7 +110,7 @@ if ($action == 'validatehistory') {
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1 .= " SET fd.fk_code_ventilation = 0"; $sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sql1 .= ' (SELECT accnt.rowid '; $sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
@ -130,11 +133,11 @@ if ($action == 'validatehistory') {
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1.= " SET fd.fk_code_ventilation = 0"; $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 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.= " 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.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
$sql1.= " AND f.entity IN (" . getEntity("accountancy", 1) . ")"; $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")";
$sql1.= ")"; $sql1.= ")";
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
@ -159,33 +162,28 @@ llxHeader('', $langs->trans("SuppliersVentilation"));
$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("SuppliersVentilation") . "&nbsp;" . $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("DescVentilSupplier") . '<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>';
//print '<div class="inline-block divButAction">'; //print '<div class="inline-block divButAction">';
// TODO Remove this. Should be done always. // TODO Remove this. Should be done always or into the repair.php script.
if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>'; if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
//print '</div>'; //print '</div>';
$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>'; $buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
$y = $year_current;
$var = true;
print '<br>';
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200" align="left">' . $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>'; print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
@ -197,18 +195,18 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
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) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(ffd.total_ht),2) 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(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$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";
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -239,7 +237,7 @@ print '<br>';
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200" align="left">' . $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>'; print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
@ -251,18 +249,18 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
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) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(ffd.total_ht),2) 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(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$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";
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -306,15 +304,15 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
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) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(ffd.total_ht),2) 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(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$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
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);

View File

@ -1,6 +1,6 @@
<?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.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.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) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -52,9 +52,11 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha'); $search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha');
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int'); $page = GETPOST('page', 'int');
@ -94,6 +96,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_amount = ''; $search_amount = '';
$search_account = ''; $search_account = '';
$search_vat = ''; $search_vat = '';
$search_country = '';
$search_tvaintra = '';
} }
if (is_array($changeaccount) && count($changeaccount) > 0) { if (is_array($changeaccount) && count($changeaccount) > 0) {
@ -149,13 +153,15 @@ 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,"; $sql = "SELECT f.rowid as facid, f.ref as facnumber, 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, aa.label, aa.account_number, "; $sql.= " l.rowid, l.fk_product, l.description, l.total_ht , l.qty, l.tva_tx, 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"; $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.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql.= " , " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql.= " , " . 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 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn";
$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.= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 "; $sql.= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
$sql.= " AND aa.rowid = l.fk_code_ventilation"; $sql.= " AND aa.rowid = l.fk_code_ventilation";
if ($search_lineid) { if ($search_lineid) {
@ -182,7 +188,13 @@ if (strlen(trim($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", $search_vat, 1);
} }
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy if (strlen(trim($search_country))) {
$sql .= " AND (co.label like'" . $search_country . "%')";
}
if (strlen(trim($search_tvaintra))) {
$sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')";
}
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -256,6 +268,8 @@ if ($result) {
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="center"><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="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_account" value="' . dol_escape_htmltag($search_account) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre"><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;
@ -273,6 +287,8 @@ if ($result) {
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $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";
@ -315,7 +331,7 @@ if ($result) {
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $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);
print '</td>'; print '</td>';
@ -325,7 +341,8 @@ if ($result) {
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '">'; print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td align="right">' . $objp->country .'</td>';
print '<td align="center">' . $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

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
@ -63,7 +63,7 @@ $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int'); $page = GETPOST('page','int');
@ -191,7 +191,8 @@ $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountan
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND product_type <= 2"; $sql.= " AND product_type <= 2";
$sql.= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy ='')"; $sql.= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy =''OR p.accountancy_code_buy NOT IN
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid ='" . $conf->global->CHARTOFACCOUNTS . "'))";
// Add search filter like // Add search filter like
if ($search_lineid) { if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1); $sql .= natural_search("l.rowid", $search_lineid, 1);
@ -217,7 +218,7 @@ if (strlen(trim($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",$search_vat,1);
} }
$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
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -381,7 +382,7 @@ if ($result) {
// Description // Description
print '<td>'; print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $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);
print '</td>'; print '</td>';

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com> * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.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

View File

@ -115,16 +115,11 @@ if ($conf->use_javascript_ajax)
{ {
if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\') if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
{ {
jQuery("#tramount").hide(); jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
jQuery("#tredit").hide();
jQuery("#trpayment").hide();
jQuery("#tremail").hide();
} }
if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\') if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
{ {
jQuery("#tramount").show(); jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
jQuery("#tredit").show();
jQuery("#trpayment").show();
if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide(); if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
else jQuery("#tremail").show(); else jQuery("#tremail").show();
} }
@ -156,9 +151,9 @@ print "</td></tr>\n";
// Force Type // Force Type
$adht = new AdherentType($db); $adht = new AdherentType($db);
print '<tr class="oddeven drag"><td>'; print '<tr class="oddeven drag" id="trforcetype"><td>';
print $langs->trans("ForceMemberType"); print $langs->trans("ForceMemberType");
print '</td><td width="60" align="center">'; print '</td><td width="60" align="right">';
$listofval = array(-1 => $langs->trans("Undefined")); $listofval = array(-1 => $langs->trans("Undefined"));
$listofval += $adht->liste_array(); $listofval += $adht->liste_array();
$forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1;

View File

@ -182,7 +182,7 @@ abstract class ActionsAdherentCardCommon
$this->object->old_name = $_POST["old_name"]; $this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"]; $this->object->old_firstname = $_POST["old_firstname"];
$result = $this->object->delete(); $result = $this->object->delete(0, $user, 0);
if ($result > 0) if ($result > 0)
{ {
header("Location: list.php"); header("Location: list.php");

View File

@ -112,7 +112,7 @@ if ($id)
$caneditfieldmember=$user->rights->adherent->creer; $caneditfieldmember=$user->rights->adherent->creer;
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membercard','globalcard')); $hookmanager->initHooks(array('membercard','globalcard'));
@ -585,7 +585,7 @@ if (empty($reshook))
if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
{ {
$result=$object->delete($id); $result=$object->delete($id, $user);
if ($result > 0) if ($result > 0)
{ {
if (! empty($backtopage)) if (! empty($backtopage))
@ -943,25 +943,12 @@ else
// Other attributes // Other attributes
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print $object->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');
} }
/*
// Third party Dolibarr
if (! empty($conf->societe->enabled))
{
print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td class="valeur">';
print $form->select_company($object->fk_soc,'socid','',1);
print '</td></tr>';
}
// Login Dolibarr
print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">';
print $form->select_dolusers($object->user_id, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</td></tr>';
*/
print '<tbody>'; print '<tbody>';
print "</table>\n"; print "</table>\n";
@ -1061,12 +1048,12 @@ else
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->id.'</td></tr>';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{ {
print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td colspan="2"><input type="text" name="login" class="maxwidth200" value="'.(isset($_POST["login"])?GETPOST("login",'alpha',2):$object->login).'"></td></tr>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" class="maxwidth200" value="'.(isset($_POST["login"])?GETPOST("login",'alpha',2):$object->login).'"></td></tr>';
} }
// Password // Password
@ -1095,7 +1082,7 @@ else
print "</td></tr>"; print "</td></tr>";
// Company // Company
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?GETPOST("societe",'',2):$object->societe).'"></td></tr>'; print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth100" value="'.(isset($_POST["societe"])?GETPOST("societe",'',2):$object->societe).'"></td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
@ -1104,11 +1091,11 @@ else
print '</tr>'; print '</tr>';
// Lastname // Lastname
print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" size="40" value="'.(isset($_POST["lastname"])?GETPOST("lastname",'',2):$object->lastname).'"></td>'; print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth100" value="'.(isset($_POST["lastname"])?GETPOST("lastname",'',2):$object->lastname).'"></td>';
print '</tr>'; print '</tr>';
// Firstname // Firstname
print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.(isset($_POST["firstname"])?GETPOST("firstname",'',3):$object->firstname).'"></td>'; print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth100" value="'.(isset($_POST["firstname"])?GETPOST("firstname",'',3):$object->firstname).'"></td>';
print '</tr>'; print '</tr>';
// Photo // Photo
@ -1131,7 +1118,7 @@ else
// Address // Address
print '<tr><td>'.$langs->trans("Address").'</td><td>'; print '<tr><td>'.$langs->trans("Address").'</td><td>';
print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(isset($_POST["address"])?GETPOST("address",'',2):$object->address).'</textarea>'; print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.(isset($_POST["address"])?GETPOST("address",'',2):$object->address).'</textarea>';
print '</td></tr>'; print '</td></tr>';
// Zip / Town // Zip / Town
@ -1143,7 +1130,7 @@ else
// Country // Country
//$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>'; print '<tr><td>'.$langs->trans('Country').'</td><td>';
print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id,'country_id'); print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>'; print '</td></tr>';
@ -1168,7 +1155,7 @@ else
// Skype // Skype
if (! empty($conf->skype->enabled)) if (! empty($conf->skype->enabled))
{ {
print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="skype" size="40" value="'.(isset($_POST["skype"])?GETPOST("skype"):$object->skype).'"></td></tr>'; print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="skype" class="minwidth100" value="'.(isset($_POST["skype"])?GETPOST("skype"):$object->skype).'"></td></tr>';
} }
// Birthday // Birthday
@ -1185,7 +1172,7 @@ else
if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire ))
{ {
print '<tr><td>' . fieldLabel('Categories', 'memcats') . '</td>'; print '<tr><td>' . fieldLabel('Categories', 'memcats') . '</td>';
print '<td colspan="2">'; print '<td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1); $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1);
$c = new Categorie($db); $c = new Categorie($db);
$cats = $c->containing($object->id, Categorie::TYPE_MEMBER); $cats = $c->containing($object->id, Categorie::TYPE_MEMBER);
@ -1197,8 +1184,9 @@ else
} }
// Other attributes // Other attributes
$parameters=array("colspan"=>2); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print $object->showOptionals($extrafields,'edit',$parameters); print $object->showOptionals($extrafields,'edit',$parameters);
@ -1488,12 +1476,7 @@ else
} }
// Other attributes // Other attributes
$parameters=array('colspan'=>2); include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields, 'view', $parameters);
}
// Date end subscription // Date end subscription
print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">'; print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';

View File

@ -705,11 +705,13 @@ class Adherent extends CommonObject
* Fonction qui supprime l'adherent et les donnees associees * Fonction qui supprime l'adherent et les donnees associees
* *
* @param int $rowid Id of member to delete * @param int $rowid Id of member to delete
* @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, 0=nothing to do, >0 if OK * @return int <0 if KO, 0=nothing to do, >0 if OK
*/ */
function delete($rowid) function delete($rowid, $user, $notrigger=0)
{ {
global $conf, $langs, $user; global $conf, $langs;
$result = 0; $result = 0;
$error=0; $error=0;
@ -720,6 +722,14 @@ class Adherent extends CommonObject
$this->db->begin(); $this->db->begin();
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
// Remove category // Remove category
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
@ -787,16 +797,6 @@ class Adherent extends CommonObject
} }
} }
if (! $error)
{
// Call trigger
$result=$this->call_trigger('MEMBER_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
@ -1097,7 +1097,7 @@ class Adherent extends CommonObject
$sql.= " WHERE d.fk_adherent_type = t.rowid"; $sql.= " WHERE d.fk_adherent_type = t.rowid";
if ($rowid) $sql.= " AND d.rowid=".$rowid; if ($rowid) $sql.= " AND d.rowid=".$rowid;
elseif ($ref || $fk_soc) { elseif ($ref || $fk_soc) {
$sql.= " AND d.entity IN (".getEntity().")"; $sql.= " AND d.entity IN (".getEntity('adherent').")";
if ($ref) $sql.= " AND d.rowid='".$this->db->escape($ref)."'"; if ($ref) $sql.= " AND d.rowid='".$this->db->escape($ref)."'";
elseif ($fk_soc > 0) $sql.= " AND d.fk_soc=".$fk_soc; elseif ($fk_soc > 0) $sql.= " AND d.fk_soc=".$fk_soc;
} }
@ -1780,7 +1780,7 @@ class Adherent extends CommonObject
$sql = "SELECT count(a.rowid) as nb"; $sql = "SELECT count(a.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.statut > 0"; $sql.= " WHERE a.statut > 0";
$sql.= " AND a.entity IN (".getEntity('adherent', 1).")"; $sql.= " AND a.entity IN (".getEntity('adherent').")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -1818,7 +1818,7 @@ class Adherent extends CommonObject
$sql = "SELECT a.rowid, a.datefin, a.statut"; $sql = "SELECT a.rowid, a.datefin, a.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.statut = 1"; $sql.= " WHERE a.statut = 1";
$sql.= " AND a.entity IN (".getEntity('adherent', 1).")"; $sql.= " AND a.entity IN (".getEntity('adherent').")";
$sql.= " AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')"; $sql.= " AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);

View File

@ -65,7 +65,7 @@ class AdherentStats extends Stats
$this->field='subscription'; $this->field='subscription';
$this->where.= " m.statut != 0"; $this->where.= " m.statut != 0";
$this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent', 1).")"; $this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")";
//if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($this->memberid) if($this->memberid)
{ {

View File

@ -100,7 +100,7 @@ class Members extends DolibarrApi
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as t";
$sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')'; $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')';
if (!empty($typeid)) if (!empty($typeid))
{ {
$sql.= ' AND t.fk_adherent_type='.$typeid; $sql.= ' AND t.fk_adherent_type='.$typeid;
@ -250,11 +250,7 @@ class Members extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
// The Adherent::delete() method uses the global variable $user. if (! $member->delete($member->id, DolibarrApiAccess::$user)) {
global $user;
$user = DolibarrApiAccess::$user;
if (! $member->delete($member->id)) {
throw new RestException(401,'error when deleting member'); throw new RestException(401,'error when deleting member');
} }

View File

@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')'; $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')';
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
@ -274,7 +274,6 @@ class MembersTypes extends DolibarrApi
unset($object->cotisation); unset($object->cotisation);
unset($object->libelle); unset($object->libelle);
unset($object->import_key);
unset($object->array_options); unset($object->array_options);
unset($object->linkedObjectsIds); unset($object->linkedObjectsIds);
unset($object->context); unset($object->context);

View File

@ -52,7 +52,7 @@ $result=restrictedArea($user,'adherent',$id);
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; } if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $conf->liste_limit * $page ; $offset = $conf->liste_limit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;

View File

@ -64,8 +64,8 @@ $sql.= " d.statut, count(d.rowid) as somme";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
$sql.= " ON t.rowid = d.fk_adherent_type"; $sql.= " ON t.rowid = d.fk_adherent_type";
$sql.= " AND d.entity IN (".getEntity().")"; $sql.= " AND d.entity IN (".getEntity('adherent').")";
$sql.= " WHERE t.entity IN (".getEntity().")"; $sql.= " WHERE t.entity IN (".getEntity('adherent').")";
$sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut";
dol_syslog("index.php::select nb of members by type", LOG_DEBUG); dol_syslog("index.php::select nb of members by type", LOG_DEBUG);
@ -100,7 +100,7 @@ $now=dol_now();
// old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future)
$sql = "SELECT count(*) as somme , d.fk_adherent_type"; $sql = "SELECT count(*) as somme , d.fk_adherent_type";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE d.entity IN (".getEntity().")"; $sql.= " WHERE d.entity IN (".getEntity('adherent').")";
//$sql.= " AND d.statut = 1 AND ((t.subscription = 0 AND d.datefin IS NULL) OR d.datefin >= '".$db->idate($now)."')"; //$sql.= " AND d.statut = 1 AND ((t.subscription = 0 AND d.datefin IS NULL) OR d.datefin >= '".$db->idate($now)."')";
$sql.= " AND d.statut = 1 AND d.datefin >= '".$db->idate($now)."'"; $sql.= " AND d.statut = 1 AND d.datefin >= '".$db->idate($now)."'";
$sql.= " AND t.rowid = d.fk_adherent_type"; $sql.= " AND t.rowid = d.fk_adherent_type";
@ -211,7 +211,7 @@ $numb=0;
$sql = "SELECT c.subscription, c.dateadh as dateh"; $sql = "SELECT c.subscription, c.dateadh as dateh";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql.= " WHERE d.entity IN (".getEntity().")"; $sql.= " WHERE d.entity IN (".getEntity('adherent').")";
$sql.= " AND d.rowid = c.fk_adherent"; $sql.= " AND d.rowid = c.fk_adherent";
if(isset($date_select) && $date_select != '') if(isset($date_select) && $date_select != '')
{ {
@ -275,7 +275,7 @@ $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company,
$sql.= " a.tms as datem, datefin as date_end_subscription,"; $sql.= " a.tms as datem, datefin as date_end_subscription,";
$sql.= " ta.rowid as typeid, ta.libelle, ta.subscription"; $sql.= " ta.rowid as typeid, ta.libelle, ta.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
$sql.= " WHERE a.entity IN (".getEntity().")"; $sql.= " WHERE a.entity IN (".getEntity('adherent').")";
$sql.= " AND a.fk_adherent_type = ta.rowid"; $sql.= " AND a.fk_adherent_type = ta.rowid";
$sql.= $db->order("a.tms","DESC"); $sql.= $db->order("a.tms","DESC");
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);
@ -336,7 +336,7 @@ $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company,
$sql.= " datefin as date_end_subscription,"; $sql.= " datefin as date_end_subscription,";
$sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; $sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c";
$sql.= " WHERE a.entity IN (".getEntity().")"; $sql.= " WHERE a.entity IN (".getEntity('adherent').")";
$sql.= " AND c.fk_adherent = a.rowid"; $sql.= " AND c.fk_adherent = a.rowid";
$sql.= $db->order("c.tms","DESC"); $sql.= $db->order("c.tms","DESC");
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);

View File

@ -31,13 +31,17 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$langs->load("members"); $langs->loadLangs(array("members","companies"));
$langs->load("companies");
$action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
// Security check // Security check
$result=restrictedArea($user,'adherent'); $result=restrictedArea($user,'adherent');
$action=GETPOST('action','aZ09');
$filter=GETPOST("filter"); $filter=GETPOST("filter");
$statut=GETPOST("statut"); $statut=GETPOST("statut");
$search=GETPOST("search"); $search=GETPOST("search");
@ -53,7 +57,7 @@ $search_country=GETPOST("search_country");
$search_phone=GETPOST("search_phone"); $search_phone=GETPOST("search_phone");
$search_phone_perso=GETPOST("search_phone_perso"); $search_phone_perso=GETPOST("search_phone_perso");
$search_phone_mobile=GETPOST("search_phone_mobile"); $search_phone_mobile=GETPOST("search_phone_mobile");
$type=GETPOST("type"); $search_type=GETPOST("search_type");
$search_email=GETPOST("search_email"); $search_email=GETPOST("search_email");
$search_categ = GETPOST("search_categ",'int'); $search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int'); $catid = GETPOST("catid",'int');
@ -62,18 +66,18 @@ $optioncss = GETPOST('optioncss','alpha');
if ($statut < -1) $statut = ''; if ($statut < -1) $statut = '';
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0; } if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page ; $offset = $limit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } 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 thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('memberlist')); $hookmanager->initHooks(array('memberlist'));
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -155,7 +159,7 @@ if (empty($reshook))
$search_firstname=""; $search_firstname="";
$search_login=""; $search_login="";
$search_company=""; $search_company="";
$type=""; $search_type="";
$search_email=""; $search_email="";
$search_address=""; $search_address="";
$search_zip=""; $search_zip="";
@ -173,6 +177,14 @@ if (empty($reshook))
$toselect=''; $toselect='';
$search_array_options=array(); $search_array_options=array();
} }
// Mass actions
$objectclass='Adherent';
$objectlabel='Members';
$permtoread = $user->rights->adherent->lire;
$permtodelete = $user->rights->adherent->supprimer;
$uploaddir = $conf->adherent->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
@ -193,8 +205,8 @@ $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.pu
$sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
$sql.= " t.libelle as type, t.subscription,"; $sql.= " t.libelle as type, t.subscription,";
$sql.= " state.code_departement as state_code, state.nom as state_name"; $sql.= " state.code_departement as state_code, state.nom as state_name";
// Add fields for extrafields // Add fields from extrafields
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks // Add fields from hooks
$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
@ -210,9 +222,9 @@ if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid);
if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ); if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
$sql.= " AND d.entity IN (".getEntity('adherent', 1).")"; $sql.= " AND d.entity IN (".getEntity('adherent').")";
if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type); if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type);
if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
if ($search_ref) if ($search_ref)
{ {
@ -298,10 +310,10 @@ elseif ($action == 'search')
$titre=$langs->trans("MembersListQualified"); $titre=$langs->trans("MembersListQualified");
} }
if ($type > 0) if ($search_type > 0)
{ {
$membertype=new AdherentType($db); $membertype=new AdherentType($db);
$result=$membertype->fetch(GETPOST("type")); $result=$membertype->fetch(GETPOST("type",'int'));
$titre.=" (".$membertype->libelle.")"; $titre.=" (".$membertype->libelle.")";
} }
@ -326,7 +338,7 @@ if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso); if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso);
if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile); if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile);
if ($filter) $param.="&filter=".urlencode($filter); if ($filter) $param.="&filter=".urlencode($filter);
if ($type > 0) $param.="&type=".urlencode($type); if ($search_type > 0) $param.="&search_type=".urlencode($search_type);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
@ -346,7 +358,7 @@ if ($user->rights->adherent->supprimer) $arrayofmassactions['delete']=$langs->tr
//if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" 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'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -444,7 +456,7 @@ if (! empty($arrayfields['t.libelle']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$listetype=$membertypestatic->liste_array(); $listetype=$membertypestatic->liste_array();
print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32);
print '</td>'; print '</td>';
} }
@ -597,7 +609,9 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); $sortonfield = "ef.".$key;
if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
} }
} }
} }
@ -832,20 +846,13 @@ while ($i < min($num, $limit))
} }
// Action column // Action column
print '<td align="center">'; print '<td align="center">';
if ($user->rights->adherent->creer) if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{ {
print "<a href=\"card.php?rowid=".$obj->rowid."&action=edit&backtopage=1\">".img_edit()."</a>"; $selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
} }
print '&nbsp;'; print '</td>';
if ($user->rights->adherent->supprimer && $obj->statut == -1)
{
print "<a href=\"card.php?rowid=".$obj->rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png')."</a>";
}
if ($user->rights->adherent->supprimer && $obj->statut == 1)
{
print "<a href=\"card.php?rowid=".$obj->rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
}
print "</td>";
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
print "</tr>\n"; print "</tr>\n";

View File

@ -67,7 +67,7 @@ $tab='byproperties';
$data = array(); $data = array();
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code"; $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
$sql.=" WHERE d.entity IN (".getEntity().")"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1"; $sql.=" AND d.statut = 1";
$sql.=" GROUP BY d.morphy"; $sql.=" GROUP BY d.morphy";
@ -101,7 +101,7 @@ else
$head = member_stats_prepare_head($adh); $head = member_stats_prepare_head($adh);
dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), 0, 'user'); dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user');
// Print title // Print title

View File

@ -79,7 +79,7 @@ if ($mode)
$data = array(); $data = array();
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label"; $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
$sql.=" WHERE d.entity IN (".getEntity().")"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1"; $sql.=" AND d.statut = 1";
$sql.=" GROUP BY c.label, c.code"; $sql.=" GROUP BY c.label, c.code";
//print $sql; //print $sql;
@ -96,7 +96,7 @@ if ($mode)
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
$sql.=" WHERE d.entity IN (".getEntity().")"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1"; $sql.=" AND d.statut = 1";
$sql.=" GROUP BY co.label, co.code, c.nom"; $sql.=" GROUP BY co.label, co.code, c.nom";
//print $sql; //print $sql;
@ -112,7 +112,7 @@ if ($mode)
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
$sql.=" WHERE d.entity IN (".getEntity().")"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1"; $sql.=" AND d.statut = 1";
$sql.=" GROUP BY co.label, co.code, r.nom"; //+ $sql.=" GROUP BY co.label, co.code, r.nom"; //+
//print $sql; //print $sql;
@ -127,7 +127,7 @@ if ($mode)
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2"; $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.=" FROM ".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";
$sql.=" WHERE d.entity IN (".getEntity().")"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1"; $sql.=" AND d.statut = 1";
$sql.=" GROUP BY c.label, c.code, d.town"; $sql.=" GROUP BY c.label, c.code, d.town";
//print $sql; //print $sql;
@ -198,7 +198,7 @@ if ($mode)
$head = member_stats_prepare_head($adh); $head = member_stats_prepare_head($adh);
dol_fiche_head($head, $tab, $langs->trans("Statistics"), 0, 'user'); dol_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user');
// Print title // Print title

View File

@ -89,7 +89,7 @@ if ($rowid)
$caneditfieldmember=$user->rights->adherent->creer; $caneditfieldmember=$user->rights->adherent->creer;
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('subscription')); $hookmanager->initHooks(array('subscription'));
// PDF // PDF
@ -647,12 +647,8 @@ if ($rowid > 0)
} }
// Other attributes // Other attributes
$parameters=array('colspan'=>2); $cols=2;
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields, 'view', $parameters);
}
// Date end subscription // Date end subscription
print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">'; print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';

View File

@ -274,7 +274,7 @@ if ($rowid && $action != 'edit')
$head = subscription_prepare_head($object); $head = subscription_prepare_head($object);
dol_fiche_head($head, 'general', $langs->trans("Subscription"), '', 'payment'); dol_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment');
// Confirmation to delete subscription // Confirmation to delete subscription
if ($action == 'delete') if ($action == 'delete')

View File

@ -53,7 +53,17 @@ $result = $object->fetch($rowid);
$head = subscription_prepare_head($object); $head = subscription_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Subscription"), '', 'payment'); dol_fiche_head($head, 'info', $langs->trans("Subscription"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback, 1);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
$object->info($rowid); $object->info($rowid);
@ -64,5 +74,7 @@ print '</td></tr></table>';
print '</div>'; print '</div>';
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -42,18 +42,18 @@ $optioncss = GETPOST('optioncss','alpha');
$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"]; $date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; } if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $limit * $page ; $offset = $limit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) { $sortorder="DESC"; } if (! $sortorder) { $sortorder="DESC"; }
if (! $sortfield) { $sortfield="c.dateadh"; } if (! $sortfield) { $sortfield="c.dateadh"; }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('subscriptionlist')); $hookmanager->initHooks(array('subscriptionlist'));
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -123,7 +123,7 @@ $sql.= " b.fk_account";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
$sql.= " WHERE d.rowid = c.fk_adherent"; $sql.= " WHERE d.rowid = c.fk_adherent";
$sql.= " AND d.entity IN (".getEntity('adherent', 1).")"; $sql.= " AND d.entity IN (".getEntity('adherent').")";
if (isset($date_select) && $date_select != '') if (isset($date_select) && $date_select != '')
{ {
$sql.= " AND c.dateadh LIKE '".$date_select."%'"; $sql.= " AND c.dateadh LIKE '".$date_select."%'";

View File

@ -44,11 +44,11 @@ $search_email = GETPOST('search_email','alpha');
$type = GETPOST('type','alpha'); $type = GETPOST('type','alpha');
$status = GETPOST('status','alpha'); $status = GETPOST('status','alpha');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0; } if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page ; $offset = $limit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -79,7 +79,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter_x") || GETP
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membertypecard','globalcard')); $hookmanager->initHooks(array('membertypecard','globalcard'));
@ -173,7 +173,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql.= " WHERE d.entity IN (".getEntity().")"; $sql.= " WHERE d.entity IN (".getEntity('adherent').")";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -278,6 +278,7 @@ if ($action == 'create')
// Other attributes // Other attributes
$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;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print $object->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');
@ -337,13 +338,7 @@ if ($rowid > 0)
print nl2br($object->mail_valid)."</td></tr>"; print nl2br($object->mail_valid)."</td></tr>";
// Other attributes // Other attributes
$parameters=array(); include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
// View extrafields
print $object->showOptionals($extrafields);
}
print '</table>'; print '</table>';
print '</div>'; print '</div>';
@ -352,8 +347,9 @@ if ($rowid > 0)
/* /*
* Hotbar * Buttons
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Edit // Edit
@ -386,7 +382,7 @@ if ($rowid > 0)
$sql.= " t.libelle as type, t.subscription"; $sql.= " t.libelle as type, t.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE d.fk_adherent_type = t.rowid "; $sql.= " WHERE d.fk_adherent_type = t.rowid ";
$sql.= " AND d.entity IN (".getEntity().")"; $sql.= " AND d.entity IN (".getEntity('adherent').")";
$sql.= " AND t.rowid = ".$object->id; $sql.= " AND t.rowid = ".$object->id;
if ($sall) if ($sall)
{ {
@ -487,18 +483,8 @@ if ($rowid > 0)
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Nature"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
print "</tr>\n";
// Lignes des champs de filtre // Lignes des champs de filtre
print '<tr class="liste_titre">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>'; print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>';
@ -521,6 +507,16 @@ if ($rowid > 0)
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Nature"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
print "</tr>\n";
while ($i < $num && $i < $conf->liste_limit) while ($i < $num && $i < $conf->liste_limit)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
@ -650,9 +646,9 @@ if ($rowid > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("subscription",$object->subscription,1); print $form->selectyesno("subscription",$object->subscription,1);
@ -674,6 +670,11 @@ if ($rowid > 0)
// Other attributes // Other attributes
$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;
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
}
print '</table>'; print '</table>';

View File

@ -33,6 +33,7 @@ if (!$user->admin)
$langs->load("admin"); $langs->load("admin");
$langs->load("other"); $langs->load("other");
$langs->load("agenda");
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$cancel = GETPOST('cancel','alpha'); $cancel = GETPOST('cancel','alpha');

View File

@ -36,6 +36,7 @@ if (!$user->admin)
$langs->load("admin"); $langs->load("admin");
$langs->load("other"); $langs->load("other");
$langs->load("agenda");
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
@ -49,6 +50,8 @@ $type = 'action';
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_(.*)/',$action,$reg)) if (preg_match('/set_(.*)/',$action,$reg))
{ {
$code=$reg[1]; $code=$reg[1];
@ -77,21 +80,6 @@ if (preg_match('/del_(.*)/',$action,$reg))
dol_print_error($db); dol_print_error($db);
} }
} }
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action == 'set') if ($action == 'set')
{ {
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
@ -397,7 +385,7 @@ print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("AGENDA_DEFAULT_VIEW").'</td>'."\n"; print '<td>'.$langs->trans("AGENDA_DEFAULT_VIEW").'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n"; print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n"; print '<td align="right">'."\n";
$tmplist=array('show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_list'=>$langs->trans("ViewList"), 'show_peruser'=>$langs->trans("ViewPerUser")); $tmplist=array('show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW); print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -174,8 +174,8 @@ $message.='<br>';
print $message; print $message;
$message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>'; $message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
//$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>'; $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>'; $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login); $message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login);

View File

@ -39,6 +39,8 @@ $action = GETPOST('action','alpha');
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setbarcodeproducton') if ($action == 'setbarcodeproducton')
{ {
$res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", GETPOST('value'), 'chaine', 0, '', $conf->entity); $res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", GETPOST('value'), 'chaine', 0, '', $conf->entity);
@ -75,32 +77,6 @@ else if ($action == 'updateengine')
} }
// define constants for models generator that need parameters
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
}
}
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action && $action != 'setcoder' && $action != 'setModuleOptions') if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
{ {
if (! $res > 0) $error++; if (! $res > 0) $error++;

View File

@ -235,7 +235,7 @@ $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,";
$sql.= " bd.rowid as boxid"; $sql.= " bd.rowid as boxid";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
$sql.= " WHERE b.box_id = bd.rowid"; $sql.= " WHERE b.box_id = bd.rowid";
$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND b.entity IN (0,".$conf->entity.")";
$sql.= " AND b.fk_user=0"; $sql.= " AND b.fk_user=0";
$sql.= " ORDER by b.position, b.box_order"; $sql.= " ORDER by b.position, b.box_order";

View File

@ -77,7 +77,7 @@ if ($action == 'setmod')
if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
{ {
$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT'); // No alpha here, we want exact string $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
@ -274,7 +274,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else else
{ {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td><td align="right">'; print '</td><td align="right">';

View File

@ -54,6 +54,8 @@ $type = 'order';
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstorder=GETPOST('maskconstorder','alpha'); $maskconstorder=GETPOST('maskconstorder','alpha');
@ -118,35 +120,6 @@ else if ($action == 'specimen')
} }
} }
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -207,7 +180,7 @@ else if ($action == 'set_COMMANDE_DRAFT_WATERMARK')
else if ($action == 'set_ORDER_FREE_TEXT') else if ($action == 'set_ORDER_FREE_TEXT')
{ {
$freetext = GETPOST("ORDER_FREE_TEXT"); // No alpha here, we want exact string $freetext = GETPOST("ORDER_FREE_TEXT",'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
@ -586,7 +559,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else else
{ {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td><td align="right">'; print '</td><td align="right">';

View File

@ -148,7 +148,6 @@ print "</tr>\n";
foreach ($list as $key) foreach ($list as $key)
{ {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param

View File

@ -50,6 +50,8 @@ if (empty($conf->global->CONTRACT_ADDON))
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst = GETPOST('maskconstcontract','alpha'); $maskconst = GETPOST('maskconstcontract','alpha');
@ -113,35 +115,6 @@ else if ($action == 'specimen') // For contract
} }
} }
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Activate a model // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -185,7 +158,7 @@ else if ($action == 'setmod')
else if ($action == 'set_other') else if ($action == 'set_other')
{ {
$freetext= GETPOST('CONTRACT_FREE_TEXT'); // No alpha here, we want exact string $freetext= GETPOST('CONTRACT_FREE_TEXT','none'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
$draft= GETPOST('CONTRACT_DRAFT_WATERMARK','alpha'); $draft= GETPOST('CONTRACT_DRAFT_WATERMARK','alpha');
@ -501,7 +474,7 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true; $var=true;
$substitutionarray=pdf_getSubstitutionArray($langs); $substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'));
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
@ -520,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else else
{ {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes');
print $doleditor->Create(); print $doleditor->Create();
} }
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.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
@ -39,11 +40,11 @@ $action=GETPOST('action','alpha');
$mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' $mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus'
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0; } if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -60,6 +61,9 @@ $urlpage = GETPOST('urlpage');
$key = GETPOST('key'); $key = GETPOST('key');
$value = GETPOST('value'); $value = GETPOST('value');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admindefaultvalues','globaladmin'));
/* /*
* Actions * Actions
@ -182,29 +186,29 @@ $formadmin = new FormAdmin($db);
$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; $wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
llxHeader('',$langs->trans("Setup"),$wikihelp); llxHeader('',$langs->trans("Setup"),$wikihelp);
print load_fiche_titre($langs->trans("DefaultValues"),'','title_setup'); $param='&mode='.$mode;
print $langs->trans("DefaultValuesDesc")."<br>\n"; $enabledisablehtml.= $langs->trans("EnableDefaultValues").' ';
print "<br>\n";
print $langs->trans("EnableDefaultValues").' ';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
{ {
// Button off, click to enable // Button off, click to enable
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;value=1">'; $enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
print img_picto($langs->trans("Disabled"),'switch_off'); $enabledisablehtml.= img_picto($langs->trans("Disabled"),'switch_off');
print '</a>'; $enabledisablehtml.= '</a>';
} }
else else
{ {
// Button on, click to disable // Button on, click to disable
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;value=0">'; $enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
print img_picto($langs->trans("Activated"),'switch_on'); $enabledisablehtml.= img_picto($langs->trans("Activated"),'switch_on');
print '</a>'; $enabledisablehtml.= '</a>';
} }
print "<br><br>\n";
$param='&mode='.$mode; print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup');
print $langs->trans("DefaultValuesDesc")."<br>\n";
print "<br>\n";
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;
if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($optioncss != '') $param.='&optioncss='.$optioncss;
@ -264,22 +268,14 @@ if ($mode != 'focus')
{ {
if ($mode != 'sortorder') if ($mode != 'sortorder')
{ {
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
// See list into GETPOST foreach($substitutionarray as $key => $val)
$texthelp.='__USERID__<br>'; {
$texthelp.='__SUPERVISORID__<br>'; $texthelp.=$key.'<br>';
$texthelp.='__MYCOUNTRYID__<br>'; }
$texthelp.='__DAY__<br>'; $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
$texthelp.='__MONTH__<br>';
$texthelp.='__YEAR__<br>';
$texthelp.='__PREVIOUS_DAY__<br>';
$texthelp.='__PREVIOUS_MONTH__<br>';
$texthelp.='__PREVIOUS_YEAR__<br>';
$texthelp.='__NEXT_DAY__<br>';
$texthelp.='__NEXT_MONTH__<br>';
$texthelp.='__NEXT_YEAR__<br>';
if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__<br>';
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, '');
} }
else else
{ {

View File

@ -165,7 +165,7 @@ if ($action == 'edit')
$var=true; $var=true;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
foreach($modules as $module => $delays) foreach($modules as $module => $delays)
{ {
@ -178,7 +178,7 @@ if ($action == 'edit')
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20px">'.img_object('',$delay['img']).'</td>'; print '<td width="20px">'.img_object('',$delay['img']).'</td>';
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>'; print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
print '<input size="5" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>'; print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
} }
} }
} }
@ -189,11 +189,11 @@ if ($action == 'edit')
// Show if meteo is enabled // Show if meteo is enabled
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
$var=false; $var=false;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td>' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . '</td></tr>'; print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . '</td></tr>';
print '</table>'; print '</table>';
@ -211,7 +211,7 @@ else
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
$var=true; $var=true;
foreach($modules as $module => $delays) foreach($modules as $module => $delays)
@ -225,7 +225,7 @@ else
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20px">'.img_object('',$delay['img']).'</td>'; print '<td width="20px">'.img_object('',$delay['img']).'</td>';
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>'; print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
print '<td>'.$value.' '.$langs->trans("days").'</td></tr>'; print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>';
} }
} }
} }
@ -236,11 +236,11 @@ else
// Show if meteo is enabled // Show if meteo is enabled
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
$var=false; $var=false;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td>' . yn($conf->global->MAIN_DISABLE_METEO) . '</td></tr>'; print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">' . yn($conf->global->MAIN_DISABLE_METEO) . '</td></tr>';
print '</table>'; print '</table>';

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