Merge branch 'develop' of github.com:atm-maxime/dolibarr into new_modimport_update_option

This commit is contained in:
Maxime Kohlhaas 2016-11-06 11:36:08 +01:00
commit e5418a7624
2598 changed files with 53604 additions and 85561 deletions

View File

@ -38,7 +38,6 @@ jQuery UI 1.11.4 GPL and MIT License Yes
jQuery select2 3.5.2 GPL and Apache License Yes JS library plugin for sexier multiselect jQuery select2 3.5.2 GPL and Apache License Yes JS library plugin for sexier multiselect
jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups)
jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors
jQuery DataTables 1.9.4 BSD Yes JS library for tables output
jQuery FileUpload 5.0.3 GPL and MIT License Yes JS library to upload files jQuery FileUpload 5.0.3 GPL and MIT License Yes JS library to upload files
jQuery Flot 0.8.3 MIT License Yes JS library to build graph jQuery Flot 0.8.3 MIT License Yes JS library to build graph
jQuery JCrop 0.9.8 GPL and MIT License Yes JS library plugin Crop (to crop images) jQuery JCrop 0.9.8 GPL and MIT License Yes JS library plugin Crop (to crop images)

View File

@ -32,33 +32,75 @@ check you make a fetch on object before calling the delete.
- The form to add a product to a draft proposal/order/invoice from the product card is hidden by default. - The form to add a product to a draft proposal/order/invoice from the product card is hidden by default.
It was not commonly used and usage generates some problems (cost price for margin calculation not entered, vat setting). It was not commonly used and usage generates some problems (cost price for margin calculation not entered, vat setting).
Set constant PRODUCT_ADD_FORM_ADD_TO to retrieve it. Set constant PRODUCT_ADD_FORM_ADD_TO to retrieve it.
- The javascript "datatables" library was used to be provided into Dolibarr sources, but it was not used by application.
So there is no reason to maintain its compatibility with other dolibarr components. If an external module need this
library, this external module must embed hte library in his own sources/packages.
- Trigger name SUPPLIER_PROPOSAL_CREATE has been renamed into PROPOSAL_SUPPLIER_CREATE
- A new paramater sqlfilters was introduced to allow filter on any fields int the REST API. Few old parameters
no more required were also removed. Use this new one if you ware using one of them.
- Method commande->deleteline($lindeid) has been replaced with commande->deleteline($user, $lineid).
***** ChangeLog for 4.0.2 compared to 4.0.1 *****
FIX: #5340
FIX: #5779
FIX: #5849
FIX: #5866
FIX: #5907
FIX: Addline if $txlocaltax1 is empty
FIX: Avoid error 500 if phpexcel is disabled
FIX: Avoid errors on debian
FIX: Can edit the customer ref even if order is not draft.
FIX: Documents not moved in new directory if we change reference of the task.
FIX: Error when CATEGORIE_RECURSIV_ADD is enabled and new category is child of an already linked to object
FIX: Extra fields of task not copied on project cloning
FIX: Hidden option PRODUCT_MAX_VISIBLE_PHOTO
FIX: Link on supplier invoice in widget was not clickable
FIX: margin tab on customer card must filter on current entity invoices
FIX: missing column into SQL on thirdparty list
FIX: Nber of attached files were not reported in event report of email sent
FIX: only show projects of related third if external user
FIX: Search provider by price
FIX: Solve backup when using mysqldump that return warning
FIX: Sql error in widget of product for stock alerts
FIX: updateligne if $txlocaltax1 is null
***** ChangeLog for 4.0.1 compared to 4.0.0 ***** ***** ChangeLog for 4.0.1 compared to 4.0.0 *****
FIX #2853 FIX: #2853
FIX #2991 FIX: #2991
FIX #3128 FIX: #3128
FIX: #5699 FIX: #5699
FIX #5734 FIX: #5734
FIX: #5742 error on project list if an extra field separator is added.
FIX: #5746 chrome php Try a fix. Not sure it solved all problems reported
FIX: #5748 Bug: Error updating to 4.0.1 with Postgresql. Field must be varchar.
FIX: #5750 Bug: CmailFile::server_parse enters an infinite loop if $server_response is false
FIX: #5752 Bug VAT NPR not propagated during proposal cloning
FIX: #5763 Bug: Cannot Create Supplier Price Request
FIX: #5770 Dolibarr doesn't modify correctly the hour of a task
FIX: #5776 FIX: #5776
FIX alignement of intervention status FIX: #5802 Incoterms not set
FIX Clean of search fields FIX: #5813 Bug: Incoterms not being read correctly
FIX Creation of donation should go back on card after creation FIX: #5818
FIX Date visible on project overview FIX: alignement of intervention status
FIX Execute a dedicated job from its id may results of launching other jobs too. FIX: Clean of search fields
FIX: Creation of donation should go back on card after creation
FIX: Date visible on project overview
FIX: Execute a dedicated job from its id may results of launching other jobs too.
FIX: Failed to export contact categories with contact extra fields FIX: Failed to export contact categories with contact extra fields
FIX inversion customer/supplier price FIX: inversion customer/supplier price
FIX link "back to list" was not visible. FIX: link "back to list" was not visible.
FIX Lost filter on opportunities FIX: Lost filter on opportunities
FIX Mandatory field payment term was not css highlighted. FIX: Mandatory field payment term was not css highlighted.
FIX Menu users not visible on dolidroid. FIX: Menu users not visible on dolidroid.
FIX SEC for HTB23302 FIX: SEC for HTB23302
FIX The email test sender in email setup was broken FIX: The email test sender in email setup was broken
FIX Translation of "Name" is not a good choice for floow-up. FIX: Translation of "Name" is not a good choice for floow-up.
FIX Update of maxnbrun on job list failed. FIX: Update of maxnbrun on job list failed.
FIX Value of payment term and project are not set on correct default value when invoice generated from template. FIX: Value of payment term and project are not set on correct default value when invoice generated from template.
FIX: vat dictionary should allow enter and edit multiple values for localtaxes, separated by: (ex -19:-15) FIX: vat dictionary should allow enter and edit multiple values for localtaxes, separated by: (ex -19:-15)
FIX: Vat not visible in dictionnary
***** ChangeLog for 4.0.0 compared to 3.9.* ***** ***** ChangeLog for 4.0.0 compared to 3.9.* *****
For users: For users:

View File

@ -3,7 +3,7 @@ FROM php:5.6-apache
RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \ RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd && docker-php-ext-install gd \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install ldap \ && docker-php-ext-install ldap \
&& docker-php-ext-install mysqli \ && docker-php-ext-install mysqli \

View File

@ -147,7 +147,7 @@ These are features that Dolibarr does **not** yet fully support:
## DOCUMENTATION ## DOCUMENTATION
Administrator, user, developer and translator's documentations are available along with other community resources on the [Wiki](http://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

View File

@ -154,8 +154,10 @@ tag 729538 -moreinfo
##### Testing a package into unstable env ##### Testing a package into unstable env
Check you have a mysql server available from another interface than "localhost". Check you have a mysql server available from another interface than "localhost".
Comment line in /etc/mysql/my.cnf if required and restart mysql Set line in /etc/mysql/my.cnf if required and restart mysql
#bind-address = 127.0.0.1
[mysqld]
bind-address = *
Create a chroot called "unstable-amd64-sbuild". Create a chroot called "unstable-amd64-sbuild".
Chroot env is stored into /srv/chroot directory. Chroot env is stored into /srv/chroot directory.
@ -170,6 +172,8 @@ Puis pour se connecter et préparer l'environnement
> schroot -c name_of_chroot > schroot -c name_of_chroot
> cat /etc/debian_chroot to check which debian branch we are into > cat /etc/debian_chroot to check which debian branch we are into
> 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 upgrade
> apt-get install links mysql-client > apt-get install links mysql-client
To test a package To test a package
@ -185,7 +189,7 @@ To test a package
If there is a problem launching apache, because port is already used, change it into your chroot install with If there is a problem launching apache, because port is already used, change it into your chroot install with
> vi /etc/apache2/ports.conf > vi /etc/apache2/ports.conf
Then restart. Then restart.
Then you can call/test dolibarr with http://localhost:port/dolibarr/ (It can be also called from host). Then you can call/test dolibarr with http://localhost:port/dolibarr/ . It can be also called FROM HOST (port must be a not used port on host).
@ -291,13 +295,18 @@ If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VER
* Edit orig.tar.gz file to remove * Edit orig.tar.gz file to remove
- debian - debian
- htdocs/includes/ckeditor - htdocs/includes/ckeditor
- htdocs/includes/jszip
- htdocs/includes/jquery/plugins/datatables
- htdocs/includes/mike42
- htdocs/includes/phpexcel or htdocs/includes/phpoffice - htdocs/includes/phpexcel or htdocs/includes/phpoffice
- htdocs/includes/tcpdf or htdocs/includes/tecnickom - htdocs/includes/swiftmailer
- htdocs/includes/restler/framework/Luracast/Restler/explorer
- htdocs/includes/tcpdf or htdocs/includes/tecnickcom
And rename file into And rename file into
dolibarr-x.y.z+dfsgw.tgz dolibarr-x.y.z+dfsgw.tgz
(x.y.z = version, w start from 1 and is increased for each new git-import-orig already done) (x.y.z = version, w start from 1 and is increased for each new git-import-orig already done)
* Staying into git root directory, run * Staying into projet gitted root directory, run
> git-import-orig -vv ../dolibarr-x.y.z+dfsgw.tgz --debian-branch=[master|jessie] --upstream-branch=[upstream|upstream-3.5.x] > git-import-orig -vv ../dolibarr-x.y.z+dfsgw.tgz --debian-branch=[master|jessie] --upstream-branch=[upstream|upstream-3.5.x]
and enter version when requested with format and enter version when requested with format
x.y.z+dfsgw x.y.z+dfsgw
@ -324,7 +333,7 @@ To update dolibarr debian package when only files into debian has changed:
To update dolibarr debian package when only files not into debian has changed: To update dolibarr debian package when only files not into debian has changed:
* Manually, add patches into debian/patches and update file debian/series, or do the 2 steps with "quilt import filepatch.patch" * Manually, add patches into debian/patches and update file debian/series, or do the 2 steps with "quilt import filepatch.patch"
* You can test patching of serie with "quilt push" (autant de fois que de patch). Avec "quilt pop -a", on revien a l'état du upstream sans les patch. * You can test patching of serie with "quilt push" (autant de fois que de patch). Avec "quilt pop -a", on revient a l'état du upstream sans les patch.
Once files has been prepared, it's time to test: Once files has been prepared, it's time to test:
@ -341,7 +350,7 @@ Note: Package is built into directory ../build-area
Note: To compare 2 packages: debdiff package1.dsc package2.dsc Note: To compare 2 packages: debdiff package1.dsc package2.dsc
* Test package (see dedicated chapter to test it with debian unstable env) * Test package (see dedicated chapter to test it with debian unstable env)
> cp ../build-area/* /srv/chroot/unstable/tmp > sudo rm /srv/chroot/unstable/tmp/* >/dev/null 2>&1; cp ../build-area/* /srv/chroot/unstable/tmp
See rest of process into dedicated chapter "To test a package" to test it with debian unstable env See rest of process into dedicated chapter "To test a package" to test it with debian unstable env
* If package .deb is ok: * If package .deb is ok:

View File

@ -16,7 +16,7 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm |
php5-mysql | php5-mysqli, php5-curl, php5-gd, php5-ldap, php5-mysql | php5-mysqli, php5-curl, php5-gd, php5-ldap,
# Required PHP libraries # Required PHP libraries
php-pear, php-mail-mime, php-pear, php-mail-mime,
# php-tcpdf, libfpdi-php, # php-tcpdf,
# libfpdf-tpl-php, php-fpdf, # libfpdf-tpl-php, php-fpdf,
# libphp-adodb, # libphp-adodb,
# libnusoap-php, # libnusoap-php,

View File

@ -1,7 +1,7 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Dolibarr Upstream-Name: Dolibarr
Upstream-Contact: Laurent Destailleur <eldy@users.sourceforge.net> Upstream-Contact: Laurent Destailleur <eldy@users.sourceforge.net>
Source: http://www.dolibarr.org/files/stable/standard/ Source: https://www.dolibarr.org/files/stable/standard/
Files: * Files: *
Copyright: 2002-2009, Rodolphe Quiedeville <rodolphe@quiedeville.org> Copyright: 2002-2009, Rodolphe Quiedeville <rodolphe@quiedeville.org>
@ -197,9 +197,6 @@ License: GPL-2+
On Debian systems, the full text of the GNU General Public On Debian systems, the full text of the GNU General Public
License version 2 can be found in the file License version 2 can be found in the file
`/usr/share/common-licenses/GPL-2'. `/usr/share/common-licenses/GPL-2'.
Comment:
Those files are not shipped in the binary package as we
configure Dolibarr to use the library packaged in "libfpdi-php".
Files: htdocs/includes/geoip/* Files: htdocs/includes/geoip/*
Copyright: 2007 MaxMind LLC Copyright: 2007 MaxMind LLC

View File

@ -147,7 +147,6 @@ case "$1" in
# File already exist. We add params not found. # File already exist. We add params not found.
#echo Add new params to overwrite path to use shared libraries/fonts #echo Add new params to overwrite path to use shared libraries/fonts
#grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "<?php \$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>" >> $config #grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "<?php \$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>" >> $config
#grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "<?php \$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>" >> $config
##grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config ##grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
#grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "<?php \$dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>" >> $config #grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "<?php \$dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>" >> $config
#grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "<?php \$dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>" >> $config #grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "<?php \$dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>" >> $config

View File

@ -30,8 +30,6 @@ $force_install_lockinstall='444';
// - not removed from package (see rm in rules file), // - not removed from package (see rm in rules file),
// - declared into dependencies (see Depends in control file) // - declared into dependencies (see Depends in control file)
//$force_dolibarr_lib_TCPDF_PATH=''; //$force_dolibarr_lib_TCPDF_PATH='';
//$force_dolibarr_lib_FPDF_PATH='/usr/share/php/fpdf';
//$force_dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi';
//$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; //$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';
//$force_dolibarr_lib_GEOIP_PATH=''; //$force_dolibarr_lib_GEOIP_PATH='';
//$force_dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; //$force_dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap';

View File

@ -79,7 +79,6 @@ override_dh_install:
# clean from all PHP embedded libraries (we use package dependencies instead) # clean from all PHP embedded libraries (we use package dependencies instead)
# rm -fr htdocs/includes/adodbtime # rm -fr htdocs/includes/adodbtime
# rm -fr htdocs/includes/fpdfi
# rm -fr htdocs/includes/geoip # rm -fr htdocs/includes/geoip
# rm -fr htdocs/includes/nusoap # rm -fr htdocs/includes/nusoap
# rm -fr htdocs/includes/odtphp/zip/pclzip # rm -fr htdocs/includes/odtphp/zip/pclzip

View File

@ -73,6 +73,8 @@ If you want to build/test package locally:
bzr commit -m "Upstream version x.y" bzr commit -m "Upstream version x.y"
bzr push bzr push
# Init debian dir repository into launchpad (when repository for sources does not exist) # Init debian dir repository into launchpad (when repository for sources does not exist)
#---------------------------------- #----------------------------------
- Create debian directory and upload it onto bzr branch lp:~yourlogin/+junk/debian-[dev|stable] - Create debian directory and upload it onto bzr branch lp:~yourlogin/+junk/debian-[dev|stable]
@ -104,12 +106,13 @@ If you want to build/test package locally:
bzr push lp:~yourlogin/+junk/debian-[dev|stable] bzr push lp:~yourlogin/+junk/debian-[dev|stable]
# Define a recipe into launchpad (a rule to build packages into a PPA) # Define a recipe into launchpad (a rule to build packages into a PPA)
#---------------------------------- #----------------------------------
- Create a file dolibarr.recipe with content - Create a file dolibarr-[beta|stable].recipe with content
cd bzr cd bzr
vi dolibarr.recipe vi dolibarr-[beta|stable].recipe
For dev: For beta/dev:
# bzr-builder format 0.3 deb-version {debupstream}-0~{revno} # bzr-builder format 0.3 deb-version {debupstream}-0~{revno}
lp:dolibarr lp:dolibarr
merge packaging lp:~yourlogin/+junk/debian-dev merge packaging lp:~yourlogin/+junk/debian-dev
@ -119,7 +122,7 @@ If you want to build/test package locally:
merge packaging lp:~yourlogin/+junk/debian-stable merge packaging lp:~yourlogin/+junk/debian-stable
- Run command - Run command
cd bzr cd bzr
bzr dailydeb dolibarr.recipe working-dir bzr dailydeb dolibarr-[beta|stable].recipe working-dir
This will create a directory "working-dir" with dolibarr sources and will add sources from ~yourlogin/+junk/debian-[dev|stable] This will create a directory "working-dir" with dolibarr sources and will add sources from ~yourlogin/+junk/debian-[dev|stable]
- Test package sources - Test package sources
sudo pbuilder build <working-dir>/<project>_<version>.dsc sudo pbuilder build <working-dir>/<project>_<version>.dsc

View File

@ -1,74 +0,0 @@
Howto (English)
##################################################
Building a live CD/USB
##################################################
This is all steps to follow to build a live CD/USB demo of Dolibarr using
SLAX distribution.
1) Download SLAX (www.slax.org) as a zip file.
2) Unzip file on a directory on any USB key with at least 512Mo free (even
if you want to build a CD live).
3) Download following modules from SLAX web sites and put files
into the /slax/modules directory:
apr-1.2.12-i486-1.lzm
apr-util-1.2.12-i486-1.lzm
cairomm-1.4.8-i686.lzm
cli-ftp-pack.lzm
codecs-essential-20071007.lzm
firefox-2.0.0.14.lzm
ghostscript-8.62-i486-5.lzm
gimp-2.4.5-i486-1sl.lzm
gparted-0.3.7-i486-1as.lzm
grsync.lzm
httpd-2.2.8-i486-1.lzm
libsigc++-2.0.18-i686.lzm
mysql-5.0.51b-i486-1.lzm
php-5.2.6-i486-1.lzm
printmodule-s6.lzm
Save_by_Pastrugno-0.1.lzm
telnet-1.5.lzm
4) Copy dolibarr files into path
\slax\changes\var\www\htdocs\dolibarr
5) Run the script
> /boot/bootinst.bat
or
> /boot/bootinst.sh
and answer yes to overwrite the MBR of the disk of your USB key.
6) Boot on USB key (Change your BIOS setup if required).
7) After boot, run the script
> mysql_install_db --user=mysql
This will create mysql empty system database.
8) Edit the file /etc/httpd/httpd.conf to uncomment the line
with PHP activation.
Include /etc/httpd/mod_php.conf
9) Edit \slax\changes\etc\httpd\php.ini file to disabled features where librairies does not
exists. You can comment lines:
;extension=gd.so
;extension=mhash.so
;extension=snmp.so
10) Personalized your desktop.
Add a link to application
"firefox http://localhost/dolibarr/htdocs/index.php"
Add a link to application
"/var/www/htdocs/dolibarr/dev/initdemo/initdemo.sh"
Add a link to application
"/var/www/htdocs/dolibarr/dev/initdemo/removedemo.sh"
11) Reboot again on your USB key.
12) Now you can run Dolibarr install process
http://localhost/dolibarr/htdocs/install/index.php
or copy USB key content to build another one quickly.
or build a CD with command (TODO).

View File

@ -1,7 +0,0 @@
README (English)
##################################################
Building a live CD/USB
##################################################
This directory contains files and docs used to build
a live CD or USB demo of Dolibarr.

View File

@ -159,6 +159,7 @@ $REL1 = $newbuild; $REL1 =~ s/-.*$//gi;
if ($RPMSUBVERSION eq 'auto') { $RPMSUBVERSION = $newbuild; $RPMSUBVERSION =~ s/^.*-//gi; } if ($RPMSUBVERSION eq 'auto') { $RPMSUBVERSION = $newbuild; $RPMSUBVERSION =~ s/^.*-//gi; }
$FILENAMETGZ2="$PROJECT-$MAJOR.$MINOR.$REL1"; $FILENAMETGZ2="$PROJECT-$MAJOR.$MINOR.$REL1";
$FILENAMERPM=$FILENAMETGZ2."-".$RPMSUBVERSION.".".$ARCH.".rpm"; $FILENAMERPM=$FILENAMETGZ2."-".$RPMSUBVERSION.".".$ARCH.".rpm";
$FILENAMERPMSRC=$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm";
# For Deb # For Deb
$newbuild = $BUILD; $newbuild = $BUILD;
$newbuild =~ s/(dev|alpha)/1/gi; # dev $newbuild =~ s/(dev|alpha)/1/gi; # dev
@ -368,6 +369,11 @@ if ($nboftargetok) {
if (! $ret) if (! $ret)
{ {
print "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n"; print "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n";
}
else
{
print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog. But you can regenerate it with commande:'\n";
}
if (! $BUILD || $BUILD eq '0-rc') # For a major version if (! $BUILD || $BUILD eq '0-rc') # For a major version
{ {
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
@ -377,11 +383,9 @@ if ($nboftargetok) {
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
} }
print "\n"; print "\n";
exit; if (! $ret)
}
else
{ {
print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog'\n"; exit;
} }
print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n"; print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n";
@ -730,8 +734,8 @@ if ($nboftargetok) {
print "Remove target ".$FILENAMERPM."...\n"; print "Remove target ".$FILENAMERPM."...\n";
unlink("$NEWDESTI/".$FILENAMERPM); unlink("$NEWDESTI/".$FILENAMERPM);
print "Remove target ".$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm...\n"; print "Remove target ".$FILENAMERPMSRC."...\n";
unlink("$NEWDESTI/".$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm"); unlink("$NEWDESTI/".$FILENAMERPMSRC);
print "Create directory $BUILDROOT/$FILENAMETGZ2\n"; print "Create directory $BUILDROOT/$FILENAMETGZ2\n";
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2`; $ret=`rm -fr $BUILDROOT/$FILENAMETGZ2`;
@ -1137,10 +1141,11 @@ if ($nboftargetok) {
print "\nList of files to publish (BUILD=$BUILD)\n"; print "\nList of files to publish (BUILD=$BUILD)\n";
%filestoscansf=( %filestoscansf=(
"$DESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"=>'signatures', "$DESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"=>'none', # none means it won't be published on SF
"$DESTI/package_rpm_generic/$FILENAMERPM"=>'Dolibarr installer for Fedora-Redhat-Mandriva-Opensuse (DoliRpm)', "$DESTI/package_rpm_generic/$FILENAMERPM"=>'Dolibarr installer for Fedora-Redhat-Mandriva-Opensuse (DoliRpm)',
"$DESTI/package_rpm_generic/$FILENAMERPMSRC"=>'none', # none means it won't be published on SF
"$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'Dolibarr installer for Debian-Ubuntu (DoliDeb)', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'Dolibarr installer for Debian-Ubuntu (DoliDeb)',
"$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'none', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'none', # none means it won't be published on SF
"$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'Dolibarr installer for Windows (DoliWamp)', "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'Dolibarr installer for Windows (DoliWamp)',
"$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM', "$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM',
"$DESTI/standard/$FILENAMETGZ.zip"=>'Dolibarr ERP-CRM' "$DESTI/standard/$FILENAMETGZ.zip"=>'Dolibarr ERP-CRM'
@ -1148,6 +1153,7 @@ if ($nboftargetok) {
%filestoscanstableasso=( %filestoscanstableasso=(
"$DESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"=>'signatures', "$DESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"=>'signatures',
"$DESTI/package_rpm_generic/$FILENAMERPM"=>'package_rpm_generic', "$DESTI/package_rpm_generic/$FILENAMERPM"=>'package_rpm_generic',
"$DESTI/package_rpm_generic/$FILENAMERPMSRC"=>'package_rpm_generic',
"$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu',
"$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu',
"$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows', "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows',
@ -1209,9 +1215,10 @@ if ($nboftargetok) {
my $filesize = -s $file; my $filesize = -s $file;
if (! $filesize) { next; } if (! $filesize) { next; }
print "\n"; if ($target eq 'SF') {
if ($filestoscan{$file} eq 'none') {
if ($target eq 'SF' && $filestoscan{$file} ne 'none') { next;
}
$destFolder="$NEWPUBLISH/$filestoscan{$file}/".$MAJOR.'.'.$MINOR.'.'.$BUILD; $destFolder="$NEWPUBLISH/$filestoscan{$file}/".$MAJOR.'.'.$MINOR.'.'.$BUILD;
} }
elsif ($target eq 'ASSO' and $NEWPUBLISH =~ /stable/) { elsif ($target eq 'ASSO' and $NEWPUBLISH =~ /stable/) {
@ -1228,6 +1235,8 @@ if ($nboftargetok) {
$filenameonly =~ s/.*\/[^\/]+\/([^\/])+$/$1/; $filenameonly =~ s/.*\/[^\/]+\/([^\/])+$/$1/;
$destFolder="$NEWPUBLISH/$dirnameonly"; $destFolder="$NEWPUBLISH/$dirnameonly";
} }
print "\n";
print "Publish file ".$file." to ".$destFolder."\n"; print "Publish file ".$file." to ".$destFolder."\n";
# mkdir # mkdir

View File

@ -36,7 +36,7 @@ Go into project you want to update. It mught be:
Once logged, click on "Add file" in section "Source Files", then select mode "Upload From: Remote URL" Once logged, click on "Add file" in section "Source Files", then select mode "Upload From: Remote URL"
Keep empty for "Filename", choose "Remote URL" and enter into last field, URL that should looks like this: Keep empty for "Filename", choose "Remote URL" and enter into last field, URL that should looks like this:
http://www.dolibarr.org/files/stable/package_rpm_generic/dolibarr-x.y.v-0.3.src.rpm http://www.dolibarr.org/files/stable/package_rpm_generic/dolibarr-x.y.v-0.4.src.rpm
Then add into Advanded - Attributes Then add into Advanded - Attributes
OBS:Screenshots http://www.dolibarr.org/images/dolibarr_screenshot1.png OBS:Screenshots http://www.dolibarr.org/images/dolibarr_screenshot1.png

View File

@ -34,7 +34,7 @@ AutoReqProv: no
%description %description
An easy to use CRM & ERP open source/free software for small An easy to use CRM & ERP open source/free software package for small
and medium companies, foundations or freelances. It includes different and medium companies, foundations or freelances. It includes different
features for Enterprise Resource Planning (ERP) and Customer Relationship features for Enterprise Resource Planning (ERP) and Customer Relationship
Management (CRM) but also for different other activities. Management (CRM) but also for different other activities.

View File

@ -75,7 +75,7 @@ AutoReqProv: no
%description %description
An easy to use CRM & ERP open source/free software for small An easy to use CRM & ERP open source/free software package for small
and medium companies, foundations or freelances. It includes different and medium companies, foundations or freelances. It includes different
features for Enterprise Resource Planning (ERP) and Customer Relationship features for Enterprise Resource Planning (ERP) and Customer Relationship
Management (CRM) but also for different other activities. Management (CRM) but also for different other activities.

View File

@ -33,7 +33,7 @@ AutoReqProv: no
%description %description
An easy to use CRM & ERP open source/free software for small An easy to use CRM & ERP open source/free software package for small
and medium companies, foundations or freelances. It includes different and medium companies, foundations or freelances. It includes different
features for Enterprise Resource Planning (ERP) and Customer Relationship features for Enterprise Resource Planning (ERP) and Customer Relationship
Management (CRM) but also for different other activities. Management (CRM) but also for different other activities.

View File

@ -36,7 +36,7 @@ AutoReqProv: no
%description %description
An easy to use CRM & ERP open source/free software for small An easy to use CRM & ERP open source/free software package for small
and medium companies, foundations or freelances. It includes different and medium companies, foundations or freelances. It includes different
features for Enterprise Resource Planning (ERP) and Customer Relationship features for Enterprise Resource Planning (ERP) and Customer Relationship
Management (CRM) but also for different other activities. Management (CRM) but also for different other activities.

View File

@ -9,6 +9,7 @@
<exclude-pattern type="relative">htdocs/includes</exclude-pattern> <exclude-pattern type="relative">htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">htdocs/conf.php</exclude-pattern> <exclude-pattern type="relative">htdocs/conf.php</exclude-pattern>
<exclude-pattern type="relative">*/nltechno*</exclude-pattern> <exclude-pattern type="relative">*/nltechno*</exclude-pattern>
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
<!-- List of all tests --> <!-- List of all tests -->

View File

