Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into new_event_with_multi_contact

This commit is contained in:
phf 2017-07-05 11:02:39 +02:00
commit 49b8689f2d
1221 changed files with 35021 additions and 73599 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 #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr
#fi 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,8 +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: Big refactorization of multicompany transverse mode.
NEW: getEntity function use true $shared value by default NEW: getEntity function use true $shared value by default.
WARNING: WARNING:
@ -17,7 +17,9 @@ 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.
@ -25,6 +27,34 @@ Following changes may create regression for some external modules, but were nece
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 $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') * 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 ***** ***** 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: #6677 Expired contracts dashboard box does not show the name of the thirdparty

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

View File

@ -10,6 +10,8 @@ source-is-missing htdocs/includes/ckeditor/ckeditor/lang/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/dialogs/*.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/*/filter/*.js
source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/templates/templates/default.js source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/templates/templates/default.js
source-is-missing htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json
source-is-missing htdocs/includes/restler/framework/Luracast/Restler/explorer/lib/*.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

@ -85,9 +85,9 @@ 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

@ -591,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
@ -972,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 +1 @@
Files and tools were moved into htdocs/modulebuilder/skeletons Files and tools were moved into htdocs/modulebuilder/template

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

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

@ -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');
// Security access // Security access
if (! empty($user->rights->accountancy->chartofaccount)) if (! empty($user->rights->accountancy->chartofaccount))
@ -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,11 +1,11 @@
<?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>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* 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
@ -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
*/ */
@ -50,23 +50,26 @@ if (! empty($user->rights->accountancy->chartofaccount))
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$list_account_main = array (
'ACCOUNTING_ACCOUNT_CUSTOMER',
'ACCOUNTING_ACCOUNT_SUPPLIER',
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
);
$list_account = array ( $list_account = array (
'ACCOUNTING_ACCOUNT_SUPPLIER', 'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'ACCOUNTING_SERVICE_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'ACCOUNTING_VAT_BUY_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT', 'ACCOUNTING_VAT_SOLD_ACCOUNT',
'ACCOUNTING_SERVICE_SOLD_ACCOUNT', 'ACCOUNTING_VAT_PAY_ACCOUNT',
'ACCOUNTING_VAT_BUY_ACCOUNT', 'ACCOUNTING_ACCOUNT_SUSPENSE',
'ACCOUNTING_VAT_SOLD_ACCOUNT', 'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'ACCOUNTING_VAT_PAY_ACCOUNT', 'DONATION_ACCOUNTINGACCOUNT',
'ACCOUNTING_ACCOUNT_SUSPENSE', 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
'ACCOUNTING_ACCOUNT_TRANSFER_CASH', 'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
'DONATION_ACCOUNTINGACCOUNT', 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
); );
@ -94,7 +97,7 @@ if (GETPOST('change_chart'))
if ($action == 'update') { if ($action == 'update') {
$error = 0; $error = 0;
foreach ( $list_account as $constname ) { foreach ( $list_account_main as $constname ) {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
@ -102,6 +105,14 @@ if ($action == 'update') {
} }
} }
foreach ( $list_account as $constname ) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
if (! $error) { if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -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,16 +140,45 @@ 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%">'; print '<table class="noborder" width="100%">';
foreach ( $list_account as $key ) { 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%">';
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>
@ -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,7 +28,7 @@ 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');

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,7 +39,7 @@ $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');

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
); );

View File

@ -38,6 +38,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');
// Security access // Security access
if (! empty($user->rights->accountancy->chartofaccount)) if (! empty($user->rights->accountancy->chartofaccount))
@ -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
@ -321,8 +322,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 +342,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 +372,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,7 +70,7 @@ $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');
@ -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;
@ -100,10 +100,10 @@ if (! empty($search_accountancy_code_end)) {
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests 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_accountancy_code_start = ''; $search_accountancy_code_start = '';
$search_accountancy_code_end = ''; $search_accountancy_code_end = '';
$search_date_start = ''; $search_date_start = '';
$search_date_end = ''; $search_date_end = '';
} }
@ -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';
@ -122,11 +125,7 @@ if ($action == 'export_csv') {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
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;
@ -137,140 +136,137 @@ if ($action == 'export_csv') {
} }
else { else {
$title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : ''); $title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : '');
llxHeader('', $title_page); llxHeader('', $title_page);
// List // List
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$nbtotalofrecords = ''; $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter);
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if ($result < 0) {
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); setEventMessages($object->error, $object->errors, 'errors');
if ($nbtotalofrecords < 0) { }
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$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 '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; $moreforfilter = '';
$button = '<input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" />'; $moreforfilter .= '<div class="divsearchfield">';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); $moreforfilter .= $langs->trans('DateStart') . ': ';
$moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1);
$moreforfilter .= $langs->trans('DateEnd') . ': ';
$moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1);
$moreforfilter .= '</div>';
if (! empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</div>';
}
$moreforfilter = ''; print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">';
$moreforfilter .= '<div class="divsearchfield">'; print '<tr class="liste_titre_filter">';
$moreforfilter .= $langs->trans('DateStart') . ': '; print '<td class="liste_titre" colspan="5">';
$moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); print $langs->trans('From');
$moreforfilter .= $langs->trans('DateEnd') . ': '; print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
$moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); print ' ';
$moreforfilter .= '</div>'; print $langs->trans('to');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
if (! empty($moreforfilter)) { print '</td>';
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<td align="right" class="liste_titre">';
print $moreforfilter;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</div>';
}
print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">';
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="5">';
print $langs->trans('From');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
print ' ';
print $langs->trans('to');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
print '</td>';
print '<td align="right" class="liste_titre">';
$searchpicto=$form->showFilterAndCheckAddButtons(0); $searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
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);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
$total_debit = 0; $total_debit = 0;
$total_credit = 0; $total_credit = 0;
$sous_total_debit = 0; $sous_total_debit = 0;
$sous_total_credit = 0; $sous_total_credit = 0;
$displayed_account = ""; $displayed_account = "";
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
$link = ''; $link = '';
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account $description = $object->get_compte_desc($line->numero_compte); // Search description of the account
$root_account_description = $object->get_compte_racine($line->numero_compte); $root_account_description = $object->get_compte_racine($line->numero_compte);
if (empty($description)) { if (empty($description)) {
$link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>'; $link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Permet d'afficher le compte comptable // Permet d'afficher le compte comptable
if ($root_account_description != $displayed_account) { if ($root_account_description != $displayed_account) {
// Affiche un Sous-Total par compte comptable // Affiche un Sous-Total par compte comptable
if ($displayed_account != "") { if ($displayed_account != "") {
print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">' . price($sous_total_debit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit - $sous_total_debit) . '</td>'; print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">' . price($sous_total_debit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit - $sous_total_debit) . '</td>';
print "<td>&nbsp;</td>\n"; print "<td>&nbsp;</td>\n";
print '</tr>'; print '</tr>';
} }
// Affiche le compte comptable en d<>but de ligne // Affiche le compte comptable en d<>but de ligne
print "<tr>"; print "<tr>";
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">' . $root_account_description . '</td>'; print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">' . $root_account_description . '</td>';
print '</tr>'; print '</tr>';
$displayed_account = $root_account_description; $displayed_account = $root_account_description;
$sous_total_debit = 0; $sous_total_debit = 0;
$sous_total_credit = 0; $sous_total_credit = 0;
} }
// $object->get_compte_racine($line->numero_compte); // $object->get_compte_racine($line->numero_compte);
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . $description . '</td>'; print '<td>' . $description . '</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->credit - $line->debit) . '</td>'; print '<td align="right">' . price($line->credit - $line->debit) . '</td>';
print '<td align="center">' . $link; print '<td align="center">' . $link;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Comptabilise le sous-total // Comptabilise le sous-total
$sous_total_debit += $line->debit; $sous_total_debit += $line->debit;
$sous_total_credit += $line->credit; $sous_total_credit += $line->credit;
} }
print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">' . price($sous_total_debit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit - $sous_total_debit) . '</td>'; print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">' . price($sous_total_debit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit) . '</td><td class="nowrap" align="right">' . price($sous_total_credit - $sous_total_debit) . '</td>';
print "<td>&nbsp;</td>\n"; print "<td>&nbsp;</td>\n";
print '</tr>'; print '</tr>';
print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("AccountBalance") . ':</td><td class="nowrap" align="right">' . price($total_debit) . '</td><td class="nowrap" align="right">' . price($total_credit) . '</td><td class="nowrap" align="right">' . price($total_credit - $total_debit) . '</td>'; print '<tr class="liste_total"><td align="right" colspan="2">' . $langs->trans("AccountBalance") . ':</td><td class="nowrap" align="right">' . price($total_debit) . '</td><td class="nowrap" align="right">' . price($total_credit) . '</td><td class="nowrap" align="right">' . price($total_credit - $total_debit) . '</td>';
print "<td>&nbsp;</td>\n"; print "<td>&nbsp;</td>\n";
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";
print '</form>'; print '</form>';
llxFooter(); llxFooter();
} }
$db->close(); $db->close();