@ -93,12 +93,12 @@ class SkeletonApi extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') or (t.import_key:=:'20160101')"
* @return array Array of skeleton objects * @return array Array of skeleton objects
* *
* @url GET /skeletons/ * @url GET /skeletons/
*/ */
function getList($mode, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { function index($mode, $sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
@ -124,18 +124,19 @@ class SkeletonApi extends DolibarrApi
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
if ($socid) $sql.= " AND s.fk_soc = ".$socid; if ($socid) $sql.= " AND s.fk_soc = ".$socid;
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0)
{ {
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
if ($sqlfilters)
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); if (! DolibarrApi::_checkFilters($sqlfilters))
$nbtotalofrecords = $db->num_rows($result); {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);

View File

@ -164,10 +164,14 @@ class Skeleton_Class extends CommonObject
$sql .= ' t.field2'; $sql .= ' t.field2';
//... //...
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql.= ' WHERE 1 = 1';
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")";
}
if (null !== $ref) { if (null !== $ref) {
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; $sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
} else { } else {
$sql .= ' WHERE t.rowid = ' . $id; $sql .= ' AND t.rowid = ' . $id;
} }
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -236,16 +240,20 @@ class Skeleton_Class extends CommonObject
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
} }
} }
if (count($sqlwhere) > 0) { $sql.= ' WHERE 1 = 1';
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")";
}
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
} }
if (!empty($sortfield)) { if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder); $sql .= $this->db->order($sortfield,$sortorder);
} }
if (!empty($limit)) { if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset); $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
} }
$this->lines = array(); $this->lines = array();
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -443,36 +451,51 @@ class Skeleton_Class extends CommonObject
* *
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to * @param string $option On what the link point to
* @param integer $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name * @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link * @param string $morecss Add more css on link
* @return string String with URL * @return string String with URL
*/ */
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
{ {
global $langs, $conf, $db; global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = ''; $result = '';
$companylink = ''; $companylink = '';
$label = '<u>' . $langs->trans("MyModule") . '</u>'; $label = '<u>' . $langs->trans("MyModule") . '</u>';
$label.= '<div width="100%">'; $label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$link = '<a href="'.DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id.'"'; $url = DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id;
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
$link.= '>'; $linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowProject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
if ($withpicto) if ($withpicto)
{ {
$result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=' ';
} }
$result.= $link . $this->ref . $linkend; $result.= $linkstart . $this->ref . $linkend;
return $result; return $result;
} }
@ -491,7 +514,7 @@ class Skeleton_Class extends CommonObject
* Return the status * Return the status
* *
* @param int $status Id status * @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
* @return string Label of status * @return string Label of status
*/ */
static function LibStatut($status,$mode=0) static function LibStatut($status,$mode=0)
@ -529,6 +552,11 @@ class Skeleton_Class extends CommonObject
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
} }
if ($mode == 6)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
} }

View File

@ -58,6 +58,7 @@ $action = GETPOST('action','alpha');
$backtopage = GETPOST('backtopage'); $backtopage = GETPOST('backtopage');
$myparam = GETPOST('myparam','alpha'); $myparam = GETPOST('myparam','alpha');
$search_all=trim(GETPOST("sall"));
$search_field1=GETPOST("search_field1"); $search_field1=GETPOST("search_field1");
$search_field2=GETPOST("search_field2"); $search_field2=GETPOST("search_field2");
$search_myfield=GETPOST('search_myfield'); $search_myfield=GETPOST('search_myfield');
@ -141,10 +142,13 @@ $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
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_field1=''; $search_field1='';
$search_field2=''; $search_field2='';
@ -154,9 +158,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPO
$search_array_options=array(); $search_array_options=array();
} }
// Mass actions
if (empty($reshook))
{
$objectclass='Skeleton'; $objectclass='Skeleton';
$objectlabel='Skeleton'; $objectlabel='Skeleton';
$permtoread = $user->rights->skeleton->read; $permtoread = $user->rights->skeleton->read;
@ -180,7 +182,6 @@ $form=new Form($db);
//$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
$help_url=''; $help_url='';
$title = $langs->trans('MyModuleListTitle'); $title = $langs->trans('MyModuleListTitle');
llxHeader('', $title, $help_url);
// Put here content of your page // Put here content of your page
@ -247,13 +248,27 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);
dol_syslog($script_file, LOG_DEBUG); dol_syslog($script_file, LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if (! $resql)
{ {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/skeleton/card.php?id='.$id);
exit;
}
llxHeader('', $title, $help_url);
$arrayofselected=is_array($toselect)?$toselect:array(); $arrayofselected=is_array($toselect)?$toselect:array();
$param=''; $param='';
@ -296,7 +311,7 @@ if ($resql)
$moreforfilter = ''; $moreforfilter = '';
$moreforfilter.='<div class="divsearchfield">'; $moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escpae_htmltag($search_myfield).'">'; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>'; $moreforfilter.= '</div>';
$parameters=array(); $parameters=array();
@ -530,24 +545,13 @@ if ($resql)
$genallowed=$user->rights->facture->lire; $genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire;
print '<br><a name="show_files"></a>'; print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
} }
else else
{ {
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
} }
}
else
{
$error++;
dol_print_error($db);
}
// End of page // End of page
llxFooter(); llxFooter();

View File

@ -14,6 +14,7 @@ fi
if [ "x$1" = "xlist" ] if [ "x$1" = "xlist" ]
then then
echo "Search duplicate keys into en_US lang files (there is no cross file check)"
for file in `find htdocs/langs/en_US -name *.lang -type f` for file in `find htdocs/langs/en_US -name *.lang -type f`
do do
dupes=$( dupes=$(

View File

@ -16,6 +16,7 @@ fi
# To detect # To detect
if [ "x$1" = "xlist" ] if [ "x$1" = "xlist" ]
then then
echo "Search duplicate line for lang en_US"
for file in `find htdocs/langs/en_US -type f -name *.lang` for file in `find htdocs/langs/en_US -type f -name *.lang`
do do
if [ `sort "$file" | grep -v '^$' | uniq -d | wc -l` -gt 0 ] if [ `sort "$file" | grep -v '^$' | uniq -d | wc -l` -gt 0 ]
@ -29,6 +30,7 @@ fi
# To fix # To fix
if [ "x$1" = "xfix" ] if [ "x$1" = "xfix" ]
then then
echo "Fix duplicate line for lang en_US"
for file in `find htdocs/langs/en_US -type f -name *.lang` for file in `find htdocs/langs/en_US -type f -name *.lang`
do do
awk -i inplace ' !x[$0]++' "$file" awk -i inplace ' !x[$0]++' "$file"

View File

@ -42,4 +42,4 @@ else
fi fi
echo Think to launch also: echo Think to launch also:
echo "> dev/fixaltlanguages.sh fix all" echo "> dev/tools/fixaltlanguages.sh fix all"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 176 KiB

View File

@ -22,19 +22,23 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief List accounting account * \brief List accounting account
*/ */
require '../../main.inc.php';
// Class require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
// Langs // Langs
$langs->load("compta"); $langs->load("compta");
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("salaries");
$mesg = ''; $mesg = '';
$action = GETPOST('action'); $action = GETPOST('action');
$cancel = GETPOST('cancel');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$search_account = GETPOST("search_account"); $search_account = GETPOST("search_account");
@ -44,10 +48,8 @@ $search_pcgtype = GETPOST("search_pcgtype");
$search_pcgsubtype = GETPOST("search_pcgsubtype"); $search_pcgsubtype = GETPOST("search_pcgsubtype");
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0) accessforbidden();
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")?GETPOST("limit","int"):$conf->liste_limit;
@ -80,6 +82,10 @@ $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if (! empty($cancel)) $action = '';
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
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 test are required to be compatible with all browsers
@ -91,6 +97,20 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPO
$search_pcgsubtype = ""; $search_pcgsubtype = "";
} }
if (GETPOST('change_chart'))
{
$chartofaccounts = GETPOST('chartofaccounts', 'int');
if (! empty($chartofaccounts)) {
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
}
if ($action == 'disable') { if ($action == 'disable') {
if ($accounting->fetch($id)) { if ($accounting->fetch($id)) {
$result = $accounting->account_desactivate($id); $result = $accounting->account_desactivate($id);
@ -109,6 +129,7 @@ if ($action == 'disable') {
setEventMessages($accounting->error, $accounting->errors, 'errors'); setEventMessages($accounting->error, $accounting->errors, 'errors');
} }
} }
}
/* /*
@ -124,6 +145,8 @@ if ($action == 'delete') {
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, ";
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
@ -152,17 +175,18 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = 0; $nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($resql);
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/admin/account.php:: $sql=' . $sql); dol_syslog('accountancy/admin/account.php:: $sql=' . $sql);
$result = $db->query($sql); $resql = $db->query($sql);
if ($result) { if ($resql) {
$num = $db->num_rows($result);
$num = $db->num_rows($resql);
$params=''; $params='';
if ($search_account != "") $params.= '&amp;search_account='.urlencode($search_account); if ($search_account != "") $params.= '&amp;search_account='.urlencode($search_account);
@ -172,13 +196,40 @@ if ($result) {
if ($search_pcgsubtype != "") $params.= '&amp;search_pcgsubtype='.urlencode($search_pcgsubtype); if ($search_pcgsubtype != "") $params.= '&amp;search_pcgsubtype='.urlencode($search_pcgsubtype);
if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($optioncss != '') $param.='&optioncss='.$optioncss;
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords); print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy');
$i = 0; $i = 0;
print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">';
print '<br/>'; // Box to select active chart of accoun
$var = ! $var;
print $langs->trans("Selectchartofaccounts") . " : ";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT rowid, pcg_version, label, active";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
$sql .= " WHERE active = 1";
dol_syslog('accountancy/admin/index.php:: $sql=' . $sql);
$resqlchart = $db->query($sql);
$var = true;
if ($resqlchart) {
$numbis = $db->num_rows($resqlchart);
$i = 0;
while ( $i < $numbis ) {
$var = ! $var;
$row = $db->fetch_row($resqlchart);
print '<option value="' . $row[0] . '"';
print $pcgver == $row[0] ? ' selected' : '';
print '>' . $row[1] . ' - ' . $row[2] . '</option>';
$i ++;
}
}
print "</select>";
print '<input type="submit" class="button" name="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
print '<br>';
print "<br>\n";
print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>'; print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
print '<a class="butAction" href="./categories.php">' . $langs->trans("ApplyMassCategories") . '</a>'; print '<a class="butAction" href="./categories.php">' . $langs->trans("ApplyMassCategories") . '</a>';
@ -194,7 +245,7 @@ if ($result) {
print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $params, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $params, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $params, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $params, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $params, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $params, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $params, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $params, "", 'width="60" align="center"', $sortfield, $sortorder);
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -205,9 +256,8 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td align="right" colspan="2" class="liste_titre">'; print '<td align="right" colspan="2" class="liste_titre">';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print '&nbsp;'; print $searchpitco;
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

File diff suppressed because it is too large Load Diff

View File

@ -22,9 +22,8 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Card of accounting account * \brief Card of accounting account
*/ */
require '../../main.inc.php';
// Class require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
@ -38,6 +37,7 @@ $langs->load("accountancy");
$mesg = ''; $mesg = '';
$action = GETPOST('action'); $action = GETPOST('action');
$backtopage = GETPOST('backtopage');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$cancel = GETPOST('cancel'); $cancel = GETPOST('cancel');
@ -47,7 +47,18 @@ $cancel = GETPOST('cancel');
$object = new AccountingAccount($db); $object = new AccountingAccount($db);
// Action
/*
* Action
*/
if (GETPOST('cancel'))
{
$urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php',1);
header("Location: ".$urltogo);
exit;
}
if ($action == 'add' && $user->rights->accounting->chartofaccount) if ($action == 'add' && $user->rights->accounting->chartofaccount)
{ {
if (! $cancel) { if (! $cancel) {
@ -85,18 +96,30 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$object->active = 1; $object->active = 1;
$res = $object->create($user); $res = $object->create($user);
if ($res == - 3) { if ($res == - 3) {
$error = 1; $error = 1;
$action = "create"; $action = "create";
setEventMessages($object->error, $object->errors, 'errors');
} }
if ($res == - 4) { elseif ($res == - 4) {
$error = 2; $error = 2;
$action = "create"; $action = "create";
setEventMessages($object->error, $object->errors, 'errors');
} }
elseif ($res < 0)
{
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action = "create";
} }
header("Location: account.php"); if (! $error)
{
setEventMessages("RecordCreatedSuccessfully",null,'mesgs');
$urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php',1);
header("Location: ".$urltogo);
exit; exit;
}
}
} else if ($action == 'edit' && $user->rights->accounting->chartofaccount) { } else if ($action == 'edit' && $user->rights->accounting->chartofaccount) {
if (! $cancel) { if (! $cancel) {
$result = $object->fetch($id); $result = $object->fetch($id);
@ -175,7 +198,7 @@ $formaccounting = new FormAccounting($db);
// Create mode // Create mode
if ($action == 'create') { if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAccount')); print load_fiche_titre($langs->trans('NewAccountingAccount'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n"; print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';

View File

@ -79,9 +79,11 @@ if ($action == 'delete') {
} }
} }
/* /*
* View * View
*/ */
llxheader('', $langs->trans('AccountAccounting')); llxheader('', $langs->trans('AccountAccounting'));
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
@ -126,6 +128,7 @@ dol_fiche_end();
print '</form>'; print '</form>';
if ($action == 'display' || $action == 'delete') { if ($action == 'display' || $action == 'delete') {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';

View File

@ -0,0 +1,156 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/admin/index.php
* \ingroup Advanced accountancy
* \brief Setup page to configure accounting expert module
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
$langs->load("compta");
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
$langs->load("salaries");
// Security check
if (! empty($user->rights->accountancy->chartofaccount))
{
accessforbidden();
}
$action = GETPOST('action', 'alpha');
$list_account = array (
'ACCOUNTING_ACCOUNT_SUPPLIER',
'ACCOUNTING_ACCOUNT_CUSTOMER',
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
'ACCOUNTING_VAT_BUY_ACCOUNT',
'ACCOUNTING_VAT_SOLD_ACCOUNT',
'ACCOUNTING_VAT_PAY_ACCOUNT',
'ACCOUNTING_ACCOUNT_SUSPENSE',
'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'DONATION_ACCOUNTINGACCOUNT'
);
/*
* Actions
*/
$accounting_mode = defined('ACCOUNTING_MODE') ? ACCOUNTING_MODE : 'RECETTES-DEPENSES';
if (GETPOST('change_chart'))
{
$chartofaccounts = GETPOST('chartofaccounts', 'int');
if (! empty($chartofaccounts)) {
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
}
if ($action == 'update') {
$error = 0;
foreach ( $list_account as $constname ) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$formaccountancy = new FormVentilation($db);
$linkback = '';
print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy');
print '<br>';
print $langs->trans("DefaultBindingDesc").'<br>';
print '<br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
// Define Chart of accounts
print '<table class="noborder" width="100%">';
foreach ( $list_account as $key ) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td>' . $label . '</td>';
// Value
print '<td>'; // Do not force align=right, or it align also the content of the select box
print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
}
print "</table>\n";
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '</form>';
llxFooter();
$db->close();

View File

@ -38,8 +38,10 @@ $langs->load("admin");
$langs->load("accountancy"); $langs->load("accountancy");
// Security check // Security check
if (! $user->admin) if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount))
{
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
@ -135,31 +137,14 @@ $var = true;
/* /*
* Main Options * Main Options
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('MainOptions') . '</td>'; print '<td colspan="3">' . $langs->trans('Options') . '</td>';
print "</tr>\n"; print "</tr>\n";
$var = ! $var; $var = ! $var;
print '<tr ' . $bc[$var] . '>';
print '<td width="50%">' . $langs->trans("Selectformat") . '</td>';
if (! $conf->use_javascript_ajax) {
print '<td class="nowrap">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
} else {
print '<td>';
$listformat = array (
'csv' => $langs->trans("csv"),
'txt' => $langs->trans("txt")
);
print $form->selectarray("format", $listformat, $conf->global->ACCOUNTING_EXPORT_FORMAT, 0);
print '</td>';
}
print "</td></tr>";
$num = count($main_option); $num = count($main_option);
if ($num) { if ($num) {
foreach ( $main_option as $key ) { foreach ( $main_option as $key ) {
@ -221,8 +206,29 @@ if ($num2) {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
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 > 1)
{
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>';
}
print '<tr ' . $bc[$var] . '>';
print '<td width="50%">' . $langs->trans("Selectformat") . '</td>';
if (! $conf->use_javascript_ajax) {
print '<td class="nowrap">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
} else {
print '<td>';
$listformat = array (
'csv' => $langs->trans("csv"),
'txt' => $langs->trans("txt")
);
print $form->selectarray("format", $listformat, $conf->global->ACCOUNTING_EXPORT_FORMAT, 0);
print '</td>';
}
print "</td></tr>";
foreach ( $model_option as $key ) { foreach ( $model_option as $key ) {
$var = ! $var; $var = ! $var;

View File

@ -45,7 +45,7 @@ $langs->load("compta");
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->mouvements->lire) // If we can read accounting records, we shoul be able to see fiscal year. if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul be able to see fiscal year.
accessforbidden(); accessforbidden();
$error = 0; $error = 0;
@ -80,7 +80,7 @@ $max = 100;
$form = new Form($db); $form = new Form($db);
$title = $langs->trans('FiscalYears'); $title = $langs->trans('AccountingPeriods');
$helpurl = ""; $helpurl = "";
llxHeader('', $title, $helpurl); llxHeader('', $title, $helpurl);
@ -106,8 +106,8 @@ if ($result) {
$i = 0; $i = 0;
$title = $langs->trans('FiscalYears'); $title = $langs->trans('AccountingPeriods');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 1);
// Load attribute_label // Load attribute_label
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';

View File

@ -41,35 +41,22 @@ $langs->load("accountancy");
$langs->load("salaries"); $langs->load("salaries");
// Security check // Security check
if (! $user->admin) if (empty($user->admin))
{
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
// Parameters ACCOUNTING_* and others // Parameters ACCOUNTING_* and others
$list = array ( $list = array (
'ACCOUNTING_LIMIT_LIST_VENTILATION', 'ACCOUNTING_LENGTH_GACCOUNT',
'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
'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT'
); );
$list_account = array (
'ACCOUNTING_ACCOUNT_SUPPLIER',
'ACCOUNTING_ACCOUNT_CUSTOMER',
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
'ACCOUNTING_VAT_BUY_ACCOUNT',
'ACCOUNTING_VAT_SOLD_ACCOUNT',
'ACCOUNTING_VAT_PAY_ACCOUNT',
'ACCOUNTING_ACCOUNT_SUSPENSE',
'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'DONATION_ACCOUNTINGACCOUNT'
);
/* /*
* Actions * Actions
@ -96,15 +83,8 @@ if ($action == 'update') {
$error ++; $error ++;
} }
$chartofaccounts = GETPOST('chartofaccounts', 'int'); if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors');
if (! empty($chartofaccounts)) {
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
} }
foreach ($list as $constname) { foreach ($list as $constname) {
@ -115,14 +95,6 @@ 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 {
@ -180,6 +152,7 @@ if ($action == 'setdisabledirectinput') {
} }
} }
/* /*
* View * View
*/ */
@ -200,9 +173,10 @@ print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron'); dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron');
print '<table class="noborder" width="100%">';
// Cas du parametre ACCOUNTING_MODE // Default mode for calculating turnover (parameter ACCOUNTING_MODE)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>'; print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
@ -226,101 +200,29 @@ print '<td colspan="2">' . nl2br($langs->trans('OptionModeVirtualDesc')) . "</td
print "</table>\n"; print "</table>\n";
print "<br>\n";
/* print '<br>';
* Define Chart of accounts
*/
print '<table class="noborder" width="100%">';
$var = true;
print '<tr class="liste_titre">';
print '<td colspan="3">';
print $langs->trans("Chartofaccounts") . '</td>';
print "</tr>\n";
$var = ! $var;
print '<tr ' . $bc[$var] . '>';
print "<td>" . $langs->trans("Selectchartofaccounts") . "</td>";
print "<td>";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT rowid, pcg_version, label, active"; // Others params
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
$sql .= " WHERE active = 1";
dol_syslog('accountancy/admin/index.php:: $sql=' . $sql);
$resql = $db->query($sql);
$var = true;
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ( $i < $num ) {
$var = ! $var;
$row = $db->fetch_row($resql);
print '<option value="' . $row[0] . '"';
print $conf->global->CHARTOFACCOUNTS == $row[0] ? ' selected' : '';
print '>' . $row[1] . ' - ' . $row[2] . '</option>';
$i ++;
}
}
print "</select>";
print "</td></tr>";
print "</table>";
print "<br>\n";
/*
* Others params
*/
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>'; print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n"; print "</tr>\n";
foreach ( $list as $key ) { if (! empty($user->admin))
$var = ! $var; {
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td><label for="' . $key . '">' . $label . '</label></td>';
// Value
print '<td>';
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
print '</td></tr>';
}
foreach ( $list_account as $key ) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td><label for="' . $key . '">' . $label . '</label></td>';
// Value
print '<td>';
print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td></tr>';
}
// TO DO Mutualize code for yes/no constants // TO DO Mutualize code for yes/no constants
$var = ! $var; $var = ! $var;
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>'; print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">'; print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
} else { } else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">'; print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>'; print '</a></td>';
} }
@ -328,13 +230,13 @@ print '</tr>';
$var = ! $var; $var = ! $var;
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>'; print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">'; print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
} else { } else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">'; print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>'; print '</a></td>';
} }
@ -342,38 +244,66 @@ print '</tr>';
$var = ! $var; $var = ! $var;
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>'; print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">'; print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
} else { } else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">'; print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>'; print '</a></td>';
} }
print '</tr>'; print '</tr>';
print "</table>\n"; $var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
}
// Param a user $user->rights->accountancy->chartofaccount can access
foreach ($list as $key)
{
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td>'.$label.'</td>';
// Value
print '<td align="right">';
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
print '</td>';
print '</tr>';
}
print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>'; print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '<br>';
print '<br>';
print $langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy"));
print '<br>';
print '</form>'; print '</form>';
llxFooter(); llxFooter();

View File

@ -35,11 +35,17 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
$langs->load("compta");
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("salaries");
// Security check // Security check
if (! $user->admin) if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount))
{
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');

View File

@ -40,17 +40,17 @@ $langs->load("companies");
$langs->load("compta"); $langs->load("compta");
$langs->load("main"); $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("products");
// Security check // Security check
if (! $user->admin) {
accessforbidden();
}
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if (! $user->rights->accounting->bind->write)
accessforbidden();
// search & action GETPOST // search & action GETPOST
$action = GETPOST('action'); $action = GETPOST('action', 'alpha');
$codeventil_buy = GETPOST('codeventil_buy', 'array'); $codeventil_buy = GETPOST('codeventil_buy', 'array');
$codeventil_sell = GETPOST('codeventil_sell', 'array'); $codeventil_sell = GETPOST('codeventil_sell', 'array');
$chk_prod = GETPOST('chk_prod', 'array'); $chk_prod = GETPOST('chk_prod', 'array');
@ -62,30 +62,49 @@ $changeaccount_sell = GETPOST('changeaccount_sell', 'array');
$search_ref = GETPOST('search_ref', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha');
$search_current_account = GETPOST('search_current_account', 'alpha');
$search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
if ($search_current_account_valid == '') $search_current_account_valid='withoutvalidaccount';
$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
$btn_changeaccount = GETPOST('changeaccount'); $btn_changeaccount = GETPOST('changeaccount');
$btn_changetype = GETPOST('changetype'); $btn_changetype = GETPOST('changetype');
$sortfield = GETPOST('sortfield', 'alpha'); $limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortorder = GETPOST('sortorder', 'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$page = GETPOST('page', 'int'); $sortorder = GETPOST("sortorder",'alpha');
if ($page < 0) $page = GETPOST("page",'int');
$page = 0; if ($page == -1) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
// bug in page limit if ACCOUNTING_LIMIT_LIST_VENTILATION < $conf->liste_limit there is no pagination displayed ! if (! $sortfield) $sortfield="p.ref";
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) && $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION >= $conf->liste_limit) { if (! $sortorder) $sortorder="ASC";
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
$offset = $limit * $page;
if (! $sortfield) { if (empty($action)) $action='list';
$sortfield = "p.ref";
} $arrayfields=array();
if (! $sortorder) {
$sortorder = "ASC";
/*
* Actions
*/
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_ref = '';
$search_label = '';
$search_desc = '';
$search_current_account = '';
$search_current_account_valid = '-1';
} }
// Sales or Purchase mode ? // Sales or Purchase mode ?
@ -111,14 +130,14 @@ if ($action == 'update') {
} }
if (! empty($btn_changeaccount)) { if (! empty($btn_changeaccount)) {
$msg = '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //$msg = '<div><span class="accountingprocessing">' . $langs->trans("Processing") . '...</span></div>';
if (! empty($chk_prod)) { if (! empty($chk_prod)) {
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
$msg .= '<div><font color="red">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</font></div>'; //$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
$cpt = 0; $cpt = 0; $ok = 0; $ko = 0;
foreach ( $chk_prod as $productid ) { foreach ( $chk_prod as $productid ) {
$accounting_account_id = GETPOST('codeventil_' . $productid); $accounting_account_id = GETPOST('codeventil_' . $productid);
@ -140,21 +159,31 @@ if ($action == 'update') {
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$msg .= '<div><font color="green">' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '</font></div>'; $ok++;
//$msg .= '<div><font color="green">' . $langs->trans("Product") . ' ' . $productid . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '</font></div>';
} else { } else {
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>'; $ko++;
//$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
} }
} }
$cpt ++; $cpt ++;
} }
} else { } else {
$msg .= '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>'; //$msg .= '<div><span class="accountingprocessing">' . $langs->trans("AnyLineVentilate") . '</span></div>';
} }
$msg .= '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>'; if ($ko) setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
if ($ok) setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
//$msg .= '<div><span class="accountingprocessing">' . $langs->trans("EndProcessing") . '</span></div>';
} }
} }
/*
* View
*/
$form = new FormVentilation($db); $form = new FormVentilation($db);
// Defaut AccountingAccount RowId Product / Service // Defaut AccountingAccount RowId Product / Service
@ -172,141 +201,169 @@ $aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $c
$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
// Purge search criteria llxHeader('', $langs->trans("ProductsBinding"));
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$search_ref = '';
$search_label = '';
$search_desc = '';
}
/* $pcgverid = $conf->global->CHARTOFACCOUNTS;
* View $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
*/ if (empty($pcgvercode)) $pcgvercode=$pcgverid;
llxHeader('', $langs->trans("InitAccountancy")); $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type,";
$sql.= " aa.rowid as aaid";
print '<script type="text/javascript">
$(function () {
$(\'#select-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = true;
});
});
$(\'#unselect-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = false;
});
});
});
</script>';
$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type";
$sql.= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql.= " FROM " . MAIN_DB_PREFIX . "product as p";
$sql .= " WHERE ("; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$pcgver = $conf->global->CHARTOFACCOUNTS; $sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
}
if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { else
$sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; {
$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; }
} else { $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
$sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL "; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN if (strlen(trim($search_current_account))) {
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; $sql .= natural_search("p.accountancy_code_buy",$search_current_account);
}
} else {
if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell",$search_current_account);
}
}
if ($search_current_account_valid == 'withoutvalidaccount')
{
$sql .= " AND aa.account_number IS NULL";
}
if ($search_current_account_valid == 'withvalidaccount')
{
$sql .= " AND aa.account_number IS NOT NULL";
} }
$sql .= ")";
// Add search filter like // Add search filter like
if (strlen(trim($search_ref))) { if (strlen(trim($search_ref))) {
$sql .= " AND (p.ref like '" . $search_ref . "%')"; $sql .= natural_search("p.ref",$search_ref);
} }
if (strlen(trim($search_label))) { if (strlen(trim($search_label))) {
$sql .= " AND (p.label like '" . $search_label . "%')"; $sql .= natural_search("p.label",$search_label);
} }
if (strlen(trim($search_desc))) { if (strlen(trim($search_desc))) {
$sql .= " AND (p.description like '%" . $search_desc . "%')"; $sql .= natural_search("p.description",$search_desc);
} }
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result)
$num_lines = $db->num_rows($result); {
$num = $db->num_rows($result);
$i = 0; $i = 0;
print_barre_liste($langs->trans("ModulesSystemTools"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy');
print '<br>'; print '<br>';
print $langs->trans("InitAccountancyDesc") . '<br>'; print $langs->trans("InitAccountancyDesc") . '<br>';
print '<br>'; print '<br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">'; // Select mode
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>'; print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr ' . $bc[false] . '><td width="25%"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>'; print '<tr ' . $bc[false] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductSellDesc')); print '<td>'.$langs->trans('OptionModeProductSellDesc');
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr ' . $bc[true] . '><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>'; print '<tr ' . $bc[true] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductBuyDesc')) . "</td></tr>\n"; print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
print "</table>\n"; print "</table>\n";
print '<div align="center"><input type="submit" class="button" value="' . $langs->trans('Refresh') . '" name="changetype"></div>'; print '<div align="center"><input type="submit" class="button" value="' . $langs->trans('Refresh') . '" name="changetype"></div>';
print "<br><br>\n"; print "<br>\n";
if (! empty($msg)) {
print $msg;
}
print '<table class="noborder" width="100%">'; // Filter on categories
$moreforfilter='';
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$texte=$langs->trans("ListOfProductsServices");
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
/* print_liste_field_titre($langs->trans("OnSell"), $_SERVER["PHP_SELF"], "p.tosell", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("OnBuy"), $_SERVER["PHP_SELF"], "p.tobuy", "", $param, 'align="center"', $sortfield, $sortorder);
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print_liste_field_titre($langs->trans("Accountancy_code_buy")); $fieldtosortaccount="p.accountancy_code_buy";
} else {
print_liste_field_titre($langs->trans("Accountancy_code_sell"));
} }
*/ else $fieldtosortaccount="p.accountancy_code_sell";
print_liste_field_titre($langs->trans("AccountAccounting")); print_liste_field_titre($langs->trans("CurrentDedicatedAccountingAccount"), $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Modify") . '<br><label id="select-all">' . $langs->trans('All') . '</label> / <label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("AssignDedicatedAccountingAccount"));
print_liste_field_titre('', '', '', '', '', 'align="center"');
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . $search_ref . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="14" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="30" name="search_desc" value="' . $search_desc . '"></td>'; if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
// On sell
print '<td class="liste_titre"></td>';
// On buy
print '<td class="liste_titre"></td>';
// Current account
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_current_account" value="' . dol_escape_htmltag($search_current_account) . '">';
$listofvals=array('withoutvalidaccount'=>$langs->trans("WithoutValidAccount"), 'withvalidaccount'=>$langs->trans("WithValidAccount"));
print ' '.$langs->trans("or").' '.$form->selectarray('search_current_account_valid', $listofvals, $search_current_account_valid, 1);
print '</td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td align="center" class="liste_titre">'; print '<td align="right" class="liste_titre">';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; $searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1);
print '&nbsp;'; print $searchpitco;
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$product_static = new Product($db);
$var = true; $var = true;
$i=0;
while ( $i < min($num_lines, 250) ) { while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$var = ! $var;
$compta_prodsell = $obj->accountancy_code_sell; // Ref produit as link
$product_static->ref = $obj->ref;
$product_static->id = $obj->rowid;
$product_static->type = $obj->product_type;
$product_static->label = $obj->label;
$product_static->description = $obj->description;
$product_static->status = $obj->tosell;
$product_static->status_buy = $obj->tobuy;
if ($obj->product_type == 0) { if ($obj->product_type == 0) {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
@ -316,8 +373,6 @@ if ($result) {
$compta_prodsell_id = $aarowid_servsell; $compta_prodsell_id = $aarowid_servsell;
} }
$compta_prodbuy = $obj->accountancy_code_buy;
if ($obj->product_type == 0) { if ($obj->product_type == 0) {
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy; $compta_prodbuy_id = $aarowid_prodbuy;
@ -326,59 +381,101 @@ if ($result) {
$compta_prodbuy_id = $aarowid_servbuy; $compta_prodbuy_id = $aarowid_servbuy;
} }
$product_static = new Product($db); $var = ! $var;
print '<tr '. $bc[$var].'>'; print '<tr '. $bc[$var].'>';
print "</tr>";
print '<tr'. $bc[$var].'>';
// Ref produit as link
$product_static->ref = $obj->ref;
$product_static->id = $obj->rowid;
$product_static->type = $obj->type;
print '<td>'; print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
else
print '-&nbsp;';
print '</td>'; print '</td>';
print '<td align="left">' . dol_trunc($obj->label, 24) . '</td>';
print '<td align="left">'.$obj->label.'</td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
{
// 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 = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64;
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>';
}
// Accounting account buy print '<td align="center">'.$product_static->getLibStatut(3, 0).'</td>';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
// print '<td align="left">' . $obj->accountancy_code_buy . '</td>'; print '<td align="center">'.$product_static->getLibStatut(3, 1).'</td>';
// TODO: replace by select
// print '<td align="left">' . $compta_prodbuy . '</td>'; // Current accounting account
// TODO: we shoul set a user defined value to adjust user square / wide screen size
// $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
print '<td align="left">'; print '<td align="left">';
print $form->select_account($compta_prodbuy_id, 'codeventil_' . $product_static->id, 1); if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print length_accountg($obj->accountancy_code_buy);
if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
else
{
print length_accountg($obj->accountancy_code_sell);
if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
print '</td>';
// Dedicated account
$defaultvalue='';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
// Accounting account buy
print '<td align="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy;
$codesell=length_accountg($obj->accountancy_code_buy);
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
print '</td>'; print '</td>';
} else { } else {
// Accounting account sell // Accounting account sell
// print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
// TODO: replace by select
// TODO: we shoul set a user defined value to adjust user square / wide screen size
// $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
print '<td align="left">'; print '<td align="left">';
print $form->select_account($compta_prodsell_id, 'codeventil_' . $product_static->id, 1); //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue=$compta_prodsell;
$codesell=length_accountg($obj->accountancy_code_sell);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
print '</td>'; print '</td>';
} }
// Checkbox select // Checkbox select
print '<td align="center">'; print '<td align="right">';
print '<input type="checkbox" name="chk_prod[]" value="' . $obj->rowid . '"/></td>'; print '<input type="checkbox" class="checkforselect" name="chk_prod[]" value="' . $obj->rowid . '"/></td>';
print "</tr>"; print "</tr>";
$i ++; $i ++;
} }
print '</table>'; print '</table>';
print '<br><div align="right"><input type="submit" class="butAction" name="changeaccount" value="' . $langs->trans("Validate") . '"></div>';
// Example : Adding jquery code
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_savebutton()
{
console.log("We check if at least one line is checked")
atleastoneselected=0;
jQuery(".checkforselect").each(function( index ) {
/* console.log( index + ": " + $( this ).text() ); */
if ($(this).is(\':checked\')) atleastoneselected++;
});
if (atleastoneselected) jQuery("#changeaccount").removeAttr(\'disabled\');
else jQuery("#changeaccount").attr(\'disabled\',\'disabled\');
if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'butAction\');
else jQuery("#changeaccount").attr(\'class\',\'butActionRefused\');
}
jQuery(".checkforselect, #checkallactions").click(function() {
init_savebutton();
});
init_savebutton();
});
</script>';
print '<br><div align="center"><input type="submit" class="butAction" id="changeaccount" name="changeaccount" value="' . $langs->trans("Save") . '"></div>';
print '</form>'; print '</form>';
$db->free($result); $db->free($result);

View File

@ -153,7 +153,7 @@ else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, 0, 'title_accountancy');
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<div class="tabsAction">' . "\n"; print '<div class="tabsAction">' . "\n";
@ -181,12 +181,12 @@ else {
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">'; print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountAccountingShort"), $_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("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $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($langs->trans("Action"), $_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";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -241,7 +241,7 @@ else {
print '</tr>'; print '</tr>';
} }
// Affiche le compte comptable en début de ligne // Affiche le compte comptable en d<EFBFBD>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>';

View File

@ -166,8 +166,18 @@ else if ($action == "confirm_delete") {
} }
else if ($action == "confirm_create") { else if ($action == "confirm_create") {
$error = 0;
$book = new BookKeeping($db); $book = new BookKeeping($db);
if (! GETPOST('next_num_mvt'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors');
$error++;
}
if (! $error)
{
$book->label_compte = ''; $book->label_compte = '';
$book->debit = 0; $book->debit = 0;
$book->credit = 0; $book->credit = 0;
@ -190,6 +200,7 @@ else if ($action == "confirm_create") {
$piece_num = $book->piece_num; $piece_num = $book->piece_num;
} }
} }
}
/* /*
* View * View
@ -232,6 +243,10 @@ if ($action == 'create') {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$next_num_mvt = $book->getNextNumMvt(); $next_num_mvt = $book->getNextNumMvt();
if (empty($next_num_mvt))
{
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";
@ -241,19 +256,19 @@ if ($action == 'create') {
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td width="25%">' . $langs->trans("NumMvts") . '</td>'; print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>';
print '<td>' . $next_num_mvt . '</td>'; print '<td>' . $next_num_mvt . '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Docdate") . '</td>'; print '<td class="fieldrequired">' . $langs->trans("Docdate") . '</td>';
print '<td>'; print '<td>';
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Codejournal") . '</td>'; print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>'; print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
print '</tr>'; print '</tr>';
@ -286,9 +301,11 @@ if ($action == 'create') {
print load_fiche_titre($langs->trans("UpdateMvts"), '<a href="list.php">' . $langs->trans('BackToList') . '</a>'); print load_fiche_titre($langs->trans("UpdateMvts"), '<a href="list.php">' . $langs->trans('BackToList') . '</a>');
dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr class="pair">'; print '<tr class="pair">';
print '<td width="25%">' . $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">'; print '<tr class="impair">';
@ -308,14 +325,17 @@ if ($action == 'create') {
print '<td>' . $book->doc_type . '</td>'; print '<td>' . $book->doc_type . '</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '<br />';
dol_fiche_end();
print '<br>';
$result = $book->fetch_all_per_mvt($piece_num); $result = $book->fetch_all_per_mvt($piece_num);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
print load_fiche_titre($langs->trans("ListeMvts")); print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">'; print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n"; print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
@ -390,10 +410,9 @@ if ($action == 'create') {
print "</tr>\n"; print "</tr>\n";
} }
if ($total_debit != $total_credit) { if ($total_debit != $total_credit)
setEventMessages(null, array ( {
$langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit) setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings');
), 'errors');
} }
if ($action == "" || $action == 'add') { if ($action == "" || $action == 'add') {
@ -410,7 +429,7 @@ if ($action == 'create') {
print '<td align="right"><input type="text" size="6" name="credit" value="' . price($credit) . '"/></td>'; print '<td align="right"><input type="text" size="6" name="credit" value="' . price($credit) . '"/></td>';
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '"></td>'; print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';

View File

@ -2,6 +2,7 @@
/* 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-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -77,9 +78,18 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; // 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);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.rowid";
$object = new BookKeeping($db); $object = new BookKeeping($db);
@ -88,86 +98,22 @@ $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 (empty($search_date_start)) {
$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'));
} }
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "t.rowid";
$options = '';
$filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$options .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$options .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
}
if (! empty($search_doc_type)) {
$filter['t.doc_type'] = $search_doc_type;
$options .= '&amp;search_doc_type=' . $search_doc_type;
}
if (! empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$options .= '&amp;doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&amp;doc_dateday=' . GETPOST('doc_dateday', 'int') . '&amp;doc_dateyear=' . GETPOST('doc_dateyear', 'int');
}
if (! empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$options .= '&amp;search_doc_ref=' . $search_doc_ref;
}
if (! empty($search_accountancy_code)) {
$filter['t.numero_compte'] = $search_accountancy_code;
$options .= '&amp;search_accountancy_code=' . $search_accountancy_code;
}
if (! empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
}
if (! empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$options .= '&amp;search_accountancy_code_end=' . $search_accountancy_code_end;
}
if (! empty($search_accountancy_aux_code)) {
$filter['t.code_tiers'] = $search_accountancy_aux_code;
$options .= '&amp;search_accountancy_aux_code=' . $search_accountancy_aux_code;
}
if (! empty($search_accountancy_aux_code_start)) {
$filter['t.code_tiers>='] = $search_accountancy_aux_code_start;
$options .= '&amp;search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
}
if (! empty($search_accountancy_aux_code_end)) {
$filter['t.code_tiers<='] = $search_accountancy_aux_code_end;
$options .= '&amp;search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
}
if (! empty($search_mvt_label)) {
$filter['t.label_compte'] = $search_mvt_label;
$options .= '&amp;search_mvt_label=' . $search_mvt_label;
}
if (! empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$options .= '&amp;search_direction=' . $search_direction;
}
if (! empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$options .= '&amp;search_ledger_code=' . $search_ledger_code;
}
if (! empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
$options .= '&amp;search_mvt_num=' . $search_mvt_num;
}
/* /*
* Action * Action
*/ */
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{ {
$search_mvt_num = ''; $search_mvt_num = '';
$search_doc_type = ''; $search_doc_type = '';
@ -210,12 +156,22 @@ if ($action == 'delbookkeepingyearconfirm') {
$deljournal=0; $deljournal=0;
} }
if (! empty($delyear) || ! empty($deljournal))
if (! empty($delyear) || ! empty($deljournal)) { {
$result = $object->deleteByYearAndJournal($delyear,$deljournal); $result = $object->deleteByYearAndJournal($delyear,$deljournal);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
else
{
setEventMessages("RecordDeleted", null, 'mesgs');
}
Header("Location: list.php");
exit;
}
else
{
setEventMessages("NoRecordDeleted", null, 'warnings');
Header("Location: list.php"); Header("Location: list.php");
exit; exit;
} }
@ -229,15 +185,93 @@ if ($action == 'delmouvconfirm') {
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
else
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
Header("Location: list.php"); Header("Location: list.php");
exit; exit;
} }
} }
/*
* View
*/
$param = '';
$filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$tmp=dol_getdate($search_date_start);
$param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year'];
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$tmp=dol_getdate($search_date_end);
$param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year'];
}
if (! empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$tmp=dol_getdate($search_doc_date);
$param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year'];
}
if (! empty($search_doc_type)) {
$filter['t.doc_type'] = $search_doc_type;
$param .= '&search_doc_type=' . $search_doc_type;
}
if (! empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref=' . $search_doc_ref;
}
if (! empty($search_accountancy_code)) {
$filter['t.numero_compte'] = $search_accountancy_code;
$param .= '&search_accountancy_code=' . $search_accountancy_code;
}
if (! empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
}
if (! empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
}
if (! empty($search_accountancy_aux_code)) {
$filter['t.code_tiers'] = $search_accountancy_aux_code;
$param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code;
}
if (! empty($search_accountancy_aux_code_start)) {
$filter['t.code_tiers>='] = $search_accountancy_aux_code_start;
$param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
}
if (! empty($search_accountancy_aux_code_end)) {
$filter['t.code_tiers<='] = $search_accountancy_aux_code_end;
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
}
if (! empty($search_mvt_label)) {
$filter['t.label_compte'] = $search_mvt_label;
$param .= '&search_mvt_label=' . $search_mvt_label;
}
if (! empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$param .= '&search_direction=' . $search_direction;
}
if (! empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code=' . $search_ledger_code;
}
if (! empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
$param .= '&search_mvt_num=' . $search_mvt_num;
}
if ($action == 'export_csv') { if ($action == 'export_csv') {
include DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; 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);
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -253,11 +287,8 @@ if ($action == 'export_csv') {
} }
} }
/* $title_page = $langs->trans("Bookkeeping");
* View if ($search_date_start || $search_date_end) $title_page .= ' ' . dol_print_date($search_date_start, 'day') . ' - ' . dol_print_date($search_date_end, 'day');
*/
$title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
llxHeader('', $title_page); llxHeader('', $title_page);
// List // List
@ -270,6 +301,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
} }
} }
// TODO Do not use this
$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -306,39 +338,53 @@ if ($action == 'delbookkeepingyear') {
'default' => $deljournal 'default' => $deljournal
); );
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250);
print $formconfirm; print $formconfirm;
} }
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); //$param=''; param started before
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<div class="tabsAction">' . "\n"; print '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="./listbyaccount.php">' . $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting")) . '</a></div>';
print '<div class="inline-block divButAction"><input type="submit" name="button_delmvt" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></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="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>'; print '<div class="inline-block divButAction"><a class="butAction" name="button_export_csv" href="'.$_SERVER["PHP_SELF"].'?action=export_csv'.($param?'&'.$param:'').'">';
if (count($filter)) print $langs->trans("ExportFilteredList");
else print $langs->trans("ExportList");
print '</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>'; print '</div>';
print ' <a href="./listbyaccount.php">' . $langs->trans("GroupByAccountAccounting") . '</a><br><br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("TransactionNumShort"), $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $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", "", $options, "", $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", "", $options, "", $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", "", $options, "", $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("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $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", "", $param, '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", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="GET">';
print '<td><input type="text" name="search_mvt_num" size="6" value="' . $search_mvt_num . '"></td>'; print '<td><input type="text" name="search_mvt_num" size="6" value="' . $search_mvt_num . '"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre center">';
print $langs->trans('From') . ': '; print $langs->trans('From') . ': ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
print '<br>'; print '<br>';
@ -360,18 +406,16 @@ print '<br>';
print $langs->trans('to'); print $langs->trans('to');
print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
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 . '"/>';
print '</td>'; print '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td align="right"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>'; print '<td align="right"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
print '<td align="right" colspan="2" class="liste_titre">'; print '<td align="right" class="liste_titre">';
$searchpitco=$form->showFilterAndCheckAddButtons(0); $searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco; print $searchpitco;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$var = True; $var = True;
@ -398,7 +442,7 @@ foreach ( $object->lines as $line ) {
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="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $options . '&page=' . $page . '">' . img_delete() . '</a>'; print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
@ -411,13 +455,13 @@ print '</td>';
print '<td align="right">'; print '<td align="right">';
print price($total_credit); print price($total_credit);
print '</td>'; print '</td>';
print '<td colspan="2"></td>'; print '<td></td>';
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";
print '</form>'; print '</form>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -60,11 +60,23 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; // Load variable for pagination
if ($page == -1) { $page = 0 ; } $limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.rowid";
if (empty($search_date_start)) {
$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'));
}
$object = new BookKeeping($db); $object = new BookKeeping($db);
@ -73,18 +85,6 @@ $formother = new FormOther($db);
$form = new Form($db); $form = new Form($db);
if (empty($search_date_start)) {
$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'));
}
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "t.rowid";
$options = ''; $options = '';
$filter = array (); $filter = array ();
@ -202,7 +202,7 @@ if ($action == 'delbookkeepingyear') {
'default' => $delyear 'default' => $delyear
); );
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250);
print $formconfirm; print $formconfirm;
} }
@ -211,7 +211,7 @@ if ($action == 'delbookkeepingyear') {
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'',0,'','',$limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,'','',$limit);
// Reverse sort order // Reverse sort order
if ( preg_match('/^asc/i', $sortorder) ) if ( preg_match('/^asc/i', $sortorder) )
@ -223,22 +223,26 @@ print '<div class="tabsAction">' . "\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>';
print ' <a href="./list.php">' . $langs->trans("ViewFlatList") . '</a><br><br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans("AccountAccounting") . '</td>'; print '<td>' . $langs->trans("AccountAccounting") . '</td>';
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("TransactionNumShort"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docdate"), $_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 '<td>' . $langs->trans("SuppliersInvoices") . ' / ' . $langs->trans("CustomersInvoices") . '</td>'; print_liste_field_titre($langs->trans("SuppliersInvoices") . ' / ' . $langs->trans("CustomersInvoices"));
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("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Action"), $_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";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="GET">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="GET">';
print '<td width >' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . '</td>'; print '<td>' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . '</td>';
print '<td class="liste_titre">'; print '<td></td>';
print '<td class="liste_titre" align="center">';
print $langs->trans('From') . ': '; print $langs->trans('From') . ': ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
print '<br>'; print '<br>';
@ -263,7 +267,7 @@ $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_number = ""; $displayed_account_number = null; // Start with undefined to be able to distinguish with empty
foreach ( $object->lines as $line ) { foreach ( $object->lines as $line ) {
$var = ! $var; $var = ! $var;
@ -271,28 +275,37 @@ foreach ( $object->lines as $line ) {
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
// Permet d'afficher le compte comptable $accountg = length_accountg($line->numero_compte);
if (length_accountg($line->numero_compte) != $displayed_account_number) { //if (empty($accountg)) $accountg = '-';
// Is it a break ?
if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) {
// Affiche un Sous-Total par compte comptable // Affiche un Sous-Total par compte comptable
if ($displayed_account_number != "") { if (isset($displayed_account_number)) {
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("SubTotal").':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td>'; print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("SubTotal").':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td>';
print "<td>&nbsp;</td>\n"; print "<td>&nbsp;</td>\n";
print '</tr>'; print '</tr>';
} }
// Affiche le compte comptable en début de ligne // Show the break account
$colspan = 9;
print "<tr>"; print "<tr>";
print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">'.length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte).'</td>'; print '<td colspan="'.$colspan.'" style="font-weight:bold; border-bottom: 1pt solid black;">';
if (! empty($line->numero_compte) && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte);
else print '<span class="error">'.$langs->trans("Unknown").'</span>';
print '</td>';
print '</tr>'; print '</tr>';
$displayed_account_number = length_accountg($line->numero_compte); $displayed_account_number = $accountg;
//if (empty($displayed_account_number)) $displayed_account_number='-';
$sous_total_debit = 0; $sous_total_debit = 0;
$sous_total_credit = 0; $sous_total_credit = 0;
} }
print '<tr '. $bc[$var].'>'; print '<tr '. $bc[$var].'>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td align="right">'.$line->piece_num.'</td>';
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><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->doc_ref . '</a></td>'; print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->doc_ref . '</a></td>';

View File

@ -171,7 +171,7 @@ if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
print_barre_liste($langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); print_barre_liste($langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy');
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<div class="liste_titre">'; print '<div class="liste_titre">';
@ -197,7 +197,7 @@ print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_type", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_type", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $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.code_tiers", "", $options, "", $sortfield, $sortorder);
@ -272,7 +272,7 @@ foreach ( $object->lines as $line ) {
print '<tr '. $bc[$var].'>'; print '<tr '. $bc[$var].'>';
print '<td>' . $line->piece_num . '</td>' . "\n"; print '<td>' . $line->piece_num . '</td>' . "\n";
print '<td>' . $line->doc_type . '</td>' . "\n"; print '<td>' . $line->doc_type . '</td>' . "\n";
print '<td>' . 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->code_tiers) . '</td>';

View File

@ -380,7 +380,7 @@ class AccountancyCategory
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error " . $this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR);
return - 1; return - 1;
} }

View File

@ -172,16 +172,15 @@ class AccountingAccount extends CommonObject
$sql .= " '" . $this->db->idate($now) . "'"; $sql .= " '" . $this->db->idate($now) . "'";
$sql .= ", " . $conf->entity; $sql .= ", " . $conf->entity;
$sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); $sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
$sql .= ", " . (! isset($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'"); $sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
$sql .= ", " . (! isset($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'"); $sql .= ", " . (empty($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'");
$sql .= ", " . (! isset($this->account_number) ? 'NULL' : "'" . $this->account_number . "'"); $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->account_number . "'");
$sql .= ", " . (! isset($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'"); $sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'");
$sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); $sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
$sql .= ", " . (! isset($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'"); $sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'");
$sql .= ", " . $user->id; $sql .= ", " . $user->id;
$sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'"); $sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
$sql .= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();

View File

@ -107,16 +107,16 @@ class BookKeeping extends CommonObject
* *
* @param User $user User that creates * @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function create(User $user, $notrigger = false) { public function create(User $user, $notrigger = false) {
global $conf, $langs;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->doc_type)) { if (isset($this->doc_type)) {
$this->doc_type = trim($this->doc_type); $this->doc_type = trim($this->doc_type);
} }
@ -162,6 +162,17 @@ class BookKeeping extends CommonObject
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
if (empty($this->debit)) $this->debit = 0;
if (empty($this->credit)) $this->credit = 0;
// Check parameters
if (empty($this->numero_compte) || $this->numero_compte == '-1')
{
$langs->load("errors");
$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet);
return -1;
}
$this->db->begin(); $this->db->begin();
@ -173,8 +184,10 @@ class BookKeeping extends CommonObject
$sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " WHERE doc_type = '" . $this->doc_type . "'";
$sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND fk_docdet = " . $this->fk_docdet;
$sql .= " AND numero_compte = '" . $this->numero_compte . "'"; $sql .= " AND numero_compte = '" . $this->numero_compte . "'";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -187,6 +200,9 @@ class BookKeeping extends CommonObject
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum); $resqlnum = $this->db->query($sqlnum);
@ -198,6 +214,9 @@ class BookKeeping extends CommonObject
if (empty($this->piece_num)) { if (empty($this->piece_num)) {
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
$sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
if (! empty($conf->multicompany->enabled)) {
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum); $resqlnum = $this->db->query($sqlnum);
@ -235,7 +254,7 @@ class BookKeeping extends CommonObject
$sql .= ", piece_num"; $sql .= ", piece_num";
$sql .= ', entity'; $sql .= ', entity';
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'" . $this->doc_date . "'"; $sql .= "'" . $this->db->idate($this->doc_date) . "'";
$sql .= ",'" . $this->doc_type . "'"; $sql .= ",'" . $this->doc_type . "'";
$sql .= ",'" . $this->doc_ref . "'"; $sql .= ",'" . $this->doc_ref . "'";
$sql .= "," . $this->fk_doc; $sql .= "," . $this->fk_doc;
@ -248,7 +267,7 @@ class BookKeeping extends CommonObject
$sql .= "," . $this->montant; $sql .= "," . $this->montant;
$sql .= ",'" . $this->sens . "'"; $sql .= ",'" . $this->sens . "'";
$sql .= ",'" . $this->fk_user_author . "'"; $sql .= ",'" . $this->fk_user_author . "'";
$sql .= ",'" . $this->date_create . "'"; $sql .= ",'" . $this->db->idate($this->date_create). "'";
$sql .= ",'" . $this->code_journal . "'"; $sql .= ",'" . $this->code_journal . "'";
$sql .= "," . $this->piece_num; $sql .= "," . $this->piece_num;
$sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity);
@ -274,11 +293,11 @@ class BookKeeping extends CommonObject
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
} }
} else { } else { // Already exists
$result = -3; $result = -3;
$error++; $error++;
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error Transaction for ('.$this->doc_type.', '.$this->doc_ref.', '.$this->fk_docdet.') were already recorded';
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_WARNING);
} }
} else { } else {
$result = - 5; $result = - 5;
@ -317,7 +336,6 @@ class BookKeeping extends CommonObject
* *
* @param User $user User that creates * @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function createStd(User $user, $notrigger = false) { public function createStd(User $user, $notrigger = false) {
@ -372,13 +390,14 @@ class BookKeeping extends CommonObject
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
if (empty($this->debit)) $this->debit = 0;
if (empty($this->credit)) $this->credit = 0;
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql .= 'doc_date,'; $sql .= 'doc_date,';
$sql .= 'doc_type,'; $sql .= 'doc_type,';
$sql .= 'doc_ref,'; $sql .= 'doc_ref,';
@ -403,16 +422,16 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ',';
$sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ',';
$sql .= ' ' . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ','; $sql .= ' ' . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ',';
$sql .= ' ' . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ',';
$sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ',';
$sql .= ' ' . (! isset($this->debit) ? 'NULL' : "'" . $this->debit . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ',';
$sql .= ' ' . (! isset($this->credit) ? 'NULL' : "'" . $this->credit . "'") . ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ',';
$sql .= ' ' . (! isset($this->montant) ? 'NULL' : "'" . $this->montant . "'") . ','; $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ',';
$sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ','; $sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ',';
$sql .= ' ' . $user->id . ','; $sql .= ' ' . $user->id . ',';
$sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ',';
$sql .= ' ' . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
$sql .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num).','; $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).',';
$sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity);
$sql .= ')'; $sql .= ')';
@ -460,11 +479,12 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = null) { public function fetch($id, $ref = null) {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= ' t.rowid,'; $sql .= ' t.rowid,';
$sql .= " t.doc_date,"; $sql .= " t.doc_date,";
$sql .= " t.doc_type,"; $sql .= " t.doc_type,";
$sql .= " t.doc_ref,"; $sql .= " t.doc_ref,";
@ -481,7 +501,6 @@ class BookKeeping extends CommonObject
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.code_journal,"; $sql .= " t.code_journal,";
$sql .= " t.piece_num"; $sql .= " t.piece_num";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
if (! empty($conf->multicompany->enabled)) { if (! empty($conf->multicompany->enabled)) {
@ -546,11 +565,12 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= ' t.rowid,'; $sql .= ' t.rowid,';
$sql .= " t.doc_date,"; $sql .= " t.doc_date,";
$sql .= " t.doc_type,"; $sql .= " t.doc_type,";
$sql .= " t.doc_ref,"; $sql .= " t.doc_ref,";
@ -567,9 +587,6 @@ class BookKeeping extends CommonObject
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.code_journal,"; $sql .= " t.code_journal,";
$sql .= " t.piece_num"; $sql .= " t.piece_num";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter // Manage filter
$sqlwhere = array (); $sqlwhere = array ();
if (count($filter) > 0) { if (count($filter) > 0) {
@ -591,7 +608,6 @@ class BookKeeping extends CommonObject
} }
} }
} }
$sql.= ' WHERE 1 = 1'; $sql.= ' WHERE 1 = 1';
if (! empty($conf->multicompany->enabled)) { if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
@ -662,11 +678,12 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= ' t.rowid,'; $sql .= ' t.rowid,';
$sql .= " t.doc_date,"; $sql .= " t.doc_date,";
$sql .= " t.doc_type,"; $sql .= " t.doc_type,";
$sql .= " t.doc_ref,"; $sql .= " t.doc_ref,";
@ -683,9 +700,7 @@ class BookKeeping extends CommonObject
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.code_journal,"; $sql .= " t.code_journal,";
$sql .= " t.piece_num"; $sql .= " t.piece_num";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter // Manage filter
$sqlwhere = array (); $sqlwhere = array ();
if (count($filter) > 0) { if (count($filter) > 0) {
@ -705,7 +720,6 @@ class BookKeeping extends CommonObject
} }
} }
} }
$sql.= ' WHERE 1 = 1'; $sql.= ' WHERE 1 = 1';
if (! empty($conf->multicompany->enabled)) { if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
@ -774,16 +788,15 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= " t.numero_compte,"; $sql .= " t.numero_compte,";
$sql .= " SUM(t.debit) as debit,"; $sql .= " SUM(t.debit) as debit,";
$sql .= " SUM(t.credit) as credit"; $sql .= " SUM(t.credit) as credit";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter // Manage filter
$sqlwhere = array (); $sqlwhere = array ();
if (count($filter) > 0) { if (count($filter) > 0) {
@ -803,9 +816,12 @@ class BookKeeping extends CommonObject
} }
} }
} }
$sql.= ' WHERE 1 = 1';
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
}
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
} }
$sql .= ' GROUP BY t.numero_compte'; $sql .= ' GROUP BY t.numero_compte';
@ -907,7 +923,6 @@ class BookKeeping extends CommonObject
// Update request // Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
$sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ','; $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ',';
$sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ','; $sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ',';
$sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ',';
@ -924,7 +939,6 @@ class BookKeeping extends CommonObject
$sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ','; $sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ',';
$sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ',';
$sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null");
$sql .= ' WHERE rowid=' . $this->id; $sql .= ' WHERE rowid=' . $this->id;
$this->db->begin(); $this->db->begin();
@ -1027,10 +1041,7 @@ class BookKeeping extends CommonObject
if (! $resql) { if (! $resql) {
$this->errors[] = "Error " . $this->db->lasterror(); $this->errors[] = "Error " . $this->db->lasterror();
foreach ( $this->errors as $errmsg ) { dol_syslog(get_class($this)."::delete Error " . $this->db->lasterror(), LOG_ERR);
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback(); $this->db->rollback();
return - 1; return - 1;
} }
@ -1042,17 +1053,29 @@ class BookKeeping extends CommonObject
/** /**
* Delete bookkepping by year * Delete bookkepping by year
* *
* @param string $delyear year to delete * @param string $delyear Year to delete
* @return int Result * @param string $journal Journal to delete
* @return int <0 if KO, >0 if OK
*/ */
function deleteByYear($delyear) { function deleteByYearAndJournal($delyear='', $journal='') {
global $conf;
if (empty($delyear) && empty($journal))
{
return -1;
}
$this->db->begin(); $this->db->begin();
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "DELETE"; $sql = "DELETE";
$sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE YEAR(doc_date) = " . $delyear; $sql.= " WHERE 1 = 1";
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
@ -1076,12 +1099,17 @@ class BookKeeping extends CommonObject
* @return int Result * @return int Result
*/ */
function deleteMvtNum($piecenum) { function deleteMvtNum($piecenum) {
global $conf;
$this->db->begin(); $this->db->begin();
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "DELETE"; $sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1179,9 +1207,14 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchPerMvt($piecenum) { public function fetchPerMvt($piecenum) {
global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1205,18 +1238,25 @@ class BookKeeping extends CommonObject
/** /**
* Return next number movement * Return next number movement
* *
* @return string Last number * @return string Next numero to use
*/ */
public function getNextNumMvt() { public function getNextNumMvt()
{
global $conf;
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element;
if (! empty($conf->multicompany->enabled)) {
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) $result = $obj->max;
return $obj->max; if (empty($result)) $result = 1;
return $result;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR);
@ -1231,12 +1271,17 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_all_per_mvt($piecenum) { function fetch_all_per_mvt($piecenum) {
global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
$sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " numero_compte, label_compte, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1281,11 +1326,16 @@ class BookKeeping extends CommonObject
* @return int Result * @return int Result
*/ */
function export_bookkeping($model = 'ebp') { function export_bookkeping($model = 'ebp') {
global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
$sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " numero_compte, label_compte, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
if (! empty($conf->multicompany->enabled)) {
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
@ -1336,10 +1386,9 @@ class BookKeeping extends CommonObject
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param array $event Event options * @param array $event Event options
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1) * @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number * @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number * @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
*
* @return string String with HTML select * @return string String with HTML select
*/ */
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
@ -1355,6 +1404,9 @@ class BookKeeping extends CommonObject
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND asy.rowid = " . $pcgver;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")";
}
$sql .= " ORDER BY account_number ASC"; $sql .= " ORDER BY account_number ASC";
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
@ -1373,7 +1425,6 @@ class BookKeeping extends CommonObject
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$label = length_accountg($obj->account_number) . ' - ' . $obj->label; $label = length_accountg($obj->account_number) . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength);
$select_value_in = $obj->rowid; $select_value_in = $obj->rowid;
$select_value_out = $obj->rowid; $select_value_out = $obj->rowid;
@ -1405,14 +1456,13 @@ class BookKeeping extends CommonObject
* Description of a root accounting account * Description of a root accounting account
* *
* @param string $account Accounting account * @param string $account Accounting account
* @return string * @return string Root account
*/ */
function get_compte_racine($account = null) function get_compte_racine($account = null)
{ {
global $conf; global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT root.account_number, root.label as label"; $sql = "SELECT root.account_number, root.label as label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
@ -1422,7 +1472,9 @@ class BookKeeping extends CommonObject
$sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " WHERE aa.account_number = '" . $account . "'";
$sql .= " AND parent.active = 1"; $sql .= " AND parent.active = 1";
$sql .= " AND root.active = 1"; $sql .= " AND root.active = 1";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1447,11 +1499,12 @@ class BookKeeping extends CommonObject
* Description of accounting account * Description of accounting account
* *
* @param string $account Accounting account * @param string $account Accounting account
* @return string * @return string Account desc
*/ */
function get_compte_desc($account = null) function get_compte_desc($account = null)
{ {
global $conf; global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa ";
@ -1460,6 +1513,10 @@ class BookKeeping extends CommonObject
$sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND asy.rowid = " . $pcgver;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
if (! empty($conf->multicompany->enabled)) {
$sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")";
}
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -1483,6 +1540,7 @@ class BookKeeping extends CommonObject
} }
/** /**
* Class BookKeepingLine * Class BookKeepingLine
*/ */

View File

@ -65,7 +65,7 @@ class FormVentilation extends Form
/** /**
* Return list of accounts with label by chart of accounts * Return list of accounts with label by chart of accounts
* *
* @param string $selectid Preselected chart of accounts * @param string $selectid Preselected id or code of accounting accounts (depends on $select_in)
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param array $event Event options * @param array $event Event options
@ -99,34 +99,37 @@ class FormVentilation extends Form
$out = ajax_combobox($htmlname, $event); $out = ajax_combobox($htmlname, $event);
// TODO Add $options in cache so next call will not execute the request
$selected = 0;
$options = array(); $options = array();
$selected = null; while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$label = length_accountg($obj->account_number) . ' - ' . $obj->label; $label = length_accountg($obj->account_number) . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength); $label = dol_trunc($label, $trunclength);
$select_value_in = $obj->rowid; $select_value_in = $obj->rowid;
$select_value_out = $obj->rowid; $select_value_out = $obj->rowid;
// Try to guess if we have found default value
if ($select_in == 1) { if ($select_in == 1) {
$select_value_in = $obj->account_number; $select_value_in = $obj->account_number;
} }
if ($select_out == 1) { if ($select_out == 1) {
$select_value_out = $obj->account_number; $select_value_out = $obj->account_number;
} }
// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
// Because same account_number can be share between different accounting_system and do have the same meaning // Because same account_number can be share between different accounting_system and do have the same meaning
if (($selectid != '') && $selectid == $select_value_in) { if ($selectid != '' && $selectid == $select_value_in) {
//var_dump("Found ".$selectid." ".$select_value_in);
$selected = $select_value_out; $selected = $select_value_out;
} }
$options[$select_value_out] = $label; $options[$select_value_out] = $label;
} }
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss); $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
$this->db->free($resql); $this->db->free($resql);
return $out; return $out;
} }

View File

@ -40,26 +40,35 @@ $id = GETPOST('id');
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
/* /*
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
if ($action == 'ventil' && $user->rights->accounting->bind->write) {
if (! GETPOST('cancel', 'alpha')) { if (! GETPOST('cancel', 'alpha')) {
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id; $sql .= " WHERE rowid = " . $id;
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) { if (! $resql) {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} }
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
} else { } else {
header("Location: ./lines.php"); header("Location: ./lines.php");
exit(); exit();
} }
} }
/* /*
* View * View
*/ */
@ -86,9 +95,7 @@ if (! empty($id)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);

View File

@ -25,9 +25,8 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Home customer ventilation * \brief Home customer ventilation
*/ */
require '../../main.inc.php';
// Class 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';
@ -39,9 +38,12 @@ $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
// Security check // Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->ventilation->read) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
// Filter // Filter
@ -56,11 +58,29 @@ if ($year == 0) {
// Validate History // Validate History
$action = GETPOST('action'); $action = GETPOST('action');
/*
* Actions
*/
if ($action == 'validatehistory') { if ($action == 'validatehistory') {
$error = 0; $error = 0;
$db->begin(); $db->begin();
// First clean corrupted data
$sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sqlclean .= " SET fd.fk_code_ventilation = 0";
$sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sqlclean .= ' (SELECT accnt.rowid ';
$sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sqlclean .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sqlclean .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')';
$resql = $db->query($sqlclean);
// Now make the binding
if ($db->type == 'pgsql') { if ($db->type == 'pgsql') {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " SET fk_code_ventilation = accnt.rowid";
@ -114,6 +134,7 @@ if ($action == 'validatehistory') {
$error = 0; $error = 0;
$db->begin(); $db->begin();
// 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 fd.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";
@ -143,16 +164,16 @@ llxHeader('', $langs->trans("CustomersVentilation"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>'; $textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>'; $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
print $langs->trans("DescVentilCustomer") . '<br>'; print $langs->trans("DescVentilCustomer") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToDispatch")) . '<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">';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>'; print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
// TODO Remove this. Should be done always. // TODO Remove this. Should be done into the repair.php script
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 > 0) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
print '</div>'; print '</div>';
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
@ -191,10 +212,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
@ -238,12 +256,9 @@ $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
if (! empty($conf->multicompany->enabled)) { dol_syslog('htdocs/accountancy/customer/index.php');
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$i = 0; $i = 0;
@ -282,10 +297,7 @@ if (! empty($conf->margin->enabled)) {
$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
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -52,27 +52,17 @@ $search_vat = GETPOST('search_vat', 'alpha');
$search_country = GETPOST('search_country', 'alpha'); $search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Getpost Order and column and limit page // 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);
$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 < 0) if ($page < 0) $page = 0;
$page = 0;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
$offset = $limit * $page; $offset = $limit * $page;
if (! $sortfield) if (! $sortfield)
$sortfield = "f.datef, f.facnumber, fd.rowid"; $sortfield = "f.datef, f.facnumber, fd.rowid";
if (! $sortorder) { if (! $sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -82,7 +72,7 @@ if (! $sortorder) {
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->ventilation->dispatch) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
@ -128,6 +118,8 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$db->rollback(); $db->rollback();
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} }
$account_parent = ''; // Protection to avoid to mass apply it a second time
} }
/* /*
@ -168,9 +160,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql .= " WHERE fd.fk_code_ventilation > 0 "; $sql .= " WHERE fd.fk_code_ventilation > 0 ";
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
$sql .= " AND f.fk_statut > 0"; $sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
@ -204,28 +194,28 @@ if (strlen(trim($search_country))) {
if (strlen(trim($search_tvaintra))) { if (strlen(trim($search_tvaintra))) {
$sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')"; $sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')";
} }
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
// Count total nb of records with no order and no limits
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
if ($resql)
$nbtotalofrecords = $db->num_rows($resql);
else
dol_print_error($db);
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/customer/lines.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accountancy/customer/lines.php", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num_lines = $db->num_rows($result); $num_lines = $db->num_rows($result);
$i = 0; $i = 0;
$param = ""; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_invoice) if ($search_invoice)
$param .= "&search_invoice=" . $search_invoice; $param .= "&search_invoice=" . $search_invoice;
if ($search_ref) if ($search_ref)
@ -244,27 +234,37 @@ if ($result) {
$param .= "&search_tvaintra=" . $search_tvaintra; $param .= "&search_tvaintra=" . $search_tvaintra;
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<td align="left"><b>' . $langs->trans("DescVentilDoneCustomer") . '</b></td>'; print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<table class="noborder" width="100%">'; print $langs->trans("DescVentilDoneCustomer") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account($account_parent, 'account_parent', 1); print $formventilation->select_account($account_parent, 'account_parent', 1);
print '<input type="submit" class="button" value="' . $langs->trans("Validate") . '"/></div>'; print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
$moreforfilter = '';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $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("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "fd.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre('', '', '', '', '', 'align="center"');
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -273,12 +273,14 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>'; print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>'; print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_country" value="' . $search_country . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_country" size="5" value="' . $search_country . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_tavintra" value="' . $search_tavintra . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_tavintra" size="5" value="' . $search_tavintra . '"></td>';
print '<td class="liste_titre" align="center"><input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; print '<td class="liste_titre" align="right"></td>';
print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">'; print '<td class="liste_titre" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(1);
print $searchpitco;
print "</td></tr>\n"; print "</td></tr>\n";
$facture_static = new Facture($db); $facture_static = new Facture($db);
@ -300,6 +302,7 @@ if ($result) {
$product_static->ref = $objp->product_ref; $product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id; $product_static->id = $objp->product_id;
$product_static->type = $objp->product_type; $product_static->type = $objp->product_type;
$product_static->label = $objp->product_label;
print '<td>'; print '<td>';
if ($product_static->id) if ($product_static->id)
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
@ -314,9 +317,10 @@ if ($result) {
print '<td>' . $codecompta . '<a href="./card.php?id=' . $objp->fdid . '">'; print '<td>' . $codecompta . '<a href="./card.php?id=' . $objp->fdid . '">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td align="right">' . $objp->country .'</td>'; print '<td>' . $objp->country .'</td>';
print '<td align="center">' . $objp->tva_intra . '</td>'; print '<td>' . $objp->tva_intra . '</td>';
print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->fdid . '"/></td>'; print '<td align="right">' . $objp->rowid . '</td>';
print '<td align="right"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->fdid . '"/></td>';
print "</tr>"; print "</tr>";
$i ++; $i ++;
@ -325,11 +329,14 @@ if ($result) {
print $db->error(); print $db->error();
} }
print "</table></form>"; print "</table>";
if ($num_lines > $conf->liste_limit) { if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, ''); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
} }
print '</form>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -4,6 +4,7 @@
* 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>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -43,7 +44,6 @@ $langs->load("accountancy");
$action = GETPOST('action'); $action = GETPOST('action');
// Select Box // Select Box
$codeventil = GETPOST('codeventil', 'array');
$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array');
// Search Getpost // Search Getpost
@ -56,25 +56,17 @@ $search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha');
// Getpost Order and column and limit page // 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);
$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 < 0) if ($page < 0) { $page = 0; }
$page = 0;
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) if (! $sortfield)
$sortfield = "f.datef, f.facnumber, l.rowid"; $sortfield = "f.datef, f.facnumber, l.rowid";
if (! $sortorder) { if (! $sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -84,7 +76,7 @@ if (! $sortorder) {
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->ventilation->dispatch) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
@ -92,8 +84,14 @@ $accounting = new AccountingAccount($db);
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1); $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
/*
* Action
*/
// Purge search criteria // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_ref = ''; $search_ref = '';
$search_invoice = ''; $search_invoice = '';
$search_label = ''; $search_label = '';
@ -103,6 +101,54 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
$search_vat = ''; $search_vat = '';
} }
if ($action == 'ventil' && ! empty($btn_ventil)) {
$msg='';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($_POST["mesCasesCochees"]).'</div>';
$msg.='<div class="detail">';
$cpt = 0;
$ok=0;
$ko=0;
foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0)
{
$msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
$ko++;
}
else
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
$ok++;
} else {
$msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br> <pre>' . $sql . '</pre></font></div>';
$ko++;
}
}
$cpt++;
}
$msg.='</div>';
} else {
setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
}
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
}
/* /*
@ -111,74 +157,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
llxHeader('', $langs->trans("Ventilation")); llxHeader('', $langs->trans("Ventilation"));
print '<script type="text/javascript"> // Customer Invoice lines
$(function () {
$(\'#select-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = true;
});
});
$(\'#unselect-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = false;
});
});
});
</script>';
/*
* Action
*/
if ($action == 'ventil' && ! empty($btn_ventil)) {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($codeventil) && ! empty($mesCasesCochees)) {
print '<div><font color="red">' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
$mesCodesVentilChoisis = $codeventil;
$cpt = 0;
foreach ( $mesCasesCochees as $maLigneCochee ) {
$maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0];
$monNumLigne = $maLigneCourante[1];
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
} else {
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
}
$cpt ++;
}
} else {
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
}
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
}
/*
* Customer Invoice lines
*/
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
$offset = $limit * $page;
$sql = "SELECT f.facnumber, f.rowid as facid, f.datef, f.type as ftype, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line,"; $sql = "SELECT f.facnumber, f.rowid as facid, f.datef, f.type as ftype, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql .= " aa.rowid as aarowid"; $sql .= " aa.rowid as aarowid";
@ -187,11 +166,9 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_fac
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql .= " WHERE f.fk_statut > 0"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.fk_code_ventilation <= 0";
$sql .= " AND product_type <= 2"; $sql .= " AND product_type <= 2";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')"; $sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')";
// Add search filter like // Add search filter like
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= " AND (f.facnumber like '%" . $search_invoice . "%')"; $sql .= " AND (f.facnumber like '%" . $search_invoice . "%')";
@ -214,53 +191,78 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; $sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
} }
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accountancy/customer/list.php", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num_lines = $db->num_rows($result); $num_lines = $db->num_rows($result);
$i = 0; $i = 0;
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); $arrayofselected=is_array($toselect)?$toselect:array();
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<table class="noborder" width="100%">'; $center='<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
if ($msg) print $msg.'<br>';
$moreforfilter = '';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $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="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccountingSuggest"), '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("AccountAccountingSuggest"), '', '', '', '', 'align="center"');
print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"');
print_liste_field_titre(''); print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"'); print_liste_field_titre('', '', '', '', '', 'align="center"');
print '</tr>'; print '</tr>';
// We add search filter // We add search filter
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . $search_ref . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>';
print '<td align="right" class="liste_titre" colspan="4">'; print '<td class="liste_titre"></td>';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; print '<td class="liste_titre"></td>';
print '&nbsp;'; print '<td class="liste_titre"></td>';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">'; print '<td align="right" class="liste_titre">';
$searchpitco=$form->showFilterAndCheckAddButtons(1);
print $searchpitco;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -328,35 +330,45 @@ if ($result) {
print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>'; print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>';
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>'; print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>';
print '<td align="right">'; print '<td align="right">';
print price($objp->total_ht); print price($objp->total_ht);
print '</td>'; print '</td>';
// Vat rate
if ($objp->vat_tx_l != $objp->vat_tx_p) if ($objp->vat_tx_l != $objp->vat_tx_p)
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
print '<td style="' . $code_vat_differ . '" align="center">'; print '<td style="' . $code_vat_differ . '" align="right">';
print price($objp->tva_tx_line); print price($objp->tva_tx_line);
print '</td>'; print '</td>';
// Accounting account suggested
print '<td align="center" style="' . $code_sell_p_notset . '">'; print '<td align="center" style="' . $code_sell_p_notset . '">';
if ($objp->code_sell_l == $objp->code_sell_p) { if ($objp->code_sell_l == $objp->code_sell_p) { // Test if there is a difference between code by default and code on product
print $objp->code_sell_l; if ($objp->code_sell_l > 0) print $objp->code_sell_l;
else print $langs->trans("Unknown");
} else { } else {
print $langs->trans("Buy") . ' = ' . $objp->code_sell_l . '<br />' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p; print $langs->trans("Default") . ' = ' . ($objp->code_sell_l > 0 ? $objp->code_sell_l : $langs->trans("Unknown"));
print '<br>';
print $langs->trans("Product") . ' = ' . ($objp->code_sell_p > 0 ? $objp->code_sell_p : $langs->trans("Unknown"));
} }
print '</td>'; print '</td>';
print '<td align="center">'; print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1);
print '</td>'; print '</td>';
// Line id
print '<td align="center">' . $objp->rowid . '</td>'; print '<td align="center">' . $objp->rowid . '</td>';
print '<td align="center">';
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; print '<td align="right">';
print '<input type="checkbox" class="checkforaction" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$i ++; $i ++;
} }
print '</table>'; print '</table>';
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
print '</form>'; print '</form>';
} else { } else {
print $db->error(); print $db->error();

View File

@ -0,0 +1,162 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/supplier/card.php
* \ingroup Accountancy
* \brief Card expense report ventilation
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
// Langs
$langs->load("bills");
$langs->load("accountancy");
$langs->load("trips");
$action = GETPOST('action', 'alpha');
$codeventil = GETPOST('codeventil');
$id = GETPOST('id');
// Security check
if ($user->societe_id > 0)
accessforbidden();
/*
* Actions
*/
if ($action == 'ventil' && $user->rights->accounting->bind->write) {
if (! GETPOST('cancel', 'alpha')) {
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
$resql = $db->query($sql);
if (! $resql) {
setEventMessages($db->lasterror(), null, 'errors');
}
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
} else {
header("Location: ./lines.php");
exit();
}
}
/*
* View
*/
llxHeader("", "FicheVentilation");
if ($cancel == $langs->trans("Cancel")) {
$action = '';
}
// Create
$form = new Form($db);
$expensereport_static = new ExpenseReport($db);
$formventilation = new FormVentilation($db);
if (! empty($id)) {
$sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
$sql .= " f.id as fees_id, f.label as fees_label,";
$sql .= " aa.account_number, aa.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id;
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
if ($num_lines) {
$objp = $db->fetch_object($result);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">';
print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_setup');
dol_fiche_head();
print '<table class="border" width="100%">';
// Ref
print '<tr><td class="titlefield">' . $langs->trans("ExpenseReport") . '</td>';
$expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid;
print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
print '</tr>';
print '<tr><td>' . $langs->trans("Line") . '</td>';
print '<td>' . stripslashes(nl2br($objp->rowid)) . '</td></tr>';
print '<tr><td>' . $langs->trans("Description") . '</td>';
print '<td>' . stripslashes(nl2br($objp->comments)) . '</td></tr>';
print '<tr><td>' . $langs->trans("TypeFees") . '</td>';
print '<td>' . dol_trunc($objp->fees_label, 24) . '</td>';
print '<tr><td>' . $langs->trans("Account") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
} else {
print "Error";
}
} else {
print "Error";
}
} else {
print "Error ID incorrect";
}
llxFooter();
$db->close();