View File

@ -1,8 +1,8 @@
<?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>
* *
* 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,7 +1,7 @@
<?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>
* *
* 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
@ -16,43 +16,40 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/accountancy/bookkeeping/card.php * \file htdocs/accountancy/bookkeeping/card.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Page to show book-entry * \brief Page to show book-entry
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/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');
$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'));
@ -64,7 +61,7 @@ $update = GETPOST('update');
if (! empty($update)) { if (! empty($update)) {
$action = 'confirm_update'; $action = 'confirm_update';
} }
$object = new BookKeeping($db);
if ($action == "confirm_update") { if ($action == "confirm_update") {
$error = 0; $error = 0;
@ -77,13 +74,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,7 +94,7 @@ 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 {
@ -119,8 +117,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,7 +140,7 @@ 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 {
@ -154,14 +153,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');
} }
@ -170,57 +168,102 @@ else if ($action == "confirm_delete") {
} }
else if ($action == "confirm_create") { else if ($action == "confirm_create") {
$error = 0; $error = 0;
$book = new BookKeeping($db); $book = new BookKeeping($db);
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');
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
$book->label_compte = ''; $book->label_compte = '';
$book->debit = 0; $book->debit = 0;
$book->credit = 0; $book->credit = 0;
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
$book->doc_type = GETPOST('doc_type'); $book->doc_type = GETPOST('doc_type');
$book->piece_num = GETPOST('next_num_mvt'); $book->piece_num = GETPOST('next_num_mvt');
$book->doc_ref = GETPOST('doc_ref'); $book->doc_ref = GETPOST('doc_ref');
$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,0, $mode);
if ($result < 0) {
$result = $book->createStd($user); setEventMessages($book->error, $book->errors, 'errors');
if ($result < 0) { } else {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($langs->trans('Saved'), null, 'mesgs');
} else { $action = 'update';
setEventMessages($langs->trans('Saved'), null, 'mesgs'); $id=$book->id;
$action = ''; $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 {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = '';
}
}
if ($action == 'setjournal') {
$journaldoc = trim(GETPOST('code_journal'));
if (!empty($journaldoc)) {
$journaldoc='\''.$journaldoc.'\'';
}
$result = $object->updateByMvt($piece_num,'code_journal',$journaldoc,$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = '';
}
}
if ($action == 'setdocref') {
$refdoc = trim(GETPOST('doc_ref'));
if (!empty($refdoc)) {
$refdoc='\''.$refdoc.'\'';
}
$result = $object->updateByMvt(doc_ref,'code_journal',$refdoc,$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = '';
}
}
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(); llxHeader();
$html = new Form($db); $html = new Form($db);
$formaccountancy = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$accountjournal = new AccountingJournal($db);
/* // 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,15 +271,17 @@ 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');
}
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 +299,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,0,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 +310,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,7 +324,7 @@ 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');
} }
@ -290,59 +334,138 @@ if ($action == 'create') {
dol_fiche_head(); dol_fiche_head();
print '<div class="fichecenter">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// account movement
print '<tr class="pair">'; print '<tr class="pair">';
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 class="impair"><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 '<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>'; print '</tr>';
//journal
print '<tr class="pair">'; print '<tr class="pair"><td>';
print '<td>' . $langs->trans("Codejournal") . '</td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<td>'; print $langs->trans('Codejournal');
$accountingjournal = new AccountingJournal($db); print '</td>';
$accountingjournal->fetch('',$book->code_journal); if ($action != 'editjournal')
print $accountingjournal->getNomUrl(0,1,1,'',1); print '<a href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$book->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>';
print '</td></tr>'; print '</tr></table>';
print '</td><td>';
print '<tr class="impair">'; if ($action == 'editjournal') {
print '<td>' . $langs->trans("Docref") . '</td>'; print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<td>' . $book->doc_ref . '</td>'; 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>'; print '</tr>';
//docref
$typelabel = $book->doc_type; print '<tr class="impair"><td>';
if ($typelabel == 'bank') { print '<table class="nobordernopadding" width="100%"><tr><td>';
$typelabel = $langs->trans('Bank'); print $langs->trans('Docref');
} print '</td>';
if ($typelabel == 'customer_invoice') { if ($action != 'editdocref')
$typelabel = $langs->trans('CustomerInvoice'); print '<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>';
if ($typelabel == 'supplier_invoice') { print '</td><td>';
$typelabel = $langs->trans('SupplierInvoice'); if ($action == 'editdocref') {
} print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
if ($typelabel == 'expense_report') { print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
$typelabel = $langs->trans('ExpenseReport'); 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>';
//doctype
print '<tr class="pair">'; print '<tr class="pair">';
print '<td>' . $langs->trans("Doctype") . '</td>'; print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td>' . $typelabel . '</td>'; print '<td>' . $book->doc_type . '</td>';
print '</tr>'; 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%">';
// Validate
print '<tr class="pair">';
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 class="impair">';
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 "</table>\n";
print '</div>';
print '</div></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 +479,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 +490,51 @@ 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("Subledger_account"));
print_liste_field_titre($langs->trans("Labelcompte")); print_liste_field_titre($langs->trans("Labelcompte"));
print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Labeloperation"));
print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Amount"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="center"');
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); print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1);
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&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '&amp;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 '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '&amp;mode='.$mode.'">';
print img_delete(); print img_delete();
print '</a>';
print '</a>';
print '</td>'; print '</td>';
} }
print "</tr>\n"; print "</tr>\n";
@ -434,17 +551,21 @@ 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); print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1);
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="' . price($debit) . '"/></td>';
print '<td></td>'; print '<td align="right"><input type="text" size="6" name="credit" value="' . 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' && $total_debit == $total_credit && $action=='') {
print '<div class="tabsAction">';
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '&action=valid">'.$langs->trans("ValidTransaction").'</a>';
print "</div>";
}
print '</form>'; print '</form>';
} }
} }
@ -453,5 +574,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,35 @@ 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');
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>'; print '</div>';
print '<div class="nowrap">';
print $langs->trans('to'); print $langs->trans('to');
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
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 +423,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 +438,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 +448,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;';

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

@ -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,159 @@ 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 Category id
* @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);
@ -80,7 +82,7 @@ class AccountingJournal extends CommonObject
$this->code = $obj->code; $this->code = $obj->code;
$this->ref = $obj->code; $this->ref = $obj->code;
$this->label = $obj->label; $this->label = $obj->label;
$this->nature = $obj->nature; $this->nature = $obj->nature;
$this->active = $obj->active; $this->active = $obj->active;
return $this->id; return $this->id;
@ -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)
* *
@ -130,17 +200,17 @@ class AccountingJournal extends CommonObject
$linkclose=''; $linkclose='';
if (empty($notooltip)) if (empty($notooltip))
{ {
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{ {
$label=$langs->trans("ShowAccoutingJournal"); $label=$langs->trans("ShowAccoutingJournal");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"'; $linkclose.=' class="classfortooltip"';
} }
$linkstart='<a href="'.$url.'"'; $linkstart='<a href="'.$url.'"';
$linkstart.=$linkclose.'>'; $linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
if ($nourl) if ($nourl)
@ -162,43 +232,45 @@ class AccountingJournal extends CommonObject
/** /**
* Retourne le libelle du statut d'un user (actif, inactif) * Retourne le libelle du statut d'un user (actif, inactif)
* *
* @param int $mode 0=libelle long, 1=libelle court * @param int $mode 0=libelle long, 1=libelle court
* @return string Label of type * @return string Label of type
*/ */
function getLibType($mode=0) function getLibType($mode=0)
{ {
return $this->LibType($this->nature,$mode); return $this->LibType($this->nature,$mode);
} }
/** /**
* Return type of an accounting journal * Return type of an accounting journal
* *
* @param int $nature Id type * @param int $nature Id type
* @param int $mode 0=libelle long, 1=libelle court * @param int $mode 0=libelle long, 1=libelle court
* @return string Label of type * @return string Label of type
*/ */
function LibType($nature,$mode=0) function LibType($nature,$mode=0)
{ {
global $langs; global $langs;
$langs->load("accountancy"); $langs->load("accountancy");
if ($mode == 0) if ($mode == 0)
{ {
$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');
if ($nature == 1) return $langs->trans('AccountingJournalType1'); if ($nature == 1) return $langs->trans('AccountingJournalType1');
} }
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');
if ($nature == 1) return $langs->trans('AccountingJournalType1'); if ($nature == 1) return $langs->trans('AccountingJournalType1');
} }
} }
} }