View File

@ -0,0 +1,267 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/expensereport/index.php
* \ingroup Advanced accountancy
* \brief Home expense report ventilation
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
accessforbidden();
// Filter
$year = $_GET["year"];
if ($year == 0) {
$year_current = strftime("%Y", time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
// Validate History
$action = GETPOST('action');
/*
* Actions
*/
if ($action == 'validatehistory') {
$error = 0;
$db->begin();
// First clean corrupted data
$sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sqlclean .= " SET fd.fk_code_ventilation = 0";
$sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sqlclean .= ' (SELECT accnt.rowid ';
$sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sqlclean .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sqlclean .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')';
$resql = $db->query($sqlclean);
// Now make the binding
if ($db->type == 'pgsql') {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql1 .= " SET fk_code_ventilation = accnt.rowid";
$sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " WHERE " . MAIN_DB_PREFIX . "facture_fourn_det.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 " . MAIN_DB_PREFIX . "facture_fourn_det.fk_code_ventilation = 0";
} 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 .= " SET fd.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 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number";
$sql1 .= " AND fd.fk_code_ventilation = 0";
}
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
$db->commit();
setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs');
}
} elseif ($action == 'fixaccountancycode') {
$error = 0;
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1 .= " SET fd.fk_code_ventilation = 0";
$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')';
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
} else {
$db->commit();
setEventMessage($langs->trans('Done'), 'mesgs');
}
} elseif ($action == 'cleanaccountancycode') {
$error = 0;
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1 .= " SET fd.fk_code_ventilation = 0";
$sql1 .= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql1 .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
$sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')";
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
} else {
$db->commit();
setEventMessage($langs->trans('Done'), 'mesgs');
}
}
/*
* View
*/
llxHeader('', $langs->trans("ExpenseReportsVentilation"));
$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>';
print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . "&nbsp;" . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
print $langs->trans("DescVentilExpenseReport") . '<br>';
print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>';
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
// TODO Remove this. Should be done always.
if ($conf->global->MAIN_FEATURES_LEVEL > 0) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
print '</div>';
$y = $year_current;
$var = true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200" align="left">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Label") . '</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 ".$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,";
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 .= " ROUND(SUM(erd.total_ht),2) as total";
$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 . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_create >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND er.date_create <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND er.fk_statut > 0 ";
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) {
$var = ! $var;
print '<tr ' . $bc[$var] . '><td>' . length_accountg($row[0]) . '</td>';
print '<td align="left">' . $row[1] . '</td>';
for($i = 2; $i <= 12; $i ++) {
print '<td align="right">' . price($row[$i]) . '</td>';
}
print '<td align="right">' . price($row[13]) . '</td>';
print '<td align="right"><b>' . price($row[14]) . '</b></td>';
print '</tr>';
}
$db->free($resql);
} else {
print $db->lasterror(); // Show last sql error
}
print "</table>\n";
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</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("TotalExpenseReport") . "' AS label,";
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 .= " ROUND(SUM(erd.total_ht),2) as total";
$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 .= " WHERE er.date_create >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND er.date_create <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND er.fk_statut > 0 ";
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) {
print '<tr><td>' . $row[0] . '</td>';
for($i = 1; $i <= 12; $i ++) {
print '<td align="right">' . price($row[$i]) . '</td>';
}
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
print '</tr>';
}
$db->free($resql);
} else {
print $db->lasterror(); // Show last sql error
}
print "</table>\n";
llxFooter();
$db->close();

View File

@ -0,0 +1,309 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/expensereport/lines.php
* \ingroup Advanced accountancy
* \brief Page of detail of the lines of ventilation of expense reports
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$langs->load("trips");
$account_parent = GETPOST('account_parent');
$changeaccount = GETPOST('changeaccount');
// Search Getpost
$search_expensereport = GETPOST('search_expensereport', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
// 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);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if ($page < 0) $page = 0;
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
$sortfield = "er.date_create, er.ref, erd.rowid";
if (! $sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC";
}
}
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
/*
* Actions
*/
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$search_expensereport = '';
$search_label = '';
$search_desc = '';
$search_amount = '';
$search_account = '';
$search_vat = '';
}
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
setEventMessages($db->lasterror(), null, 'errors');
}
if (! $error) {
$db->commit();
setEventMessages($langs->trans('Save'), null, 'mesgs');
} else {
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
}
$account_parent = ''; // Protection to avoid to mass apply it a second time
}
/*
* View
*/
llxHeader('', $langs->trans("ExpenseReportsVentilation") . ' - ' . $langs->trans("Dispatched"));
print '<script type="text/javascript">
$(function () {
$(\'#select-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = true;
});
});
$(\'#unselect-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = false;
});
});
});
</script>';
/*
* Expense reports lines
*/
$sql = "SELECT er.ref, er.rowid as erid, erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, aa.label, aa.account_number, ";
$sql .= " f.id as fees_id, f.label as fees_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql .= " , " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " , " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut >= 5 AND erd.fk_code_ventilation <> 0 ";
$sql .= " AND aa.rowid = erd.fk_code_ventilation";
if (strlen(trim($search_expensereport))) {
$sql .= " AND er.ref like '%" . $search_expensereport . "%'";
}
if (strlen(trim($search_label))) {
$sql .= " AND f.label like '%" . $search_label . "%'";
}
if (strlen(trim($search_desc))) {
$sql .= " AND er.comments like '%" . $search_desc . "%'";
}
if (strlen(trim($search_amount))) {
$sql .= " AND erd.total_ht like '%" . $search_amount . "%'";
}
if (strlen(trim($search_account))) {
$sql .= " AND aa.account_number like '%" . $search_account . "%'";
}
if (strlen(trim($search_vat))) {
$sql .= " AND (erd.tva_tx like '" . $search_vat . "%')";
}
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/expensereport/lines.php::list');
$result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_expensereport)
$param .= "&search_expensereport=" . $search_expensereport;
if ($search_label)
$param .= "&search_label=" . $search_label;
if ($search_desc)
$param .= "&search_desc=" . $search_desc;
if ($search_account)
$param .= "&search_account=" . $search_account;
if ($search_vat)
$param .= "&search_vat=" . $search_vat;
if ($search_country)
$param .= "&search_country=" . $search_country;
if ($search_tvaintra)
$param .= "&search_tvaintra=" . $search_tvaintra;
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print_barre_liste($langs->trans("ExpenseReportLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print $langs->trans("DescVentilDoneExpenseReport") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
$moreforfilter = '';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("ExpenseReport"), $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("TypeFees"), $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "erd.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre('');
print_liste_field_titre('', '', '', '', '', 'align="center"');
print "</tr>\n";
print '<tr class="liste_titre"><td><input type="text" class="flat" name="search_expensereport" size="10" value="' . $search_expensereport . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
print '<td class="liste_titre" align="right"></td>';
print '<td class="liste_titre" align="right"></td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(1);
print $searchpicto;
print '</td>';
print "</tr>\n";
$expensereport_static = new ExpenseReport($db);
$var = True;
while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
$codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label;
print '<tr '. $bc[$var].'>';
// Ref Invoice
$expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid;
print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
print '<td>' . dol_trunc($objp->fees_label, 24) . '</td>';
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print '<td>' . nl2br(dol_trunc($objp->comments, $trunclength)) . '</td>';
print '<td align="right">' . price($objp->total_ht) . '</td>';
print '<td align="center">' . price($objp->tva_tx) . '</td>';
print '<td>' . $codeCompta . '</td>';
print '<td align="right">' . $objp->rowid . '</td>';
print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '">';
print img_edit();
print '</a></td>';
print '<td align="right"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print "</tr>";
$i ++;
}
} else {
print $db->error();
}
print "</table>";
if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
}
print '</form>';
llxFooter();
$db->close();

View File

@ -0,0 +1,328 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/expensereport/list.php
* \ingroup Advanced accountancy
* \brief Ventilation page from expense reports
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("trips");
$langs->load("main");
$langs->load("accountancy");
$action = GETPOST('action');
// Select Box
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
// Search Getpost
$search_expensereport = GETPOST('search_expensereport', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha');
// 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);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
if ($page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
$sortfield = "er.date_create, er.ref, erd.rowid";
if (! $sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC";
}
}
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
// Defaut AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
// so we need to get those default value rowid first
$accounting = new AccountingAccount($db);
/*
* Action
*/
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_expensereport = '';
$search_label = '';
$search_desc = '';
$search_amount = '';
$search_account = '';
$search_vat = '';
}
if ($action == 'ventil' && ! empty($btn_ventil)) {
$msg='';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($_POST["mesCasesCochees"]).'</div>';
$msg.='<div class="detail">';
$mesCodesVentilChoisis = $codeventil;
$cpt = 0;
$ok=0;
$ko=0;
foreach ( $mesCasesCochees as $maLigneCochee ) {
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
$maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0)
{
$msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
$ko++;
}
else
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog('accountancy/expensereport/list.php:: sql=' . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$ok++;
$msg.= '<div><font color="green">' . $langs->trans("LineOfExpenseReport") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
} else {
$ko++;
$msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
}
}
$cpt++;
}
$msg.='</div>';
} else {
setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
}
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
}
/*
* View
*/
llxHeader('', $langs->trans("ExpenseReportsVentilation"));
// Expense report lines
$sql = "SELECT er.ref, er.rowid as erid, er.date_debut, erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, ";
$sql .= " f.id as fees_id, f.label as fees_label, f.accountancy_code as code_buy,";
$sql .= " aa.rowid as aarowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql .= " WHERE er.fk_statut > 4 AND erd.fk_code_ventilation <= 0";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR f.accountancy_code IS NULL OR f.accountancy_code ='')";
// Add search filter like
if (strlen(trim($search_expensereport))) {
$sql .= " AND (er.ref like '%" . $search_expensereport . "%')";
}
if (strlen(trim($search_label))) {
$sql .= " AND (f.label like '%" . $search_label . "%')";
}
if (strlen(trim($search_desc))) {
$sql .= " AND (erd.comments like '%" . $search_desc . "%')";
}
if (strlen(trim($search_amount))) {
$sql .= " AND erd.total_ht like '" . $search_amount . "%'";
}
if (strlen(trim($search_account))) {
$sql .= " AND aa.account_number like '%" . $search_account . "%'";
}
if (strlen(trim($search_vat))) {
$sql .= " AND (erd.tva_tx like '" . $search_vat . "%')";
}
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/expensereport/list.php');
$result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
$center='<div class="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, 0, 'title_accountancy', 0, '', '', $limit);
if ($msg) print $msg.'<br>';
print $langs->trans("DescVentilTodoExpenseReport") . '</br><br>';
$moreforfilter = '';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("ExpenseReport"), $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("TypeFees"), $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccountingSuggest"), '', '', '', '', 'align="center"');
print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"');
print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "erd.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre('', '', '', '', '', 'align="center"');
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_expensereport" value="' . $search_expensereport . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td align="right" class="liste_titre">';
$searchpicto=$form->showFilterAndCheckAddButtons(1);
print $searchpicto;
print '</td>';
print '</tr>';
$expensereport_static = new ExpenseReport($db);
$form = new Form($db);
$var = True;
while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
$objp->aarowid_suggest = '';
$objp->aarowid_suggest = $objp->aarowid;
print '<tr '. $bc[$var].'>';
// Ref Expense report
$expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid;
print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
// Fees label
print '<td>';
print dol_trunc($objp->fees_label, 24);
print '</td>';
// Fees description -- Can be null
// TODO: we should set a user defined value to adjust user square / wide screen size
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print '<td>' . nl2br(dol_trunc($objp->comments, $trunclength)) . '</td>';
print '<td align="right">';
print price($objp->price);
print '</td>';
// Vat rate
print '<td align="right">';
print price($objp->tva_tx_line);
print '</td>';
// Accounting account suggested
print '<td align="center">';
print length_accountg(html_entity_decode($objp->code_buy));
print '</td>';
// Colonne choix du compte
print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1);
print '</td>';
// Line id
print '<td align="center">' . $objp->rowid . '</td>';
// Colonne choix ligne a ventiler
print '<td align="right">';
print '<input type="checkbox" class="checkforaction" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>';
print "</tr>";
$i ++;
}
print '</table>';
print '</form>';
} else {
print $db->error();
}
llxFooter();
$db->close();

View File

@ -0,0 +1,164 @@
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/index.php
* \ingroup Advanced accountancy
* \brief Home accounting module
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
// Security check
if ($user->societe_id > 0)
accessforbidden();
// Validate History
$action = GETPOST('action');
$langs->load("admin");
$langs->load("dict");
$langs->load("bills");
$langs->load("accountancy");
$langs->load("compta");
$langs->load("banks");
$langs->load("loans");
/*
* Actions
*/
/*
* View
*/
llxHeader('', $langs->trans("AccountancyArea"));
print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy');
$step = 0;
print "<br>\n";
print $langs->trans("AccountancyAreaDescIntro")."<br>\n";
print "<br>\n";print "<br>\n";
print_fiche_titre($langs->trans("AccountancyAreaDescActionOnce"), '', 'object_calendar')."<br>\n";
print '<hr>';
print "<br>\n";
// STEPS
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").'</strong>');
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").'</strong>');
print "<br>\n";
print "<br>\n";
print $langs->trans("AccountancyAreaDescActionOnceBis");
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>')."<br>\n";
print "<br>\n";
$step++;
$textlink = '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink);
print "<br>\n";
print "<br>\n";
if (! empty($conf->tax->enabled))
{
$textlink = '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong>';
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink);
print "<br>\n";
print "<br>\n";
}
/*if (! empty($conf->salaries->enabled))
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
// htdocs/admin/salaries.php
print "<br>\n";
print "<br>\n";
}*/
if (! empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}
if (! empty($conf->loan->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuLoanAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}
/*
if (! empty($conf->don->enabled))
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDonationAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}*/
$step++;
$textlink='<strong>'.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink);
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'</strong>')."<br>\n";
print "<br>\n";
print "<br>\n";
print_fiche_titre($langs->trans("AccountancyAreaDescActionFreq"), '', 'object_calendarweek');
print '<hr>';
print "<br>\n";
$step = 0;
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescCustomer", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'</strong>')."<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSupplier", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>')."<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>')."<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", $step)."<br>\n";
print "<br>\n";
llxFooter();
$db->close();

View File

@ -42,6 +42,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
@ -73,9 +74,13 @@ $now = dol_now();
if ($user->societe_id > 0 && empty($id_bank_account)) if ($user->societe_id > 0 && empty($id_bank_account))
accessforbidden(); accessforbidden();
/* /*
* View * Actions
*/ */
$error = 0;
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1; $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
@ -96,16 +101,15 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0]; $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, soc.code_compta, ba.courant,"; $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 .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop"; $sql .= " ba.courant, ba.ref as baref, ba.account_number,";
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
$sql .= " WHERE ba.rowid=" . $id_bank_account; $sql .= " WHERE ba.rowid=" . $id_bank_account;
if (! empty($conf->multicompany->enabled)) { $sql .= ' AND ba.entity IN ('.getEntity('banque', 0).')'; // We don't share object for accountancy
$sql .= " AND ba.entity = " . $conf->entity;
}
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) . "'";
$sql .= " ORDER BY b.datev"; $sql .= " ORDER BY b.datev";
@ -138,28 +142,33 @@ if ($result) {
$account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef")); $account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef"));
$account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : $langs->trans("CodeNotDef")); $account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : $langs->trans("CodeNotDef"));
$tabcompany = array();
$tabpay = array (); $tabpay = array ();
$tabbq = array (); $tabbq = array ();
$tabtp = array (); $tabtp = array ();
$tabtype = array (); $tabtype = array ();
// Loop on each line into bank account. For each line, we should get:
// on line tabpay = line into bank
// one line for bank jounral = tabbq
// one line for thirdparty journal = tabtp
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$tabcompany[$obj->rowid] = array ( // Set accountancy code (for bank and thirdparty)
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_compta
);
// Controls
$compta_bank = $obj->account_number; $compta_bank = $obj->account_number;
if ($obj->label == '(SupplierInvoicePayment)') if ($obj->label == '(SupplierInvoicePayment)')
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier); $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier);
if ($obj->label == '(CustomerInvoicePayment)') if ($obj->label == '(CustomerInvoicePayment)')
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer); $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer);
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
'code_compta' => $compta_soc,
);
// Variable bookkeeping // Variable bookkeeping
$tabpay[$obj->rowid]["date"] = $obj->do; $tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
@ -174,16 +183,24 @@ if ($result) {
// get_url may return -1 which is not traversable // get_url may return -1 which is not traversable
if (is_array($links)) { if (is_array($links)) {
// 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'))) // So we excluded 'company' here
{
// 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'];
}
if ($links[$key]['type'] == 'payment') { if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id']; $paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
} else if ($links[$key]['type'] == 'payment_supplier') { } else if ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id']; $paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id']; $paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id;
} else if ($links[$key]['type'] == 'company') { } else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id']; $societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label']; $societestatic->name = $links[$key]['label'];
@ -248,6 +265,26 @@ if ($result) {
$tabbq[$obj->rowid][$compta_bank] += $obj->amount; $tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// Check account number is ok
/*if ($action == 'writebookkeeping') // Make test now in such a case
{
reset($tabbq[$obj->rowid]);
$first_key_tabbq = key($tabbq[$obj->rowid]);
if (empty($first_key_tabbq))
{
$error++;
setEventMessages($langs->trans('ErrorAccountancyCodeOnBankAccountNotDefined', $obj->baref), null, 'errors');
}
reset($tabtp[$obj->rowid]);
$first_key_tabtp = key($tabtp[$obj->rowid]);
if (empty($first_key_tabtp))
{
$error++;
setEventMessages($langs->trans('ErrorAccountancyCodeOnThirdPartyNotDefined'), null, 'errors');
}
}*/
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
$i ++; $i ++;
@ -257,16 +294,26 @@ if ($result) {
} }
/* /*
* Actions var_dump($tabpay);
var_dump($tabbq);
var_dump($tabtp);
*/ */
// Write bookkeeping // Write bookkeeping
if ($action == 'writebookkeeping') { if (! $error && $action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
$error = 0; $error = 0;
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank
$errorforline = 0;
$db->begin();
// Bank // Bank
if (! $errorforline)
{
// Line into bank account
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -274,7 +321,6 @@ if ($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->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $compte->label; $bookkeeping->label_compte = $compte->label;
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
@ -286,6 +332,7 @@ if ($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'];
$sqlmid = 'SELECT fac.facnumber'; $sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
@ -296,9 +343,10 @@ if ($action == 'writebookkeeping') {
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber; $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'];
$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 ";
@ -309,17 +357,23 @@ if ($action == 'writebookkeeping') {
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
$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 . ')'; // Ref on invoice
} }
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
}
// Third party // Third party
if (! $errorforline)
{
// Line into thirdparty account
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -336,11 +390,10 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_create = $now; $bookkeeping->date_create = $now;
if ($tabtype[$key] == 'sc') { if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') { } 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';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -352,9 +405,9 @@ if ($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 = $k; $bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment_supplier') { } 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 ";
@ -367,41 +420,59 @@ if ($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 = $k; $bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'company') {
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sqlmid .= " WHERE pay.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->doc_ref = $objmid->facnumber;
}
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
} else { } else {
// FIXME Should be a 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_CUSTOMER;
$bookkeeping->numero_compte = 'CodeNotDef';
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
} }
if (! $errorforline)
{
$db->commit();
}
else
{
$db->rollback();
}
}
if (empty($error)) { if (empty($error)) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} }
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} }
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action = '';
}
/*
* View
*/
$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;
@ -437,7 +508,6 @@ if ($action == 'export_csv') {
$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'];
// Bank // Bank
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
@ -562,14 +632,17 @@ if ($action == 'export_csv') {
} }
} }
} }
else {
$form = new Form($db); if (empty($action) || $action == 'view') {
$invoicestatic = new Facture($db);
$invoicesupplierstatic = new FactureFournisseur($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
$nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1); $nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1);
$builddate = time(); $builddate = time();
$description = $langs->trans("DescFinanceJournal") . '<br>'; //$description = $langs->trans("DescFinanceJournal") . '<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);
$varlink = 'id_account=' . $id_bank_account; $varlink = 'id_account=' . $id_bank_account;
@ -585,14 +658,17 @@ else {
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
// TODO Avoid using js. We can use a direct link with $param
print ' print '
<script type="text/javascript"> <script type="text/javascript">
function launch_export() { function launch_export() {
console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv"); $("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click(); $("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
} }
function writebookkeeping() { function writebookkeeping() {
console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping"); $("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click(); $("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
@ -607,9 +683,10 @@ else {
$i = 0; $i = 0;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>"; print "<td>" . $langs->trans("Type") . "</td>";
print "<td>" . $langs->trans("PaymentMode") . "</td>"; print "<td>" . $langs->trans("PaymentMode") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
@ -618,7 +695,7 @@ else {
$var = true; $var = true;
$r = ''; $r = '';
foreach ( $tabpay as $key => $val ) { foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank
$date = dol_print_date($db->jdate($val["date"]), 'day'); $date = dol_print_date($db->jdate($val["date"]), 'day');
$reflabel = $val["ref"]; $reflabel = $val["ref"];
@ -638,12 +715,55 @@ else {
$reflabel = $langs->trans('SubscriptionPayment'); $reflabel = $langs->trans('SubscriptionPayment');
} }
$ref=$reflabel;
if ($tabtype[$key] == 'payment')
{
$sqlmid = 'SELECT payfac.fk_facture as id';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac";
$sqlmid .= " WHERE payfac.fk_paiement=" . $val["paymentid"];
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$invoicestatic->fetch($objmid->id);
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
}
else dol_print_error($db);
}
elseif ($tabtype[$key] == 'payment_supplier')
{
$sqlmid = 'SELECT payfac.fk_facturefourn as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac";
$sqlmid .= " WHERE payfac.fk_paiementfourn=" . $val["paymentsupplierid"];
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$invoicesupplierstatic->fetch($objmid->id);
$ref=$langs->trans("SupplierInvoice").' '.$invoicesupplierstatic->getNomUrl(1);
}
else dol_print_error($db);
}
/*$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];*/
// Bank // Bank
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td><!-- Bank bank.rowid=".$key."--></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>"; print "<td>" . $ref . "</td>";
print "<td>" . length_accountg($k) . "</td>"; print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
if ($val['soclib'] == '') { if ($val['soclib'] == '') {
print "<td>" . $bank_code_journal->label . " - " . $val["ref"] . "</td>"; print "<td>" . $bank_code_journal->label . " - " . $val["ref"] . "</td>";
} else { } else {
@ -660,9 +780,17 @@ else {
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') { if ($k != 'type') {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td><!-- Thirdparty bank.rowid=".$key." --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>"; print "<td>" . $ref . "</td>";
print "<td>" . length_accounta($k) . "</td>"; print "<td>";
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $reflabel . ' ' . $val['soclib'] . "</td>"; print "<td>" . $reflabel . ' ' . $val['soclib'] . "</td>";
print "<td>" . $val["type_payment"] . "</td>"; print "<td>" . $val["type_payment"] . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
@ -673,9 +801,16 @@ else {
} else { } else {
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td><!-- Wait bank.rowid=".$key." --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>"; print "<td>" . $ref . "</td>";
print "<td>" . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . "</td>"; print "<td>";
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
}
else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) .
print "</td>";
print "<td>" . $reflabel . "</td>"; print "<td>" . $reflabel . "</td>";
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
@ -690,4 +825,5 @@ else {
llxFooter(); llxFooter();
} }
$db->close(); $db->close();

View File

@ -0,0 +1,545 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/journal/expensereportsjournal.php
* \ingroup Advanced accountancy
* \brief Page with expense reports journal
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
$now = dol_now();
// Security check
if ($user->societe_id > 0)
accessforbidden();
$action = GETPOST('action');
/*
* Actions
*/
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0];
$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 .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_code,";
$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 .= " 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_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 .= " 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_valid";
$sql .= " WHERE er.fk_statut > 0 ";
$sql .= " AND erd.fk_code_ventilation > 0 ";
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
if ($date_start && $date_end)
$sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'";
$sql .= " ORDER BY er.date_debut";
dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
// les variables
$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");
$taber = array ();
$tabht = array ();
$tabtva = array ();
$def_tva = array ();
$tabttc = array ();
$tabuser = array ();
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object($result);
// Controls
$compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
$compta_fees = $obj->compte;
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat);
// Define array for display vat tx
$def_tva[$obj->rowid]=price($obj->tva_tx);
$taber[$obj->rowid]["date"] = $db->jdate($obj->de);
$taber[$obj->rowid]["ref"] = $obj->ref;
$taber[$obj->rowid]["comments"] = $obj->comments;
$taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid;
$tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabuser[$obj->rowid] = array (
'id' => $obj->uid,
'name' => $obj->firstname.' '.$obj->lastname,
'user_accountancy_code' => $obj->user_accountancy_account
);
$i ++;
}
} else {
dol_print_error($db);
}
// Bookkeeping Write
if ($action == 'writebookkeeping') {
$now = dol_now();
$error = 0;
foreach ($taber as $key => $val)
{
$errorforline = 0;
foreach ( $tabttc[$key] as $k => $mt ) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->label_compte = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
// Fees
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k);
if ($mt) {
// get compte id and label
$accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'expense_report';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key];
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
$error++;
$errorforline++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
if (! $errorforline)
{
$db->commit();
}
else
{
$db->rollback();
}
}
if (empty($error) && count($tabpay)) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
}
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
}
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action='';
}
/*
* View
*/
$form = new Form($db);
$userstatic = new User($db);
// Export
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
// Model Cegid Expert Export
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
foreach ( $taber as $key => $val ) {
$date = dol_print_date($val["date"], '%d%m%Y');
// Fees
foreach ( $tabht[$key] as $k => $mt ) {
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
$userstatic->client = $tabuser[$key]['code_client'];
if ($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;
print dol_trunc($val["comments"], 32) . $sep;
print $val["ref"];
print "\n";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($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;
print $langs->trans("VAT") . $sep;
print $val["ref"];
print "\n";
}
}
foreach ( $tabttc[$key] as $k => $mt ) {
print $date . $sep;
print $journal . $sep;
print length_accountg($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) . $sep;
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print $userstatic->name . $sep;
print $val["ref"];
print "\n";
}
}
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Model Classic Export
foreach ( $taber as $key => $val ) {
$date = dol_print_date($val["date"], 'day');
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
// Fees
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k);
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($langs->trans("VAT")) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
}
}
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($userstatic->name) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
}
print "\n";
}
}
}
if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("ExpenseReportsJournal"));
$nom = $langs->trans("ExpenseReportsJournal");
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate = time();
$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);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
} else {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
/*
* Show result array
*/
print '<br><br>';
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>";
print "<td>" . $langs->trans("Label") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n";
$var = true;
$r = '';
$expensereportstatic = new ExpenseReport($db);
$expensereportlinestatic = new ExpenseReportLine($db);
foreach ( $taber as $key => $val ) {
$expensereportstatic->id = $key;
$expensereportstatic->ref = $val["ref"];
$expensereportlinestatic->comments = html_entity_decode(dol_trunc($val["comments"], 32));
$date = dol_print_date($val["date"], 'day');
// Fees
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k);
if ($mt) {
print "<tr " . $bc[$var] . " >";
print "<td><!-- Fees --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print "<tr " . $bc[$var] . " >";
print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VatAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}
}
print "<tr " . $bc[$var] . ">";
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
print "<td>";
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("Code_tiers") . "</td>";
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
}
print "</tr>";
$var = ! $var;
}
print "</table>";
// End of page
llxFooter();
}
$db->close();

View File