File diff suppressed because it is too large Load Diff

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

View File

@ -1,9 +1,9 @@
<?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>
* *
* 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
@ -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';
@ -40,7 +40,7 @@ $langs->load("accountancy");
// Security check // Security check
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
@ -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,7 +137,7 @@ 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)) . "'";
@ -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%">';
@ -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);
@ -269,14 +265,14 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>'; print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; $sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
@ -293,25 +289,25 @@ 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);
while ( $row = $db->fetch_row($resql)) { while ( $row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>' . length_accountg($row[0]) . '</td>'; print '<tr class="oddeven"><td>' . length_accountg($row[0]) . '</td>';
print '<td align="left">' . $row[1] . '</td>'; print '<td align="left">' . $row[1] . '</td>';
for($i = 2; $i <= 12; $i ++) { for($i = 2; $i <= 12; $i ++) {
print '<td align="right">' . price($row[$i]) . '</td>'; print '<td align="right">' . price($row[$i]) . '</td>';
} }
print '<td align="right">' . price($row[13]) . '</td>'; print '<td align="right">' . price($row[13]) . '</td>';
print '<td align="right"><b>' . price($row[14]) . '</b></td>'; print '<td align="right"><b>' . price($row[14]) . '</b></td>';
print '</tr>'; print '</tr>';
} }
$db->free($resql); $db->free($resql);
} else { } else {
print $db->lasterror(); // Show last sql error print $db->lasterror(); // Show last sql error
} }
print "</table>\n"; print "</table>\n";
@ -319,101 +315,100 @@ print "</table>\n";
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
{ {
print '<br>'; print '<br>';
print '<br>'; print '<br>';
print_fiche_titre($langs->trans("OtherInfo"), '', ''); print_fiche_titre($langs->trans("OtherInfo"), '', '');
print "<br>\n"; print "<br>\n";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>'; print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>'; print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
} }
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>'; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate(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'); 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)) {
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>';
} }
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 { print $db->lasterror(); // Show last sql error
print $db->lasterror(); // Show last sql error }
} print "</table>\n";
print "</table>\n";
if (! empty($conf->margin->enabled)) {
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
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"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; if (! empty($conf->margin->enabled)) {
for($i = 1; $i <= 12; $i ++) { print "<br>\n";
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; print '<table class="noborder" width="100%">';
} print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; for($i = 1; $i <= 12; $i ++) {
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
$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)) . "'"; print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
$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
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
}
dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
$resql = $db->query($sql); for($i = 1; $i <= 12; $i ++) {
if ($resql) { $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
$num = $db->num_rows($resql); }
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$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 .= " 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
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
}
while ($row = $db->fetch_row($resql)) { dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
print '<tr><td>' . $row[0] . '</td>'; while ($row = $db->fetch_row($resql)) {
for($i = 1; $i <= 12; $i ++) {
print '<td align="right">' . price(price2num($row[$i])) . '</td>'; print '<tr><td>' . $row[0] . '</td>';
} for($i = 1; $i <= 12; $i ++) {
print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>'; print '<td align="right">' . price(price2num($row[$i])) . '</td>';
print '</tr>'; }
} print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>';
$db->free($resql); print '</tr>';
} else { }
print $db->lasterror(); // Show last sql error $db->free($resql);
} } else {
print "</table>\n"; print $db->lasterror(); // Show last sql error
} }
print "</table>\n";
}
} }

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');
@ -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');
@ -375,7 +375,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