@ -59,6 +59,7 @@ if ($user->societe_id > 0)
$action = GETPOST('action'); $action = GETPOST('action');
/* /*
* Actions * Actions
*/ */
@ -85,8 +86,8 @@ $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,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur, s.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 .= " s.code_compta_fournisseur, 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 , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
$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";
@ -95,9 +96,7 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_factu
$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 ";
$sql .= " AND fd.fk_code_ventilation > 0 "; $sql .= " AND fd.fk_code_ventilation > 0 ";
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
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 (0,1,2)";
else else
@ -168,6 +167,10 @@ if ($action == 'writebookkeeping') {
foreach ($tabfac as $key => $val) foreach ($tabfac as $key => $val)
{ {
$errorforline = 0;
$db->begin();
$companystatic = new Societe($db); $companystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db); $invoicestatic = new FactureFournisseur($db);
@ -179,6 +182,10 @@ if ($action == 'writebookkeeping') {
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
@ -204,6 +211,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
@ -236,6 +244,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
@ -267,21 +276,46 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
if (! $errorforline)
{
$db->commit();
}
else
{
$db->rollback();
} }
if (empty($error)) { }
if (empty($error) && count($tabpay)) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} }
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
}
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action='';
} }
/* /*
* View * View
*/ */
$form = new Form($db);
$companystatic = new Fournisseur($db); $companystatic = new Fournisseur($db);
// Export // Export
@ -402,18 +436,19 @@ if ($action == 'export_csv') {
print "\n"; print "\n";
} }
} }
} else { }
if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("PurchasesJournal")); llxHeader('', $langs->trans("PurchasesJournal"));
$form = new Form($db);
$nom = $langs->trans("PurchasesJournal"); $nom = $langs->trans("PurchasesJournal");
$nomlink = ''; $nomlink = '';
$periodlink = ''; $periodlink = '';
$exportlink = ''; $exportlink = '';
$builddate = time(); $builddate = time();
$description = $langs->trans("DescPurchasesJournal") . '<br>'; //$description = $langs->trans("DescPurchasesJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
} else { } else {
@ -456,9 +491,10 @@ if ($action == 'export_csv') {
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
// /print "<td>".$langs->trans("JournalNum")."</td>"; // /print "<td>".$langs->trans("JournalNum")."</td>";
print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>"; print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n"; print "</tr>\n";
@ -486,9 +522,17 @@ if ($action == 'export_csv') {
if ($mt) { if ($mt) {
print "<tr " . $bc[$var] . " >"; print "<tr " . $bc[$var] . " >";
print "<td><!-- Product --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>"; print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>";
@ -502,9 +546,17 @@ if ($action == 'export_csv') {
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
print "<tr " . $bc[$var] . " >"; print "<tr " . $bc[$var] . " >";
print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>"; print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VatAccountNotDefined").'</span>';
}
else print $accountoshow;
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"). ' '.$def_tva[$key]. "</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>";
@ -515,11 +567,19 @@ if ($action == 'export_csv') {
// Third party // Third party
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
print "<td>" . length_accounta($k) . "</td>"; print "<td>";
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
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("Code_tiers") . "</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) . ')';

View File

@ -62,8 +62,9 @@ if ($user->societe_id > 0)
$action = GETPOST('action'); $action = GETPOST('action');
/* /*
* View * Actions
*/ */
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
@ -88,7 +89,7 @@ $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,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; $sql .= " s.rowid as socid, s.nom as name, s.code_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 .= " fd.situation_percent,ct.accountancy_code_sell as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
@ -98,9 +99,7 @@ $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.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$sql .= " WHERE fd.fk_code_ventilation > 0"; $sql .= " WHERE fd.fk_code_ventilation > 0";
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
}
$sql .= " AND f.fk_statut > 0"; $sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
@ -187,11 +186,6 @@ if ($result) {
dol_print_error($db); dol_print_error($db);
} }
/*
* Action
* FIXME Action must be set before any view part to respect MVC
*/
// Bookkeeping Write // Bookkeeping Write
if ($action == 'writebookkeeping') { if ($action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
@ -199,11 +193,19 @@ if ($action == 'writebookkeeping') {
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
$errorforline = 0;
$db->begin();
$companystatic = new Societe($db); $companystatic = new Societe($db);
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
$invoicestatic->id = $key; $invoicestatic->id = $key;
@ -231,6 +233,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
@ -261,6 +264,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
@ -291,16 +295,46 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$errorforline++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
if (! $errorforline)
{
$db->commit();
}
else
{
$db->rollback();
} }
if (empty($error)) { }
if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} }
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} }
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action='';
}
/*
* View
*/
$form = new Form($db);
// Export // Export
if ($action == 'export_csv') { if ($action == 'export_csv') {
@ -422,9 +456,9 @@ if ($action == 'export_csv') {
} }
} }
} }
} else { }
$form = new Form($db); if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("SellsJournal")); llxHeader('', $langs->trans("SellsJournal"));
@ -433,7 +467,8 @@ if ($action == 'export_csv') {
$periodlink = ''; $periodlink = '';
$exportlink = ''; $exportlink = '';
$builddate = time(); $builddate = time();
$description = $langs->trans("DescSellsJournal") . '<br>'; //$description = $langs->trans("DescSellsJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$description .= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
else else
@ -473,9 +508,10 @@ if ($action == 'export_csv') {
$i = 0; $i = 0;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>"; print "<td>" . $langs->trans("Type") . "</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>";
@ -497,14 +533,23 @@ if ($action == 'export_csv') {
// Third party // Third party
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$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'];
print "<td>" . length_accounta($k); $companystatic->client = $tabcompany[$key]['code_client'];
print "<td>";
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
// 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>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "</td>";
print "</td><td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "</td><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>";
@ -518,9 +563,17 @@ if ($action == 'export_csv') {
if ($mt) { if ($mt) {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td><!-- Product --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>"; print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
// print "<td>" . $accountingaccount->label . "</td>"; // print "<td>" . $accountingaccount->label . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
@ -533,9 +586,17 @@ if ($action == 'export_csv') {
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>"; print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
}
else print $accountoshow;
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") . ' '.$def_tva[$key]. "</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>";

View File

@ -75,7 +75,7 @@ $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); print load_fiche_titre($langs->trans('ReportInOut') . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -103,7 +103,10 @@ foreach($months as $k => $v){
print '</tr>'; print '</tr>';
$cats = $AccCat->getCatsCpts(); $cats = $AccCat->getCatsCpts();
if ($cats < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
$catsCalcule = $AccCat->getCatsCal(); $catsCalcule = $AccCat->getCatsCal();
if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
$j=1; $j=1;
$sommes = array(); $sommes = array();

View File

@ -44,23 +44,35 @@ $id = GETPOST('id');
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
/*
* Actions
*/
if ($action == 'ventil' && $user->rights->accounting->bind->write) {
if (! GETPOST('cancel', 'alpha')) { if (! GETPOST('cancel', 'alpha')) {
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id; $sql .= " WHERE rowid = " . $id;
dol_syslog('accountancy/supplier/card.php:: $sql=' . $sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) { if (! $resql) {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} }
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
} else { } else {
header("Location: ./lines.php"); header("Location: ./lines.php");
exit(); exit();
} }
} }
/* /*
* View * View
*/ */
@ -70,9 +82,7 @@ if ($cancel == $langs->trans("Cancel")) {
$action = ''; $action = '';
} }
/* // Create
* Create
*/
$form = new Form($db); $form = new Form($db);
$facturefournisseur_static = new FactureFournisseur($db); $facturefournisseur_static = new FactureFournisseur($db);
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
@ -86,9 +96,7 @@ if (! empty($id)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);

View File

@ -23,9 +23,8 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Home supplier ventilation * \brief Home supplier ventilation
*/ */
require '../../main.inc.php';
// Class 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';
@ -37,9 +36,12 @@ $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
// Security check // Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->ventilation->read) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
// Filter // Filter
@ -54,11 +56,28 @@ if ($year == 0) {
// Validate History // Validate History
$action = GETPOST('action'); $action = GETPOST('action');
/*
* Actions
*/
if ($action == 'validatehistory') { if ($action == 'validatehistory') {
$error = 0; $error = 0;
$db->begin(); $db->begin();
// First clean corrupted data
$sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sqlclean .= " SET fd.fk_code_ventilation = 0";
$sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN ';
$sqlclean .= ' (SELECT accnt.rowid ';
$sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sqlclean .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sqlclean .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')';
$resql = $db->query($sqlclean);
// Now make the binding
if ($db->type == 'pgsql') { if ($db->type == 'pgsql') {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " SET fk_code_ventilation = accnt.rowid";
@ -138,17 +157,17 @@ 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); print load_fiche_titre($langs->trans("SuppliersVentilation") . "&nbsp;" . $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("ToDispatch")) . '<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">';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>'; print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
// TODO Remove this. Should be done always. // TODO Remove this. Should be done always.
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 > 0) 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; $y = $year_current;
@ -175,10 +194,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND ff.fk_statut > 0 "; $sql .= " AND ff.fk_statut > 0 ";
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
@ -223,10 +239,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND ff.fk_statut > 0 "; $sql .= " AND ff.fk_statut > 0 ";
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -51,26 +51,17 @@ $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');
// Getpost Order and column and limit page // 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);
$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 < 0) $page = 0;
if ($page < 0)
$page = 0;
$offset = $conf->liste_limit * $page; $offset = $conf->liste_limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
if (! $sortfield) if (! $sortfield)
$sortfield = "f.datef, f.ref, l.rowid"; $sortfield = "f.datef, f.ref, l.rowid";
if (! $sortorder) { if (! $sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -80,7 +71,7 @@ if (! $sortorder) {
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->ventilation->dispatch) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
@ -124,6 +115,8 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$db->rollback(); $db->rollback();
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} }
$account_parent = ''; // Protection to avoid to mass apply it a second time
} }
@ -182,41 +175,78 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; $sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
} }
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/supplier/lines.php::list sql= ' . $sql1); dol_syslog('accountancy/supplier/lines.php::list');
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num_lines = $db->num_rows($result); $num_lines = $db->num_rows($result);
$i = 0; $i = 0;
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_invoice)
$param .= "&search_invoice=" . $search_invoice;
if ($search_ref)
$param .= "&search_ref=" . $search_ref;
if ($search_label)
$param .= "&search_label=" . $search_label;
if ($search_desc)
$param .= "&search_desc=" . $search_desc;
if ($search_account)
$param .= "&search_account=" . $search_account;
if ($search_vat)
$param .= "&search_vat=" . $search_vat;
if ($search_country)
$param .= "&search_country=" . $search_country;
if ($search_tvaintra)
$param .= "&search_tvaintra=" . $search_tvaintra;
print '<td align="left"><b>' . $langs->trans("DescVentilDoneSupplier") . '</b></td>'; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<table class="noborder" width="100%">';
print $langs->trans("DescVentilDoneSupplier") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>'; print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
print '<input type="submit" class="button" value="' . $langs->trans("Validate") . '" /></div>'; print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
$moreforfilter = '';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $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, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre(''); print_liste_field_titre('');
print_liste_field_titre(''); print_liste_field_titre('', '', '', '', '', 'align="center"');
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"');
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre"><td><input type="text" class="flat" name="search_invoice" size="10" value="' . $search_invoice . '"></td>'; print '<tr class="liste_titre"><td><input type="text" class="flat" name="search_invoice" size="10" value="' . $search_invoice . '"></td>';
@ -224,11 +254,12 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>'; print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>'; print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
print '<td class="liste_titre" colspan="2">&nbsp;</td>'; print '<td class="liste_titre" align="right"></td>';
print '<td class="liste_titre" align="right"></td>';
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0); $searchpitco=$form->showFilterAndCheckAddButtons(1);
print $searchpitco; print $searchpitco;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -253,6 +284,7 @@ if ($result) {
$product_static->ref = $objp->product_ref; $product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id; $product_static->id = $objp->product_id;
$product_static->type = $objp->type; $product_static->type = $objp->type;
$product_static->label = $objp->product_label;
print '<td>'; print '<td>';
if ($product_static->id) if ($product_static->id)
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
@ -270,7 +302,7 @@ if ($result) {
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->rowid . '"/></td>'; print '<td align="right"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print "</tr>"; print "</tr>";
$i ++; $i ++;
@ -279,7 +311,14 @@ if ($result) {
print $db->error(); print $db->error();
} }
print "</table></form>"; print "</table>";
if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
}
print '</form>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -4,6 +4,7 @@
* 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
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -43,7 +44,6 @@ $langs->load("accountancy");
$action = GETPOST('action'); $action = GETPOST('action');
// Select Box // Select Box
$codeventil = GETPOST('codeventil', 'array');
$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array');
// Search Getpost // Search Getpost
@ -56,23 +56,15 @@ $search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha');
// Getpost Order and column and limit page // 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);
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
$page = GETPOST('page'); if ($page < 0) { $page = 0; }
if ($page < 0)
$page = 0;
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) if (! $sortfield)
$sortfield = "f.datef, f.ref, l.rowid"; $sortfield = "f.datef, f.ref, l.rowid";
if (! $sortorder) { if (! $sortorder) {
@ -84,7 +76,7 @@ if (! $sortorder) {
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->ventilation->dispatch) if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
@ -98,8 +90,13 @@ $accounting = new AccountingAccount($db);
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
/*
* Action
*/
// Purge search criteria // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{ {
$search_ref = ''; $search_ref = '';
$search_label = ''; $search_label = '';
@ -109,45 +106,30 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_vat = ''; $search_vat = '';
} }
/*
* View
*/
llxHeader('', $langs->trans("SuppliersVentilation"));
print '<script type="text/javascript">
$(function () {
$(\'#select-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = true;
});
});
$(\'#unselect-all\').click(function(event) {
// Iterate each checkbox
$(\':checkbox\').each(function() {
this.checked = false;
});
});
});
</script>';
/*
* Action
*/
if ($action == 'ventil' && ! empty($btn_ventil)) { if ($action == 'ventil' && ! empty($btn_ventil)) {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; $msg='';
if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) { //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
print '<div><font color="red">' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '</font></div>'; if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($_POST["mesCasesCochees"]).'</div>';
$msg.='<div class="detail">';
$mesCodesVentilChoisis = $codeventil; $mesCodesVentilChoisis = $codeventil;
$cpt = 0; $cpt = 0;
$ok=0;
$ko=0;
foreach ( $mesCasesCochees as $maLigneCochee ) { foreach ( $mesCasesCochees as $maLigneCochee ) {
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>"; // print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monNumLigne = $maLigneCourante[1]; $monCompte = GETPOST('codeventil'.$monId);
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
if ($monCompte <= 0)
{
$msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
$ko++;
}
else
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $monCompte; $sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId; $sql .= " WHERE rowid = " . $monId;
@ -157,32 +139,31 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG); dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>'; $ok++;
$msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
} else { } else {
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>'; $ko++;
$msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
}
} }
$cpt++; $cpt++;
} }
$msg.='</div>';
} else { } else {
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>'; setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
} }
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>'; $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
} }
/* /*
* Supplier Invoice Lines * View
*/ */
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { llxHeader('', $langs->trans("SuppliersVentilation"));
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
$offset = $limit * $page;
// Supplier Invoice Lines
$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, f.datef, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, "; $sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, f.datef, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, ";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod";
$sql .= " , aa.rowid as aarowid"; $sql .= " , aa.rowid as aarowid";
@ -191,9 +172,9 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation <= 0"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND product_type <= 2"; $sql .= " AND product_type <= 2";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='')"; $sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy ='')";
// Add search filter like // Add search filter like
if (strlen(trim($search_invoice))) { if (strlen(trim($search_invoice))) {
$sql .= " AND (f.ref like '%" . $search_invoice . "%')"; $sql .= " AND (f.ref like '%" . $search_invoice . "%')";
@ -216,55 +197,77 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; $sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
} }
if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/supplier/list.php:: $sql=' . $sql); dol_syslog('accountancy/supplier/list.php');
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num_lines = $db->num_rows($result); $num_lines = $db->num_rows($result);
$i = 0; $i = 0;
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... $arrayofselected=is_array($toselect)?$toselect:array();
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>'; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<table class="noborder" width="100%">'; $center='<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, 0, 'title_accountancy', 0, '', '', $limit);
if ($msg) print $msg.'<br>';
print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
$moreforfilter = '';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $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="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccounting"), '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("AccountAccountingSuggest"), '', '', '', '', 'align="center"');
print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"');
print_liste_field_titre(''); print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"'); print_liste_field_titre('', '', '', '', '', 'align="center"');
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>';
print '<td class="liste_titre">%<input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . $search_ref . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="center">%<input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center">&nbsp;</td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre"></td>';
print '<td align="right" colspan="2" class="liste_titre">'; print '<td class="liste_titre"></td>';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; print '<td align="right" class="liste_titre">';
print '&nbsp;'; $searchpitco=$form->showFilterAndCheckAddButtons(1);
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">'; print $searchpitco;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -342,29 +345,36 @@ if ($result) {
print price($objp->price); print price($objp->price);
print '</td>'; print '</td>';
// Vat rate
if ($objp->vat_tx_l != $objp->vat_tx_p) if ($objp->vat_tx_l != $objp->vat_tx_p)
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
print '<td style="' . $code_vat_differ . '" align="center">'; print '<td style="' . $code_vat_differ . '" align="right">';
print price($objp->tva_tx_line); print price($objp->tva_tx_line);
print '</td>'; print '</td>';
// Accounting account suggested
print '<td align="center" style="' . $code_buy_p_notset . '">'; print '<td align="center" style="' . $code_buy_p_notset . '">';
// if not same kind of product_type stored in product & facturedt we display both account and let user choose if ($objp->code_buy_l == $objp->code_buy_p) { // Test if there is a difference between code by default and code on product
if ($objp->code_buy_l == $objp->code_buy_p) { if ($objp->code_buy_l > 0) print $objp->code_buy_l;
print $objp->code_buy_l; else print $langs->trans("Unknown");
} else { } else {
print 'lines=' . $objp->code_buy_l . '<br />product=' . $objp->code_buy_p; print $langs->trans("Default") . ' = ' . ($objp->code_buy_l > 0 ? $objp->code_buy_l : $langs->trans("Unknown"));
print '<br>';
print $langs->trans("Product") . ' = ' . ($objp->code_buy_p > 0 ? $objp->code_buy_p : $langs->trans("Unknown"));
} }
print '</td>'; print '</td>';
// Colonne choix du compte // Colonne choix du compte
print '<td align="center">'; print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1);
print '</td>'; print '</td>';
// Line id
print '<td align="center">' . $objp->rowid . '</td>'; print '<td align="center">' . $objp->rowid . '</td>';
// Colonne choix ligne a ventiler // Colonne choix ligne a ventiler
print '<td align="center">'; print '<td align="right">';
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; print '<input type="checkbox" class="checkforaction" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
@ -372,7 +382,6 @@ if ($result) {
} }
print '</table>'; print '</table>';
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil" ></div>';
print '</form>'; print '</form>';
} else { } else {
print $db->error(); print $db->error();

View File

@ -120,6 +120,13 @@ if ($object->id > 0)
print '</table>'; print '</table>';
print '<br>';
$object->info($id);
print dol_print_object_info($object, 1);
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();

View File

@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
@ -51,6 +52,7 @@ $cancel=GETPOST('cancel','alpha');
$backtopage=GETPOST('backtopage','alpha'); $backtopage=GETPOST('backtopage','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$rowid=GETPOST('rowid','int'); $rowid=GETPOST('rowid','int');
$id=GETPOST('id')?GETPOST('id','int'):$rowid;
$typeid=GETPOST('typeid','int'); $typeid=GETPOST('typeid','int');
$userid=GETPOST('userid','int'); $userid=GETPOST('userid','int');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
@ -71,7 +73,7 @@ $extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr) // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($rowid); $object->getCanvas($id);
$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); $canvas = $object->canvas?$object->canvas:GETPOST("canvas");
$objcanvas=null; $objcanvas=null;
if (! empty($canvas)) if (! empty($canvas))
@ -82,12 +84,12 @@ if (! empty($canvas))
} }
// Security check // Security check
$result=restrictedArea($user, 'adherent', $rowid, '', '', 'fk_soc', 'rowid', $objcanvas); $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid', $objcanvas);
if ($rowid > 0) if ($id > 0)
{ {
// Load member // Load member
$result = $object->fetch($rowid); $result = $object->fetch($id);
// Define variables to know what current user can do on users // Define variables to know what current user can do on users
$canadduser=($user->admin || $user->rights->user->user->creer); $canadduser=($user->admin || $user->rights->user->user->creer);
@ -105,7 +107,7 @@ if ($rowid > 0)
// Define variables to determine what the current user can do on the members // Define variables to determine what the current user can do on the members
$canaddmember=$user->rights->adherent->creer; $canaddmember=$user->rights->adherent->creer;
// Define variables to determine what the current user can do on the properties of a member // Define variables to determine what the current user can do on the properties of a member
if ($rowid) if ($id)
{ {
$caneditfieldmember=$user->rights->adherent->creer; $caneditfieldmember=$user->rights->adherent->creer;
} }
@ -114,12 +116,14 @@ if ($rowid)
$hookmanager->initHooks(array('membercard','globalcard')); $hookmanager->initHooks(array('membercard','globalcard'));
/* /*
* Actions * Actions
*/ */
if ($cancel) $action=''; if ($cancel) $action='';
$parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas); $parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@ -253,6 +257,7 @@ if (empty($reshook))
} }
$lastname=$_POST["lastname"]; $lastname=$_POST["lastname"];
$firstname=$_POST["firstname"]; $firstname=$_POST["firstname"];
$societe=$_POST["societe"];
$morphy=$_POST["morphy"]; $morphy=$_POST["morphy"];
$login=$_POST["login"]; $login=$_POST["login"];
if ($morphy != 'mor' && empty($lastname)) { if ($morphy != 'mor' && empty($lastname)) {
@ -343,15 +348,15 @@ if (empty($reshook))
$object->setCategories($categories); $object->setCategories($categories);
// Logo/Photo save // Logo/Photo save
$dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'member').'/photos'; $dir= $conf->adherent->dir_output . '/' . get_exdir(0,0,0,1,$object,'member').'/photos';
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK) if ($file_OK)
{ {
if (GETPOST('deletephoto')) if (GETPOST('deletephoto'))
{ {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/'.$object->photo; $fileimg=$conf->adherent->dir_output.'/'.get_exdir(0,0,0,1,$object,'member').'/photos/'.$object->photo;
$dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/thumbs'; $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir(0,0,0,1,$object,'member').'/photos/thumbs';
dol_delete_file($fileimg); dol_delete_file($fileimg);
dol_delete_dir_recursive($dirthumbs); dol_delete_dir_recursive($dirthumbs);
} }
@ -394,6 +399,7 @@ if (empty($reshook))
} }
$rowid=$object->id; $rowid=$object->id;
$id=$object->id;
$action=''; $action='';
if (! empty($backtopage)) if (! empty($backtopage))
@ -556,6 +562,7 @@ if (empty($reshook))
$db->commit(); $db->commit();
$rowid=$object->id; $rowid=$object->id;
$id=$object->id;
$action=''; $action='';
} }
else else
@ -578,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($rowid); $result=$object->delete($id);
if ($result > 0) if ($result > 0)
{ {
if (! empty($backtopage)) if (! empty($backtopage))
@ -707,6 +714,11 @@ if (empty($reshook))
} }
} }
} }
// Actions to build doc
$upload_dir = $conf->adherent->dir_output;
$permissioncreate=$user->rights->adherent->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
} }
@ -715,6 +727,7 @@ if (empty($reshook))
*/ */
$form = new Form($db); $form = new Form($db);
$formfile = new FormFile($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
$title=$langs->trans("Member") . " - " . $langs->trans("Card"); $title=$langs->trans("Member") . " - " . $langs->trans("Card");
@ -728,10 +741,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// ----------------------------------------- // -----------------------------------------
// When used with CANVAS // When used with CANVAS
// ----------------------------------------- // -----------------------------------------
if (empty($object->error) && $rowid) if (empty($object->error) && $id)
{ {
$object = new Adherent($db); $object = new Adherent($db);
$result=$object->fetch($rowid); $result=$object->fetch($id);
if ($result <= 0) dol_print_error('',$object->error); if ($result <= 0) dol_print_error('',$object->error);
} }
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
@ -971,7 +984,7 @@ else
* *
********************************************/ ********************************************/
$res=$object->fetch($rowid); $res=$object->fetch($id);
if ($res < 0) { if ($res < 0) {
dol_print_error($db,$object->error); exit; dol_print_error($db,$object->error); exit;
} }
@ -1036,14 +1049,10 @@ else
print '</script>'."\n"; print '</script>'."\n";
} }
$rowspan=15;
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
if (! empty($conf->societe->enabled)) $rowspan++;
print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">'; print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
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" />';
print '<input type="hidden" name="rowid" value="'.$rowid.'" />'; print '<input type="hidden" name="rowid" value="'.$id.'" />';
print '<input type="hidden" name="statut" value="'.$object->statut.'" />'; print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">'; if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
@ -1052,7 +1061,7 @@ else
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
@ -1065,21 +1074,7 @@ else
$morphys["mor"] = $langs->trans("Morale"); $morphys["mor"] = $langs->trans("Morale");
print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td>"; print "</td></tr>";
// Photo
print '<td align="center" class="hideonsmartphone" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $form->showphoto('memberphoto',$object)."\n";
if ($caneditfieldmember)
{
if ($object->photo) print "<br>\n";
print '<table class="nobordernopadding">';
if ($object->photo) print '<tr><td align="center"><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
print '</table>';
}
print '</td>';
// Type // Type
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
@ -1111,6 +1106,21 @@ else
print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td>'; print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td>';
print '</tr>'; print '</tr>';
// Photo
print '<tr><td>'.$langs->trans("Photo").'</td>';
print '<td class="hideonsmartphone" valign="middle">';
print $form->showphoto('memberphoto',$object)."\n";
if ($caneditfieldmember)
{
if ($object->photo) print "<br>\n";
print '<table class="nobordernopadding">';
if ($object->photo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
print '</table>';
}
print '</td></tr>';
// EMail // EMail
print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="email" size="40" value="'.(isset($_POST["email"])?$_POST["email"]:$object->email).'"></td></tr>'; print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="email" size="40" value="'.(isset($_POST["email"])?$_POST["email"]:$object->email).'"></td></tr>';
@ -1235,7 +1245,7 @@ else
} }
if ($rowid && $action != 'edit') if ($id > 0 && $action != 'edit')
{ {
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
@ -1243,7 +1253,7 @@ else
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
$res=$object->fetch($rowid); $res=$object->fetch($id);
if ($res < 0) { if ($res < 0) {
dol_print_error($db,$object->error); exit; dol_print_error($db,$object->error); exit;
} }
@ -1343,13 +1353,13 @@ else
if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) { if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
$formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
} }
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1,1); print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1,1);
} }
// Confirm send card by mail // Confirm send card by mail
if ($action == 'sendinfo') if ($action == 'sendinfo')
{ {
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); print $form->formconfirm("card.php?rowid=".$id,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
} }
// Confirm terminate // Confirm terminate
@ -1380,7 +1390,7 @@ else
$formquestion=array(); $formquestion=array();
if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false')); if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1); print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1);
} }
// Confirm remove member // Confirm remove member
@ -1388,18 +1398,18 @@ else
{ {
$formquestion=array(); $formquestion=array();
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1); print $form->formconfirm("card.php?rowid=".$id,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
} }
// Confirm add in spip // Confirm add in spip
if ($action == 'add_spip') if ($action == 'add_spip')
{ {
print $form->formconfirm("card.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip'); print $form->formconfirm("card.php?rowid=".$id, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
} }
// Confirm removed from spip // Confirm removed from spip
if ($action == 'del_spip') if ($action == 'del_spip')
{ {
print $form->formconfirm("card.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
} }
$rowspan=17; $rowspan=17;
@ -1601,7 +1611,7 @@ else
// Modify // Modify
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=edit">'.$langs->trans("Modify")."</a></div>"; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=edit">'.$langs->trans("Modify")."</a></div>";
} }
else else
{ {
@ -1613,7 +1623,7 @@ else
{ {
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Validate")."</a></div>\n"; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=valid">'.$langs->trans("Validate")."</a></div>\n";
} }
else else
{ {
@ -1626,7 +1636,7 @@ else
{ {
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=valid">'.$langs->trans("Reenable")."</a></div>\n"; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=valid">'.$langs->trans("Reenable")."</a></div>\n";
} }
else else
{ {
@ -1657,7 +1667,7 @@ else
{ {
if ($user->rights->adherent->supprimer) if ($user->rights->adherent->supprimer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$rowid.'&action=resign">'.$langs->trans("Resiliate")."</a></div>\n"; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=resign">'.$langs->trans("Resiliate")."</a></div>\n";
} }
else else
{ {
@ -1726,7 +1736,48 @@ else
{ {
print '<br><br><font class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</font>'; print '<br><br><font class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</font>';
} }
print "<br>\n";
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Documents generes
$filename = dol_sanitizeFileName($object->ref);
//$filename = 'tmp_cards.php';
//$filedir = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'member') . dol_sanitizeFileName($object->ref);
$filedir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 0, $object, 'member');
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
$genallowed = $user->rights->adherent->creer;
$delallowed = $user->rights->adherent->supprimer;
print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object);
$somethingshown = $formfile->numoffiles;
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
//$somethingshown = $form->showLinkedObjectBlock($object, '');
// Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
// Link for paypal payment
/*
if (! empty($conf->paypal->enabled) && $object->statut != 0) {
include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
print showPaypalPaymentUrl('invoice', $object->ref);
}
*/
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
/* Already in tab Agenda/Events
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'member', $socid);
*/
print '</div></div></div>';
} }
} }

View File

@ -121,7 +121,10 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
if (is_numeric($foruserid) || $foruserlogin) if (is_numeric($foruserid) || $foruserlogin)
{ {
for($j=0;$j<100;$j++) $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
if ($nb <= 0) $nb=1; // Protection to avoid empty page
for($j=0;$j<$nb;$j++)
{ {
$arrayofmembers[]=array( $arrayofmembers[]=array(
'textleft'=>$textleft, 'textleft'=>$textleft,

View File

@ -1070,6 +1070,7 @@ class Adherent extends CommonObject
$sql.= " d.datevalid as datev,"; $sql.= " d.datevalid as datev,";
$sql.= " d.country,"; $sql.= " d.country,";
$sql.= " d.state_id,"; $sql.= " d.state_id,";
$sql.= " d.model_pdf,";
$sql.= " c.rowid as country_id, c.code as country_code, c.label as country,"; $sql.= " c.rowid as country_id, c.code as country_code, c.label as country,";
$sql.= " dep.nom as state, dep.code_departement as state_code,"; $sql.= " dep.nom as state, dep.code_departement as state_code,";
$sql.= " t.libelle as type, t.subscription as subscription,"; $sql.= " t.libelle as type, t.subscription as subscription,";
@ -1155,6 +1156,8 @@ class Adherent extends CommonObject
$this->user_id = $obj->user_id; $this->user_id = $obj->user_id;
$this->user_login = $obj->user_login; $this->user_login = $obj->user_login;
$this->model_pdf = $obj->model_pdf;
// Retreive all extrafield for thirdparty // Retreive all extrafield for thirdparty
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
@ -1679,6 +1682,17 @@ class Adherent extends CommonObject
if ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'),'statut5').' '.$langs->trans("MemberStatusResiliated"); if ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'),'statut5').' '.$langs->trans("MemberStatusResiliated");
} }
if ($mode == 5) if ($mode == 5)
{
if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'),'statut0');
if ($statut >= 1)
{
if (! $date_end_subscription) return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusActiveShort").' </span>'.img_picto($langs->trans('MemberStatusActive'),'statut1');
elseif ($date_end_subscription < time()) return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusActiveLateShort").' </span>'.img_picto($langs->trans('MemberStatusActiveLate'),'statut3');
else return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusPaidShort").' </span>'.img_picto($langs->trans('MemberStatusPaid'),'statut4');
}
if ($statut == 0) return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusResiliated").' </span>'.img_picto($langs->trans('MemberStatusResiliated'),'statut5');
}
if ($mode == 6)
{ {
if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'),'statut0'); if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'),'statut0');
if ($statut >= 1) if ($statut >= 1)
@ -1783,6 +1797,41 @@ class Adherent extends CommonObject
} }
/**
* Create a document onto disk according to template module.
*
* @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
global $conf,$langs;
$langs->load("orders");
// Positionne le modele sur le nom du modele a utiliser
if (! dol_strlen($modele))
{
if (! empty($conf->global->ADHERENT_ADDON_PDF))
{
$modele = $conf->global->ADHERENT_ADDON_PDF;
}
else
{
$modele = 'standard';
}
}
$modelpath = "core/modules/member/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
/** /**
* Initialise an instance with random values. * Initialise an instance with random values.
* Used to build previews or test instances. * Used to build previews or test instances.

View File

@ -36,14 +36,25 @@ class AdherentType extends CommonObject
public $table_element = 'adherent_type'; public $table_element = 'adherent_type';
public $element = 'adherent_type'; public $element = 'adherent_type';
var $id; /** @var string Label */
var $ref; public $libelle;
var $libelle; /**
var $subscription; // Subscription required * @var bool
var $note; * @deprecated Use subscription
var $vote; // Can vote * @see subscription
var $mail_valid; // mail sent during validation */
var $statut; public $cotisation;
/**
* @var bool Subsription required
* @since 5.0
*/
public $subscription;
/** @var string Public note */
public $note;
/** @var bool Can vote*/
public $vote;
/** @var bool Email sent during validation */
public $mail_valid;
/** /**

View File

@ -84,13 +84,12 @@ class Members extends DolibarrApi
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param string $typeid ID of the type of member * @param string $typeid ID of the type of member
* @param string $login To filter the members by login * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param string $name To filter the members by name (firstname, lastname or company name matching the filter)
* @return array Array of member objects * @return array Array of member objects
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "a.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $typeid = '', $login = '', $name = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $typeid = '', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
@ -99,25 +98,22 @@ class Members extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT a.rowid"; $sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as t";
$sql.= ' WHERE a.entity IN ('.getEntity('adherent', 1).')'; $sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')';
if (!empty($typeid)) if (!empty($typeid))
{ {
$sql.= ' AND a.fk_adherent_type='.$typeid; $sql.= ' AND t.fk_adherent_type='.$typeid;
} }
if (!empty($login)) { // Add sql filters
$sql .= " AND a.login LIKE '%".$login."%'"; if ($sqlfilters)
}
if (!empty($name)) {
$sql .= " AND (a.firstname LIKE '%".$name."%' OR a.lastname LIKE '%".$name."%' OR a.societe LIKE '%".$name."%')";
}
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); if (! DolibarrApi::_checkFilters($sqlfilters))
$nbtotalofrecords = $db->num_rows($result); {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
@ -271,7 +267,7 @@ class Members extends DolibarrApi
/** /**
* Validate fields before creating an object * Validate fields before creating an object
* *
* @param array $data Data to validate * @param array|null $data Data to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException

View File

@ -80,11 +80,12 @@ class Subscriptions extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
* @return array Array of subscription objects * @return array Array of subscription objects
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 0, $page = 0) { function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
@ -94,13 +95,17 @@ class Subscriptions extends DolibarrApi
} }
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."subscription as t";
$sql.= ' WHERE 1 = 1';
$nbtotalofrecords = 0; // Add sql filters
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if ($sqlfilters)
{ {
$result = $db->query($sql); if (! DolibarrApi::_checkFilters($sqlfilters))
$nbtotalofrecords = $db->num_rows($result); {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
@ -225,7 +230,7 @@ class Subscriptions extends DolibarrApi
/** /**
* Validate fields before creating an object * Validate fields before creating an object
* *
* @param array $data Data to validate * @param array|null $data Data to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException

View File

@ -69,7 +69,7 @@ if ($result < 0)
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$upload_dir = $conf->adherent->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'member') . '/' . dol_sanitizeFileName($object->ref); $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member');
/* /*
@ -158,6 +158,7 @@ if ($id > 0)
$modulepart = 'member'; $modulepart = 'member';
$permission = $user->rights->adherent->creer; $permission = $user->rights->adherent->creer;
$permtoedit = $user->rights->adherent->creer;
$param = '&id=' . $object->id; $param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
print "<br><br>"; print "<br><br>";

View File

@ -1,77 +0,0 @@
<?php
/* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/adherents/info.php
* \ingroup member
* \brief Page des informations d'un adherent
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
$langs->load("companies");
$langs->load("bills");
$langs->load("members");
$langs->load("users");
$id=(GETPOST('id','int') ? GETPOST('id','int') : GETPOST('rowid','int'));
// Security check
$result=restrictedArea($user,'adherent',$id);
/*
* View
*/
$form = new Form($db);
$title=$langs->trans("Member") . " - " . $langs->trans("Info");
$helpurl="EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
llxHeader("",$title,$helpurl);
$object = new Adherent($db);
$object->fetch($id);
$object->info($id);
$head = member_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Member"), 0, 'user');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
dol_print_object_info($object);
print '</div>';
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -129,21 +129,25 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
} }
} }
/* /*
* Actions * Actions
*/ */
if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction')) { $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both 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=""; $search="";
$search_ref=""; $search_ref="";
@ -168,6 +172,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$statut=''; $statut='';
$search_array_options=array(); $search_array_options=array();
} }
}
/* /*
@ -179,8 +184,6 @@ $formother=new FormOther($db);
$membertypestatic=new AdherentType($db); $membertypestatic=new AdherentType($db);
$memberstatic=new Adherent($db); $memberstatic=new Adherent($db);
llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$now=dol_now(); $now=dol_now();
$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,";
@ -259,10 +262,23 @@ $sql.= $db->plimit($limit+1, $offset);
dol_syslog("get list", LOG_DEBUG); dol_syslog("get list", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if (! $resql)
{ {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0;
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id);
exit;
}
llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$titre=$langs->trans("MembersList"); $titre=$langs->trans("MembersList");
if (isset($_GET["statut"])) if (isset($_GET["statut"]))
@ -287,7 +303,9 @@ if ($resql)
} }
$param=''; $param='';
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall != "") $param.="&sall=".urlencode($sall);
if ($statut != "") $param.="&statut=".urlencode($statut); if ($statut != "") $param.="&statut=".urlencode($statut);
if ($search_ref) $param.="&search_ref=".urlencode($search_ref); if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
if ($search_nom) $param.="&search_nom=".urlencode($search_nom); if ($search_nom) $param.="&search_nom=".urlencode($search_nom);
@ -577,6 +595,7 @@ if ($resql)
print "</tr>\n"; print "</tr>\n";
$var=True; $var=True;
$i = 0;
while ($i < $num && $i < $conf->liste_limit) while ($i < $num && $i < $conf->liste_limit)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
@ -790,7 +809,7 @@ if ($resql)
if (! empty($arrayfields['d.statut']['checked'])) if (! empty($arrayfields['d.statut']['checked']))
{ {
print '<td align="right" class="nowrap">'; print '<td align="right" class="nowrap">';
print $memberstatic->LibStatut($obj->statut,$obj->subscription,$datefin,2); print $memberstatic->LibStatut($obj->statut,$obj->subscription,$datefin,5);
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
@ -826,13 +845,7 @@ if ($resql)
print '</form>'; print '</form>';
if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1); if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1);
}
else
{
dol_print_error($db);
}
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -21,7 +21,7 @@
* \brief Page to add/edit/remove a member subscription * \brief Page to add/edit/remove a member subscription
*/ */
require '../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';

View File

@ -22,7 +22,7 @@
* \brief Page with information of subscriptions of a member * \brief Page with information of subscriptions of a member
*/ */
require '../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';

View File

@ -23,7 +23,7 @@
* \brief list of subscription * \brief list of subscription
*/ */
require '../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';

View File

@ -203,7 +203,6 @@ dol_fiche_head($head, 'other', $langs->trans("Agenda"), 0, 'action');
* Documents models for supplier orders * Documents models for supplier orders
*/ */
print load_fiche_titre($langs->trans("AgendaModelModule"),'','');
// Define array def of models // Define array def of models
$def = array(); $def = array();
@ -230,6 +229,10 @@ else
dol_print_error($db); dol_print_error($db);
} }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
print load_fiche_titre($langs->trans("AgendaModelModule"),'','');
print '<table class="noborder" width="100%">'."\n"; print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre">'."\n"; print '<tr class="liste_titre">'."\n";
print '<td width="100">'.$langs->trans("Name").'</td>'."\n"; print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
@ -333,6 +336,7 @@ foreach ($dirmodels as $reldir)
} }
} }
print '</table><br>'; print '</table><br>';
}
$var=true; $var=true;

View File

@ -43,6 +43,7 @@ if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/acco
$langs->load("errors"); $langs->load("errors");
$langs->load("admin"); $langs->load("admin");
$langs->load("main");
$langs->load("companies"); $langs->load("companies");
$langs->load("resource"); $langs->load("resource");
$langs->load("holiday"); $langs->load("holiday");
@ -54,7 +55,10 @@ $confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$rowid=GETPOST('rowid','alpha'); $rowid=GETPOST('rowid','alpha');
if (!$user->admin) accessforbidden(); $allowed=$user->admin;
if ($id == 7 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Tax page allowed to manager of chart account
if ($id == 10 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Vat page allowed to manager of chart account
if (! $allowed) accessforbidden();
$acts[0] = "activate"; $acts[0] = "activate";
$acts[1] = "disable"; $acts[1] = "disable";
@ -73,6 +77,8 @@ $offset = $listlimit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$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 thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('admin')); $hookmanager->initHooks(array('admin'));
@ -114,7 +120,7 @@ $tabname[27]= MAIN_DB_PREFIX."c_stcomm";
$tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; $tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
$tabname[29]= MAIN_DB_PREFIX."c_lead_status"; $tabname[29]= MAIN_DB_PREFIX."c_lead_status";
$tabname[30]= MAIN_DB_PREFIX."c_format_cards"; $tabname[30]= MAIN_DB_PREFIX."c_format_cards";
$tabname[31]= MAIN_DB_PREFIX."accounting_system"; //$tabname[31]= MAIN_DB_PREFIX."accounting_system";
$tabname[32]= MAIN_DB_PREFIX."c_accounting_category"; $tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
$tabname[33]= MAIN_DB_PREFIX."c_hrm_department"; $tabname[33]= MAIN_DB_PREFIX."c_hrm_department";
$tabname[34]= MAIN_DB_PREFIX."c_hrm_function"; $tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
@ -151,7 +157,7 @@ $tablib[27]= "DictionaryProspectStatus";
$tablib[28]= "DictionaryHolidayTypes"; $tablib[28]= "DictionaryHolidayTypes";
$tablib[29]= "DictionaryOpportunityStatus"; $tablib[29]= "DictionaryOpportunityStatus";
$tablib[30]= "DictionaryFormatCards"; $tablib[30]= "DictionaryFormatCards";
$tablib[31]= "DictionaryAccountancysystem"; //$tablib[31]= "DictionaryAccountancysystem";
$tablib[32]= "DictionaryAccountancyCategory"; $tablib[32]= "DictionaryAccountancyCategory";
$tablib[33]= "DictionaryDepartment"; $tablib[33]= "DictionaryDepartment";
$tablib[34]= "DictionaryFunction"; $tablib[34]= "DictionaryFunction";
@ -169,7 +175,7 @@ $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as
$tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c";
$tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; $tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.fdm, c.decalage, c.active, c.sortorder FROM ".MAIN_DB_PREFIX.'c_payment_term AS c'; $tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement AS c"; $tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement AS c";
$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; $tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1";
$tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; $tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
@ -188,7 +194,7 @@ $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREF
$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
$tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; $tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s";
$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; $tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
$tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department";
$tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function";
@ -225,7 +231,7 @@ $tabsqlsort[27]="code ASC";
$tabsqlsort[28]="country ASC, code ASC"; $tabsqlsort[28]="country ASC, code ASC";
$tabsqlsort[29]="position ASC"; $tabsqlsort[29]="position ASC";
$tabsqlsort[30]="code ASC"; $tabsqlsort[30]="code ASC";
$tabsqlsort[31]="pcg_version ASC"; //$tabsqlsort[31]="pcg_version ASC";
$tabsqlsort[32]="position ASC"; $tabsqlsort[32]="position ASC";
$tabsqlsort[33]="code ASC"; $tabsqlsort[33]="code ASC";
$tabsqlsort[34]="code ASC"; $tabsqlsort[34]="code ASC";
@ -243,7 +249,7 @@ $tabfield[8] = "code,libelle,country_id,country".(! empty($conf->global->SOCIETE
$tabfield[9] = "code,label,unicode"; $tabfield[9] = "code,label,unicode";
$tabfield[10]= "country_id,country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[10]= "country_id,country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[11]= "element,source,code,libelle,position"; $tabfield[11]= "element,source,code,libelle,position";
$tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage,sortorder"; $tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
$tabfield[13]= "code,libelle,type,accountancy_code"; $tabfield[13]= "code,libelle,type,accountancy_code";
$tabfield[14]= "code,libelle,price,organization,country_id,country"; $tabfield[14]= "code,libelle,price,organization,country_id,country";
$tabfield[15]= "code,libelle,width,height,unit"; $tabfield[15]= "code,libelle,width,height,unit";
@ -262,7 +268,7 @@ $tabfield[27]= "code,libelle";
$tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country";
$tabfield[29]= "code,label,percent,position"; $tabfield[29]= "code,label,percent,position";
$tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; $tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
$tabfield[31]= "pcg_version,label"; //$tabfield[31]= "pcg_version,label";
$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country"; $tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country";
$tabfield[33]= "code,label"; $tabfield[33]= "code,label";
$tabfield[34]= "code,label"; $tabfield[34]= "code,label";
@ -280,7 +286,7 @@ $tabfieldvalue[8] = "code,libelle,country".(! empty($conf->global->SOCIETE_SORT_
$tabfieldvalue[9] = "code,label,unicode"; $tabfieldvalue[9] = "code,label,unicode";
$tabfieldvalue[10]= "country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[10]= "country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[11]= "element,source,code,libelle,position"; $tabfieldvalue[11]= "element,source,code,libelle,position";
$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage,sortorder"; $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
$tabfieldvalue[13]= "code,libelle,type,accountancy_code"; $tabfieldvalue[13]= "code,libelle,type,accountancy_code";
$tabfieldvalue[14]= "code,libelle,price,organization,country"; $tabfieldvalue[14]= "code,libelle,price,organization,country";
$tabfieldvalue[15]= "code,libelle,width,height,unit"; $tabfieldvalue[15]= "code,libelle,width,height,unit";
@ -299,7 +305,7 @@ $tabfieldvalue[27]= "code,libelle";
$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; $tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country";
$tabfieldvalue[29]= "code,label,percent,position"; $tabfieldvalue[29]= "code,label,percent,position";
$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; $tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
$tabfieldvalue[31]= "pcg_version,label"; //$tabfieldvalue[31]= "pcg_version,label";
$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country"; $tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country";
$tabfieldvalue[33]= "code,label"; $tabfieldvalue[33]= "code,label";
$tabfieldvalue[34]= "code,label"; $tabfieldvalue[34]= "code,label";
@ -317,7 +323,7 @@ $tabfieldinsert[8] = "code,libelle,fk_country".(! empty($conf->global->SOCIETE_S
$tabfieldinsert[9] = "code_iso,label,unicode"; $tabfieldinsert[9] = "code_iso,label,unicode";
$tabfieldinsert[10]= "fk_pays,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[10]= "fk_pays,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[11]= "element,source,code,libelle,position"; $tabfieldinsert[11]= "element,source,code,libelle,position";
$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage,sortorder"; $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder";
$tabfieldinsert[13]= "code,libelle,type,accountancy_code"; $tabfieldinsert[13]= "code,libelle,type,accountancy_code";
$tabfieldinsert[14]= "code,libelle,price,organization,fk_pays"; $tabfieldinsert[14]= "code,libelle,price,organization,fk_pays";
$tabfieldinsert[15]= "code,label,width,height,unit"; $tabfieldinsert[15]= "code,label,width,height,unit";
@ -336,7 +342,7 @@ $tabfieldinsert[27]= "code,libelle";
$tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country";
$tabfieldinsert[29]= "code,label,percent,position"; $tabfieldinsert[29]= "code,label,percent,position";
$tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; $tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
$tabfieldinsert[31]= "pcg_version,label"; //$tabfieldinsert[31]= "pcg_version,label";
$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; $tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country";
$tabfieldinsert[33]= "code,label"; $tabfieldinsert[33]= "code,label";
$tabfieldinsert[34]= "code,label"; $tabfieldinsert[34]= "code,label";
@ -375,7 +381,7 @@ $tabrowid[27]= "id";
$tabrowid[28]= ""; $tabrowid[28]= "";
$tabrowid[29]= ""; $tabrowid[29]= "";
$tabrowid[30]= ""; $tabrowid[30]= "";
$tabrowid[31]= ""; //$tabrowid[31]= "";
$tabrowid[32]= ""; $tabrowid[32]= "";
$tabrowid[33]= "rowid"; $tabrowid[33]= "rowid";
$tabrowid[34]= "rowid"; $tabrowid[34]= "rowid";
@ -412,7 +418,7 @@ $tabcond[27]= ! empty($conf->societe->enabled);
$tabcond[28]= ! empty($conf->holiday->enabled); $tabcond[28]= ! empty($conf->holiday->enabled);
$tabcond[29]= ! empty($conf->projet->enabled); $tabcond[29]= ! empty($conf->projet->enabled);
$tabcond[30]= ! empty($conf->label->enabled); $tabcond[30]= ! empty($conf->label->enabled);
$tabcond[31]= ! empty($conf->accounting->enabled); //$tabcond[31]= ! empty($conf->accounting->enabled);
$tabcond[32]= ! empty($conf->accounting->enabled); $tabcond[32]= ! empty($conf->accounting->enabled);
$tabcond[33]= ! empty($conf->hrm->enabled); $tabcond[33]= ! empty($conf->hrm->enabled);
$tabcond[34]= ! empty($conf->hrm->enabled); $tabcond[34]= ! empty($conf->hrm->enabled);
@ -430,7 +436,7 @@ $tabhelp[8] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->
$tabhelp[9] = array('code'=>$langs->trans("EnterAnyCode"), 'unicode'=>$langs->trans("UnicodeCurrency")); $tabhelp[9] = array('code'=>$langs->trans("EnterAnyCode"), 'unicode'=>$langs->trans("UnicodeCurrency"));
$tabhelp[10] = array('code'=>$langs->trans("EnterAnyCode"), 'taux'=>$langs->trans("SellTaxRate"), 'recuperableonly'=>$langs->trans("RecuperableOnly"), 'localtax1_type'=>$langs->trans("LocalTaxDesc"), 'localtax2_type'=>$langs->trans("LocalTaxDesc")); $tabhelp[10] = array('code'=>$langs->trans("EnterAnyCode"), 'taux'=>$langs->trans("SellTaxRate"), 'recuperableonly'=>$langs->trans("RecuperableOnly"), 'localtax1_type'=>$langs->trans("LocalTaxDesc"), 'localtax2_type'=>$langs->trans("LocalTaxDesc"));
$tabhelp[11] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList")); $tabhelp[11] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[12] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[12] = array('code'=>$langs->trans("EnterAnyCode"), 'type_cdr'=>$langs->trans("TypeCdr"));
$tabhelp[13] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[13] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[14] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[14] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[15] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[15] = array('code'=>$langs->trans("EnterAnyCode"));
@ -449,7 +455,7 @@ $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList")); $tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize")); $tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); //$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
@ -486,7 +492,7 @@ $tabfieldcheck[27] = array();
$tabfieldcheck[28] = array(); $tabfieldcheck[28] = array();
$tabfieldcheck[29] = array(); $tabfieldcheck[29] = array();
$tabfieldcheck[30] = array(); $tabfieldcheck[30] = array();
$tabfieldcheck[31] = array(); //$tabfieldcheck[31] = array();
$tabfieldcheck[32] = array(); $tabfieldcheck[32] = array();
$tabfieldcheck[33] = array(); $tabfieldcheck[33] = array();
$tabfieldcheck[34] = array(); $tabfieldcheck[34] = array();
@ -577,6 +583,16 @@ if ($id == 10)
} }
/*
* Actions
*/
if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
{
$search_country_id = '';
}
// Actions add or modify an entry into a dictionary // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd') || GETPOST('actionmodify')) if (GETPOST('actionadd') || GETPOST('actionmodify'))
{ {
@ -659,8 +675,8 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
} }
// Clean some parameters // Clean some parameters
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (! empty($_POST["localtax1_type"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 if (! empty($_POST["localtax2_type"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
@ -706,7 +722,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql.=","; if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
@ -755,7 +771,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
} }
if ($i) $sql.=","; if ($i) $sql.=",";
$sql.= $field."="; $sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
@ -896,7 +912,19 @@ if ($id)
$titre.=' - '.$langs->trans($tablib[$id]); $titre.=' - '.$langs->trans($tablib[$id]);
$linkback='<a href="'.$_SERVER['PHP_SELF'].'">'.$langs->trans("BackToDictionaryList").'</a>'; $linkback='<a href="'.$_SERVER['PHP_SELF'].'">'.$langs->trans("BackToDictionaryList").'</a>';
} }
print load_fiche_titre($titre,$linkback,'title_setup'); $titlepicto='title_setup';
if ($id == 10 && GETPOST('from') == 'accountancy')
{
$titre=$langs->trans("MenuVatAccounts");
$titlepicto='title_accountancy';
}
if ($id == 7 && GETPOST('from') == 'accountancy')
{
$titre=$langs->trans("MenuTaxAccounts");
$titlepicto='title_accountancy';
}
print load_fiche_titre($titre,$linkback,$titlepicto);
if (empty($id)) if (empty($id))
{ {
@ -921,6 +949,13 @@ if ($id)
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id]; $sql=$tabsql[$id];
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " c.rowid = ".$search_country_id;
}
if ($sortfield) if ($sortfield)
{ {
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
@ -946,6 +981,8 @@ if ($id)
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" 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="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// Form to add a new line // Form to add a new line
@ -970,12 +1007,12 @@ if ($id)
if ($fieldlist[$field]=='taux') { if ($fieldlist[$field]=='taux') {
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate");
else $valuetoshow=$langs->trans("Amount"); else $valuetoshow=$langs->trans("Amount");
$align='right'; $align='center';
} }
if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; }
if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2";} if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; }
if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; }
if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3";} if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; }
if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
if ($fieldlist[$field]=='type') { if ($fieldlist[$field]=='type') {
@ -995,7 +1032,7 @@ if ($id)
} }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); } if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
@ -1034,9 +1071,11 @@ if ($id)
} }
if ($id == 4) print '<td></td>'; if ($id == 4) print '<td></td>';
print '<td colspan="4">'; print '<td>';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>'; print '</td>';
print '<td style="min-width: 26px;"></td>';
print '<td style="min-width: 26px;"></td>';
print '</tr>'; print '</tr>';
// Line to enter new values // Line to enter new values
@ -1048,7 +1087,7 @@ if ($id)
{ {
foreach ($fieldlist as $key=>$val) foreach ($fieldlist as $key=>$val)
{ {
if (GETPOST($val)) if (GETPOST($val) != '')
$obj->$val=GETPOST($val); $obj->$val=GETPOST($val);
} }
} }
@ -1058,7 +1097,7 @@ if ($id)
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors; $error=$hookmanager->error; $errors=$hookmanager->errors;
if ($id == 3) unset($fieldlist[2]); if ($id == 3) unset($fieldlist[2]); // Remove field ??? if ???
if (empty($reshook)) if (empty($reshook))
{ {
@ -1101,11 +1140,9 @@ if ($id)
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 '</form>';
// List of available record in database
// List of available values in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG); dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
@ -1113,23 +1150,29 @@ if ($id)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$var=true; $var=true;
if ($num)
{ $param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
$paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
// There is several pages // There is several pages
if ($num > $listlimit) if ($num > $listlimit)
{ {
print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">'; print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], '&id='.$id, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>'); print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '</td></tr>'; print '</td></tr>';
} }
// Title of lines // Title of lines
print '<tr class="liste_titre">'; print '<tr class="liste_titre liste_titre_add">';
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
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$showfield=1; // Par defaut $showfield=1; // By defaut
$align="left"; $align="left";
$sortable=1; $sortable=1;
$valuetoshow=''; $valuetoshow='';
@ -1140,19 +1183,19 @@ if ($id)
$align=$tmp['align']; $align=$tmp['align'];
$sortable=$tmp['sortable']; $sortable=$tmp['sortable'];
*/ */
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
if ($fieldlist[$field]=='taux') { if ($fieldlist[$field]=='taux') {
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate");
else $valuetoshow=$langs->trans("Amount"); else $valuetoshow=$langs->trans("Amount");
$align='right'; $align='center';
} }
if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; }
if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $sortable=0; } if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; $sortable=0; }
if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; }
if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $sortable=0; } if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; $sortable=0; }
if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
@ -1166,7 +1209,7 @@ if ($id)
if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); } if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
@ -1190,17 +1233,49 @@ if ($id)
// Affiche nom du champ // Affiche nom du champ
if ($showfield) if ($showfield)
{ {
print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
} }
} }
// Favorite - Only activated on country dictionary // Favorite - Only activated on country dictionary
if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"),0,$_SERVER["PHP_SELF"],"favorite",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
// Title line with search boxes
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value)
{
$showfield=1; // By defaut
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
if ($showfield)
{
if ($value == 'country')
{
print '<td>';
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>';
}
else
{
print '<td></td>';
}
}
}
if ($id == 4) print '<td></td>';
print '<td></td>';
print '<td class="liste_titre" colspan="2" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
print '</td>';
print '</tr>';
if ($num)
{
// Lines with values // Lines with values
while ($i < $num) while ($i < $num)
{ {
@ -1223,8 +1298,11 @@ if ($id)
if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
print '<td colspan="3" align="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<td colspan="3" align="center">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</td>';
} }
else else
{ {
@ -1268,10 +1346,16 @@ if ($id)
$valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country);
} }
} }
else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
$valuetoshow=yn($valuetoshow); $valuetoshow=yn($valuetoshow);
$align="center"; $align="center";
} }
else if ($fieldlist[$field]=='type_cdr') {
if(empty($valuetoshow)) $valuetoshow = $langs->trans('None');
elseif($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth');
elseif($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext');
$align="center";
}
else if ($fieldlist[$field]=='price' || preg_match('/^amount/i',$fieldlist[$field])) { else if ($fieldlist[$field]=='price' || preg_match('/^amount/i',$fieldlist[$field])) {
$valuetoshow=price($valuetoshow); $valuetoshow=price($valuetoshow);
} }
@ -1369,24 +1453,26 @@ if ($id)
$key = $langs->trans('SizeUnit'.strtolower($obj->unit)); $key = $langs->trans('SizeUnit'.strtolower($obj->unit));
$valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]}); $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]});
} }
else if ($fieldlist[$field]=='localtax1' || $fieldlist[$field]=='localtax2') {
$align="center";
}
else if ($fieldlist[$field]=='localtax1_type') { else if ($fieldlist[$field]=='localtax1_type') {
if ($obj->localtax1 != 0) if ($obj->localtax1 != 0)
$valuetoshow=$localtax_typeList[$valuetoshow]; $valuetoshow=$localtax_typeList[$valuetoshow];
else else
$valuetoshow = ''; $valuetoshow = '';
$align="right"; $align="center";
} }
else if ($fieldlist[$field]=='localtax2_type') { else if ($fieldlist[$field]=='localtax2_type') {
if ($obj->localtax2 != 0) if ($obj->localtax2 != 0)
$valuetoshow=$localtax_typeList[$valuetoshow]; $valuetoshow=$localtax_typeList[$valuetoshow];
else else
$valuetoshow = ''; $valuetoshow = '';
$align="right"; $align="center";
} }
else if ($fieldlist[$field]=='taux') { else if ($fieldlist[$field]=='taux') {
$valuetoshow = price($valuetoshow, 0, $langs, 0, 0); $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
$align="right"; $align="center";
} }
else if (in_array($fieldlist[$field],array('recuperableonly'))) else if (in_array($fieldlist[$field],array('recuperableonly')))
{ {
@ -1417,7 +1503,9 @@ if ($id)
$canbemodified=$iserasable; $canbemodified=$iserasable;
if ($obj->code == 'RECEP') $canbemodified=1; if ($obj->code == 'RECEP') $canbemodified=1;
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;id='.$id.'&amp;'; $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
if ($param) $url .= '&'.$param;
$url.='&';
// Favorite // Favorite
// Only activated on country dictionary // Only activated on country dictionary
@ -1446,7 +1534,13 @@ if ($id)
else print '<td>&nbsp;</td>'; else print '<td>&nbsp;</td>';
// Delete link // Delete link
if ($iserasable) print '<td align="center"><a href="'.$url.'action=delete">'.img_delete().'</a></td>'; if ($iserasable)
{
print '<td align="center">';
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionnary can be edited by other profile than admin
print '</td>';
}
else print '<td>&nbsp;</td>'; else print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
@ -1625,14 +1719,19 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
print 'user<input type="hidden" name="type" value="user">'; print 'user<input type="hidden" name="type" value="user">';
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
print '<td>'; if ($fieldlist[$field] == 'type_cdr') print '<td align="center">';
else print '<td>';
if ($fieldlist[$field] == 'type_cdr') {
print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
} else {
print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1); print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1);
}
print '</td>'; print '</td>';
} }
elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) {
$align="left"; $align="left";
if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="center"; // Fields aligned on right
print '<td align="'.$align.'">'; print '<td align="'.$align.'">';
print '<input type="text" class="flat" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" size="3" name="'.$fieldlist[$field].'">'; print '<input type="text" class="flat" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" size="3" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
@ -1687,12 +1786,14 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
print '<td>'; print '<td>';
if (! empty($conf->accounting->enabled)) if (! empty($conf->accounting->enabled))
{ {
$accountancy_account = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); $fieldname = $fieldlist[$field];
$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
} }
else else
{ {
print '<input type="text" size="10" class="flat" value="'.(isset($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" name="'.$fieldlist[$field].'">'; $fieldname = $fieldlist[$field];
print '<input type="text" size="10" class="flat" value="'.(isset($obj->$fieldname)?$obj->$fieldname:'').'" name="'.$fieldlist[$field].'">';
} }
print '</td>'; print '</td>';
} }
@ -1702,8 +1803,8 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
$size=''; $class=''; $size=''; $class='';
if ($fieldlist[$field]=='code') $size='size="8" '; if ($fieldlist[$field]=='code') $size='size="8" ';
if ($fieldlist[$field]=='position') $size='size="4" '; if ($fieldlist[$field]=='position') $size='size="4" ';
if ($fieldlist[$field]=='libelle') $size='centpercent'; if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
if ($fieldlist[$field]=='tracking') $class='centpercent'; if ($fieldlist[$field]=='tracking') $class='quatrevingtpercent';
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';

View File