@ -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,8 +131,9 @@ 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)) . "'";
@ -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,7 +199,7 @@ $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";
@ -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>';
@ -263,7 +263,7 @@ $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We d
$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,7 +307,7 @@ 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)) . "'";
@ -315,14 +315,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$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');
@ -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');
@ -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

@ -63,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";

View File

@ -50,6 +50,7 @@ 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->load("companies"); $langs->load("companies");
$langs->load("other"); $langs->load("other");
@ -60,6 +61,7 @@ $langs->load('donations');
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("trips"); $langs->load("trips");
$langs->load("salaries"); $langs->load("salaries");
$langs->load("hrm");
// Multi journal // Multi journal
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
@ -70,10 +72,10 @@ $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'); $action = GETPOST('action','alpha');
// Security check // Security check
if ($user->societe_id > 0 && empty($id_journal)) if ($user->societe_id > 0 && empty($id_journal))
@ -103,8 +105,7 @@ 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, ba.fk_accountancy_journal,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
@ -120,6 +121,8 @@ $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);
@ -132,6 +135,7 @@ $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
$accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic = new AccountingJournal($db);
@ -144,6 +148,7 @@ $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"));
@ -208,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', 'payment_donation', 'payment_salary'))) // 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'];
@ -250,9 +255,9 @@ if ($result) {
$sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
@ -285,6 +290,15 @@ if ($result) {
$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;
@ -353,7 +367,8 @@ 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);
@ -364,7 +379,7 @@ if (! $error && $action == 'writebookkeeping') {
$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";
@ -378,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";
@ -392,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";
@ -405,15 +420,18 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport
} }
} else if ($tabtype[$key] == 'payment_vat') { } else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment
} else if ($tabtype[$key] == 'payment_donation') { } else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
} else if ($tabtype[$key] == 'payment_salary') { } else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment $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);
@ -447,7 +465,7 @@ 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);
@ -458,7 +476,19 @@ if (! $error && $action == 'writebookkeeping') {
$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,8 +502,9 @@ 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 ";
@ -486,29 +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->numero_compte = $k; $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') { } else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat
} else if ($tabtype[$key] == 'payment_donation') { } else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->code_tiers = ''; $bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
} else if ($tabtype[$key] == 'payment_salary') { } else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment $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);
@ -537,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
}
} }
} }
@ -556,7 +612,6 @@ if (! $error && $action == 'writebookkeeping') {
} }
// Export // Export
/*
if ($action == 'export_csv') { if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
@ -565,165 +620,101 @@ 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) foreach ( $tabpay as $key => $val ) {
{ $date = dol_print_date($db->jdate($val["date"]), 'day');
$sep = ";";
foreach ( $tabpay as $key => $val ) { $reflabel = $val["ref"];
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); if ($reflabel == '(SupplierInvoicePayment)') {
$reflabel = $langs->trans('Supplier');
$reflabel = $val["ref"]; }
if ($reflabel == '(SupplierInvoicePayment)') { if ($reflabel == '(CustomerInvoicePayment)') {
$reflabel = $langs->trans('Supplier'); $reflabel = $langs->trans('Customer');
} }
if ($reflabel == '(CustomerInvoicePayment)') { if ($reflabel == '(SocialContributionPayment)') {
$reflabel = $langs->trans('Customer'); $reflabel = $langs->trans('SocialContribution');
} }
if ($reflabel == '(SocialContributionPayment)') { if ($reflabel == '(DonationPayment)') {
$reflabel = $langs->trans('SocialContribution'); $reflabel = $langs->trans('Donation');
} }
if ($reflabel == '(DonationPayment)') { if ($reflabel == '(SubscriptionPayment)') {
$reflabel = $langs->trans('Donation'); $reflabel = $langs->trans('Subscription');
} }
if ($reflabel == '(SubscriptionPayment)') { if ($reflabel == '(ExpenseReportPayment)') {
$reflabel = $langs->trans('Subscription'); $reflabel = $langs->trans('Employee');
}
if ($reflabel == '(ExpenseReportPayment)') {
$reflabel = $langs->trans('Employee');
}
$companystatic->id = $tabcompany[$key]['id'];
$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->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $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;
if ($companystatic->name == '') { print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans('Bank') . " - " . utf8_decode($val["ref"]) . '"' . $sep; print " " . $sep;
} else { if ($companystatic->name == '') {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . $langs->trans('Bank') . " - " . utf8_decode($reflabel) . '"' . $sep;
}
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
}
// Third party
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print '"' . $journal . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
if ($companystatic->name == '') {
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($val["ref"]) . '"' . $sep;
} else {
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
}
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
}
}
} else { } else {
foreach ( $tabbq[$key] as $k => $mt ) { print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
}
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
}
// Third party
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print '"' . $journal . '"' . $sep; print '"' . $journal . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
if ($companystatic->name == '') {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($val["ref"]) . '"' . $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 { } else {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
}
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
if ($companystatic->name == '') {
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep;
} else {
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
} }
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n"; print "\n";
} }
} }
} else {
foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . $journal . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
print " " . $sep;
if ($companystatic->name == '') {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($reflabel) . '"' . $sep;
} else {
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
}
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
}
} }
} }
} }
*/
/* /*
@ -739,6 +730,7 @@ if (empty($action) || $action == 'view') {
$vatstatic = new Tva($db); $vatstatic = new Tva($db);
$donationstatic = new Don($db); $donationstatic = new Don($db);
$salarystatic = new PaymentSalary($db); $salarystatic = new PaymentSalary($db);
$variousstatic = new PaymentVarious($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
@ -746,7 +738,7 @@ if (empty($action) || $action == 'view') {
$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_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;
@ -758,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
@ -821,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')
@ -907,7 +903,20 @@ if (empty($action) || $action == 'view') {
} }
else dol_print_error($db); 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"];

View File

@ -52,6 +52,7 @@ $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();
@ -86,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");
@ -128,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;
@ -142,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
); );
@ -163,6 +172,7 @@ if ($action == 'writebookkeeping') {
$db->begin(); $db->begin();
// Thirdparty
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
@ -175,8 +185,9 @@ 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';
@ -205,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);
@ -222,8 +233,9 @@ 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';
@ -253,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) {
@ -267,8 +279,9 @@ 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';
@ -304,6 +317,12 @@ if ($action == 'writebookkeeping') {
else else
{ {
$db->rollback(); $db->rollback();
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
}
} }
} }
@ -450,7 +469,7 @@ if (empty($action) || $action == 'view') {
$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);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;
@ -462,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>';
@ -553,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>";
@ -576,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("subledger_account") . "</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@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>
* *
@ -51,6 +51,7 @@ $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();
@ -85,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);
@ -114,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");
@ -129,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;
@ -139,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 . ')';
@ -202,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"];
@ -214,9 +223,11 @@ 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("subledger_account");
$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;
@ -261,8 +272,10 @@ 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';
@ -306,8 +319,10 @@ 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';
@ -343,6 +358,12 @@ if ($action == 'writebookkeeping') {
else else
{ {
$db->rollback(); $db->rollback();
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
}
} }
} }
@ -367,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 == 'export_csv') {
$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;
@ -450,44 +417,60 @@ $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') {
@ -506,7 +489,7 @@ 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);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;
@ -518,8 +501,19 @@ 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
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; 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("ExportDraftJournal") . '" onclick="launch_export();" />';
print '</div>'; print '</div>';
print ' print '
@ -612,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>";
@ -635,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("subledger_account") . "</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

@ -1,13 +1,13 @@
<?php <?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* 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 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.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>
* *
* 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
@ -46,7 +46,7 @@ $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','aZ09'); $action = GETPOST('action','alpha');
$date_startmonth = GETPOST('date_startmonth'); $date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday'); $date_startday = GETPOST('date_startday');
@ -54,6 +54,7 @@ $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();
@ -89,31 +90,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);
@ -127,29 +129,34 @@ 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;
if (empty($compta_prod)) { if (empty($compta_prod)) {
if ($obj->product_type == 0) if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
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);
@ -231,10 +238,11 @@ 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("subledger_account");
$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;
@ -277,9 +285,11 @@ 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;
@ -321,9 +331,11 @@ 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;
@ -358,6 +370,12 @@ if ($action == 'writebookkeeping') {
else else
{ {
$db->rollback(); $db->rollback();
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
}
} }
} }
@ -386,76 +404,18 @@ if ($action == 'writebookkeeping') {
$form = new Form($db); $form = new Form($db);
// Export // Export
/*if ($action == 'export_csv') { if ($action == 'export_csv') {
$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 foreach ( $tabfac as $key => $val ) {
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 ) {
$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'];
@ -466,13 +426,19 @@ $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 '"' . $date . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
print "\n"; 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 '"' . $sell_journal . '"' ;
print "\n";
} }
// Product / Service // Product / Service
@ -480,33 +446,48 @@ $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 '"' . $date . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print "\n"; 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 '"' . $sell_journal . '"' ;
print "\n";
} }
} }
// VAT // VAT
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
print '"' . $date . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep; print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print "\n"; 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 '"' . $sell_journal . '"' ;
print "\n";
} }
} }
}
} }
} }
*/
if (empty($action) || $action == 'view') { if (empty($action) || $action == 'view') {
@ -524,19 +505,25 @@ 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);
$varlink = 'id_journal=' . $id_journal; $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);
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { // Button to write into Ledger
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>'; if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
} else { print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
}*/ }
print '<div class="tabsAction">'; print '<div class="tabsAction tabsActionNoBottom">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; 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("ExportDraftJournal") . '" onclick="launch_export();" />';
print '</div>'; print '</div>';
print ' print '
@ -565,7 +552,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";
@ -591,7 +578,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')
@ -602,7 +588,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("subledger_account") . "</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>";
@ -649,7 +635,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";
}
// 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"; 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>

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,7 +133,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_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)) . "'";
@ -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,7 +195,7 @@ $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";
@ -208,7 +206,7 @@ $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We d
$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,7 +249,7 @@ $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";
@ -262,7 +260,7 @@ $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We d
$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,7 +304,7 @@ 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)) . "'";
@ -314,7 +312,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$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 .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " , " . MAIN_DB_PREFIX . "facture_fourn_det as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $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,6 +188,12 @@ 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);
} }
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 .= " 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');
@ -381,7 +381,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,6 +943,7 @@ 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');
@ -1185,6 +1186,7 @@ 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',$parameters); print $object->showOptionals($extrafields,'edit',$parameters);

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;
} }

View File

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

@ -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,7 +66,7 @@ $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');
@ -73,7 +77,7 @@ $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
@ -212,7 +224,7 @@ if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_ca
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').")"; $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,21 +846,14 @@ 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 '&nbsp;'; print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
if ($user->rights->adherent->supprimer && $obj->statut == -1) }
{ print '</td>';
print "<a href=\"card.php?rowid=".$obj->rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png')."</a>"; if (! $i) $totalarray['nbfield']++;
}
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']++;
print "</tr>\n"; print "</tr>\n";
$i++; $i++;

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

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);

View File

@ -44,7 +44,7 @@ $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');
@ -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');
@ -380,7 +381,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)
{ {
@ -668,6 +669,7 @@ 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)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print $object->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');

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');

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

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

@ -559,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

@ -493,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,7 +40,7 @@ $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');
@ -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;

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>';

View File

@ -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');
$allowed=$user->admin; $allowed=$user->admin;
if ($id == 7 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Tax page allowed to manager of chart account if ($id == 7 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Tax page allowed to manager of chart account
@ -72,7 +73,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 @@ $pagenext = $page + 1;
$search_country_id = GETPOST('search_country_id','int'); $search_country_id = GETPOST('search_country_id','int');
$search_code = GETPOST('search_code','alpha'); $search_code = GETPOST('search_code','alpha');
// 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
@ -502,6 +503,14 @@ $tabfieldcheck[34] = array();
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);
// Defaut sortorder
if (empty($sortfield))
{
$tmp1 = explode(',',$tabsqlsort[$id]);
$tmp2 = explode(' ',$tmp1[0]);
$sortfield=preg_replace('/^.*\./', '', $tmp2[0]);
}
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array(); $elementList = array();
$sourceList=array(); $sourceList=array();
@ -808,8 +817,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='".dol_escape_htmltag($_GET["code"])."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -828,8 +837,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='".dol_escape_htmltag($_GET["code"])."'"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -848,8 +857,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='".dol_escape_htmltag($_GET["code"])."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -868,8 +877,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='".dol_escape_htmltag($_GET["code"])."'"; $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
@ -930,7 +939,7 @@ if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
// 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.'&':'').'rowid='.$rowid.'&code='.urlencode($_GET["code"]).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'rowid='.$rowid.'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
} }
//var_dump($elementList); //var_dump($elementList);
@ -944,7 +953,8 @@ if ($id)
if (! preg_match('/ WHERE /',$sql)) $sql.= " WHERE 1 = 1"; if (! preg_match('/ WHERE /',$sql)) $sql.= " WHERE 1 = 1";
if ($search_country_id > 0) $sql.= " AND c.rowid = ".$search_country_id; if ($search_country_id > 0) $sql.= " AND c.rowid = ".$search_country_id;
if ($search_code != '') $sql.= natural_search("code", $search_code); if ($search_code != '' && $id != 9) $sql.= natural_search("code", $search_code);
if ($search_code != '' && $id == 9) $sql.= natural_search("code_iso", $search_code);
if ($sortfield) if ($sortfield)
{ {
@ -1493,9 +1503,12 @@ if ($id)
} }
$class='tddict'; $class='tddict';
if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200';
if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto';
if ($fieldlist[$field] == 'code') $class.=' width100'; if ($fieldlist[$field] == 'code') $class.=' width100';
if ($fieldlist[$field] == 'position') $class.=' right'; if ($fieldlist[$field] == 'position') $class.=' right';
if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap';
if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap';
// Show value for field // Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>'; if ($showfield) print '<!-- '.$fieldlist[$field].' --><td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
} }
@ -1685,7 +1698,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
} // For state page, we do not show the country input (we link to region, not country) } // For state page, we do not show the country input (we link to region, not country)
print '<td>'; print '<td>';
$fieldname='country'; $fieldname='country';
print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone');
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'country_id') elseif ($fieldlist[$field] == 'country_id')
@ -1811,7 +1824,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
{ {
$fieldname = $fieldlist[$field]; $fieldname = $fieldlist[$field];
$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
} }
else else
{ {

View File

@ -493,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

@ -497,7 +497,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

@ -731,7 +731,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

@ -525,7 +525,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">';
@ -559,6 +559,7 @@ print '/>';
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n"; print "</td></tr>\n";
print '</form>';
// Use services duration // Use services duration
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';

View File

@ -29,7 +29,7 @@ $langs->load("companies");
if (!$user->admin) accessforbidden(); if (!$user->admin) 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('homesetup')); $hookmanager->initHooks(array('homesetup'));
@ -70,13 +70,13 @@ if (! empty($conf->global->MAIN_MOTD_SETUPPAGE))
print $langs->trans("SetupDescription1").' '; print $langs->trans("SetupDescription1").' ';
print $langs->trans("AreaForAdminOnly").' '; print $langs->trans("AreaForAdminOnly").' ';
print $langs->trans("SetupDescription2")."<br><br>"; print $langs->trans("SetupDescription2", $langs->trans("MenuCompanySetup"), $langs->trans("Modules"))."<br><br>";
print '<br>'; print '<br>';
// Show info setup company // Show info setup company
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1;
print img_picto('','puce').' '.$langs->trans("SetupDescription3",DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit')); print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->trans("Setup"), $langs->trans("MenuCompanySetup"));
if (! empty($setupcompanynotcomplete)) if (! empty($setupcompanynotcomplete))
{ {
$langs->load("errors"); $langs->load("errors");
@ -88,7 +88,7 @@ print '<br>';
print '<br>'; print '<br>';
// Show info setup module // Show info setup module
print img_picto('','puce').' '.$langs->trans("SetupDescription4",DOL_URL_ROOT.'/admin/modules.php?mainmenu=home'); print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->trans("Setup"), $langs->trans("Modules"));
if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled
{ {
$langs->load("errors"); $langs->load("errors");

View File

@ -100,7 +100,7 @@ $form=new Form($db);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup")); dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"), -1);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';

View File

@ -107,7 +107,7 @@ if (! function_exists("ldap_connect"))
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
dol_fiche_head($head, 'contacts', $langs->trans("LDAPSetup")); dol_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescContact").'<br>'; print $langs->trans("LDAPDescContact").'<br>';

View File

@ -96,7 +96,7 @@ if (! function_exists("ldap_connect"))
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
} }
dol_fiche_head($head, 'groups', $langs->trans("LDAPSetup")); dol_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescGroups").'<br>'; print $langs->trans("LDAPDescGroups").'<br>';

View File

@ -126,7 +126,7 @@ if (! function_exists("ldap_connect"))
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head($head, 'members', $langs->trans("LDAPSetup")); dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescMembers").'<br>'; print $langs->trans("LDAPDescMembers").'<br>';

View File

@ -113,7 +113,7 @@ print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head($head, 'users', $langs->trans("LDAPSetup")); dol_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescUsers").'<br>'; print $langs->trans("LDAPDescUsers").'<br>';
print '<br>'; print '<br>';

View File

@ -474,7 +474,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

@ -673,6 +673,7 @@ else
// Show email send test form // Show email send test form
if ($action == 'test' || $action == 'testhtml') if ($action == 'test' || $action == 'testhtml')
{ {
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend")); print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend"));
// Cree l'objet formulaire mail // Cree l'objet formulaire mail

View File

@ -50,6 +50,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');
$search_label=GETPOST('search_label','alpha');
$allowed=$user->admin; $allowed=$user->admin;
if (! $allowed) accessforbidden(); if (! $allowed) accessforbidden();
@ -66,22 +67,18 @@ $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;
// 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('emailtemplates')); $hookmanager->initHooks(array('emailtemplates'));
// Name of SQL tables of dictionaries // Name of SQL tables of dictionaries
$tabname=array(); $tabname=array();
$tabname[25]= MAIN_DB_PREFIX."c_email_templates"; $tabname[25]= MAIN_DB_PREFIX."c_email_templates";
// Requests to extract data
$tabsql=array();
$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")";
// Criteria to sort dictionaries // Criteria to sort dictionaries
$tabsqlsort=array(); $tabsqlsort=array();
$tabsqlsort[25]="label ASC"; $tabsqlsort[25]="label ASC";
@ -173,211 +170,223 @@ $id = 25;
* Actions * Actions
*/ */
if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) if (GETPOST('cancel')) { $action='list'; $massaction=''; }
{ if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
//$search_country_id = '';
}
// Actions add or modify an entry into a dictionary $parameters=array();
if (GETPOST('actionadd') || GETPOST('actionmodify')) $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
{ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
$listfieldinsert=explode(',',$tabfieldinsert[$id]);
$listfieldmodify=explode(',',$tabfieldinsert[$id]);
$listfieldvalue=explode(',',$tabfieldvalue[$id]);
// Check that all fields are filled if (empty($reshook))
$ok=1; {
foreach ($listfield as $f => $value) // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{ {
if ($value == 'content') continue; $search_label='';
if ($value == 'content_lines') continue; $toselect='';
if ($value == 'content') $value='content-'.$rowid; $search_array_options=array();
if ($value == 'content_lines') $value='content_lines-'.$rowid;
if (! isset($_POST[$value]) || $_POST[$value]=='')
{
$ok=0;
$fieldnamekey=$listfield[$f];
// We take translate key of field
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
} }
// Si verif ok et action add, on ajoute la ligne // Actions add or modify an entry into a dictionary
if ($ok && GETPOST('actionadd')) if (GETPOST('actionadd') || GETPOST('actionmodify'))
{ {
if ($tabrowid[$id]) $listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
$listfieldinsert=explode(',',$tabfieldinsert[$id]);
$listfieldmodify=explode(',',$tabfieldinsert[$id]);
$listfieldvalue=explode(',',$tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
foreach ($listfield as $f => $value)
{ {
// Recupere id libre pour insertion if ($value == 'content') continue;
$newid=0; if ($value == 'content_lines') continue;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; if ($value == 'content') $value='content-'.$rowid;
$result = $db->query($sql); if ($value == 'content_lines') $value='content_lines-'.$rowid;
if ($result)
if (! isset($_POST[$value]) || $_POST[$value]=='')
{ {
$obj = $db->fetch_object($result); $ok=0;
$newid=($obj->newid + 1); $fieldnamekey=$listfield[$f];
// We take translate key of field
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
} else { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
dol_print_error($db);
} }
} }
// Add new entry // Si verif ok et action add, on ajoute la ligne
$sql = "INSERT INTO ".$tabname[$id]." ("; if ($ok && GETPOST('actionadd'))
// List of fields {
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) if ($tabrowid[$id])
$sql.= $tabrowid[$id].","; {
$sql.= $tabfieldinsert[$id]; // Recupere id libre pour insertion
$sql.=",active)"; $newid=0;
$sql.= " VALUES("; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
// List of values } else {
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) dol_print_error($db);
$sql.= $newid.","; }
$i=0;
foreach ($listfieldinsert as $f => $value)
{
//var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql.=",";
if ($value == 'private' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='0';
if ($value == 'position' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='1';
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
dol_syslog("actionadd", LOG_DEBUG); // Add new entry
$result = $db->query($sql); $sql = "INSERT INTO ".$tabname[$id]." (";
if ($result) // Add is ok // List of fields
{ if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); $sql.= $tabrowid[$id].",";
$_POST=array('id'=>$id); // Clean $_POST array, we keep only $sql.= $tabfieldinsert[$id];
} $sql.=",active)";
else $sql.= " VALUES(";
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { // List of values
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
$sql.= $newid.",";
$i=0;
foreach ($listfieldinsert as $f => $value)
{
//var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($value == 'private' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='0';
if ($value == 'position' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='1';
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
} }
else { $sql.=",1)";
dol_print_error($db);
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
}
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
}
else {
dol_print_error($db);
}
}
}
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
{
if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid];
if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
if ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
{
setEventMessages($db->error(), null, 'errors');
} }
} }
} }
// Si verif ok et action modify, on modifie la ligne if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($ok && GETPOST('actionmodify'))
{ {
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; } else { $rowidcol="rowid"; }
// Modify entry $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
{
if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid];
if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid];
if ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
//print $sql; $result = $db->query($sql);
$resql = $db->query($sql); if (! $result)
if (! $resql)
{ {
setEventMessages($db->error(), null, 'errors'); if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
}
else
{
dol_print_error($db);
}
} }
} }
}
if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate
{ if ($action == $acts[0])
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
{ {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
{ else { $rowidcol="rowid"; }
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
} }
else elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
}
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
}
$result = $db->query($sql);
if (!$result)
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($_GET["code"]) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'";
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
}
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($_GET["code"]) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'";
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
}
/* /*
* View * View
@ -412,12 +421,15 @@ dol_fiche_head($head, 'templates', '', -1);
// 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);
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id]; $sql="SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active";
$sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates";
$sql.=" WHERE entity IN (".getEntity('email_template').")";
if ($search_label) $sql.=natural_search('label', $search_label);
if ($search_country_id > 0) if ($search_country_id > 0)
{ {
@ -572,9 +584,19 @@ if ($action != 'edit')
$colspan=count($fieldlist)+1; $colspan=count($fieldlist)+1;
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height //print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
} }
print '</table>';
print '</form>';
print '<br>';
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
print '<table class="noborder" width="100%">';
// List of available record in database // List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG); dol_syslog("htdocs/admin/dict", LOG_DEBUG);
@ -599,8 +621,26 @@ if ($resql)
print '</td></tr>'; print '</td></tr>';
} }
// Title line with search boxes
print '<tr class="liste_titre">';
$filterfound=0;
foreach ($fieldlist as $field => $value)
{
if ($value == 'label') print '<td class="liste_titre"><input type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
}
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
// Action column
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
// Title of lines // Title of lines
print '<tr class="liste_titre'.($action != 'edit' ? ' liste_titre_add' : '').'">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
@ -642,18 +682,6 @@ if ($resql)
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
// Title line with search boxes
print '<tr class="liste_titre">';
$filterfound=0;
foreach ($fieldlist as $field => $value)
{
if (! in_array($field, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
}
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '</tr>';
if ($num) if ($num)
{ {
// Lines with values // Lines with values

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