@ -262,23 +262,6 @@ if ($action == 'setforcedate')
} }
} }
if ($action == 'set_INVOICE_AUTO_FILLJS')
{
$freetext = GETPOST('INVOICE_AUTO_FILLJS'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_AUTO_FILLJS",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/* /*
@ -750,20 +733,6 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" /
print "</td></tr>\n"; print "</td></tr>\n";
print '</form>'; print '</form>';
// Add js auto fill amount on paiement form
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_INVOICE_AUTO_FILLJS" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("JSOnPaimentBill");
print '</td><td width="60" align="center">';
print $form->selectyesno("INVOICE_AUTO_FILLJS",$conf->global->INVOICE_AUTO_FILLJS,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print '</form>';
$var=! $var; $var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';

View File

@ -104,7 +104,7 @@ if ($action == 'update')
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', implode(',',colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array())),'chaine',0,'',$conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', implode(',',colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array())),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLISTE_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
@ -225,7 +225,7 @@ if ($action == 'edit') // Edit
// Max size of short lists on customer card // Max size of short lists on customer card
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLISTE_LIMIT . '"></td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
@ -408,7 +408,7 @@ else // Show
print "</tr>"; print "</tr>";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLISTE_LIMIT . '</td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print "</tr>"; print "</tr>";

View File

@ -77,6 +77,7 @@ if ($action == 'update' && empty($_POST["cancel"]))
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE',GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'),'chaine',0,'',$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit; exit;
@ -89,6 +90,7 @@ $actiontypecode='';
$trigger_name=''; $trigger_name='';
$paramname='id'; $paramname='id';
$mode='emailfortest'; $mode='emailfortest';
$trackid=(($action == 'testhtml')?"testhtml":"test");
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if ($action == 'presend' && GETPOST('trackid') == 'test') $action='test'; if ($action == 'presend' && GETPOST('trackid') == 'test') $action='test';
@ -398,6 +400,20 @@ if ($action == 'edit')
print '<td><input class="flat" name="MAIN_MAIL_EMAIL_FROM" size="32" value="' . (! empty($conf->global->MAIN_MAIL_EMAIL_FROM)?$conf->global->MAIN_MAIL_EMAIL_FROM:''); print '<td><input class="flat" name="MAIN_MAIL_EMAIL_FROM" size="32" value="' . (! empty($conf->global->MAIN_MAIL_EMAIL_FROM)?$conf->global->MAIN_MAIL_EMAIL_FROM:'');
print '"></td></tr>'; print '"></td></tr>';
// Default from type
$var=!$var;
$liste = array();
$liste['user'] = $langs->trans('UserEmail');
$liste['company'] = $langs->trans('CompanyEmail');
print '<tr '.$bc[$var?1:0].'><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td><td>';
print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE',$liste,$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE,0);
print '</td></tr>';
// Separator
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
// From // From
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
@ -409,6 +425,7 @@ if ($action == 'edit')
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="' . (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)?$conf->global->MAIN_MAIL_AUTOCOPY_TO:''); print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="' . (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)?$conf->global->MAIN_MAIL_AUTOCOPY_TO:'');
print '"></td></tr>'; print '"></td></tr>';
print '</table>'; print '</table>';
print '<br><div class="center">'; print '<br><div class="center">';
@ -517,6 +534,21 @@ else
if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail"));
print '</td></tr>'; print '</td></tr>';
// Default from type
$var=!$var;
print '<tr '.$bc[$var?1:0].'><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
print '<td>';
if($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user'){
print $langs->trans('UserEmail');
} else {
print $langs->trans('CompanyEmail');
}
print '</td></tr>';
// Separator
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
// Errors To // Errors To
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
@ -539,6 +571,7 @@ else
} }
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
@ -558,6 +591,7 @@ else
print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
} }
// Boutons actions // Boutons actions
print '<div class="tabsAction">'; print '<div class="tabsAction">';

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> /* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.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
@ -33,10 +34,14 @@ $langs->load('other');
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();
$dirstandard = "/core/menus/standard"; $dirstandard = array();
$dirsmartphone = "/core/menus/smartphone"; $dirsmartphone = array();
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
$dirmenu = array($dirstandard,$dirsmartphone); foreach($dirmenus as $dirmenu)
{
$dirstandard[]=$dirmenu.'standard';
$dirsmartphone[]=$dirmenu.'smartphone';
}
$action=GETPOST('action'); $action=GETPOST('action');
@ -244,7 +249,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
$db->query($sql); $result=$db->query($sql);
if ($result == 0) if ($result == 0)
{ {
@ -331,7 +336,7 @@ if ($action == 'create')
// Handler // Handler
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
print '<td>'; print '<td>';
$formadmin->select_menu_families($menu_handler,'menu_handler',$dirmenu); $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/',$menu_handler)?'':'_menu'),'menu_handler',array_merge($dirstandard,$dirsmartphone));
print '</td>'; print '</td>';
print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>'; print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';

View File

@ -319,7 +319,7 @@ print '<input type="hidden" name="action" value="add_currency">';
print '<td>'.$form->selectCurrency('', 'code').'</td>'; print '<td>'.$form->selectCurrency('', 'code').'</td>';
print '<td align="center" width="20">&nbsp;</td>'; print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="300">'; print '<td align="right" width="300">';
print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('rate').'" />&nbsp;'; print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('Rate').'" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></form></tr>'; print '</td></form></tr>';

View File

@ -24,9 +24,8 @@
*/ */
require '../main.inc.php'; require '../main.inc.php';
// required 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/oauth.lib.php';
// Define $urlwithroot // Define $urlwithroot
@ -44,224 +43,6 @@ if (!$user->admin)
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
// Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth)
$supportedoauth2array=array('OAUTH_GOOGLE_NAME'=>'google');
// API access parameters OAUTH
$list = array (
array(
'OAUTH_AMAZON_NAME',
'OAUTH_AMAZON_ID',
'OAUTH_AMAZON_SECRET',
),
array(
'OAUTH_BITBUCKET_NAME',
'OAUTH_BITBUCKET_ID',
'OAUTH_BITBUCKET_SECRET',
),
array(
'OAUTH_BITLY_NAME',
'OAUTH_BITLY_ID',
'OAUTH_BITLY_SECRET',
),
array(
'OAUTH_BITRIX24_NAME',
'OAUTH_BITRIX24_ID',
'OAUTH_BITRIX24_SECRET',
),
array(
'OAUTH_BOX_NAME',
'OAUTH_BOX_ID',
'OAUTH_BOX_SECRET',
),
array(
'OAUTH_BUFFER_NAME',
'OAUTH_BUFFER_ID',
'OAUTH_BUFFER_SECRET',
),
array(
'OAUTH_DAILYMOTION_NAME',
'OAUTH_DAILYMOTION_ID',
'OAUTH_DAILYMOTION_SECRET',
),
array(
'OAUTH_DEVIANTART_NAME',
'OAUTH_DEVIANTART_ID',
'OAUTH_DEVIANTART_SECRET',
),
array(
'OAUTH_DROPBOX_NAME',
'OAUTH_DROPBOX_ID',
'OAUTH_DROPBOX_SECRET',
),
array(
'OAUTH_ETSY_NAME',
'OAUTH_ETSY_ID',
'OAUTH_ETSY_SECRET',
),
array(
'OAUTH_EVEONLINE_NAME',
'OAUTH_EVEONLINE_ID',
'OAUTH_EVEONLINE_SECRET',
),
array(
'OAUTH_FACEBOOK_NAME',
'OAUTH_FACEBOOK_ID',
'OAUTH_FACEBOOK_SECRET',
),
array(
'OAUTH_FITBIT_NAME',
'OAUTH_FITBIT_ID',
'OAUTH_FITBIT_SECRET',
),
array(
'OAUTH_FIVEHUNDREDPX_NAME',
'OAUTH_FIVEHUNDREDPX_ID',
'OAUTH_FIVEHUNDREDPX_SECRET',
),
array(
'OAUTH_FLICKR_NAME',
'OAUTH_FLICKR_ID',
'OAUTH_FLICKR_SECRET',
),
array(
'OAUTH_FOURSQUARE_NAME',
'OAUTH_FOURSQUARE_ID',
'OAUTH_FOURSQUARE_SECRET',
),
array(
'OAUTH_GITHUB_NAME',
'OAUTH_GITHUB_ID',
'OAUTH_GITHUB_SECRET',
),
array(
'OAUTH_GOOGLE_NAME',
'OAUTH_GOOGLE_ID',
'OAUTH_GOOGLE_SECRET',
'OAUTH_GOOGLE_DESC',
),
array(
'OAUTH_HUBIC_NAME',
'OAUTH_HUBIC_ID',
'OAUTH_HUBIC_SECRET',
),
array(
'OAUTH_INSTAGRAM_NAME',
'OAUTH_INSTAGRAM_ID',
'OAUTH_INSTAGRAM_SECRET',
),
array(
'OAUTH_LINKEDIN_NAME',
'OAUTH_LINKEDIN_ID',
'OAUTH_LINKEDIN_SECRET',
),
array(
'OAUTH_MAILCHIMP_NAME',
'OAUTH_MAILCHIMP_ID',
'OAUTH_MAILCHIMP_SECRET',
),
array(
'OAUTH_MICROSOFT_NAME',
'OAUTH_MICROSOFT_ID',
'OAUTH_MICROSOFT_SECRET',
),
array(
'OAUTH_NEST_NAME',
'OAUTH_NEST_ID',
'OAUTH_NEST_SECRET',
),
array(
'OAUTH_NETATMO_NAME',
'OAUTH_NETATMO_ID',
'OAUTH_NETATMO_SECRET',
),
array(
'OAUTH_PARROTFLOWERPOWER_NAME',
'OAUTH_PARROTFLOWERPOWER_ID',
'OAUTH_PARROTFLOWERPOWER_SECRET',
),
array(
'OAUTH_PAYPAL_NAME',
'OAUTH_PAYPAL_ID',
'OAUTH_PAYPAL_SECRET',
),
array(
'OAUTH_POCKET_NAME',
'OAUTH_POCKET_ID',
'OAUTH_POCKET_SECRET',
),
array(
'OAUTH_QUICKBOOKS_NAME',
'OAUTH_QUICKBOOKS_ID',
'OAUTH_QUICKBOOKS_SECRET',
),
array(
'OAUTH_REDDIT_NAME',
'OAUTH_REDDIT_ID',
'OAUTH_REDDIT_SECRET',
),
array(
'OAUTH_REDMINE_NAME',
'OAUTH_REDMINE_ID',
'OAUTH_REDMINE_SECRET',
),
array(
'OAUTH_RUNKEEPER_NAME',
'OAUTH_RUNKEEPER_ID',
'OAUTH_RUNKEEPER_SECRET',
),
array(
'OAUTH_SCOOPIT_NAME',
'OAUTH_SCOOPIT_ID',
'OAUTH_SCOOPIT_SECRET',
),
array(
'OAUTH_SOUNDCLOUD_NAME',
'OAUTH_SOUNDCLOUD_ID',
'OAUTH_SOUNDCLOUD_SECRET',
),
array(
'OAUTH_SPOTIFY_NAME',
'OAUTH_SPOTIFY_ID',
'OAUTH_SPOTIFY_SECRET',
),
array(
'OAUTH_STRAVA_NAME',
'OAUTH_STRAVA_ID',
'OAUTH_STRAVA_SECRET',
),
array(
'OAUTH_TUMBLR_NAME',
'OAUTH_TUMBLR_ID',
'OAUTH_TUMBLR_SECRET',
),
array(
'OAUTH_TWITTER_NAME',
'OAUTH_TWITTER_ID',
'OAUTH_TWITTER_SECRET',
),
array(
'OAUTH_USTREAM_NAME',
'OAUTH_USTREAM_ID',
'OAUTH_USTREAM_SECRET',
),
array(
'OAUTH_VIMEO_NAME',
'OAUTH_VIMEO_ID',
'OAUTH_VIMEO_SECRET',
),
array(
'OAUTH_YAHOO_NAME',
'OAUTH_YAHOO_ID',
'OAUTH_YAHOO_SECRET',
),
array(
'OAUTH_YAMMER_NAME',
'OAUTH_YAMMER_ID',
'OAUTH_YAMMER_SECRET',
),
);
/* /*
* Actions * Actions
@ -303,10 +84,9 @@ 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">';
/* $head = oauthadmin_prepare_head();
* Parameters
*/ dol_fiche_head($head, 'services', '', 0, 'technic');
dol_fiche_head(array(), '', '', 0, 'technic');
print $langs->trans("ListOfSupportedOauthProviders").'<br><br>'; print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
@ -314,6 +94,7 @@ print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$var = true; $var = true;
$i=0;
foreach ($list as $key) foreach ($list as $key)
{ {
@ -321,7 +102,9 @@ foreach ($list as $key)
if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1; if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1;
if (! $supported) continue; // show only supported if (! $supported) continue; // show only supported
print '<tr class="liste_titre">'; $i++;
print '<tr class="liste_titre'.($i > 1 ?' liste_titre_add':'').'">';
// Api Name // Api Name
$label = $langs->trans($key[0]); $label = $langs->trans($key[0]);
print '<td>'.$label.'</td>'; print '<td>'.$label.'</td>';

View File

@ -0,0 +1,275 @@
<?php
/* Copyright (C) 2013-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014-2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/oauthlogintoken.php
* \ingroup oauth
* \brief Setup page to configure oauth access to login information
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
use OAuth\Common\Storage\DoliStorage;
$langs->load("admin");
$langs->load("printing");
$langs->load("oauth");
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha');
$value = GETPOST('value','alpha');
$varname = GETPOST('varname', 'alpha');
$driver = GETPOST('driver', 'alpha');
if (! empty($driver)) $langs->load($driver);
if (!$mode) $mode='setup';
/*
* Action
*/
/*if (($mode == 'test' || $mode == 'setup') && empty($driver))
{
setEventMessages($langs->trans('PleaseSelectaDriverfromList'), null);
header("Location: ".$_SERVER['PHP_SELF'].'?mode=config');
exit;
}*/
if ($action == 'setconst' && $user->admin)
{
$error=0;
$db->begin();
foreach ($_POST['setupdriver'] as $setupconst) {
//print '<pre>'.print_r($setupconst, true).'</pre>';
$result=dolibarr_set_const($db, $setupconst['varname'],$setupconst['value'],'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null);
}
else
{
$db->rollback();
dol_print_error($db);
}
$action='';
}
if ($action == 'setvalue' && $user->admin)
{
$db->begin();
$result=dolibarr_set_const($db, $varname, $value,'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null);
}
else
{
$db->rollback();
dol_print_error($db);
}
$action = '';
}
/*
* View
*/
$form = new Form($db);
llxHeader('',$langs->trans("PrintingSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ConfigOAuth'),$linkback,'title_setup');
$head=oauthadmin_prepare_head($mode);
dol_fiche_head($head, 'tokengeneration', '', 0, 'technic');
if ($mode == 'setup' && $user->admin)
{
print $langs->trans("OAuthSetupForLogin")."<br><br>\n";
foreach($list as $key)
{
$supported=0;
if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1;
if (! $supported) continue; // show only supported
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&amp;driver='.$driver.'" autocomplete="off">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setconst">';
print '<table class="noborder" width="100%">'."\n";
$var=true;
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Parameters").'</th>';
print '<th>'.$langs->trans("Value").'</th>';
print '<th>&nbsp;</th>';
print "</tr>\n";
$submit_enabled=0;
print '<tr '.$bc[$var].'>';
print '<td'.($key['required']?' class=required':'').'>'.$langs->trans($key['varname']).'</td>';
print '<td>'.$langs->trans($key['info']).'</td>';
print '<td>';
if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS')
{
// Delete remote tokens
if (! empty($key['delete'])) print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>';
// Request remote token
print '<a class="button" href="'.$key['renew'].'">'.$langs->trans('RequestAccess').'</a><br><br>';
// Check remote access
print $langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME_GOOGLE).': <a href="https://security.google.com/settings/security/permissions" target="_google">https://security.google.com/settings/security/permissions</a>';
}
print '</td>';
print '</tr>'."\n";
// Show value of token
if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS')
{
// Token
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("Token").'</td>';
print '<td>';
// Dolibarr storage
$storage = new DoliStorage($db, $conf);
try
{
$tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE);
}
catch(Exception $e)
{
// Return an error if token not found
}
if (is_object($tokenobj))
{
//var_dump($tokenobj);
print $tokenobj->getAccessToken().'<br>';
//print 'Refresh: '.$tokenobj->getRefreshToken().'<br>';
//print 'EndOfLife: '.$tokenobj->getEndOfLife().'<br>';
//var_dump($tokenobj->getExtraParams());
/*print '<br>Extra: <br><textarea class="quatrevingtpercent">';
print ''.join(',',$tokenobj->getExtraParams());
print '</textarea>';*/
}
print '</td>';
print '<td>';
print '</td>';
print '</tr>'."\n";
}
print '</table>';
if (! empty($driver))
{
if ($submit_enabled) {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>';
}
}
print '</form>';
}
}
if ($mode == 'test' && $user->admin)
{
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
print '<table class="noborder" width="100%">';
if (! empty($driver))
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$classname = 'printing_'.$driver;
$langs->load($driver);
$printer = new $classname($db);
//print '<pre>'.print_r($printer, true).'</pre>';
if (count($printer->getlist_available_printers())) {
if ($printer->listAvailablePrinters()==0) {
print $printer->resprint;
} else {
setEventMessages($printer->error, $printer->errors, 'errors');
}
}
else {
print $langs->trans('PleaseConfigureDriverfromList');
}
}
print '</table>';
}
if ($mode == 'userconf' && $user->admin)
{
print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n";
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("User").'</th>';
print '<th>'.$langs->trans("PrintModule").'</th>';
print '<th>'.$langs->trans("PrintDriver").'</th>';
print '<th>'.$langs->trans("Printer").'</th>';
print '<th>'.$langs->trans("PrinterLocation").'</th>';
print '<th>'.$langs->trans("PrinterId").'</th>';
print '<th>'.$langs->trans("NumberOfCopy").'</th>';
print '<th class="center">'.$langs->trans("Delete").'</th>';
print "</tr>\n";
$sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid';
$resql = $db->query($sql);
while ($row=$db->fetch_array($resql)) {
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$row['login'].'</td>';
print '<td>'.$row['module'].'</td>';
print '<td>'.$row['driver'].'</td>';
print '<td>'.$row['printer_name'].'</td>';
print '<td>'.$row['printer_location'].'</td>';
print '<td>'.$row['printer_id'].'</td>';
print '<td>'.$row['copy'].'</td>';
print '<td class="center">'.img_picto($langs->trans("Delete"), 'delete').'</td>';
print "</tr>\n";
}
print '</table>';
}
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -69,7 +69,7 @@ if ($action == 'setmod')
dolibarr_set_const($db, "PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity); dolibarr_set_const($db, "PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity);
} }
if ($action == 'set_FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') if ($action == 'setparams')
{ {
$freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS'); // No alpha here, we want exact string $freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS'); // No alpha here, we want exact string
@ -77,16 +77,31 @@ if ($action == 'set_FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS')
if (! $res > 0) $error++; if (! $res > 0) $error++;
if ($error)
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
/*
$freetext = GETPOST('INVOICE_AUTO_FILLJS'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_AUTO_FILLJS",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if ($error)
{
setEventMessages($langs->trans("Error"), null, 'errors');
}*/
if (! $error) if (! $error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
} }
/* /*
* View * View
*/ */
@ -235,6 +250,10 @@ print "<br />";
print load_fiche_titre($langs->trans("OtherOptions"),'',''); print load_fiche_titre($langs->trans("OtherOptions"),'','');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="setparams" />';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>'; print '<td>'.$langs->trans("Parameter").'</td>';
@ -244,20 +263,32 @@ print "</tr>\n";
// Allow payments on different thirdparties bills but same parent company // Allow payments on different thirdparties bills but same parent company
$var=! $var; $var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS" />';
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
print $langs->trans("PaymentOnDifferentThirdBills"); print $langs->trans("PaymentOnDifferentThirdBills");
print '</td><td width="60" align="center">'; print '</td><td width="60" align="center">';
print $form->selectyesno("FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS",$conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS,1); print $form->selectyesno("FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS",$conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS,1);
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n"; print "</td></tr>\n";
print '</form>';
// Add js auto fill amount on paiement form
/* always on now
$var=! $var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("JSOnPaimentBill");
print '</td><td width="60" align="center">';
print $form->selectyesno("INVOICE_AUTO_FILLJS",$conf->global->INVOICE_AUTO_FILLJS,1);
print '</td><td align="right">';
print "</td></tr>\n";
*/
print '</table>'; print '</table>';
print '<center>';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print '</center>';
print '</form>';
dol_fiche_end(); dol_fiche_end();

144
htdocs/admin/resource.php Normal file
View File

@ -0,0 +1,144 @@
<?php
/* Copyright (C) 2016 Florian HENRY <florian.henry@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/admin/resource.php
* \ingroup resource
* \brief Setup page to configure resource module
*/
require '../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
if (! empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php';
$langs->load("admin");
$langs->load("resource");
// Security check
if (!$user->admin)
accessforbidden();
$action = GETPOST('action', 'alpha');
/*
* Actions
*/
if ($action == 'updateoptions')
{
if (GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'))
{
if (dolibarr_set_const($db, "RESOURCE_USE_SEARCH_TO_SELECT", GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'), 'chaine', 0, '', $conf->entity))
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
}
/*
* View
*/
llxHeader('',$langs->trans('ResourceSetup'));
$form = new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ResourceSetup'),$linkback,'title_setup');
$head=resource_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("ResourceSingular"), 0, 'action');
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateoptions">';
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
print '<td align="right" width="60">'.$langs->trans("Value").'</td>'."\n";
print '<td></td>';
// Utilisation formulaire Ajax sur choix produit
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td width="80%">'.$langs->trans("UseSearchToSelectResource").'</td>';
if (empty($conf->use_javascript_ajax))
{
print '<td class="nowrap" align="right" colspan="2">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print '</td>';
}
else
{
print '<td width="60" align="right">';
$arrval=array(
'0'=>$langs->trans("No"),
'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
);
print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT",$arrval,$conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
print '</td>';
print '<td align="right">';
print '<input type="submit" class="button" name="RESOURCE_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
print '</td>';
}
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans('DisabledResourceLinkUser').'</td>';
print '<td>';
echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_USER');
print '</td>';
print '<td></td>';
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans('DisabledResourceLinkContact').'</td>';
print '<td>';
echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY');
print '</td>';
print '<td></td>';
print '</tr>';
print '</table>';
print '</form>';
//RESOURCE_HIDE_ADD_CONTACT_USER
//RESOURCE_HIDE_ADD_CONTACT_THIPARTY
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -0,0 +1,122 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/resource_extrafields.php
* \ingroup agenda
* \brief Page to setup extra fields of resource
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin)
accessforbidden();
$langs->load("admin");
$langs->load("other");
$langs->load("resource");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='resource'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject=$langs->transnoentitiesnoconv("ResourceSingular");
llxHeader('',$langs->trans("ResourceSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ResourceSetup"),$linkback,'title_setup');
print "<br>\n";
$head=resource_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), 0, 'action');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();

View File

@ -199,6 +199,23 @@ else if ($action == 'set_SUPPLIER_ORDER_OTHER')
} }
} }
// Activate ask for payment bank
else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER')
{
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER",$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/* /*
* View * View
@ -487,6 +504,38 @@ $var=false;
$var=!$var; $var=!$var;
//} //}
// Ask for payment bank during supplier order
/* Kept as hidden for the moment
if ($conf->banque->enabled)
{
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").'</td><td>&nbsp</td><td align="center">';
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER');
}
else
{
if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER))
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
}
}
print '</td></tr>';
}
else
{
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
}
*/
print '<tr '.$bc[$var].'><td colspan="2">'; print '<tr '.$bc[$var].'><td colspan="2">';
print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>'; print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>';
$variablename='SUPPLIER_ORDER_FREE_TEXT'; $variablename='SUPPLIER_ORDER_FREE_TEXT';

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2007-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
@ -25,6 +25,7 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
$langs->load("admin"); $langs->load("admin");
@ -78,31 +79,36 @@ $xmlshortfile = '/install/filelist-'.DOL_VERSION.'.xml';
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
$xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
$enableremotecheck = False;
// Test if remote test is ok
$enableremotecheck = True;
if (preg_match('/beta|alpha/i', DOL_VERSION)) $enableremotecheck=False;
print '<form name="check" action="'.$_SERVER["PHP_SELF"].'">'; print '<form name="check" action="'.$_SERVER["PHP_SELF"].'">';
print $langs->trans("MakeIntegrityAnalysisFrom").':<br>'; print $langs->trans("MakeIntegrityAnalysisFrom").':<br>';
if (dol_is_file($xmlfile)) if (dol_is_file($xmlfile))
{ {
print '<input type="checkbox" name="local" checked> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'<br>'; print '<input type="radio" name="target" value="local"'.((! GETPOST('target') || GETPOST('target') == 'local') ? 'checked="checked"':'').'"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'<br>';
} }
else else
{ {
print '<input type="checkbox" name="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span><br>'; print '<input type="radio" name="target" value="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span><br>';
} }
if ($enableremotecheck) if ($enableremotecheck)
{ {
print '<input type="checkbox" name="remote"> '.$langs->trans("RemoteSignature").' = '.$xmlremote.'<br>'; print '<input type="radio" name="target" value="remote"'.(GETPOST('target') == 'remote' ? 'checked="checked"':'').'> '.$langs->trans("RemoteSignature").' = '.$xmlremote.'<br>';
} }
else else
{ {
print '<input type="checkbox" name="remote" disabled> '.$langs->trans("RemoteSignature").' = '.$xmlremote.' <span class="warning">('.$langs->trans("FeatureNotYetAvailable").')</span><br>'; print '<input type="radio" name="target" value="remote" disabled="disabled"> '.$langs->trans("RemoteSignature").' = '.$xmlremote.' <span class="warning">('.$langs->trans("FeatureAvailableOnlyOnStable").')</span><br>';
} }
print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans("Check").'"></div>'; print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans("Check").'"></div>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
print '<br>';
if (GETPOST('local')) if (GETPOST('target') == 'local')
{ {
if (dol_is_file($xmlfile)) if (dol_is_file($xmlfile))
{ {
@ -114,17 +120,20 @@ if (GETPOST('local'))
$error++; $error++;
} }
} }
if (GETPOST('remote')) if (GETPOST('target') == 'remote')
{ {
// TODO $xmlarray = getURLContent($xmlremote);
//$xmlfile = ;
if (1 == 1) // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404')
{ {
//$xml = simplexml_load_file($xmlfile); $xmlfile = $xmlarray['content'];
$xml = simplexml_load_file($xmlfile);
} }
else else
{ {
print $langs->trans('XmlNotFound') . ': ' . $xmlfile; $errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
setEventMessages($errormsg, null, 'errors');
$error++; $error++;
} }
} }

View File

@ -204,7 +204,7 @@ if ($mode == 'overwrite')
print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("NewTranslationStringToShow"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("NewTranslationStringToShow"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder);
if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder); //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
print '<td align="center"></td>'; print '<td align="center"></td>';
print "</tr>\n"; print "</tr>\n";
@ -222,7 +222,7 @@ if ($mode == 'overwrite')
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="">'; print '<input type="text" class="quatrevingtpercent" name="transvalue" value="">';
print '</td>'; print '</td>';
// Limit to superadmin // Limit to superadmin
if (! empty($conf->multicompany->enabled) && !$user->entity) /*if (! empty($conf->multicompany->enabled) && !$user->entity)
{ {
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">'; print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
@ -230,10 +230,10 @@ if ($mode == 'overwrite')
print '<td align="center">'; print '<td align="center">';
} }
else else
{ {*/
print '<td align="center">'; print '<td align="center">';
print '<input type="hidden" name="entity" value="'.$conf->entity.'">'; print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
} //}
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="add">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="add">';
print "</td>\n"; print "</td>\n";
print '</tr>'; print '</tr>';
@ -371,7 +371,7 @@ if ($mode == 'searchkey')
print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder).'</td>'; print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder).'</td>';
print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CurrentTranslationString"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CurrentTranslationString"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder);
if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder); //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
print '<td align="center"></td>'; print '<td align="center"></td>';
print "</tr>\n"; print "</tr>\n";
@ -388,18 +388,18 @@ if ($mode == 'searchkey')
print '</td><td>'; print '</td><td>';
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$transvalue.'">'; print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$transvalue.'">';
// Limit to superadmin // Limit to superadmin
if (! empty($conf->multicompany->enabled) && !$user->entity) /*if (! empty($conf->multicompany->enabled) && !$user->entity)
{ {
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">'; print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">';
} }
else else
{ {*/
print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">'; print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">';
} //}
print '</td>'; print '</td>';
// Action column // Action column
print '<td class="liste_titre" align="middle">'; print '<td class="liste_titre nowrap" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpitco; print $searchpitco;
print '</td>'; print '</td>';
@ -427,6 +427,10 @@ if ($mode == 'searchkey')
$htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]);
print $form->textwithpicto('', $htmltext, 1, 'warning'); print $form->textwithpicto('', $htmltext, 1, 'warning');
} }
/*if (! empty($conf->multicompany->enabled) && !$user->entity)
{
print $val;
}*/
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }

View File

@ -535,7 +535,8 @@ if ($id)
{ {
$showfield=1; $showfield=1;
$align="left"; $align="left";
$valuetoshow=$obj->$fieldlist[$field]; $fieldname=$fieldlist[$field];
$valuetoshow=$obj->$fieldname;
// Show value for field // Show value for field
if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>'; if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
@ -613,14 +614,15 @@ function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='')
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$fieldname = $fieldlist[$field];
if ($fieldlist[$field] == 'lang') if ($fieldlist[$field] == 'lang')
{ {
print '<td>'; print '<td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang'); print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang');
print '</td>'; print '</td>';
} }
elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" size="10" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldname)?$obj->$fieldname:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
} }
else else
{ {
@ -631,7 +633,7 @@ function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='')
if ($fieldlist[$field]=='libelle') $size='size="32" '; if ($fieldlist[$field]=='libelle') $size='size="32" ';
if ($fieldlist[$field]=='tracking') $size='size="92" '; if ($fieldlist[$field]=='tracking') $size='size="92" ';
if ($fieldlist[$field]=='sortorder') $size='size="2" '; if ($fieldlist[$field]=='sortorder') $size='size="2" ';
print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname)?$obj->$fieldname:'').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }
} }

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) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 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
@ -73,8 +73,10 @@ print '<table class="noborder" width="100%">'."\n";
clearstatcache(); clearstatcache();
$workflowcodes=array( $workflowcodes=array(
// Automatic creation
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
// Automatic classification
'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'), 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'), 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
// For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card. // For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card.
@ -108,7 +110,11 @@ foreach($workflowcodes as $key => $params)
if ($oldfamily != $family) if ($oldfamily != $family)
{ {
print '<tr class="liste_titre">'."\n"; print '<tr class="liste_titre">'."\n";
print ' <td>'.$langs->trans("Description").'</td>'; print ' <td>';
if ($family == 'create') print $langs->trans("AutomaticCreation");
elseif ($family == 'classify') print $langs->trans("AutomaticClassification");
else print $langs->trans("Description");
print '</td>';
print ' <td align="center">'.$langs->trans("Status").'</td>'; print ' <td align="center">'.$langs->trans("Status").'</td>';
print "</tr>\n"; print "</tr>\n";
$oldfamily = $family; $oldfamily = $family;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.org> * Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
@ -27,6 +27,7 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$langs->load("admin"); $langs->load("admin");
@ -41,10 +42,18 @@ if ($action == 'setproductionmode')
$status = GETPOST('status','alpha'); $status = GETPOST('status','alpha');
if (dolibarr_set_const($db, 'API_PRODUCTION_MODE', $status, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, 'API_PRODUCTION_MODE', $status, 'chaine', 0, '', $conf->entity) > 0)
{
$result = dol_mkdir($conf->api->dir_temp);
if ($result < 0)
{
setEventMessages($langs->trans("ErrorFaildToCreateDir", $conf->api->dir_temp), null, 'errors');
}
else
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
}
else else
{ {
dol_print_error($db); dol_print_error($db);
@ -70,7 +79,7 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print "<td>".$langs->trans("Parameter")."</td>"; print "<td>".$langs->trans("Parameter")."</td>";
print "<td>".$langs->trans("Value")."</td>"; print '<td align="center">'.$langs->trans("Value")."</td>";
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "</tr>"; print "</tr>";
@ -111,9 +120,15 @@ print '<br>';
// Explorer // Explorer
print '<u>'.$langs->trans("ApiExporerIs").':</u><br>'; print '<u>'.$langs->trans("ApiExporerIs").':</u><br>';
if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer'))
{
$url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
}
else
{
print $langs->trans("NotAvailableWithThisDistribution");
}
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -162,4 +162,60 @@ class DolibarrApi
return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray,$resource_id,$dbtablename,$feature2,$dbt_keyfield,$dbt_select); return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray,$resource_id,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
} }
/**
* Return if a $sqlfilters parameter is valid
*
* @param string $sqlfilters sqlfilter string
* @return boolean True if valid, False if not valid
*/
function _checkFilters($sqlfilters)
{
//$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
//$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
$tmp=$sqlfilters;
$ok=0;
$i=0; $nb=count($tmp);
$counter=0;
while ($i < $nb)
{
if ($tmp[$i]=='(') $counter++;
if ($tmp[$i]==')') $counter--;
if ($counter < 0)
{
$error="Bad sqlfilters=".$sqlfilters;
dol_syslog($error, LOG_WARNING);
return false;
}
$i++;
}
return true;
}
/**
* Function to forge a SQL criteria
*
* @param array $matches Array of found string by regex search
* @return string Forged criteria. Example: "t.field like 'abc%'"
*/
static function _forge_criteria_callback($matches)
{
global $db;
//dol_syslog("Convert matches ".$matches[1]);
if (empty($matches[1])) return '';
$tmp=explode(':',$matches[1]);
if (count($tmp) < 3) return '';
$tmpescaped=$tmp[2];
if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
{
$tmpescaped = "'".$db->escape($regbis[1])."'";
}
else
{
$tmpescaped = $db->escape($tmpescaped);
}
return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;
}
} }

View File

@ -54,28 +54,32 @@ class DictionnaryCountries extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param string $filter To filter the countries by name * @param string $filter To filter the countries by name
* @param string $lang Code of the language the label of the countries must be translated to * @param string $lang Code of the language the label of the countries must be translated to
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return List of countries * @return List of countries
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '') function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '')
{ {
$list = array(); $list = array();
// Note: The filter is not applied in the SQL request because it must // Note: The filter is not applied in the SQL request because it must
// be applied to the translated names, not to the names in database. // be applied to the translated names, not to the names in database.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
$sql.=" WHERE 1 = 1";
$nbtotalofrecords = 0; // Add sql filters
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if ($sqlfilters)
{ {
$result = $this->db->query($sql); if (! DolibarrApi::_checkFilters($sqlfilters))
$nbtotalofrecords = $this->db->num_rows($result); {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $this->db->order($sortfield, $sortorder); $sql.= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) { if ($page < 0) {
$page = 0; $page = 0;

View File

@ -47,26 +47,31 @@ class DictionnaryTowns extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param string $zipcode To filter on zipcode * @param string $zipcode To filter on zipcode
* @param string $town To filter on city name * @param string $town To filter on city name
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return List of towns * @return List of towns
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '') function index($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '')
{ {
$list = array(); $list = array();
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql.= " WHERE active = 1"; $sql.= " WHERE t.active = 1";
if ($zipcode) $sql.=" AND zip LIKE '%" . $this->db->escape($zipcode) . "%'"; if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
if ($town) $sql.=" AND town LIKE '%" . $this->db->escape($town) . "%'"; if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
// Add sql filters
$nbtotalofrecords = 0; if ($sqlfilters)
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $this->db->query($sql); if (! DolibarrApi::_checkFilters($sqlfilters))
$nbtotalofrecords = $this->db->num_rows($result); {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder); $sql.= $this->db->order($sortfield, $sortorder);

View File

@ -98,11 +98,12 @@ class Categories extends DolibarrApi
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of category objects * @return array Array of category objects
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type = '', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
@ -111,19 +112,22 @@ class Categories extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT s.rowid"; $sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
$sql.= ' WHERE s.entity IN ('.getEntity('categorie', 1).')'; $sql.= ' WHERE t.entity IN ('.getEntity('categorie', 1).')';
if (!empty($type)) if (!empty($type))
{ {
$sql.= ' AND s.type='.array_search($type,Categories::$TYPES); $sql.= ' AND t.type='.array_search($type,Categories::$TYPES);
} }
// Add sql filters
$nbtotalofrecords = 0; if ($sqlfilters)
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); if (! DolibarrApi::_checkFilters($sqlfilters))
$nbtotalofrecords = $db->num_rows($result); {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
@ -258,6 +262,7 @@ class Categories extends DolibarrApi
if(! DolibarrApiAccess::$user->rights->categorie->creer) { if(! DolibarrApiAccess::$user->rights->categorie->creer) {
throw new RestException(401); throw new RestException(401);
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
@ -337,7 +342,7 @@ class Categories extends DolibarrApi
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
* @param array $data Data to validate * @param array|null $data Data to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException

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