Merge branch 'develop' of github.com:atm-maxime/dolibarr into new_modimport_update_option
This commit is contained in:
commit
e5418a7624
@ -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 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 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 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)
|
||||
|
||||
84
ChangeLog
84
ChangeLog
@ -22,7 +22,7 @@ WARNING:
|
||||
Following changes may create regression for some external modules, but were necessary to make
|
||||
Dolibarr better:
|
||||
- Function delete of class Facture (invoice) need the object $user as first parameter. Also you must
|
||||
check you make a fetch on object before calling the delete.
|
||||
check you make a fetch on object before calling the delete.
|
||||
- The old driver of "mysql" has been removed. Dolibarr use the new one (mysqli) by default.
|
||||
- Remove not used function calculate_byte(). Use dol_print_size() instead.
|
||||
- Function pdf_getTotalQty is now deprecated. Not used by Dolibarr core.
|
||||
@ -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.
|
||||
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.
|
||||
- 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 *****
|
||||
FIX #2853
|
||||
FIX #2991
|
||||
FIX #3128
|
||||
FIX: #2853
|
||||
FIX: #2991
|
||||
FIX: #3128
|
||||
FIX: #5699
|
||||
FIX #5734
|
||||
FIX : #5776
|
||||
FIX alignement of intervention status
|
||||
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: #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: #5802 Incoterms not set
|
||||
FIX: #5813 Bug: Incoterms not being read correctly
|
||||
FIX: #5818
|
||||
FIX: alignement of intervention status
|
||||
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 inversion customer/supplier price
|
||||
FIX link "back to list" was not visible.
|
||||
FIX Lost filter on opportunities
|
||||
FIX Mandatory field payment term was not css highlighted.
|
||||
FIX Menu users not visible on dolidroid.
|
||||
FIX SEC for HTB23302
|
||||
FIX The email test sender in email setup was broken
|
||||
FIX Translation of "Name" is not a good choice for floow-up.
|
||||
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: inversion customer/supplier price
|
||||
FIX: link "back to list" was not visible.
|
||||
FIX: Lost filter on opportunities
|
||||
FIX: Mandatory field payment term was not css highlighted.
|
||||
FIX: Menu users not visible on dolidroid.
|
||||
FIX: SEC for HTB23302
|
||||
FIX: The email test sender in email setup was broken
|
||||
FIX: Translation of "Name" is not a good choice for floow-up.
|
||||
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: 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.* *****
|
||||
For users:
|
||||
|
||||
@ -3,7 +3,7 @@ FROM php:5.6-apache
|
||||
RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& 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-install ldap \
|
||||
&& docker-php-ext-install mysqli \
|
||||
|
||||
@ -147,7 +147,7 @@ These are features that Dolibarr does **not** yet fully support:
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
@ -154,8 +154,10 @@ tag 729538 -moreinfo
|
||||
##### Testing a package into unstable env
|
||||
|
||||
Check you have a mysql server available from another interface than "localhost".
|
||||
Comment line in /etc/mysql/my.cnf if required and restart mysql
|
||||
#bind-address = 127.0.0.1
|
||||
Set line in /etc/mysql/my.cnf if required and restart mysql
|
||||
|
||||
[mysqld]
|
||||
bind-address = *
|
||||
|
||||
Create a chroot called "unstable-amd64-sbuild".
|
||||
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
|
||||
> 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)
|
||||
> apt-get update
|
||||
> apt-get upgrade
|
||||
> apt-get install links mysql-client
|
||||
|
||||
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
|
||||
> vi /etc/apache2/ports.conf
|
||||
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
|
||||
- debian
|
||||
- htdocs/includes/ckeditor
|
||||
- htdocs/includes/jszip
|
||||
- htdocs/includes/jquery/plugins/datatables
|
||||
- htdocs/includes/mike42
|
||||
- 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
|
||||
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)
|
||||
|
||||
* 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]
|
||||
and enter version when requested with format
|
||||
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:
|
||||
|
||||
* 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:
|
||||
|
||||
@ -341,7 +350,7 @@ Note: Package is built into directory ../build-area
|
||||
Note: To compare 2 packages: debdiff package1.dsc package2.dsc
|
||||
|
||||
* 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
|
||||
|
||||
* If package .deb is ok:
|
||||
|
||||
@ -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,
|
||||
# Required PHP libraries
|
||||
php-pear, php-mail-mime,
|
||||
# php-tcpdf, libfpdi-php,
|
||||
# php-tcpdf,
|
||||
# libfpdf-tpl-php, php-fpdf,
|
||||
# libphp-adodb,
|
||||
# libnusoap-php,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: Dolibarr
|
||||
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: *
|
||||
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
|
||||
License version 2 can be found in the file
|
||||
`/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/*
|
||||
Copyright: 2007 MaxMind LLC
|
||||
|
||||
@ -147,7 +147,6 @@ case "$1" in
|
||||
# File already exist. We add params not found.
|
||||
#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_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_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
|
||||
|
||||
@ -30,8 +30,6 @@ $force_install_lockinstall='444';
|
||||
// - not removed from package (see rm in rules file),
|
||||
// - declared into dependencies (see Depends in control file)
|
||||
//$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_GEOIP_PATH='';
|
||||
//$force_dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap';
|
||||
|
||||
@ -79,7 +79,6 @@ override_dh_install:
|
||||
|
||||
# clean from all PHP embedded libraries (we use package dependencies instead)
|
||||
# rm -fr htdocs/includes/adodbtime
|
||||
# rm -fr htdocs/includes/fpdfi
|
||||
# rm -fr htdocs/includes/geoip
|
||||
# rm -fr htdocs/includes/nusoap
|
||||
# rm -fr htdocs/includes/odtphp/zip/pclzip
|
||||
|
||||
@ -73,6 +73,8 @@ If you want to build/test package locally:
|
||||
bzr commit -m "Upstream version x.y"
|
||||
bzr push
|
||||
|
||||
|
||||
|
||||
# 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]
|
||||
@ -104,12 +106,13 @@ If you want to build/test package locally:
|
||||
bzr push lp:~yourlogin/+junk/debian-[dev|stable]
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
vi dolibarr.recipe
|
||||
For dev:
|
||||
vi dolibarr-[beta|stable].recipe
|
||||
For beta/dev:
|
||||
# bzr-builder format 0.3 deb-version {debupstream}-0~{revno}
|
||||
lp:dolibarr
|
||||
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
|
||||
- Run command
|
||||
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]
|
||||
- Test package sources
|
||||
sudo pbuilder build <working-dir>/<project>_<version>.dsc
|
||||
|
||||
@ -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).
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -159,6 +159,7 @@ $REL1 = $newbuild; $REL1 =~ s/-.*$//gi;
|
||||
if ($RPMSUBVERSION eq 'auto') { $RPMSUBVERSION = $newbuild; $RPMSUBVERSION =~ s/^.*-//gi; }
|
||||
$FILENAMETGZ2="$PROJECT-$MAJOR.$MINOR.$REL1";
|
||||
$FILENAMERPM=$FILENAMETGZ2."-".$RPMSUBVERSION.".".$ARCH.".rpm";
|
||||
$FILENAMERPMSRC=$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm";
|
||||
# For Deb
|
||||
$newbuild = $BUILD;
|
||||
$newbuild =~ s/(dev|alpha)/1/gi; # dev
|
||||
@ -368,20 +369,23 @@ if ($nboftargetok) {
|
||||
if (! $ret)
|
||||
{
|
||||
print "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n";
|
||||
if (! $BUILD || $BUILD eq '0-rc') # For a major version
|
||||
{
|
||||
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
|
||||
}
|
||||
else # For a maintenance release
|
||||
{
|
||||
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
|
||||
}
|
||||
print "\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog'\n";
|
||||
print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog. But you can regenerate it with commande:'\n";
|
||||
}
|
||||
if (! $BUILD || $BUILD eq '0-rc') # For a major version
|
||||
{
|
||||
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
|
||||
}
|
||||
else # For a maintenance release
|
||||
{
|
||||
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
|
||||
}
|
||||
print "\n";
|
||||
if (! $ret)
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n";
|
||||
@ -730,8 +734,8 @@ if ($nboftargetok) {
|
||||
|
||||
print "Remove target ".$FILENAMERPM."...\n";
|
||||
unlink("$NEWDESTI/".$FILENAMERPM);
|
||||
print "Remove target ".$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm...\n";
|
||||
unlink("$NEWDESTI/".$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm");
|
||||
print "Remove target ".$FILENAMERPMSRC."...\n";
|
||||
unlink("$NEWDESTI/".$FILENAMERPMSRC);
|
||||
|
||||
print "Create directory $BUILDROOT/$FILENAMETGZ2\n";
|
||||
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2`;
|
||||
@ -1137,10 +1141,11 @@ if ($nboftargetok) {
|
||||
|
||||
print "\nList of files to publish (BUILD=$BUILD)\n";
|
||||
%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/$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/${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/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM',
|
||||
"$DESTI/standard/$FILENAMETGZ.zip"=>'Dolibarr ERP-CRM'
|
||||
@ -1148,6 +1153,7 @@ if ($nboftargetok) {
|
||||
%filestoscanstableasso=(
|
||||
"$DESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"=>'signatures',
|
||||
"$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/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu',
|
||||
"$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows',
|
||||
@ -1209,9 +1215,10 @@ if ($nboftargetok) {
|
||||
my $filesize = -s $file;
|
||||
if (! $filesize) { next; }
|
||||
|
||||
print "\n";
|
||||
|
||||
if ($target eq 'SF' && $filestoscan{$file} ne 'none') {
|
||||
if ($target eq 'SF') {
|
||||
if ($filestoscan{$file} eq 'none') {
|
||||
next;
|
||||
}
|
||||
$destFolder="$NEWPUBLISH/$filestoscan{$file}/".$MAJOR.'.'.$MINOR.'.'.$BUILD;
|
||||
}
|
||||
elsif ($target eq 'ASSO' and $NEWPUBLISH =~ /stable/) {
|
||||
@ -1228,6 +1235,8 @@ if ($nboftargetok) {
|
||||
$filenameonly =~ s/.*\/[^\/]+\/([^\/])+$/$1/;
|
||||
$destFolder="$NEWPUBLISH/$dirnameonly";
|
||||
}
|
||||
|
||||
print "\n";
|
||||
print "Publish file ".$file." to ".$destFolder."\n";
|
||||
|
||||
# mkdir
|
||||
|
||||
@ -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"
|
||||
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
|
||||
OBS:Screenshots http://www.dolibarr.org/images/dolibarr_screenshot1.png
|
||||
|
||||
@ -34,7 +34,7 @@ AutoReqProv: no
|
||||
|
||||
|
||||
%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
|
||||
features for Enterprise Resource Planning (ERP) and Customer Relationship
|
||||
Management (CRM) but also for different other activities.
|
||||
|
||||
@ -75,7 +75,7 @@ AutoReqProv: no
|
||||
|
||||
|
||||
%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
|
||||
features for Enterprise Resource Planning (ERP) and Customer Relationship
|
||||
Management (CRM) but also for different other activities.
|
||||
|
||||
@ -33,7 +33,7 @@ AutoReqProv: no
|
||||
|
||||
|
||||
%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
|
||||
features for Enterprise Resource Planning (ERP) and Customer Relationship
|
||||
Management (CRM) but also for different other activities.
|
||||
|
||||
@ -36,7 +36,7 @@ AutoReqProv: no
|
||||
|
||||
|
||||
%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
|
||||
features for Enterprise Resource Planning (ERP) and Customer Relationship
|
||||
Management (CRM) but also for different other activities.
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
<exclude-pattern type="relative">htdocs/includes</exclude-pattern>
|
||||
<exclude-pattern type="relative">htdocs/conf.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">*/nltechno*</exclude-pattern>
|
||||
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
|
||||
|
||||
<!-- List of all tests -->
|
||||
|
||||
|
||||
@ -93,12 +93,12 @@ class SkeletonApi extends DolibarrApi
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @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
|
||||
*
|
||||
* @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;
|
||||
|
||||
$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 ($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
|
||||
|
||||
// Insert sale filter
|
||||
if ($search_sale > 0)
|
||||
{
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
|
||||
$nbtotalofrecords = 0;
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
if ($sqlfilters)
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
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);
|
||||
|
||||
@ -164,10 +164,14 @@ class Skeleton_Class extends CommonObject
|
||||
$sql .= ' t.field2';
|
||||
//...
|
||||
$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) {
|
||||
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\'';
|
||||
$sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
|
||||
} else {
|
||||
$sql .= ' WHERE t.rowid = ' . $id;
|
||||
$sql .= ' AND t.rowid = ' . $id;
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@ -236,16 +240,20 @@ class Skeleton_Class extends CommonObject
|
||||
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||
}
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")";
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||
}
|
||||
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= $this->db->order($sortfield,$sortorder);
|
||||
}
|
||||
if (!empty($limit)) {
|
||||
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$this->lines = array();
|
||||
|
||||
$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 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 string $morecss Add more css on link
|
||||
* @return string String with URL
|
||||
*/
|
||||
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 $menumanager;
|
||||
|
||||
|
||||
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
|
||||
|
||||
$result = '';
|
||||
$companylink = '';
|
||||
|
||||
$label = '<u>' . $langs->trans("MyModule") . '</u>';
|
||||
$label.= '<div width="100%">';
|
||||
$label.= '<br>';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
|
||||
$link = '<a href="'.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.= '>';
|
||||
$url = DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id;
|
||||
|
||||
$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>';
|
||||
|
||||
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.=' ';
|
||||
}
|
||||
$result.= $link . $this->ref . $linkend;
|
||||
$result.= $linkstart . $this->ref . $linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -491,7 +514,7 @@ class Skeleton_Class extends CommonObject
|
||||
* Return the 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
|
||||
*/
|
||||
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 == 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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@ $action = GETPOST('action','alpha');
|
||||
$backtopage = GETPOST('backtopage');
|
||||
$myparam = GETPOST('myparam','alpha');
|
||||
|
||||
$search_all=trim(GETPOST("sall"));
|
||||
$search_field1=GETPOST("search_field1");
|
||||
$search_field2=GETPOST("search_field2");
|
||||
$search_myfield=GETPOST('search_myfield');
|
||||
@ -141,22 +142,23 @@ $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');
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// 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_field1='';
|
||||
$search_field2='';
|
||||
$search_date_creation='';
|
||||
$search_date_update='';
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
$search_field1='';
|
||||
$search_field2='';
|
||||
$search_date_creation='';
|
||||
$search_date_update='';
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
|
||||
// Mass actions
|
||||
$objectclass='Skeleton';
|
||||
$objectlabel='Skeleton';
|
||||
$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='';
|
||||
$title = $langs->trans('MyModuleListTitle');
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
// Put here content of your page
|
||||
|
||||
@ -247,305 +248,308 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
|
||||
$sql.= $db->plimit($limit+1, $offset);
|
||||
|
||||
|
||||
dol_syslog($script_file, LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
if (! $resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$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;
|
||||
if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1);
|
||||
if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2);
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
// Add $param from extra fields
|
||||
foreach ($search_array_options as $key => $val)
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1);
|
||||
if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2);
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
// Add $param from extra fields
|
||||
foreach ($search_array_options as $key => $val)
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
|
||||
$arrayofmassactions = array(
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
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="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
|
||||
$moreforfilter.= '</div>';
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
if (! empty($moreforfilter))
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
// Fields title
|
||||
print '<tr class="liste_titre">';
|
||||
// LIST_OF_TD_TITLE_FIELDS
|
||||
//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
|
||||
//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hook fields
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Fields title search
|
||||
print '<tr class="liste_titre">';
|
||||
// LIST_OF_TD_TITLE_SEARCH
|
||||
//if (! empty($arrayfields['t.field1']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field1" value="'.$search_field1.'" size="10"></td>';
|
||||
//if (! empty($arrayfields['t.field2']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field2" value="'.$search_field2.'" size="10"></td>';
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
|
||||
$arrayofmassactions = array(
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
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="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escpae_htmltag($search_myfield).'">';
|
||||
$moreforfilter.= '</div>';
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
if (! empty($moreforfilter))
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
// Fields title
|
||||
print '<tr class="liste_titre">';
|
||||
// LIST_OF_TD_TITLE_FIELDS
|
||||
//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
|
||||
//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hook fields
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Fields title search
|
||||
print '<tr class="liste_titre">';
|
||||
// LIST_OF_TD_TITLE_SEARCH
|
||||
//if (! empty($arrayfields['t.field1']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field1" value="'.$search_field1.'" size="10"></td>';
|
||||
//if (! empty($arrayfields['t.field2']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field2" value="'.$search_field2.'" size="10"></td>';
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
$typeofextrafield=$extrafields->attribute_type[$key];
|
||||
print '<td class="liste_titre'.($align?' '.$align:'').'">';
|
||||
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
$searchclass='';
|
||||
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
|
||||
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
|
||||
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
$typeofextrafield=$extrafields->attribute_type[$key];
|
||||
print '<td class="liste_titre'.($align?' '.$align:'').'">';
|
||||
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
$searchclass='';
|
||||
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
|
||||
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
|
||||
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['t.datec']['checked']))
|
||||
{
|
||||
// Date creation
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
// Date modification
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
/*if (! empty($arrayfields['u.statut']['checked']))
|
||||
{
|
||||
// Status
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
|
||||
print '</td>';
|
||||
}*/
|
||||
// Action column
|
||||
print '<td class="liste_titre" align="right">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||
print $searchpitco;
|
||||
}
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['t.datec']['checked']))
|
||||
{
|
||||
// Date creation
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
}
|
||||
if (! empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
// Date modification
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
/*if (! empty($arrayfields['u.statut']['checked']))
|
||||
{
|
||||
// Status
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
|
||||
print '</td>';
|
||||
}*/
|
||||
// Action column
|
||||
print '<td class="liste_titre" align="right">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
$i=0;
|
||||
$var=true;
|
||||
$totalarray=array();
|
||||
while ($i < min($num, $limit))
|
||||
|
||||
$i=0;
|
||||
$var=true;
|
||||
$totalarray=array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
$var = !$var;
|
||||
|
||||
// Show here line of result
|
||||
print '<tr '.$bc[$var].'>';
|
||||
// LIST_OF_TD_FIELDS_LIST
|
||||
/*
|
||||
if (! empty($arrayfields['t.field1']['checked']))
|
||||
{
|
||||
$var = !$var;
|
||||
|
||||
// Show here line of result
|
||||
print '<tr '.$bc[$var].'>';
|
||||
// LIST_OF_TD_FIELDS_LIST
|
||||
/*
|
||||
if (! empty($arrayfields['t.field1']['checked']))
|
||||
{
|
||||
print '<td>'.$obj->field1.'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
if (! empty($arrayfields['t.field2']['checked']))
|
||||
{
|
||||
print '<td>'.$obj->field2.'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}*/
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
print '<td';
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
if ($align) print ' align="'.$align.'"';
|
||||
print '>';
|
||||
$tmpkey='options_'.$key;
|
||||
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Date creation
|
||||
if (! empty($arrayfields['t.datec']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Date modification
|
||||
if (! empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Status
|
||||
/*
|
||||
if (! empty($arrayfields['u.statut']['checked']))
|
||||
{
|
||||
$userstatic->statut=$obj->statut;
|
||||
print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
|
||||
}*/
|
||||
|
||||
// Action column
|
||||
print '<td class="nowrap" align="center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
print '</tr>';
|
||||
print '<td>'.$obj->field1.'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
$i++;
|
||||
if (! empty($arrayfields['t.field2']['checked']))
|
||||
{
|
||||
print '<td>'.$obj->field2.'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}*/
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
print '<td';
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
if ($align) print ' align="'.$align.'"';
|
||||
print '>';
|
||||
$tmpkey='options_'.$key;
|
||||
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Date creation
|
||||
if (! empty($arrayfields['t.datec']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Date modification
|
||||
if (! empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Status
|
||||
/*
|
||||
if (! empty($arrayfields['u.statut']['checked']))
|
||||
{
|
||||
$userstatic->statut=$obj->statut;
|
||||
print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
|
||||
}*/
|
||||
|
||||
// Action column
|
||||
print '<td class="nowrap" align="center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Show total line
|
||||
if (isset($totalarray['totalhtfield']))
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
$i=0;
|
||||
while ($i < $totalarray['nbfield'])
|
||||
{
|
||||
$i++;
|
||||
if ($i == 1)
|
||||
{
|
||||
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
}
|
||||
elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
|
||||
elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
|
||||
elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
|
||||
else print '<td></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Show total line
|
||||
if (isset($totalarray['totalhtfield']))
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
$i=0;
|
||||
while ($i < $totalarray['nbfield'])
|
||||
{
|
||||
$i++;
|
||||
if ($i == 1)
|
||||
{
|
||||
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
}
|
||||
elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
|
||||
elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
|
||||
elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
|
||||
else print '<td></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>'."\n";
|
||||
$db->free($resql);
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
|
||||
{
|
||||
// Show list of available documents
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
$urlsource.=str_replace('&','&',$param);
|
||||
|
||||
$filedir=$diroutputmassaction;
|
||||
$genallowed=$user->rights->facture->lire;
|
||||
$delallowed=$user->rights->facture->lire;
|
||||
|
||||
print '<br><a name="show_files"></a>';
|
||||
$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
|
||||
{
|
||||
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
|
||||
}
|
||||
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>'."\n";
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
|
||||
{
|
||||
// Show list of available documents
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
$urlsource.=str_replace('&','&',$param);
|
||||
|
||||
$filedir=$diroutputmassaction;
|
||||
$genallowed=$user->rights->facture->lire;
|
||||
$delallowed=$user->rights->facture->lire;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($db);
|
||||
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ fi
|
||||
|
||||
if [ "x$1" = "xlist" ]
|
||||
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`
|
||||
do
|
||||
dupes=$(
|
||||
|
||||
@ -16,6 +16,7 @@ fi
|
||||
# To detect
|
||||
if [ "x$1" = "xlist" ]
|
||||
then
|
||||
echo "Search duplicate line for lang en_US"
|
||||
for file in `find htdocs/langs/en_US -type f -name *.lang`
|
||||
do
|
||||
if [ `sort "$file" | grep -v '^$' | uniq -d | wc -l` -gt 0 ]
|
||||
@ -29,6 +30,7 @@ fi
|
||||
# To fix
|
||||
if [ "x$1" = "xfix" ]
|
||||
then
|
||||
echo "Fix duplicate line for lang en_US"
|
||||
for file in `find htdocs/langs/en_US -type f -name *.lang`
|
||||
do
|
||||
awk -i inplace ' !x[$0]++' "$file"
|
||||
@ -42,4 +42,4 @@ else
|
||||
fi
|
||||
|
||||
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 |
@ -22,19 +22,23 @@
|
||||
* \ingroup Advanced accountancy
|
||||
* \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 . '/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("admin");
|
||||
$langs->load("accountancy");
|
||||
$langs->load("salaries");
|
||||
|
||||
$mesg = '';
|
||||
$action = GETPOST('action');
|
||||
$cancel = GETPOST('cancel');
|
||||
$id = GETPOST('id', 'int');
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
$search_account = GETPOST("search_account");
|
||||
@ -44,10 +48,8 @@ $search_pcgtype = GETPOST("search_pcgtype");
|
||||
$search_pcgsubtype = GETPOST("search_pcgsubtype");
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->chartofaccount)
|
||||
accessforbidden();
|
||||
if ($user->societe_id > 0) accessforbidden();
|
||||
if (! $user->rights->accounting->chartofaccount) accessforbidden();
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
|
||||
@ -80,34 +82,53 @@ $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');
|
||||
|
||||
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 (empty($reshook))
|
||||
{
|
||||
$search_account = "";
|
||||
$search_label = "";
|
||||
$search_accountparent = "";
|
||||
$search_pcgtype = "";
|
||||
$search_pcgsubtype = "";
|
||||
}
|
||||
|
||||
if ($action == 'disable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$result = $accounting->account_desactivate($id);
|
||||
}
|
||||
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
} else if ($action == 'enable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$result = $accounting->account_activate($id);
|
||||
}
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
if (! empty($cancel)) $action = '';
|
||||
|
||||
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
|
||||
{
|
||||
$search_account = "";
|
||||
$search_label = "";
|
||||
$search_accountparent = "";
|
||||
$search_pcgtype = "";
|
||||
$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 ($accounting->fetch($id)) {
|
||||
$result = $accounting->account_desactivate($id);
|
||||
}
|
||||
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
} else if ($action == 'enable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$result = $accounting->account_activate($id);
|
||||
}
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -124,6 +145,8 @@ if ($action == 'delete') {
|
||||
|
||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, ";
|
||||
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||
@ -152,17 +175,18 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
$nbtotalofrecords = 0;
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
}
|
||||
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/admin/account.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
if ($resql) {
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$params='';
|
||||
if ($search_account != "") $params.= '&search_account='.urlencode($search_account);
|
||||
@ -172,13 +196,40 @@ if ($result) {
|
||||
if ($search_pcgsubtype != "") $params.= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
|
||||
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;
|
||||
|
||||
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="./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("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("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 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"> </td>';
|
||||
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")) . '">';
|
||||
print ' ';
|
||||
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")) . '">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
1429
htdocs/accountancy/admin/accountmodel.php
Normal file
1429
htdocs/accountancy/admin/accountmodel.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -22,9 +22,8 @@
|
||||
* \ingroup Advanced accountancy
|
||||
* \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 . '/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
|
||||
@ -38,6 +37,7 @@ $langs->load("accountancy");
|
||||
|
||||
$mesg = '';
|
||||
$action = GETPOST('action');
|
||||
$backtopage = GETPOST('backtopage');
|
||||
$id = GETPOST('id', 'int');
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
$cancel = GETPOST('cancel');
|
||||
@ -47,7 +47,18 @@ $cancel = GETPOST('cancel');
|
||||
|
||||
$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 (! $cancel) {
|
||||
@ -85,18 +96,30 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
|
||||
$object->active = 1;
|
||||
|
||||
$res = $object->create($user);
|
||||
|
||||
if ($res == - 3) {
|
||||
$error = 1;
|
||||
$action = "create";
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
if ($res == - 4) {
|
||||
elseif ($res == - 4) {
|
||||
$error = 2;
|
||||
$action = "create";
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
elseif ($res < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = "create";
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages("RecordCreatedSuccessfully",null,'mesgs');
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php',1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
header("Location: account.php");
|
||||
exit;
|
||||
} else if ($action == 'edit' && $user->rights->accounting->chartofaccount) {
|
||||
if (! $cancel) {
|
||||
$result = $object->fetch($id);
|
||||
@ -175,7 +198,7 @@ $formaccounting = new FormAccounting($db);
|
||||
|
||||
// Create mode
|
||||
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 '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
|
||||
@ -79,9 +79,11 @@ if ($action == 'delete') {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxheader('', $langs->trans('AccountAccounting'));
|
||||
|
||||
$formaccounting = new FormAccounting($db);
|
||||
@ -126,6 +128,7 @@ dol_fiche_end();
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
if ($action == 'display' || $action == 'delete') {
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
156
htdocs/accountancy/admin/defaultaccounts.php
Normal file
156
htdocs/accountancy/admin/defaultaccounts.php
Normal 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();
|
||||
@ -38,8 +38,10 @@ $langs->load("admin");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (! $user->admin)
|
||||
accessforbidden();
|
||||
if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount))
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
@ -135,31 +137,14 @@ $var = true;
|
||||
/*
|
||||
* Main Options
|
||||
*/
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('MainOptions') . '</td>';
|
||||
print '<td colspan="3">' . $langs->trans('Options') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$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);
|
||||
if ($num) {
|
||||
foreach ( $main_option as $key ) {
|
||||
@ -221,8 +206,29 @@ if ($num2) {
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1)
|
||||
{
|
||||
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 ) {
|
||||
$var = ! $var;
|
||||
|
||||
@ -45,7 +45,7 @@ $langs->load("compta");
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
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();
|
||||
|
||||
$error = 0;
|
||||
@ -80,7 +80,7 @@ $max = 100;
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans('FiscalYears');
|
||||
$title = $langs->trans('AccountingPeriods');
|
||||
$helpurl = "";
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
@ -106,8 +106,8 @@ if ($result) {
|
||||
|
||||
$i = 0;
|
||||
|
||||
$title = $langs->trans('FiscalYears');
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit, 1);
|
||||
$title = $langs->trans('AccountingPeriods');
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 1);
|
||||
|
||||
// Load attribute_label
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -41,35 +41,22 @@ $langs->load("accountancy");
|
||||
$langs->load("salaries");
|
||||
|
||||
// Security check
|
||||
if (! $user->admin)
|
||||
if (empty($user->admin))
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
// Parameters ACCOUNTING_* and others
|
||||
$list = array (
|
||||
'ACCOUNTING_LIMIT_LIST_VENTILATION',
|
||||
'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_GACCOUNT',
|
||||
'ACCOUNTING_LENGTH_AACCOUNT'
|
||||
'ACCOUNTING_LENGTH_GACCOUNT',
|
||||
'ACCOUNTING_LENGTH_AACCOUNT' ,
|
||||
'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
|
||||
);
|
||||
|
||||
$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
|
||||
@ -96,90 +83,76 @@ if ($action == 'update') {
|
||||
$error ++;
|
||||
}
|
||||
|
||||
$chartofaccounts = GETPOST('chartofaccounts', 'int');
|
||||
|
||||
if (! empty($chartofaccounts)) {
|
||||
|
||||
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
} else {
|
||||
$error ++;
|
||||
}
|
||||
|
||||
foreach ( $list as $constname ) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error ++;
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
if ($error) {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
|
||||
foreach ($list 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');
|
||||
}
|
||||
}
|
||||
|
||||
// TO DO Mutualize code for yes/no constants
|
||||
if ($action == 'setlistsorttodo') {
|
||||
$setlistsorttodo = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
$setlistsorttodo = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setlistsortdone') {
|
||||
$setlistsortdone = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
$setlistsortdone = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setmanagezero') {
|
||||
$setmanagezero = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
$setmanagezero = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setdisabledirectinput') {
|
||||
$setdisabledirectinput = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
$setdisabledirectinput = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
|
||||
if (! $res > 0)
|
||||
$error ++;
|
||||
if (! $error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -200,9 +173,10 @@ print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
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 '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
|
||||
@ -226,154 +200,110 @@ print '<td colspan="2">' . nl2br($langs->trans('OptionModeVirtualDesc')) . "</td
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
/*
|
||||
* Define Chart of accounts
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
$var = true;
|
||||
print '<br>';
|
||||
|
||||
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";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
|
||||
$sql .= " WHERE active = 1";
|
||||
// Others params
|
||||
|
||||
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 '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
|
||||
print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ( $list 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 '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
|
||||
print '</td></tr>';
|
||||
if (! empty($user->admin))
|
||||
{
|
||||
// TO DO Mutualize code for yes/no constants
|
||||
$var = ! $var;
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
|
||||
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$var = ! $var;
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
|
||||
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$var = ! $var;
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
|
||||
if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$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>';
|
||||
}
|
||||
|
||||
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>';
|
||||
|
||||
// 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>';
|
||||
}
|
||||
|
||||
// TO DO Mutualize code for yes/no constants
|
||||
$var = ! $var;
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
|
||||
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 img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&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("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
|
||||
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 img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
$var = ! $var;
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print '<td width="80%">' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</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)) {
|
||||
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&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=setdisabledirectinput&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
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>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -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 . '/compta/bank/class/account.class.php';
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("admin");
|
||||
$langs->load("accountancy");
|
||||
$langs->load("salaries");
|
||||
|
||||
// Security check
|
||||
if (! $user->admin)
|
||||
accessforbidden();
|
||||
if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount))
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
|
||||
@ -40,17 +40,17 @@ $langs->load("companies");
|
||||
$langs->load("compta");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
$langs->load("products");
|
||||
|
||||
// Security check
|
||||
if (! $user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
// search & action GETPOST
|
||||
$action = GETPOST('action');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$codeventil_buy = GETPOST('codeventil_buy', 'array');
|
||||
$codeventil_sell = GETPOST('codeventil_sell', 'array');
|
||||
$chk_prod = GETPOST('chk_prod', 'array');
|
||||
@ -62,32 +62,51 @@ $changeaccount_sell = GETPOST('changeaccount_sell', 'array');
|
||||
$search_ref = GETPOST('search_ref', 'alpha');
|
||||
$search_label = GETPOST('search_label', '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');
|
||||
$btn_changeaccount = GETPOST('changeaccount');
|
||||
$btn_changetype = GETPOST('changetype');
|
||||
|
||||
$sortfield = GETPOST('sortfield', 'alpha');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$page = GETPOST('page', 'int');
|
||||
if ($page < 0)
|
||||
$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 == -1) { $page = 0; }
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
// bug in page limit if ACCOUNTING_LIMIT_LIST_VENTILATION < $conf->liste_limit there is no pagination displayed !
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) && $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION >= $conf->liste_limit) {
|
||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
||||
} else {
|
||||
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
if (! $sortfield) $sortfield="p.ref";
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
|
||||
if (! $sortfield) {
|
||||
$sortfield = "p.ref";
|
||||
if (empty($action)) $action='list';
|
||||
|
||||
$arrayfields=array();
|
||||
|
||||
|
||||
/*
|
||||
* 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';
|
||||
}
|
||||
if (! $sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
|
||||
// Sales or Purchase mode ?
|
||||
if ($action == 'update') {
|
||||
if (! empty($btn_changetype)) {
|
||||
@ -111,14 +130,14 @@ if ($action == 'update') {
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
||||
$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 ) {
|
||||
|
||||
$accounting_account_id = GETPOST('codeventil_' . $productid);
|
||||
@ -140,21 +159,31 @@ if ($action == 'update') {
|
||||
|
||||
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
|
||||
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 {
|
||||
$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 ++;
|
||||
}
|
||||
} 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);
|
||||
|
||||
// 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_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
llxHeader('', $langs->trans("ProductsBinding"));
|
||||
|
||||
$pcgverid = $conf->global->CHARTOFACCOUNTS;
|
||||
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
|
||||
if (empty($pcgvercode)) $pcgvercode=$pcgverid;
|
||||
|
||||
$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";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "product as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
$sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$search_ref = '';
|
||||
$search_label = '';
|
||||
$search_desc = '';
|
||||
$sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('', $langs->trans("InitAccountancy"));
|
||||
|
||||
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 .= " WHERE (";
|
||||
|
||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') {
|
||||
$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
|
||||
(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.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_buy",$search_current_account);
|
||||
}
|
||||
} else {
|
||||
$sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL ";
|
||||
$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN
|
||||
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
||||
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
|
||||
if (strlen(trim($search_ref))) {
|
||||
$sql .= " AND (p.ref like '" . $search_ref . "%')";
|
||||
$sql .= natural_search("p.ref",$search_ref);
|
||||
}
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= " AND (p.label like '" . $search_label . "%')";
|
||||
$sql .= natural_search("p.label",$search_label);
|
||||
}
|
||||
if (strlen(trim($search_desc))) {
|
||||
$sql .= " AND (p.description like '%" . $search_desc . "%')";
|
||||
$sql .= natural_search("p.description",$search_desc);
|
||||
}
|
||||
$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);
|
||||
|
||||
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$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 $langs->trans("InitAccountancyDesc") . '<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">';
|
||||
|
||||
// Select mode
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
|
||||
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 '<td colspan="2">' . nl2br($langs->trans('OptionModeProductSellDesc'));
|
||||
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>'.$langs->trans('OptionModeProductSellDesc');
|
||||
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 '<td colspan="2">' . nl2br($langs->trans('OptionModeProductBuyDesc')) . "</td></tr>\n";
|
||||
|
||||
print '<tr ' . $bc[true] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
|
||||
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
|
||||
print "</table>\n";
|
||||
|
||||
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;
|
||||
}
|
||||
// Filter on categories
|
||||
$moreforfilter='';
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
$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_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("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
|
||||
/*
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
print_liste_field_titre($langs->trans("Accountancy_code_buy"));
|
||||
} else {
|
||||
print_liste_field_titre($langs->trans("Accountancy_code_sell"));
|
||||
}
|
||||
*/
|
||||
print_liste_field_titre($langs->trans("AccountAccounting"));
|
||||
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"');
|
||||
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') {
|
||||
$fieldtosortaccount="p.accountancy_code_buy";
|
||||
}
|
||||
else $fieldtosortaccount="p.accountancy_code_sell";
|
||||
print_liste_field_titre($langs->trans("CurrentDedicatedAccountingAccount"), $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("AssignDedicatedAccountingAccount"));
|
||||
print_liste_field_titre('', '', '', '', '', 'align="center"');
|
||||
print '</tr>';
|
||||
|
||||
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="20" name="search_label" value="' . $search_label . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="30" name="search_desc" value="' . $search_desc . '"></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="14" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
|
||||
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
|
||||
// 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"> </td>';
|
||||
print '<td align="center" 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")) . '">';
|
||||
print ' ';
|
||||
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, 'checkforselect', 1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$var = true;
|
||||
$product_static = new Product($db);
|
||||
|
||||
while ( $i < min($num_lines, 250) ) {
|
||||
$var = true;
|
||||
$i=0;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$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) {
|
||||
$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_prodbuy = $obj->accountancy_code_buy;
|
||||
|
||||
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_id = $aarowid_prodbuy;
|
||||
@ -326,59 +381,101 @@ if ($result) {
|
||||
$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>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print '- ';
|
||||
print $product_static->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td align="left">' . dol_trunc($obj->label, 24) . '</td>';
|
||||
// TODO ADJUST DESCRIPTION SIZE
|
||||
// print '<td align="left">' . $obj->description . '</td>';
|
||||
// TODO: we shoul set a user defined value to adjust user square / wide screen size
|
||||
$trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64;
|
||||
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
|
||||
|
||||
// Accounting account buy
|
||||
print '<td align="left">'.$obj->label.'</td>';
|
||||
|
||||
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
|
||||
{
|
||||
// TODO ADJUST DESCRIPTION SIZE
|
||||
// print '<td align="left">' . $obj->description . '</td>';
|
||||
// TODO: we shoul set a user defined value to adjust user square / wide screen size
|
||||
$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 align="center">'.$product_static->getLibStatut(3, 0).'</td>';
|
||||
|
||||
print '<td align="center">'.$product_static->getLibStatut(3, 1).'</td>';
|
||||
|
||||
// Current accounting account
|
||||
print '<td align="left">';
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
// print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
||||
// TODO: replace by select
|
||||
// print '<td align="left">' . $compta_prodbuy . '</td>';
|
||||
// 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 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">';
|
||||
print $form->select_account($compta_prodbuy_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_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>';
|
||||
} else {
|
||||
// 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 $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>';
|
||||
}
|
||||
|
||||
// Checkbox select
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="chk_prod[]" value="' . $obj->rowid . '"/></td>';
|
||||
|
||||
print '<td align="right">';
|
||||
print '<input type="checkbox" class="checkforselect" name="chk_prod[]" value="' . $obj->rowid . '"/></td>';
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
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>';
|
||||
|
||||
$db->free($result);
|
||||
|
||||
@ -153,7 +153,7 @@ else {
|
||||
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 '<div class="tabsAction">' . "\n";
|
||||
@ -181,12 +181,12 @@ else {
|
||||
|
||||
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
|
||||
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("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("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 class="liste_titre">';
|
||||
@ -241,7 +241,7 @@ else {
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Affiche le compte comptable en début de ligne
|
||||
// Affiche le compte comptable en d<EFBFBD>but de ligne
|
||||
print "<tr>";
|
||||
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'. $root_account_description .'</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -166,28 +166,39 @@ else if ($action == "confirm_delete") {
|
||||
}
|
||||
|
||||
else if ($action == "confirm_create") {
|
||||
$book = new BookKeeping($db);
|
||||
$error = 0;
|
||||
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$book->label_compte = '';
|
||||
$book->debit = 0;
|
||||
$book->credit = 0;
|
||||
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = GETPOST('next_num_mvt');
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = 0;
|
||||
$book->fk_docdet = 0;
|
||||
|
||||
$book->montant = 0;
|
||||
|
||||
$result = $book->createStd($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($book->error, $book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessages($langs->trans('Saved'), null, 'mesgs');
|
||||
$action = '';
|
||||
$piece_num = $book->piece_num;
|
||||
if (! GETPOST('next_num_mvt'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$book->label_compte = '';
|
||||
$book->debit = 0;
|
||||
$book->credit = 0;
|
||||
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = GETPOST('next_num_mvt');
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = 0;
|
||||
$book->fk_docdet = 0;
|
||||
|
||||
$book->montant = 0;
|
||||
|
||||
$result = $book->createStd($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($book->error, $book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessages($langs->trans('Saved'), null, 'mesgs');
|
||||
$action = '';
|
||||
$piece_num = $book->piece_num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,6 +243,10 @@ if ($action == 'create') {
|
||||
|
||||
$book = new BookKeeping($db);
|
||||
$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 '<input type="hidden" name="action" value="confirm_create">' . "\n";
|
||||
@ -241,19 +256,19 @@ if ($action == 'create') {
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
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 '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td class="fieldrequired">' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td>';
|
||||
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
|
||||
print '</td>';
|
||||
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 '</tr>';
|
||||
|
||||
@ -286,9 +301,11 @@ if ($action == 'create') {
|
||||
|
||||
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 '<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 '</tr>';
|
||||
print '<tr class="impair">';
|
||||
@ -308,14 +325,17 @@ if ($action == 'create') {
|
||||
print '<td>' . $book->doc_type . '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '<br />';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<br>';
|
||||
|
||||
$result = $book->fetch_all_per_mvt($piece_num);
|
||||
if ($result < 0) {
|
||||
setEventMessages($book->error, $book->errors, 'errors');
|
||||
} 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 '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
|
||||
@ -390,10 +410,9 @@ if ($action == 'create') {
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
if ($total_debit != $total_credit) {
|
||||
setEventMessages(null, array (
|
||||
$langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)
|
||||
), 'errors');
|
||||
if ($total_debit != $total_credit)
|
||||
{
|
||||
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings');
|
||||
}
|
||||
|
||||
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></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 '</table>';
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||
* 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
|
||||
* 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_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;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if ($sortorder == "") $sortorder = "ASC";
|
||||
if ($sortfield == "") $sortfield = "t.rowid";
|
||||
|
||||
|
||||
$object = new BookKeeping($db);
|
||||
|
||||
@ -88,86 +98,22 @@ $formother = new FormOther($db);
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
if ($action != 'export_csv' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction'])) {
|
||||
$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 (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 = '';
|
||||
$filter = array ();
|
||||
if (! empty($search_date_start)) {
|
||||
$filter['t.doc_date>='] = $search_date_start;
|
||||
$options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int');
|
||||
}
|
||||
if (! empty($search_date_end)) {
|
||||
$filter['t.doc_date<='] = $search_date_end;
|
||||
$options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int');
|
||||
}
|
||||
if (! empty($search_doc_type)) {
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$options .= '&search_doc_type=' . $search_doc_type;
|
||||
}
|
||||
if (! empty($search_doc_date)) {
|
||||
$filter['t.doc_date'] = $search_doc_date;
|
||||
$options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int');
|
||||
}
|
||||
if (! empty($search_doc_ref)) {
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$options .= '&search_doc_ref=' . $search_doc_ref;
|
||||
}
|
||||
if (! empty($search_accountancy_code)) {
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$options .= '&search_accountancy_code=' . $search_accountancy_code;
|
||||
}
|
||||
if (! empty($search_accountancy_code_start)) {
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$options .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
|
||||
}
|
||||
if (! empty($search_accountancy_code_end)) {
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$options .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code)) {
|
||||
$filter['t.code_tiers'] = $search_accountancy_aux_code;
|
||||
$options .= '&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 .= '&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 .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
|
||||
}
|
||||
if (! empty($search_mvt_label)) {
|
||||
$filter['t.label_compte'] = $search_mvt_label;
|
||||
$options .= '&search_mvt_label=' . $search_mvt_label;
|
||||
}
|
||||
if (! empty($search_direction)) {
|
||||
$filter['t.sens'] = $search_direction;
|
||||
$options .= '&search_direction=' . $search_direction;
|
||||
}
|
||||
if (! empty($search_ledger_code)) {
|
||||
$filter['t.code_journal'] = $search_ledger_code;
|
||||
$options .= '&search_ledger_code=' . $search_ledger_code;
|
||||
}
|
||||
if (! empty($search_mvt_num)) {
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$options .= '&search_mvt_num=' . $search_mvt_num;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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_doc_type = '';
|
||||
@ -210,15 +156,25 @@ if ($action == 'delbookkeepingyearconfirm') {
|
||||
$deljournal=0;
|
||||
}
|
||||
|
||||
|
||||
if (! empty($delyear) || ! empty($deljournal)) {
|
||||
if (! empty($delyear) || ! empty($deljournal))
|
||||
{
|
||||
$result = $object->deleteByYearAndJournal($delyear,$deljournal);
|
||||
if ($result < 0) {
|
||||
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");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($action == 'delmouvconfirm') {
|
||||
|
||||
@ -227,37 +183,112 @@ if ($action == 'delmouvconfirm') {
|
||||
if (! empty($mvt_num)) {
|
||||
$result = $object->deleteMvtNum($mvt_num);
|
||||
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");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($action == 'export_csv') {
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
|
||||
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines);
|
||||
if (!empty($accountancyexport->errors)) {
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
|
||||
$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') {
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
|
||||
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines);
|
||||
if (!empty($accountancyexport->errors)) {
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$title_page = $langs->trans("Bookkeeping");
|
||||
if ($search_date_start || $search_date_end) $title_page .= ' ' . dol_print_date($search_date_start, 'day') . ' - ' . dol_print_date($search_date_end, 'day');
|
||||
llxHeader('', $title_page);
|
||||
|
||||
// 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);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -306,39 +338,53 @@ if ($action == 'delbookkeepingyear') {
|
||||
'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_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="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"><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 ' <a href="./listbyaccount.php">' . $langs->trans("GroupByAccountAccounting") . '</a><br><br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
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("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $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("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $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("Labelcompte"), $_SERVER['PHP_SELF'], "bk_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("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("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $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", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
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 class="liste_titre">';
|
||||
print '<td class="liste_titre center">';
|
||||
print $langs->trans('From') . ': ';
|
||||
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
|
||||
print '<br>';
|
||||
@ -360,18 +406,16 @@ print '<br>';
|
||||
print $langs->trans('to');
|
||||
print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
|
||||
print '</td>';
|
||||
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </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);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$var = True;
|
||||
@ -379,13 +423,13 @@ $var = True;
|
||||
$total_debit = 0;
|
||||
$total_credit = 0;
|
||||
|
||||
foreach ( $object->lines as $line ) {
|
||||
foreach ($object->lines as $line ) {
|
||||
$var = ! $var;
|
||||
|
||||
$total_debit += $line->debit;
|
||||
$total_credit += $line->credit;
|
||||
|
||||
print '<tr'. $bc[$var].'>';
|
||||
print '<tr '. $bc[$var].'>';
|
||||
|
||||
print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->piece_num . '</a></td>';
|
||||
print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
|
||||
@ -398,7 +442,7 @@ foreach ( $object->lines as $line ) {
|
||||
print '<td align="center">' . $line->code_journal . '</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a> ';
|
||||
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 "</tr>\n";
|
||||
}
|
||||
@ -411,13 +455,13 @@ print '</td>';
|
||||
print '<td align="right">';
|
||||
print price($total_credit);
|
||||
print '</td>';
|
||||
print '<td colspan="2"></td>';
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</form>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
|
||||
$db->close();
|
||||
$db->close();
|
||||
|
||||
@ -60,11 +60,23 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
|
||||
$search_direction = GETPOST('search_direction', 'alpha');
|
||||
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
|
||||
|
||||
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
$offset = $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');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$page = GETPOST('page','int');
|
||||
if ($page < 0) { $page = 0; }
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $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);
|
||||
|
||||
@ -73,18 +85,6 @@ $formother = new FormOther($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 = '';
|
||||
$filter = array ();
|
||||
|
||||
@ -202,7 +202,7 @@ if ($action == 'delbookkeepingyear') {
|
||||
'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;
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ if ($action == 'delbookkeepingyear') {
|
||||
|
||||
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
|
||||
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>';
|
||||
|
||||
print ' <a href="./list.php">' . $langs->trans("ViewFlatList") . '</a><br><br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
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 '<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("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("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" 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('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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 class="liste_titre">';
|
||||
print '<td>' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . '</td>';
|
||||
print '<td></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $langs->trans('From') . ': ';
|
||||
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
|
||||
print '<br>';
|
||||
@ -263,7 +267,7 @@ $total_debit = 0;
|
||||
$total_credit = 0;
|
||||
$sous_total_debit = 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 ) {
|
||||
$var = ! $var;
|
||||
@ -271,38 +275,47 @@ foreach ( $object->lines as $line ) {
|
||||
$total_debit += $line->debit;
|
||||
$total_credit += $line->credit;
|
||||
|
||||
// Permet d'afficher le compte comptable
|
||||
if (length_accountg($line->numero_compte) != $displayed_account_number) {
|
||||
|
||||
// Affiche un Sous-Total par compte comptable
|
||||
if ($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 "<td> </td>\n";
|
||||
print '</tr>';
|
||||
$accountg = length_accountg($line->numero_compte);
|
||||
//if (empty($accountg)) $accountg = '-';
|
||||
|
||||
// Is it a break ?
|
||||
if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) {
|
||||
|
||||
// Affiche un Sous-Total par compte comptable
|
||||
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 "<td> </td>\n";
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Show the break account
|
||||
$colspan = 9;
|
||||
print "<tr>";
|
||||
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>';
|
||||
|
||||
$displayed_account_number = $accountg;
|
||||
//if (empty($displayed_account_number)) $displayed_account_number='-';
|
||||
$sous_total_debit = 0;
|
||||
$sous_total_credit = 0;
|
||||
}
|
||||
|
||||
// Affiche le compte comptable en début de ligne
|
||||
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 '</tr>';
|
||||
|
||||
$displayed_account_number = length_accountg($line->numero_compte);
|
||||
$sous_total_debit = 0;
|
||||
$sous_total_credit = 0;
|
||||
}
|
||||
|
||||
print '<tr'. $bc[$var].'>';
|
||||
print '<tr '. $bc[$var].'>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.$line->piece_num.'</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>';
|
||||
|
||||
// Affiche un lien vers la facture client/fournisseur
|
||||
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
|
||||
if ($line->doc_type == 'supplier_invoice')
|
||||
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a></td>' : '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a><br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
|
||||
elseif ($line->doc_type == 'customer_invoice')
|
||||
|
||||
// Affiche un lien vers la facture client/fournisseur
|
||||
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
|
||||
if ($line->doc_type == 'supplier_invoice')
|
||||
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a></td>' : '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a><br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
|
||||
elseif ($line->doc_type == 'customer_invoice')
|
||||
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td><a href="/compta/facture/list.php?search_ref=' . $doc_ref . '">' . $line->label_compte . '</a></td>' : '<td><a href="/compta/facture/list.php?search_ref=' . $doc_ref . '">' . $line->label_compte . '</a><br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
|
||||
else
|
||||
else
|
||||
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td>' . $line->label_compte . '</td>' : '<td>' . $line->label_compte . '<br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
|
||||
|
||||
|
||||
|
||||
@ -171,7 +171,7 @@ if ($result < 0) {
|
||||
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 '<div class="liste_titre">';
|
||||
@ -197,7 +197,7 @@ print "<table class=\"noborder\" width=\"100%\">";
|
||||
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("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("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);
|
||||
@ -269,10 +269,10 @@ $var = True;
|
||||
foreach ( $object->lines as $line ) {
|
||||
$var = ! $var;
|
||||
|
||||
print '<tr'. $bc[$var].'>';
|
||||
print '<tr '. $bc[$var].'>';
|
||||
print '<td>' . $line->piece_num . '</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>' . length_accountg($line->numero_compte) . '</td>';
|
||||
print '<td>' . length_accounta($line->code_tiers) . '</td>';
|
||||
@ -289,4 +289,4 @@ print "</table>";
|
||||
print '</form>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
$db->close();
|
||||
|
||||
@ -230,7 +230,7 @@ class AccountancyCategory
|
||||
/**
|
||||
* Function to know all category from accounting account
|
||||
*
|
||||
* @return array Result in table
|
||||
* @return array Result in table
|
||||
*/
|
||||
public function getCatsCpts() {
|
||||
global $mysoc;
|
||||
@ -283,7 +283,7 @@ class AccountancyCategory
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
|
||||
|
||||
return - 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ class AccountancyCategory
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
|
||||
dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR);
|
||||
|
||||
return - 1;
|
||||
}
|
||||
|
||||
@ -172,16 +172,15 @@ class AccountingAccount extends CommonObject
|
||||
|
||||
$sql .= " '" . $this->db->idate($now) . "'";
|
||||
$sql .= ", " . $conf->entity;
|
||||
$sql .= ", " . (! isset($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 .= ", " . (! isset($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'");
|
||||
$sql .= ", " . (! isset($this->account_number) ? 'NULL' : "'" . $this->account_number . "'");
|
||||
$sql .= ", " . (! isset($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'");
|
||||
$sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
|
||||
$sql .= ", " . (! isset($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'");
|
||||
$sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
|
||||
$sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
|
||||
$sql .= ", " . (empty($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'");
|
||||
$sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->account_number . "'");
|
||||
$sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'");
|
||||
$sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
|
||||
$sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'");
|
||||
$sql .= ", " . $user->id;
|
||||
$sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'");
|
||||
|
||||
$sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active));
|
||||
$sql .= ")";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -105,18 +105,18 @@ class BookKeeping extends CommonObject
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
*
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
public function create(User $user, $notrigger = false) {
|
||||
global $conf, $langs;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->doc_type)) {
|
||||
$this->doc_type = trim($this->doc_type);
|
||||
}
|
||||
@ -162,6 +162,17 @@ class BookKeeping extends CommonObject
|
||||
if (isset($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();
|
||||
|
||||
@ -173,8 +184,10 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
||||
$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);
|
||||
|
||||
if ($resql) {
|
||||
@ -187,6 +200,9 @@ class BookKeeping extends CommonObject
|
||||
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
|
||||
$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);
|
||||
$resqlnum = $this->db->query($sqlnum);
|
||||
@ -198,7 +214,10 @@ class BookKeeping extends CommonObject
|
||||
if (empty($this->piece_num)) {
|
||||
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
|
||||
$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);
|
||||
$resqlnum = $this->db->query($sqlnum);
|
||||
if ($resqlnum) {
|
||||
@ -235,7 +254,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= ", piece_num";
|
||||
$sql .= ', entity';
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'" . $this->doc_date . "'";
|
||||
$sql .= "'" . $this->db->idate($this->doc_date) . "'";
|
||||
$sql .= ",'" . $this->doc_type . "'";
|
||||
$sql .= ",'" . $this->doc_ref . "'";
|
||||
$sql .= "," . $this->fk_doc;
|
||||
@ -248,7 +267,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= "," . $this->montant;
|
||||
$sql .= ",'" . $this->sens . "'";
|
||||
$sql .= ",'" . $this->fk_user_author . "'";
|
||||
$sql .= ",'" . $this->date_create . "'";
|
||||
$sql .= ",'" . $this->db->idate($this->date_create). "'";
|
||||
$sql .= ",'" . $this->code_journal . "'";
|
||||
$sql .= "," . $this->piece_num;
|
||||
$sql .= ", " . (! isset($this->entity) ? '1' : $this->entity);
|
||||
@ -274,11 +293,11 @@ class BookKeeping extends CommonObject
|
||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
$result = - 3;
|
||||
$error ++;
|
||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||
} else { // Already exists
|
||||
$result = -3;
|
||||
$error++;
|
||||
$this->errors[] = 'Error Transaction for ('.$this->doc_type.', '.$this->doc_ref.', '.$this->fk_docdet.') were already recorded';
|
||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_WARNING);
|
||||
}
|
||||
} else {
|
||||
$result = - 5;
|
||||
@ -315,10 +334,9 @@ class BookKeeping extends CommonObject
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
*
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
public function createStd(User $user, $notrigger = false) {
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
@ -372,13 +390,14 @@ class BookKeeping extends CommonObject
|
||||
if (isset($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
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Insert request
|
||||
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
|
||||
|
||||
$sql .= 'doc_date,';
|
||||
$sql .= 'doc_type,';
|
||||
$sql .= 'doc_ref,';
|
||||
@ -403,16 +422,16 @@ class BookKeeping extends CommonObject
|
||||
$sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ',';
|
||||
$sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ',';
|
||||
$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->debit) ? 'NULL' : "'" . $this->debit . "'") . ',';
|
||||
$sql .= ' ' . (! isset($this->credit) ? 'NULL' : "'" . $this->credit . "'") . ',';
|
||||
$sql .= ' ' . (! isset($this->montant) ? 'NULL' : "'" . $this->montant . "'") . ',';
|
||||
$sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ',';
|
||||
$sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ',';
|
||||
$sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ',';
|
||||
$sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ',';
|
||||
$sql .= ' ' . $user->id . ',';
|
||||
$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 .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num).',';
|
||||
$sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
|
||||
$sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).',';
|
||||
$sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity);
|
||||
$sql .= ')';
|
||||
|
||||
@ -460,11 +479,12 @@ class BookKeeping extends CommonObject
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = null) {
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = 'SELECT';
|
||||
$sql .= ' t.rowid,';
|
||||
|
||||
$sql .= " t.doc_date,";
|
||||
$sql .= " t.doc_type,";
|
||||
$sql .= " t.doc_ref,";
|
||||
@ -481,7 +501,6 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " t.import_key,";
|
||||
$sql .= " t.code_journal,";
|
||||
$sql .= " t.piece_num";
|
||||
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
$sql .= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
@ -546,11 +565,12 @@ class BookKeeping extends CommonObject
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = 'SELECT';
|
||||
$sql .= ' t.rowid,';
|
||||
|
||||
$sql .= " t.doc_date,";
|
||||
$sql .= " t.doc_type,";
|
||||
$sql .= " t.doc_ref,";
|
||||
@ -567,9 +587,6 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " t.import_key,";
|
||||
$sql .= " t.code_journal,";
|
||||
$sql .= " t.piece_num";
|
||||
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
|
||||
// Manage filter
|
||||
$sqlwhere = array ();
|
||||
if (count($filter) > 0) {
|
||||
@ -591,7 +608,6 @@ class BookKeeping extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
@ -662,11 +678,12 @@ class BookKeeping extends CommonObject
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = 'SELECT';
|
||||
$sql .= ' t.rowid,';
|
||||
|
||||
$sql .= " t.doc_date,";
|
||||
$sql .= " t.doc_type,";
|
||||
$sql .= " t.doc_ref,";
|
||||
@ -683,9 +700,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " t.import_key,";
|
||||
$sql .= " t.code_journal,";
|
||||
$sql .= " t.piece_num";
|
||||
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
|
||||
// Manage filter
|
||||
$sqlwhere = array ();
|
||||
if (count($filter) > 0) {
|
||||
@ -705,7 +720,6 @@ class BookKeeping extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
@ -774,16 +788,15 @@ class BookKeeping extends CommonObject
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = 'SELECT';
|
||||
$sql .= " t.numero_compte,";
|
||||
$sql .= " SUM(t.debit) as debit,";
|
||||
$sql .= " SUM(t.credit) as credit";
|
||||
|
||||
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
|
||||
// Manage filter
|
||||
$sqlwhere = array ();
|
||||
if (count($filter) > 0) {
|
||||
@ -803,11 +816,14 @@ class BookKeeping extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||
}
|
||||
|
||||
$sql .= ' GROUP BY t.numero_compte';
|
||||
|
||||
if (! empty($sortfield)) {
|
||||
@ -907,7 +923,6 @@ class BookKeeping extends CommonObject
|
||||
|
||||
// Update request
|
||||
$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_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") . ',';
|
||||
@ -924,7 +939,6 @@ class BookKeeping extends CommonObject
|
||||
$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 .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null");
|
||||
|
||||
$sql .= ' WHERE rowid=' . $this->id;
|
||||
|
||||
$this->db->begin();
|
||||
@ -1012,7 +1026,7 @@ class BookKeeping extends CommonObject
|
||||
/**
|
||||
* Delete bookkepping by importkey
|
||||
*
|
||||
* @param string $importkey Import key
|
||||
* @param string $importkey Import key
|
||||
* @return int Result
|
||||
*/
|
||||
function deleteByImportkey($importkey) {
|
||||
@ -1027,10 +1041,7 @@ class BookKeeping extends CommonObject
|
||||
|
||||
if (! $resql) {
|
||||
$this->errors[] = "Error " . $this->db->lasterror();
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
dol_syslog(get_class($this)."::delete Error " . $this->db->lasterror(), LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return - 1;
|
||||
}
|
||||
@ -1042,17 +1053,29 @@ class BookKeeping extends CommonObject
|
||||
/**
|
||||
* Delete bookkepping by year
|
||||
*
|
||||
* @param string $delyear year to delete
|
||||
* @return int Result
|
||||
* @param string $delyear Year to delete
|
||||
* @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();
|
||||
|
||||
// first check if line not yet in bookkeeping
|
||||
$sql = "DELETE";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||
$sql .= " WHERE YEAR(doc_date) = " . $delyear;
|
||||
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||
$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);
|
||||
|
||||
if (! $resql) {
|
||||
@ -1062,7 +1085,7 @@ class BookKeeping extends CommonObject
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return - 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
@ -1076,12 +1099,17 @@ class BookKeeping extends CommonObject
|
||||
* @return int Result
|
||||
*/
|
||||
function deleteMvtNum($piecenum) {
|
||||
global $conf;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// first check if line not yet in bookkeeping
|
||||
$sql = "DELETE";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||
$sql .= " WHERE piece_num = " . $piecenum;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -1179,9 +1207,14 @@ class BookKeeping extends CommonObject
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchPerMvt($piecenum) {
|
||||
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||
$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);
|
||||
$result = $this->db->query($sql);
|
||||
@ -1205,18 +1238,25 @@ class BookKeeping extends CommonObject
|
||||
/**
|
||||
* 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;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
return $obj->max;
|
||||
if ($obj) $result = $obj->max;
|
||||
if (empty($result)) $result = 1;
|
||||
return $result;
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
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
|
||||
*/
|
||||
function fetch_all_per_mvt($piecenum) {
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||
$sql .= " numero_compte, label_compte, debit, credit,";
|
||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||
$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);
|
||||
$result = $this->db->query($sql);
|
||||
@ -1281,11 +1326,16 @@ class BookKeeping extends CommonObject
|
||||
* @return int Result
|
||||
*/
|
||||
function export_bookkeping($model = 'ebp') {
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||
$sql .= " numero_compte, label_compte, debit, credit,";
|
||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||
$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);
|
||||
|
||||
@ -1329,75 +1379,76 @@ class BookKeeping extends CommonObject
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return list of accounts with label by chart of accounts
|
||||
*
|
||||
* @param string $selectid Preselected chart of accounts
|
||||
* @param string $htmlname Name of field in html form
|
||||
* @param int $showempty Add an empty field
|
||||
* @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_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
|
||||
*
|
||||
* @return string String with HTML select
|
||||
*/
|
||||
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
|
||||
global $conf;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
|
||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
$sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte";
|
||||
$sql .= " AND aa.active = 1";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $pcgver;
|
||||
$sql .= " ORDER BY account_number ASC";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if (!$resql) {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$out = ajax_combobox($htmlname, $event);
|
||||
|
||||
$options = array();
|
||||
$selected = null;
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
||||
$label = dol_trunc($label, $trunclength);
|
||||
|
||||
$select_value_in = $obj->rowid;
|
||||
$select_value_out = $obj->rowid;
|
||||
|
||||
if ($select_in == 1) {
|
||||
$select_value_in = $obj->account_number;
|
||||
}
|
||||
if ($select_out == 1) {
|
||||
$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
|
||||
// Because same account_number can be share between different accounting_system and do have the same meaning
|
||||
if (($selectid != '') && $selectid == $select_value_in) {
|
||||
$selected = $select_value_out;
|
||||
}
|
||||
|
||||
$options[$select_value_out] = $label;
|
||||
}
|
||||
|
||||
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
|
||||
$this->db->free($resql);
|
||||
return $out;
|
||||
}
|
||||
/**
|
||||
* Return list of accounts with label by chart of accounts
|
||||
*
|
||||
* @param string $selectid Preselected chart of accounts
|
||||
* @param string $htmlname Name of field in html form
|
||||
* @param int $showempty Add an empty field
|
||||
* @param array $event Event options
|
||||
* @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 $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
|
||||
*/
|
||||
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
|
||||
global $conf;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
|
||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
$sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte";
|
||||
$sql .= " AND aa.active = 1";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $pcgver;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||
}
|
||||
$sql .= " ORDER BY account_number ASC";
|
||||
|
||||
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if (! $resql) {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
|
||||
return - 1;
|
||||
}
|
||||
|
||||
$out = ajax_combobox($htmlname, $event);
|
||||
|
||||
$options = array();
|
||||
$selected = null;
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
||||
|
||||
$select_value_in = $obj->rowid;
|
||||
$select_value_out = $obj->rowid;
|
||||
|
||||
if ($select_in == 1) {
|
||||
$select_value_in = $obj->account_number;
|
||||
}
|
||||
if ($select_out == 1) {
|
||||
$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
|
||||
// Because same account_number can be share between different accounting_system and do have the same meaning
|
||||
if (($selectid != '') && $selectid == $select_value_in) {
|
||||
$selected = $select_value_out;
|
||||
}
|
||||
|
||||
$options[$select_value_out] = $label;
|
||||
}
|
||||
|
||||
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
|
||||
$this->db->free($resql);
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1405,25 +1456,26 @@ class BookKeeping extends CommonObject
|
||||
* Description of a root accounting account
|
||||
*
|
||||
* @param string $account Accounting account
|
||||
* @return string
|
||||
* @return string Root account
|
||||
*/
|
||||
function get_compte_racine($account = null)
|
||||
{
|
||||
global $conf;
|
||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
|
||||
$sql = "SELECT root.account_number, root.label as label";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $pcgver;
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid";
|
||||
$sql .= " WHERE aa.account_number = '" . $account . "'";
|
||||
$sql .= " AND parent.active = 1";
|
||||
$sql .= " AND root.active = 1";
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT root.account_number, root.label as label";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
$sql .= " AND asy.rowid = " . $pcgver;
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid";
|
||||
$sql .= " WHERE aa.account_number = '" . $account . "'";
|
||||
$sql .= " AND parent.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);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
@ -1447,11 +1499,12 @@ class BookKeeping extends CommonObject
|
||||
* Description of accounting account
|
||||
*
|
||||
* @param string $account Accounting account
|
||||
* @return string
|
||||
* @return string Account desc
|
||||
*/
|
||||
function get_compte_desc($account = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||
$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 ";
|
||||
@ -1460,6 +1513,10 @@ class BookKeeping extends CommonObject
|
||||
$sql .= " AND asy.rowid = " . $pcgver;
|
||||
$sql .= " AND aa.active = 1";
|
||||
$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);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
@ -1483,6 +1540,7 @@ class BookKeeping extends CommonObject
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class BookKeepingLine
|
||||
*/
|
||||
|
||||
@ -65,7 +65,7 @@ class FormVentilation extends Form
|
||||
/**
|
||||
* 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 int $showempty Add an empty field
|
||||
* @param array $event Event options
|
||||
@ -99,34 +99,37 @@ class FormVentilation extends Form
|
||||
|
||||
$out = ajax_combobox($htmlname, $event);
|
||||
|
||||
// TODO Add $options in cache so next call will not execute the request
|
||||
$selected = 0;
|
||||
$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 = dol_trunc($label, $trunclength);
|
||||
|
||||
$select_value_in = $obj->rowid;
|
||||
$select_value_out = $obj->rowid;
|
||||
|
||||
// Try to guess if we have found default value
|
||||
if ($select_in == 1) {
|
||||
$select_value_in = $obj->account_number;
|
||||
}
|
||||
if ($select_out == 1) {
|
||||
$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
|
||||
// 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;
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
@ -40,26 +40,35 @@ $id = GETPOST('id');
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
|
||||
|
||||
if ($action == 'ventil' && $user->rights->accounting->bind->write) {
|
||||
if (! GETPOST('cancel', 'alpha')) {
|
||||
if ($codeventil < 0) $codeventil = 0;
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
|
||||
$sql .= " SET fk_code_ventilation = " . $codeventil;
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
|
||||
$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
|
||||
*/
|
||||
@ -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 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
|
||||
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -25,9 +25,8 @@
|
||||
* \ingroup Advanced accountancy
|
||||
* \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/accounting.lib.php';
|
||||
|
||||
@ -39,12 +38,15 @@ $langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->read)
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
// Filter
|
||||
// Filter
|
||||
$year = $_GET["year"];
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
@ -56,11 +58,29 @@ if ($year == 0) {
|
||||
|
||||
// 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 . "facturedet";
|
||||
$sql1 .= " SET fk_code_ventilation = accnt.rowid";
|
||||
@ -113,12 +133,13 @@ if ($action == 'validatehistory') {
|
||||
} elseif ($action == 'cleanaccountancycode') {
|
||||
$error = 0;
|
||||
$db->begin();
|
||||
|
||||
|
||||
// Now clean
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$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 f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
||||
$sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')";
|
||||
$sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')";
|
||||
|
||||
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
||||
|
||||
@ -143,16 +164,16 @@ llxHeader('', $langs->trans("CustomersVentilation"));
|
||||
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
|
||||
$textnextyear = ' <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("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToDispatch")) . '<br>';
|
||||
print $langs->trans("DescVentilMore", $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.
|
||||
print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
|
||||
// TODO Remove this. Should be done into the repair.php script
|
||||
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>';
|
||||
|
||||
$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 .= " 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)) . "'";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
$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 .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
if (! empty($conf->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');
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$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 .= " 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)) . "'";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
@ -52,37 +52,27 @@ $search_vat = GETPOST('search_vat', 'alpha');
|
||||
$search_country = GETPOST('search_country', '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');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$page = GETPOST('page', 'int');
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
|
||||
if ($page < 0) $page = 0;
|
||||
$pageprev = $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;
|
||||
|
||||
if (! $sortfield)
|
||||
$sortfield = "f.datef, f.facnumber, fd.rowid";
|
||||
|
||||
if (! $sortorder) {
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
|
||||
$sortorder = " DESC ";
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
@ -128,6 +118,8 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
|
||||
$db->rollback();
|
||||
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 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
|
||||
$sql .= " WHERE fd.fk_code_ventilation > 0 ";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$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))) {
|
||||
$sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')";
|
||||
}
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$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 .= " AND f.entity IN (" . getEntity("facture", 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/customer/lines.php sql=" . $sql, LOG_DEBUG);
|
||||
dol_syslog("/accountancy/customer/lines.php", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$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)
|
||||
$param .= "&search_invoice=" . $search_invoice;
|
||||
if ($search_ref)
|
||||
@ -243,28 +233,38 @@ if ($result) {
|
||||
if ($search_tvaintra)
|
||||
$param .= "&search_tvaintra=" . $search_tvaintra;
|
||||
|
||||
|
||||
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords);
|
||||
print '<td align="left"><b>' . $langs->trans("DescVentilDoneCustomer") . '</b></td>';
|
||||
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
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("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
|
||||
print $langs->trans("DescVentilDoneCustomer") . '<br>';
|
||||
|
||||
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
|
||||
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_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("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("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("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("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'align="center"', $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("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
|
||||
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 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="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="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" name="search_country" 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" 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 '<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"><input type="text" class="flat" name="search_country" size="5" value="' . $search_country . '"></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="right"></td>';
|
||||
print '<td class="liste_titre" align="right">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons(1);
|
||||
print $searchpitco;
|
||||
print "</td></tr>\n";
|
||||
|
||||
$facture_static = new Facture($db);
|
||||
@ -289,7 +291,7 @@ if ($result) {
|
||||
$var = ! $var;
|
||||
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte;
|
||||
|
||||
print '<tr'. $bc[$var].'>';
|
||||
print '<tr '. $bc[$var].'>';
|
||||
|
||||
// Ref Invoice
|
||||
$facture_static->ref = $objp->facnumber;
|
||||
@ -300,6 +302,7 @@ if ($result) {
|
||||
$product_static->ref = $objp->product_ref;
|
||||
$product_static->id = $objp->product_id;
|
||||
$product_static->type = $objp->product_type;
|
||||
$product_static->label = $objp->product_label;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
@ -314,9 +317,10 @@ if ($result) {
|
||||
print '<td>' . $codecompta . '<a href="./card.php?id=' . $objp->fdid . '">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
print '<td align="right">' . $objp->country .'</td>';
|
||||
print '<td align="center">' . $objp->tva_intra . '</td>';
|
||||
print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->fdid . '"/></td>';
|
||||
print '<td>' . $objp->country .'</td>';
|
||||
print '<td>' . $objp->tva_intra . '</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>";
|
||||
$i ++;
|
||||
@ -325,11 +329,14 @@ if ($result) {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
print "</table></form>";
|
||||
print "</table>";
|
||||
|
||||
if ($num_lines > $conf->liste_limit) {
|
||||
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '');
|
||||
if ($nbtotalofrecords > $limit) {
|
||||
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
|
||||
}
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* 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>
|
||||
* 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
|
||||
@ -43,7 +44,6 @@ $langs->load("accountancy");
|
||||
$action = GETPOST('action');
|
||||
|
||||
// Select Box
|
||||
$codeventil = GETPOST('codeventil', 'array');
|
||||
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
|
||||
|
||||
// Search Getpost
|
||||
@ -56,35 +56,27 @@ $search_account = GETPOST('search_account', 'alpha');
|
||||
$search_vat = GETPOST('search_vat', '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');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$page = GETPOST('page', 'int');
|
||||
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;
|
||||
}
|
||||
$page = GETPOST('page','int');
|
||||
if ($page < 0) { $page = 0; }
|
||||
$offset = $limit * $page;
|
||||
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield)
|
||||
$sortfield = "f.datef, f.facnumber, l.rowid";
|
||||
|
||||
if (! $sortorder) {
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
|
||||
$sortorder = " DESC ";
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
@ -92,8 +84,14 @@ $accounting = new AccountingAccount($db);
|
||||
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
|
||||
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
|
||||
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
// 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_invoice = '';
|
||||
$search_label = '';
|
||||
@ -103,6 +101,54 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
|
||||
$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"));
|
||||
|
||||
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)) {
|
||||
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;
|
||||
|
||||
// Customer Invoice lines
|
||||
$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 .= " 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 . "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 .= " WHERE f.fk_statut > 0";
|
||||
$sql .= " AND l.fk_code_ventilation <= 0";
|
||||
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
|
||||
$sql .= " AND product_type <= 2";
|
||||
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')";
|
||||
|
||||
// Add search filter like
|
||||
if (strlen(trim($search_invoice))) {
|
||||
$sql .= " AND (f.facnumber like '%" . $search_invoice . "%')";
|
||||
@ -214,53 +191,78 @@ if (strlen(trim($search_account))) {
|
||||
if (strlen(trim($search_vat))) {
|
||||
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
|
||||
}
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 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/customer/list.php sql=" . $sql, LOG_DEBUG);
|
||||
dol_syslog("/accountancy/customer/list.php", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
|
||||
$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 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 '<table class="noborder" width="100%">';
|
||||
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_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("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("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $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("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="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('');
|
||||
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"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre('', '', '', '', '', 'align="center"');
|
||||
print '</tr>';
|
||||
|
||||
// We add search filter
|
||||
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="15" 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="20" name="search_desc" value="' . $search_desc . '"></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="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="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 align="right" class="liste_titre" colspan="4">';
|
||||
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 ' ';
|
||||
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 class="liste_titre" align="right"><input type="text" class="flat" size="3" 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">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons(1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -305,7 +307,7 @@ if ($result) {
|
||||
if ($objp->code_sell_l != $objp->code_sell_p)
|
||||
$code_sell_p_l_differ = 'color:red';
|
||||
|
||||
print '<tr'. $bc[$var].'>';
|
||||
print '<tr '. $bc[$var].'>';
|
||||
|
||||
// Ref Invoice
|
||||
$facture_static->ref = $objp->facnumber;
|
||||
@ -328,35 +330,45 @@ if ($result) {
|
||||
print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
$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 align="right">';
|
||||
print price($objp->total_ht);
|
||||
print '</td>';
|
||||
|
||||
// Vat rate
|
||||
if ($objp->vat_tx_l != $objp->vat_tx_p)
|
||||
$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 '</td>';
|
||||
|
||||
// Accounting account suggested
|
||||
print '<td align="center" style="' . $code_sell_p_notset . '">';
|
||||
if ($objp->code_sell_l == $objp->code_sell_p) {
|
||||
print $objp->code_sell_l;
|
||||
if ($objp->code_sell_l == $objp->code_sell_p) { // Test if there is a difference between code by default and code on product
|
||||
if ($objp->code_sell_l > 0) print $objp->code_sell_l;
|
||||
else print $langs->trans("Unknown");
|
||||
} 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 align="center">';
|
||||
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1);
|
||||
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1);
|
||||
print '</td>';
|
||||
|
||||
// Line id
|
||||
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 '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $db->error();
|
||||
|
||||
162
htdocs/accountancy/expensereport/card.php
Normal file
162
htdocs/accountancy/expensereport/card.php
Normal 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 ' ';
|
||||
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();
|
||||
0
htdocs/accountancy/expensereport/index.html
Normal file
0
htdocs/accountancy/expensereport/index.html
Normal file
267
htdocs/accountancy/expensereport/index.php
Normal file
267
htdocs/accountancy/expensereport/index.php
Normal 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 = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $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();
|
||||
309
htdocs/accountancy/expensereport/lines.php
Normal file
309
htdocs/accountancy/expensereport/lines.php
Normal 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();
|
||||
328
htdocs/accountancy/expensereport/list.php
Normal file
328
htdocs/accountancy/expensereport/list.php
Normal 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();
|
||||
164
htdocs/accountancy/index.php
Normal file
164
htdocs/accountancy/index.php
Normal 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();
|
||||
@ -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 . '/compta/tva/class/tva.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/fournisseur.facture.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))
|
||||
accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$error = 0;
|
||||
|
||||
$year_current = strftime("%Y", dol_now());
|
||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$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);
|
||||
$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 .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop";
|
||||
$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
|
||||
$sql .= " ba.courant, ba.ref as baref, ba.account_number,";
|
||||
$sql .= " 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 .= " 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 . "societe as soc on bu1.url_id=soc.rowid";
|
||||
$sql .= " WHERE ba.rowid=" . $id_bank_account;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ba.entity = " . $conf->entity;
|
||||
}
|
||||
$sql .= ' AND ba.entity IN ('.getEntity('banque', 0).')'; // We don't share object for accountancy
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
|
||||
$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_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : $langs->trans("CodeNotDef"));
|
||||
|
||||
$tabcompany = array();
|
||||
$tabpay = array ();
|
||||
$tabbq = array ();
|
||||
$tabtp = 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;
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$tabcompany[$obj->rowid] = array (
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_client' => $obj->code_compta
|
||||
);
|
||||
|
||||
// Controls
|
||||
// Set accountancy code (for bank and thirdparty)
|
||||
$compta_bank = $obj->account_number;
|
||||
if ($obj->label == '(SupplierInvoicePayment)')
|
||||
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier);
|
||||
if ($obj->label == '(CustomerInvoicePayment)')
|
||||
$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
|
||||
$tabpay[$obj->rowid]["date"] = $obj->do;
|
||||
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
|
||||
@ -174,16 +183,24 @@ if ($result) {
|
||||
|
||||
// get_url may return -1 which is not traversable
|
||||
if (is_array($links)) {
|
||||
// Now loop on each link of record in bank.
|
||||
foreach ( $links as $key => $val ) {
|
||||
$tabtype[$obj->rowid] = $links[$key]['type'];
|
||||
|
||||
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'];
|
||||
}
|
||||
|
||||
if ($links[$key]['type'] == 'payment') {
|
||||
$paymentstatic->id = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
|
||||
$tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
|
||||
} else if ($links[$key]['type'] == 'payment_supplier') {
|
||||
$paymentsupplierstatic->id = $links[$key]['url_id'];
|
||||
$paymentsupplierstatic->ref = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
|
||||
$tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id;
|
||||
} else if ($links[$key]['type'] == 'company') {
|
||||
$societestatic->id = $links[$key]['url_id'];
|
||||
$societestatic->name = $links[$key]['label'];
|
||||
@ -248,6 +265,26 @@ if ($result) {
|
||||
|
||||
$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;
|
||||
|
||||
$i ++;
|
||||
@ -257,151 +294,185 @@ if ($result) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
var_dump($tabpay);
|
||||
var_dump($tabbq);
|
||||
var_dump($tabtp);
|
||||
*/
|
||||
|
||||
// Write bookkeeping
|
||||
if ($action == 'writebookkeeping') {
|
||||
if (! $error && $action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
|
||||
$error = 0;
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank
|
||||
|
||||
$errorforline = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
// Bank
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $compte->label;
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
|
||||
$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;
|
||||
}
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
|
||||
$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.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->ref_supplier . ' (' . $objmid->ref . ')';
|
||||
}
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
if (! $errorforline)
|
||||
{
|
||||
// Line into bank account
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $compte->label;
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||
|
||||
$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; // Ref of invoice
|
||||
}
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||
|
||||
$sqlmid = 'SELECT facf.ref_supplier, facf.ref';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.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->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice
|
||||
}
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Third party
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if ($tabtype[$key] == 'sc') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else if ($tabtype[$key] == 'payment') {
|
||||
|
||||
$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 if ($tabtype[$key] == 'payment_supplier') {
|
||||
|
||||
$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.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->ref_supplier . ' (' . $objmid->ref . ')';
|
||||
}
|
||||
$bookkeeping->code_tiers = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
} 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 {
|
||||
|
||||
$bookkeeping->doc_ref = $k;
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
if (! $errorforline)
|
||||
{
|
||||
// Line into thirdparty account
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
|
||||
$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 = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} 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 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
|
||||
$sqlmid .= " WHERE payf.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->ref_supplier . ' (' . $objmid->ref . ')';
|
||||
}
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else {
|
||||
// FIXME Should be a temporary account ???
|
||||
$bookkeeping->doc_ref = $k;
|
||||
//$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
$bookkeeping->numero_compte = 'CodeNotDef';
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $errorforline)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
@ -437,7 +508,6 @@ if ($action == 'export_csv') {
|
||||
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
// Bank
|
||||
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"));
|
||||
|
||||
$nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1);
|
||||
$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);
|
||||
|
||||
$varlink = 'id_account=' . $id_bank_account;
|
||||
@ -585,14 +658,17 @@ else {
|
||||
|
||||
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 '
|
||||
<script type="text/javascript">
|
||||
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[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
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[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
@ -607,9 +683,10 @@ else {
|
||||
$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("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("Account") . "</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("Type") . "</td>";
|
||||
print "<td>" . $langs->trans("PaymentMode") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
@ -618,9 +695,9 @@ else {
|
||||
$var = true;
|
||||
$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');
|
||||
|
||||
|
||||
$reflabel = $val["ref"];
|
||||
if ($reflabel == '(SupplierInvoicePayment)') {
|
||||
$reflabel = $langs->trans('Supplier');
|
||||
@ -637,13 +714,56 @@ else {
|
||||
if ($reflabel == '(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
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td>" . $date . "</td>";
|
||||
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td><!-- Bank bank.rowid=".$key."--></td>";
|
||||
print "<td>" . $date . "</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'] == '') {
|
||||
print "<td>" . $bank_code_journal->label . " - " . $val["ref"] . "</td>";
|
||||
} else {
|
||||
@ -660,9 +780,17 @@ else {
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($k != 'type') {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td><!-- Thirdparty bank.rowid=".$key." --></td>";
|
||||
print "<td>" . $date . "</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>" . $val["type_payment"] . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
@ -673,9 +801,16 @@ else {
|
||||
} else {
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td><!-- Wait bank.rowid=".$key." --></td>";
|
||||
print "<td>" . $date . "</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> </td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
@ -690,4 +825,5 @@ else {
|
||||
|
||||
llxFooter();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
545
htdocs/accountancy/journal/expensereportsjournal.php
Normal file
545
htdocs/accountancy/journal/expensereportsjournal.php
Normal 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();
|
||||
@ -59,6 +59,7 @@ if ($user->societe_id > 0)
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
|
||||
/*
|
||||
* 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 .= " 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.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 .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
|
||||
$sql .= " 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 . "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 .= " WHERE f.fk_statut > 0 ";
|
||||
$sql .= " AND fd.fk_code_ventilation > 0 ";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||
$sql .= " AND f.type IN (0,1,2)";
|
||||
else
|
||||
@ -168,6 +167,10 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
foreach ($tabfac as $key => $val)
|
||||
{
|
||||
$errorforline = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
$companystatic = new Societe($db);
|
||||
$invoicestatic = new FactureFournisseur($db);
|
||||
|
||||
@ -179,6 +182,10 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$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'];
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
@ -203,8 +210,9 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,7 +243,8 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -266,154 +275,180 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (! $errorforline)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||
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);
|
||||
|
||||
$companystatic = new Fournisseur($db);
|
||||
|
||||
// Export
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
// Model Cegid Expert Export
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
|
||||
$sep = ";";
|
||||
// Model Cegid Expert Export
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
|
||||
$sep = ";";
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$date = dol_print_date($val["date"], '%d%m%Y');
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($val["description"], 32) . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $companystatic->name . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
|
||||
// Model Classic Export
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
$invoicestatic->ref = $val["refsologest"];
|
||||
$invoicestatic->refsupplier = $val["refsuppliersologest"];
|
||||
$invoicestatic->type = $val["type"];
|
||||
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
|
||||
|
||||
$date = dol_print_date($val["date"], 'day');
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$date = dol_print_date($val["date"], '%d%m%Y');
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
// Product / Service
|
||||
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($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $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 '"' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($val["description"], 32) . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// 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($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
// VAT
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $companystatic->name . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
|
||||
// Model Classic Export
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
$invoicestatic->ref = $val["refsologest"];
|
||||
$invoicestatic->refsupplier = $val["refsuppliersologest"];
|
||||
$invoicestatic->type = $val["type"];
|
||||
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
|
||||
|
||||
$date = dol_print_date($val["date"], 'day');
|
||||
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
// Product / Service
|
||||
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($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $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 '"' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $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($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($action) || $action == 'view') {
|
||||
|
||||
llxHeader('', $langs->trans("PurchasesJournal"));
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$nom = $langs->trans("PurchasesJournal");
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$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)) {
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
} else {
|
||||
@ -456,9 +491,10 @@ if ($action == 'export_csv') {
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
// /print "<td>".$langs->trans("JournalNum")."</td>";
|
||||
print "<td></td>";
|
||||
print "<td>" . $langs->trans("Date") . "</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 "</tr>\n";
|
||||
|
||||
@ -486,9 +522,17 @@ if ($action == 'export_csv') {
|
||||
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . " >";
|
||||
print "<td><!-- Product --></td>";
|
||||
print "<td>" . $date . "</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->name = $tabcompany[$key]['name'];
|
||||
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 ) {
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . " >";
|
||||
print "<td><!-- VAT --></td>";
|
||||
print "<td>" . $date . "</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 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
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td><!-- Thirdparty --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$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><td>" . $langs->trans("ThirdParty");
|
||||
// print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')';
|
||||
|
||||
@ -62,16 +62,17 @@ if ($user->societe_id > 0)
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$year_current = strftime("%Y", dol_now());
|
||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||
$pastmonthyear = $year_current;
|
||||
if ($pastmonth == 0) {
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
$pastmonth = 12;
|
||||
$pastmonthyear --;
|
||||
}
|
||||
|
||||
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
|
||||
@ -79,8 +80,8 @@ $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);
|
||||
$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);
|
||||
@ -88,7 +89,7 @@ $idpays = $p[0];
|
||||
|
||||
$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 .= " 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 .= " fd.situation_percent,ct.accountancy_code_sell as account_tva";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
@ -97,334 +98,367 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid =
|
||||
$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 .= " 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 ";
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
||||
}
|
||||
$sql .= " WHERE fd.fk_code_ventilation > 0";
|
||||
$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
}
|
||||
$sql .= " AND fd.product_type IN (0,1)";
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " ORDER BY f.datef";
|
||||
|
||||
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$tabfac = array ();
|
||||
$tabht = array ();
|
||||
$tabtva = array ();
|
||||
$def_tva = array ();
|
||||
$tabttc = array ();
|
||||
$tabcompany = array ();
|
||||
$tabfac = array ();
|
||||
$tabht = array ();
|
||||
$tabtva = array ();
|
||||
$def_tva = array ();
|
||||
$tabttc = array ();
|
||||
$tabcompany = array ();
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object($result);
|
||||
// les variables
|
||||
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
|
||||
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object($result);
|
||||
// les variables
|
||||
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
|
||||
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
|
||||
|
||||
$compta_prod = $obj->compte;
|
||||
if (empty($compta_prod)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
else
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
}
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
||||
$compta_prod = $obj->compte;
|
||||
if (empty($compta_prod)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
else
|
||||
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
}
|
||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
||||
|
||||
|
||||
//Define array for display vat tx
|
||||
$def_tva[$obj->rowid]=price($obj->tva_tx);
|
||||
//Define array for display vat tx
|
||||
$def_tva[$obj->rowid]=price($obj->tva_tx);
|
||||
|
||||
// Situation invoices handling
|
||||
$line = new FactureLigne($db);
|
||||
$line->fetch($obj->fdid);
|
||||
$prev_progress = $line->get_prev_progress($obj->fdid);
|
||||
if ($obj->type == Facture::TYPE_SITUATION) {
|
||||
// Avoid divide by 0
|
||||
if ($obj->situation_percent == 0) {
|
||||
$situation_ratio = 0;
|
||||
} else {
|
||||
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
|
||||
}
|
||||
} else {
|
||||
$situation_ratio = 1;
|
||||
}
|
||||
// Situation invoices handling
|
||||
$line = new FactureLigne($db);
|
||||
$line->fetch($obj->fdid);
|
||||
$prev_progress = $line->get_prev_progress($obj->fdid);
|
||||
if ($obj->type == Facture::TYPE_SITUATION) {
|
||||
// Avoid divide by 0
|
||||
if ($obj->situation_percent == 0) {
|
||||
$situation_ratio = 0;
|
||||
} else {
|
||||
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
|
||||
}
|
||||
} else {
|
||||
$situation_ratio = 1;
|
||||
}
|
||||
|
||||
// Invoice lines
|
||||
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
|
||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
|
||||
$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
|
||||
if (! isset($tabttc[$obj->rowid][$compta_soc]))
|
||||
$tabttc[$obj->rowid][$compta_soc] = 0;
|
||||
if (! isset($tabht[$obj->rowid][$compta_prod]))
|
||||
$tabht[$obj->rowid][$compta_prod] = 0;
|
||||
if (! isset($tabtva[$obj->rowid][$compta_tva]))
|
||||
$tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
|
||||
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
|
||||
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
|
||||
$tabcompany[$obj->rowid] = array (
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_client' => $obj->code_compta
|
||||
);
|
||||
// Invoice lines
|
||||
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
|
||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
|
||||
$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
|
||||
if (! isset($tabttc[$obj->rowid][$compta_soc]))
|
||||
$tabttc[$obj->rowid][$compta_soc] = 0;
|
||||
if (! isset($tabht[$obj->rowid][$compta_prod]))
|
||||
$tabht[$obj->rowid][$compta_prod] = 0;
|
||||
if (! isset($tabtva[$obj->rowid][$compta_tva]))
|
||||
$tabtva[$obj->rowid][$compta_tva] = 0;
|
||||
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
|
||||
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
|
||||
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
|
||||
$tabcompany[$obj->rowid] = array (
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_client' => $obj->code_compta
|
||||
);
|
||||
|
||||
$i ++;
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Action
|
||||
* FIXME Action must be set before any view part to respect MVC
|
||||
*/
|
||||
|
||||
// Bookkeeping Write
|
||||
if ($action == 'writebookkeeping') {
|
||||
$now = dol_now();
|
||||
$error = 0;
|
||||
$now = dol_now();
|
||||
$error = 0;
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
|
||||
$errorforline = 0;
|
||||
|
||||
$companystatic = new Societe($db);
|
||||
$invoicestatic = new Facture($db);
|
||||
$db->begin();
|
||||
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
$companystatic = new Societe($db);
|
||||
$invoicestatic = new Facture($db);
|
||||
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = (string) $val["ref"];
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$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'];
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
// $bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers");
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = (string) $val["ref"];
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
// $bookkeeping->label_compte = $tabcompany[$key]['name'];
|
||||
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers");
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
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 = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
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 = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$errorforline++;
|
||||
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// VAT
|
||||
// var_dump($tabtva);
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_facturedet"];
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
|
||||
if (empty($error)) {
|
||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||
}
|
||||
$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) > 0) {
|
||||
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
|
||||
if ($action == 'export_csv') {
|
||||
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
$companystatic = new Client($db);
|
||||
$companystatic = new Client($db);
|
||||
|
||||
// Model Cegid Expert Export
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
|
||||
$sep = ";";
|
||||
// Model Cegid Expert Export
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
|
||||
$sep = ";";
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
|
||||
$date = dol_print_date($val["date"], '%d%m%Y');
|
||||
$date = dol_print_date($val["date"], '%d%m%Y');
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount_static = new AccountingAccount($db);
|
||||
if ($accountingaccount_static->fetch(null, $k)) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount_static = new AccountingAccount($db);
|
||||
if ($accountingaccount_static->fetch(null, $k)) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// TVA
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
|
||||
// print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
|
||||
// Model Classic Export
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
// TVA
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
|
||||
// print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
|
||||
// Model Classic Export
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
|
||||
$date = dol_print_date($val["date"], 'day');
|
||||
$date = dol_print_date($val["date"], 'day');
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k);
|
||||
// Product / Service
|
||||
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($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . 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($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 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($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form = new Form($db);
|
||||
if (empty($action) || $action == 'view') {
|
||||
|
||||
llxHeader('', $langs->trans("SellsJournal"));
|
||||
|
||||
@ -433,7 +467,8 @@ if ($action == 'export_csv') {
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$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))
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
else
|
||||
@ -473,9 +508,10 @@ if ($action == 'export_csv') {
|
||||
$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("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("Account") . "</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("Type") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
@ -497,14 +533,23 @@ if ($action == 'export_csv') {
|
||||
// Third party
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td><!-- Thirdparty --></td>";
|
||||
print "<td>" . $date . "</td>";
|
||||
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$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 ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
|
||||
print '</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 align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
@ -518,9 +563,17 @@ if ($action == 'export_csv') {
|
||||
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td><!-- Product --></td>";
|
||||
print "<td>" . $date . "</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>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
@ -533,9 +586,17 @@ if ($action == 'export_csv') {
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print "<tr " . $bc[$var] . ">";
|
||||
print "<td><!-- VAT --></td>";
|
||||
print "<td>" . $date . "</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>" . $langs->trans("VAT") . "</td>";
|
||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
|
||||
@ -75,7 +75,7 @@ $form = new Form($db);
|
||||
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
|
||||
$textnextyear = ' <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%">';
|
||||
|
||||
@ -103,14 +103,17 @@ foreach($months as $k => $v){
|
||||
print '</tr>';
|
||||
|
||||
$cats = $AccCat->getCatsCpts();
|
||||
if ($cats < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
|
||||
|
||||
$catsCalcule = $AccCat->getCatsCal();
|
||||
if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
|
||||
|
||||
$j=1;
|
||||
$sommes = array();
|
||||
|
||||
if(!empty($cats))
|
||||
if (!empty($cats))
|
||||
{
|
||||
foreach ( $cats as $name_cat => $cpts )
|
||||
foreach ($cats as $name_cat => $cpts)
|
||||
{
|
||||
print "<tr class='liste_titre'>";
|
||||
print '<td colspan="17">' . $name_cat . '</td>';
|
||||
|
||||
@ -44,23 +44,35 @@ $id = GETPOST('id');
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
|
||||
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'ventil' && $user->rights->accounting->bind->write) {
|
||||
if (! GETPOST('cancel', 'alpha')) {
|
||||
if ($codeventil < 0) $codeventil = 0;
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = " . $codeventil;
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
dol_syslog('accountancy/supplier/card.php:: $sql=' . $sql);
|
||||
$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
|
||||
*/
|
||||
@ -70,9 +82,7 @@ if ($cancel == $langs->trans("Cancel")) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
/*
|
||||
* Create
|
||||
*/
|
||||
// Create
|
||||
$form = new Form($db);
|
||||
$facturefournisseur_static = new FactureFournisseur($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 .= " 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;
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -23,9 +23,8 @@
|
||||
* \ingroup Advanced accountancy
|
||||
* \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/accounting.lib.php';
|
||||
|
||||
@ -37,9 +36,12 @@ $langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->read)
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
// Filter
|
||||
@ -54,11 +56,28 @@ if ($year == 0) {
|
||||
|
||||
// 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";
|
||||
@ -138,17 +157,17 @@ llxHeader('', $langs->trans("SuppliersVentilation"));
|
||||
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
|
||||
$textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear);
|
||||
print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
|
||||
|
||||
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 '<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.
|
||||
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>';
|
||||
|
||||
$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 .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0 ";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 1) . ")";
|
||||
}
|
||||
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
$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 .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0 ";
|
||||
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 1) . ")";
|
||||
}
|
||||
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
@ -51,36 +51,27 @@ $search_amount = GETPOST('search_amount', 'alpha');
|
||||
$search_account = GETPOST('search_account', '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');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$page = GETPOST('page', 'int');
|
||||
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
if ($page < 0) $page = 0;
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $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)
|
||||
$sortfield = "f.datef, f.ref, l.rowid";
|
||||
|
||||
if (! $sortorder) {
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
|
||||
$sortorder = " DESC ";
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
@ -124,6 +115,8 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
|
||||
$db->rollback();
|
||||
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))) {
|
||||
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
|
||||
}
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 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/supplier/lines.php::list sql= ' . $sql1);
|
||||
dol_syslog('accountancy/supplier/lines.php::list');
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$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_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
|
||||
|
||||
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print $langs->trans("DescVentilDoneSupplier") . '<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" 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_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("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("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("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($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 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="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="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" colspan="2"> </td>';
|
||||
print '<td class="liste_titre" align="right"></td>';
|
||||
print '<td class="liste_titre" align="right"></td>';
|
||||
print '<td class="liste_titre" align="right">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons(0);
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons(1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
@ -242,7 +273,7 @@ if ($result) {
|
||||
$var = ! $var;
|
||||
$codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label;
|
||||
|
||||
print '<tr'. $bc[$var].'>';
|
||||
print '<tr '. $bc[$var].'>';
|
||||
|
||||
// Ref Invoice
|
||||
$facturefournisseur_static->ref = $objp->facnumber;
|
||||
@ -253,6 +284,7 @@ if ($result) {
|
||||
$product_static->ref = $objp->product_ref;
|
||||
$product_static->id = $objp->product_id;
|
||||
$product_static->type = $objp->type;
|
||||
$product_static->label = $objp->product_label;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
@ -270,7 +302,7 @@ if ($result) {
|
||||
print img_edit();
|
||||
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>";
|
||||
$i ++;
|
||||
@ -279,7 +311,14 @@ if ($result) {
|
||||
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();
|
||||
$db->close();
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* 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
|
||||
@ -43,7 +44,6 @@ $langs->load("accountancy");
|
||||
$action = GETPOST('action');
|
||||
|
||||
// Select Box
|
||||
$codeventil = GETPOST('codeventil', 'array');
|
||||
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
|
||||
|
||||
// Search Getpost
|
||||
@ -56,35 +56,27 @@ $search_account = GETPOST('search_account', 'alpha');
|
||||
$search_vat = GETPOST('search_vat', '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');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
|
||||
$page = GETPOST('page');
|
||||
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;
|
||||
}
|
||||
$page = GETPOST('page','int');
|
||||
if ($page < 0) { $page = 0; }
|
||||
$offset = $limit * $page;
|
||||
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield)
|
||||
$sortfield = "f.datef, f.ref, l.rowid";
|
||||
if (! $sortorder) {
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
|
||||
$sortorder = " DESC ";
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->ventilation->dispatch)
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
$formventilation = new FormVentilation($db);
|
||||
@ -98,91 +90,80 @@ $accounting = new AccountingAccount($db);
|
||||
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
|
||||
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
|
||||
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
// 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_label = '';
|
||||
$search_desc = '';
|
||||
$search_amount = '';
|
||||
$search_account = '';
|
||||
$search_vat = '';
|
||||
$search_ref = '';
|
||||
$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 . "facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = " . $monCompte;
|
||||
$sql .= " WHERE rowid = " . $monId;
|
||||
|
||||
$accountventilated = new AccountingAccount($db);
|
||||
$accountventilated->fetch($monCompte, '');
|
||||
|
||||
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
$ok++;
|
||||
$msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $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("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)) {
|
||||
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) {
|
||||
print '<div><font color="red">' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
|
||||
$mesCodesVentilChoisis = $codeventil;
|
||||
$cpt = 0;
|
||||
|
||||
foreach ( $mesCasesCochees as $maLigneCochee ) {
|
||||
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monNumLigne = $maLigneCourante[1];
|
||||
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = " . $monCompte;
|
||||
$sql .= " WHERE rowid = " . $monId;
|
||||
|
||||
$accountventilated = new AccountingAccount($db);
|
||||
$accountventilated->fetch($monCompte, '');
|
||||
|
||||
dol_syslog('accountancy/supplier/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>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Supplier 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;
|
||||
|
||||
// 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 .= " 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";
|
||||
@ -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 . "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 .= " 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 (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
|
||||
if (strlen(trim($search_invoice))) {
|
||||
$sql .= " AND (f.ref like '%" . $search_invoice . "%')";
|
||||
@ -216,55 +197,77 @@ if (strlen(trim($search_account))) {
|
||||
if (strlen(trim($search_vat))) {
|
||||
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
|
||||
}
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 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/supplier/list.php:: $sql=' . $sql);
|
||||
dol_syslog('accountancy/supplier/list.php');
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
|
||||
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
|
||||
|
||||
$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 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);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
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_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("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("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $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("AccountAccounting"), '', '', '', '', 'align="center"');
|
||||
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="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('');
|
||||
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"], "l.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_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="20" 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" 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="5" name="search_vat" value="' . $search_vat . '"></td>';
|
||||
print '<td class="liste_titre" align="center"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
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")) . '">';
|
||||
print ' ';
|
||||
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 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="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">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons(1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -314,7 +317,7 @@ if ($result) {
|
||||
if ($objp->code_buy_l != $objp->code_buy_p)
|
||||
$code_buy_p_l_differ = 'color:red';
|
||||
|
||||
print '<tr'. $bc[$var].'>';
|
||||
print '<tr '. $bc[$var].'>';
|
||||
|
||||
// Ref Invoice
|
||||
$facturefourn_static->ref = $objp->ref;
|
||||
@ -342,29 +345,36 @@ if ($result) {
|
||||
print price($objp->price);
|
||||
print '</td>';
|
||||
|
||||
// Vat rate
|
||||
if ($objp->vat_tx_l != $objp->vat_tx_p)
|
||||
$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 '</td>';
|
||||
|
||||
// Accounting account suggested
|
||||
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) {
|
||||
print $objp->code_buy_l;
|
||||
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 > 0) print $objp->code_buy_l;
|
||||
else print $langs->trans("Unknown");
|
||||
} 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>';
|
||||
|
||||
// Colonne choix du compte
|
||||
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>';
|
||||
|
||||
// Line id
|
||||
print '<td align="center">' . $objp->rowid . '</td>';
|
||||
|
||||
// Colonne choix ligne a ventiler
|
||||
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 "</tr>";
|
||||
@ -372,7 +382,6 @@ if ($result) {
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil" ></div>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $db->error();
|
||||
|
||||
@ -120,6 +120,13 @@ if ($object->id > 0)
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
$object->info($id);
|
||||
print dol_print_object_info($object, 1);
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
@ -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.'/core/class/extrafields.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("bills");
|
||||
@ -51,6 +52,7 @@ $cancel=GETPOST('cancel','alpha');
|
||||
$backtopage=GETPOST('backtopage','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$rowid=GETPOST('rowid','int');
|
||||
$id=GETPOST('id')?GETPOST('id','int'):$rowid;
|
||||
$typeid=GETPOST('typeid','int');
|
||||
$userid=GETPOST('userid','int');
|
||||
$socid=GETPOST('socid','int');
|
||||
@ -71,7 +73,7 @@ $extrafields = new ExtraFields($db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// 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");
|
||||
$objcanvas=null;
|
||||
if (! empty($canvas))
|
||||
@ -82,12 +84,12 @@ if (! empty($canvas))
|
||||
}
|
||||
|
||||
// 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
|
||||
$result = $object->fetch($rowid);
|
||||
$result = $object->fetch($id);
|
||||
|
||||
// Define variables to know what current user can do on users
|
||||
$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
|
||||
$canaddmember=$user->rights->adherent->creer;
|
||||
// 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;
|
||||
}
|
||||
@ -114,12 +116,14 @@ if ($rowid)
|
||||
$hookmanager->initHooks(array('membercard','globalcard'));
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
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
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
@ -253,6 +257,7 @@ if (empty($reshook))
|
||||
}
|
||||
$lastname=$_POST["lastname"];
|
||||
$firstname=$_POST["firstname"];
|
||||
$societe=$_POST["societe"];
|
||||
$morphy=$_POST["morphy"];
|
||||
$login=$_POST["login"];
|
||||
if ($morphy != 'mor' && empty($lastname)) {
|
||||
@ -343,15 +348,15 @@ if (empty($reshook))
|
||||
$object->setCategories($categories);
|
||||
|
||||
// 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']);
|
||||
if ($file_OK)
|
||||
{
|
||||
if (GETPOST('deletephoto'))
|
||||
{
|
||||
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;
|
||||
$dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/thumbs';
|
||||
$fileimg=$conf->adherent->dir_output.'/'.get_exdir(0,0,0,1,$object,'member').'/photos/'.$object->photo;
|
||||
$dirthumbs=$conf->adherent->dir_output.'/'.get_exdir(0,0,0,1,$object,'member').'/photos/thumbs';
|
||||
dol_delete_file($fileimg);
|
||||
dol_delete_dir_recursive($dirthumbs);
|
||||
}
|
||||
@ -394,6 +399,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
$rowid=$object->id;
|
||||
$id=$object->id;
|
||||
$action='';
|
||||
|
||||
if (! empty($backtopage))
|
||||
@ -556,6 +562,7 @@ if (empty($reshook))
|
||||
|
||||
$db->commit();
|
||||
$rowid=$object->id;
|
||||
$id=$object->id;
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
@ -578,7 +585,7 @@ if (empty($reshook))
|
||||
|
||||
if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
|
||||
{
|
||||
$result=$object->delete($rowid);
|
||||
$result=$object->delete($id);
|
||||
if ($result > 0)
|
||||
{
|
||||
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);
|
||||
$formfile = new FormFile($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
$title=$langs->trans("Member") . " - " . $langs->trans("Card");
|
||||
@ -728,10 +741,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
if (empty($object->error) && $rowid)
|
||||
if (empty($object->error) && $id)
|
||||
{
|
||||
$object = new Adherent($db);
|
||||
$result=$object->fetch($rowid);
|
||||
$result=$object->fetch($id);
|
||||
if ($result <= 0) dol_print_error('',$object->error);
|
||||
}
|
||||
$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) {
|
||||
dol_print_error($db,$object->error); exit;
|
||||
}
|
||||
@ -1036,14 +1049,10 @@ else
|
||||
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 '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
|
||||
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.'" />';
|
||||
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%">';
|
||||
|
||||
// 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
|
||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
|
||||
@ -1065,21 +1074,7 @@ else
|
||||
$morphys["mor"] = $langs->trans("Morale");
|
||||
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 "</td>";
|
||||
|
||||
// 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>';
|
||||
print "</td></tr>";
|
||||
|
||||
// Type
|
||||
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>';
|
||||
|
||||
// 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
|
||||
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) {
|
||||
dol_print_error($db,$object->error); exit;
|
||||
}
|
||||
@ -1343,13 +1353,13 @@ else
|
||||
if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
|
||||
$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
|
||||
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
|
||||
@ -1380,7 +1390,7 @@ else
|
||||
$formquestion=array();
|
||||
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"]));
|
||||
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
|
||||
@ -1388,18 +1398,18 @@ else
|
||||
{
|
||||
$formquestion=array();
|
||||
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
|
||||
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
|
||||
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;
|
||||
@ -1601,7 +1611,7 @@ else
|
||||
// Modify
|
||||
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
|
||||
{
|
||||
@ -1613,7 +1623,7 @@ else
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -1626,7 +1636,7 @@ else
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -1657,7 +1667,7 @@ else
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -1726,8 +1736,49 @@ else
|
||||
{
|
||||
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>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -89,25 +89,25 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
|
||||
|
||||
// List of values to scan for a replacement
|
||||
$substitutionarray = array (
|
||||
'%ID%'=>$objp->rowid,
|
||||
'%LOGIN%'=>$objp->login,
|
||||
'%FIRSTNAME%'=>$objp->firstname,
|
||||
'%LASTNAME%'=>$objp->lastname,
|
||||
'%FULLNAME%'=>$adherentstatic->getFullName($langs),
|
||||
'%COMPANY%'=>$objp->company,
|
||||
'%ADDRESS%'=>$objp->address,
|
||||
'%ZIP%'=>$objp->zip,
|
||||
'%TOWN%'=>$objp->town,
|
||||
'%COUNTRY%'=>$objp->country,
|
||||
'%COUNTRY_CODE%'=>$objp->country_code,
|
||||
'%EMAIL%'=>$objp->email,
|
||||
'%BIRTH%'=>dol_print_date($objp->birth,'day'),
|
||||
'%TYPE%'=>$objp->type,
|
||||
'%YEAR%'=>$year,
|
||||
'%MONTH%'=>$month,
|
||||
'%DAY%'=>$day,
|
||||
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
|
||||
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||
'%ID%'=>$objp->rowid,
|
||||
'%LOGIN%'=>$objp->login,
|
||||
'%FIRSTNAME%'=>$objp->firstname,
|
||||
'%LASTNAME%'=>$objp->lastname,
|
||||
'%FULLNAME%'=>$adherentstatic->getFullName($langs),
|
||||
'%COMPANY%'=>$objp->company,
|
||||
'%ADDRESS%'=>$objp->address,
|
||||
'%ZIP%'=>$objp->zip,
|
||||
'%TOWN%'=>$objp->town,
|
||||
'%COUNTRY%'=>$objp->country,
|
||||
'%COUNTRY_CODE%'=>$objp->country_code,
|
||||
'%EMAIL%'=>$objp->email,
|
||||
'%BIRTH%'=>dol_print_date($objp->birth,'day'),
|
||||
'%TYPE%'=>$objp->type,
|
||||
'%YEAR%'=>$year,
|
||||
'%MONTH%'=>$month,
|
||||
'%DAY%'=>$day,
|
||||
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
|
||||
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs);
|
||||
|
||||
@ -121,7 +121,10 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
|
||||
|
||||
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(
|
||||
'textleft'=>$textleft,
|
||||
|
||||
@ -1070,6 +1070,7 @@ class Adherent extends CommonObject
|
||||
$sql.= " d.datevalid as datev,";
|
||||
$sql.= " d.country,";
|
||||
$sql.= " d.state_id,";
|
||||
$sql.= " d.model_pdf,";
|
||||
$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.= " t.libelle as type, t.subscription as subscription,";
|
||||
@ -1154,6 +1155,8 @@ class Adherent extends CommonObject
|
||||
|
||||
$this->user_id = $obj->user_id;
|
||||
$this->user_login = $obj->user_login;
|
||||
|
||||
$this->model_pdf = $obj->model_pdf;
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
// fetch optionals attributes and labels
|
||||
@ -1679,6 +1682,17 @@ class Adherent extends CommonObject
|
||||
if ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'),'statut5').' '.$langs->trans("MemberStatusResiliated");
|
||||
}
|
||||
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)
|
||||
@ -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.
|
||||
* Used to build previews or test instances.
|
||||
|
||||
@ -33,17 +33,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
*/
|
||||
class AdherentType extends CommonObject
|
||||
{
|
||||
public $table_element = 'adherent_type';
|
||||
public $element = 'adherent_type';
|
||||
public $table_element = 'adherent_type';
|
||||
public $element = 'adherent_type';
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $libelle;
|
||||
var $subscription; // Subscription required
|
||||
var $note;
|
||||
var $vote; // Can vote
|
||||
var $mail_valid; // mail sent during validation
|
||||
var $statut;
|
||||
/** @var string Label */
|
||||
public $libelle;
|
||||
/**
|
||||
* @var bool
|
||||
* @deprecated Use subscription
|
||||
* @see subscription
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -84,13 +84,12 @@ class Members extends DolibarrApi
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $typeid ID of the type of member
|
||||
* @param string $login To filter the members by login
|
||||
* @param string $name To filter the members by name (firstname, lastname or company name matching the filter)
|
||||
* @return array Array of member objects
|
||||
* @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 member objects
|
||||
*
|
||||
* @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;
|
||||
|
||||
$obj_ret = array();
|
||||
@ -99,27 +98,24 @@ class Members extends DolibarrApi
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT a.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
||||
$sql.= ' WHERE a.entity IN ('.getEntity('adherent', 1).')';
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as t";
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')';
|
||||
if (!empty($typeid))
|
||||
{
|
||||
$sql.= ' AND a.fk_adherent_type='.$typeid;
|
||||
$sql.= ' AND t.fk_adherent_type='.$typeid;
|
||||
}
|
||||
if (!empty($login)) {
|
||||
$sql .= " AND a.login LIKE '%".$login."%'";
|
||||
}
|
||||
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))
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
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);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
@ -271,7 +267,7 @@ class Members extends DolibarrApi
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array $data Data to validate
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
|
||||
@ -80,11 +80,12 @@ class Subscriptions extends DolibarrApi
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @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
|
||||
*
|
||||
* @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;
|
||||
|
||||
$obj_ret = array();
|
||||
@ -94,15 +95,19 @@ class Subscriptions extends DolibarrApi
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."subscription";
|
||||
|
||||
$nbtotalofrecords = 0;
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."subscription as t";
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
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);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
@ -225,7 +230,7 @@ class Subscriptions extends DolibarrApi
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array $data Data to validate
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
|
||||
@ -69,7 +69,7 @@ if ($result < 0)
|
||||
dol_print_error($db);
|
||||
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';
|
||||
$permission = $user->rights->adherent->creer;
|
||||
$permtoedit = $user->rights->adherent->creer;
|
||||
$param = '&id=' . $object->id;
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
print "<br><br>";
|
||||
|
||||
@ -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érents|ES:Mó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();
|
||||
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
* \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.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
* \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.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
* \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/subscription.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
@ -203,7 +203,6 @@ dol_fiche_head($head, 'other', $langs->trans("Agenda"), 0, 'action');
|
||||
* Documents models for supplier orders
|
||||
*/
|
||||
|
||||
print load_fiche_titre($langs->trans("AgendaModelModule"),'','');
|
||||
|
||||
// Define array def of models
|
||||
$def = array();
|
||||
@ -230,109 +229,114 @@ else
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre">'."\n";
|
||||
print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
|
||||
print '<td>'.$langs->trans("Description").'</td>'."\n";
|
||||
print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
|
||||
print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
|
||||
print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$var=true;
|
||||
foreach ($dirmodels as $reldir)
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/action/doc/");
|
||||
|
||||
if (is_dir($dir))
|
||||
print load_fiche_titre($langs->trans("AgendaModelModule"),'','');
|
||||
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre">'."\n";
|
||||
print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
|
||||
print '<td>'.$langs->trans("Description").'</td>'."\n";
|
||||
print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
|
||||
print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
|
||||
print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$var=true;
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
if (is_resource($handle))
|
||||
$dir = dol_buildpath($reldir."core/modules/action/doc/");
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
$handle=opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new ActionComm($db));
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">\n";
|
||||
print "<td>";
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.$file;
|
||||
$module = new $classname($db,$specimenthirdparty);
|
||||
if (method_exists($module,'info'))
|
||||
print $module->info($langs);
|
||||
else
|
||||
print $module->description;
|
||||
print "</td>\n";
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
|
||||
print '<td align="center">'."\n";
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">';
|
||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||
}
|
||||
print "</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
// Default
|
||||
print '<td align="center">';
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
|
||||
{
|
||||
print img_picto($langs->trans("Default"),'on');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('',$htmltooltip,1,0);
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new ActionComm($db));
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">\n";
|
||||
print "<td>";
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.$file;
|
||||
$module = new $classname($db,$specimenthirdparty);
|
||||
if (method_exists($module,'info'))
|
||||
print $module->info($langs);
|
||||
else
|
||||
print $module->description;
|
||||
print "</td>\n";
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
|
||||
print '<td align="center">'."\n";
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">';
|
||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||
}
|
||||
print "</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
// Default
|
||||
print '<td align="center">';
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
|
||||
{
|
||||
print img_picto($langs->trans("Default"),'on');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('',$htmltooltip,1,0);
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
print '</table><br>';
|
||||
}
|
||||
print '</table><br>';
|
||||
|
||||
$var=true;
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/acco
|
||||
|
||||
$langs->load("errors");
|
||||
$langs->load("admin");
|
||||
$langs->load("main");
|
||||
$langs->load("companies");
|
||||
$langs->load("resource");
|
||||
$langs->load("holiday");
|
||||
@ -54,7 +55,10 @@ $confirm=GETPOST('confirm','alpha');
|
||||
$id=GETPOST('id','int');
|
||||
$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[1] = "disable";
|
||||
@ -73,6 +77,8 @@ $offset = $listlimit * $page ;
|
||||
$pageprev = $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
|
||||
$hookmanager->initHooks(array('admin'));
|
||||
|
||||
@ -114,7 +120,7 @@ $tabname[27]= MAIN_DB_PREFIX."c_stcomm";
|
||||
$tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
|
||||
$tabname[29]= MAIN_DB_PREFIX."c_lead_status";
|
||||
$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[33]= MAIN_DB_PREFIX."c_hrm_department";
|
||||
$tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
|
||||
@ -151,7 +157,7 @@ $tablib[27]= "DictionaryProspectStatus";
|
||||
$tablib[28]= "DictionaryHolidayTypes";
|
||||
$tablib[29]= "DictionaryOpportunityStatus";
|
||||
$tablib[30]= "DictionaryFormatCards";
|
||||
$tablib[31]= "DictionaryAccountancysystem";
|
||||
//$tablib[31]= "DictionaryAccountancysystem";
|
||||
$tablib[32]= "DictionaryAccountancyCategory";
|
||||
$tablib[33]= "DictionaryDepartment";
|
||||
$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[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[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[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";
|
||||
@ -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[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[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[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";
|
||||
@ -225,7 +231,7 @@ $tabsqlsort[27]="code ASC";
|
||||
$tabsqlsort[28]="country ASC, code ASC";
|
||||
$tabsqlsort[29]="position ASC";
|
||||
$tabsqlsort[30]="code ASC";
|
||||
$tabsqlsort[31]="pcg_version ASC";
|
||||
//$tabsqlsort[31]="pcg_version ASC";
|
||||
$tabsqlsort[32]="position ASC";
|
||||
$tabsqlsort[33]="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[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[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[14]= "code,libelle,price,organization,country_id,country";
|
||||
$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[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[31]= "pcg_version,label";
|
||||
//$tabfield[31]= "pcg_version,label";
|
||||
$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country";
|
||||
$tabfield[33]= "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[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[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[14]= "code,libelle,price,organization,country";
|
||||
$tabfieldvalue[15]= "code,libelle,width,height,unit";
|
||||
@ -299,7 +305,7 @@ $tabfieldvalue[27]= "code,libelle";
|
||||
$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country";
|
||||
$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[31]= "pcg_version,label";
|
||||
//$tabfieldvalue[31]= "pcg_version,label";
|
||||
$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country";
|
||||
$tabfieldvalue[33]= "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[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[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[14]= "code,libelle,price,organization,fk_pays";
|
||||
$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[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[31]= "pcg_version,label";
|
||||
//$tabfieldinsert[31]= "pcg_version,label";
|
||||
$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country";
|
||||
$tabfieldinsert[33]= "code,label";
|
||||
$tabfieldinsert[34]= "code,label";
|
||||
@ -375,7 +381,7 @@ $tabrowid[27]= "id";
|
||||
$tabrowid[28]= "";
|
||||
$tabrowid[29]= "";
|
||||
$tabrowid[30]= "";
|
||||
$tabrowid[31]= "";
|
||||
//$tabrowid[31]= "";
|
||||
$tabrowid[32]= "";
|
||||
$tabrowid[33]= "rowid";
|
||||
$tabrowid[34]= "rowid";
|
||||
@ -412,7 +418,7 @@ $tabcond[27]= ! empty($conf->societe->enabled);
|
||||
$tabcond[28]= ! empty($conf->holiday->enabled);
|
||||
$tabcond[29]= ! empty($conf->projet->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[33]= ! 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[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[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[14] = 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[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[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
|
||||
//$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
@ -486,7 +492,7 @@ $tabfieldcheck[27] = array();
|
||||
$tabfieldcheck[28] = array();
|
||||
$tabfieldcheck[29] = array();
|
||||
$tabfieldcheck[30] = array();
|
||||
$tabfieldcheck[31] = array();
|
||||
//$tabfieldcheck[31] = array();
|
||||
$tabfieldcheck[32] = array();
|
||||
$tabfieldcheck[33] = 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
|
||||
if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
{
|
||||
@ -659,8 +675,8 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
}
|
||||
|
||||
// Clean some parameters
|
||||
if (isset($_POST["localtax1"]) && 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["localtax1_type"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='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_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
|
||||
@ -706,7 +722,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
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]])."'";
|
||||
$i++;
|
||||
}
|
||||
@ -755,7 +771,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
}
|
||||
if ($i) $sql.=",";
|
||||
$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]])."'";
|
||||
$i++;
|
||||
}
|
||||
@ -896,7 +912,19 @@ if ($id)
|
||||
$titre.=' - '.$langs->trans($tablib[$id]);
|
||||
$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))
|
||||
{
|
||||
@ -921,6 +949,13 @@ if ($id)
|
||||
// Complete requete recherche valeurs avec critere de tri
|
||||
$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 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 '<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%">';
|
||||
|
||||
// Form to add a new line
|
||||
@ -970,12 +1007,12 @@ if ($id)
|
||||
if ($fieldlist[$field]=='taux') {
|
||||
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate");
|
||||
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') { $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') { $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]=='lang') { $valuetoshow=$langs->trans("Language"); }
|
||||
if ($fieldlist[$field]=='type') {
|
||||
@ -995,7 +1032,7 @@ if ($id)
|
||||
}
|
||||
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
|
||||
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]=='width') { $valuetoshow=$langs->trans("Width"); }
|
||||
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
|
||||
@ -1034,9 +1071,11 @@ if ($id)
|
||||
}
|
||||
|
||||
if ($id == 4) print '<td></td>';
|
||||
print '<td colspan="4">';
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
print '</td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '<td style="min-width: 26px;"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Line to enter new values
|
||||
@ -1048,7 +1087,7 @@ if ($id)
|
||||
{
|
||||
foreach ($fieldlist as $key=>$val)
|
||||
{
|
||||
if (GETPOST($val))
|
||||
if (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
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
|
||||
if ($id == 3) unset($fieldlist[2]);
|
||||
if ($id == 3) unset($fieldlist[2]); // Remove field ??? if ???
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
@ -1101,11 +1140,9 @@ if ($id)
|
||||
print '<tr><td colspan="'.$colspan.'"> </td></tr>'; // Keep to have a line with enough height
|
||||
}
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
|
||||
// List of available values in database
|
||||
// List of available record in database
|
||||
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -1113,94 +1150,132 @@ if ($id)
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$var=true;
|
||||
|
||||
$param = '&id='.$id;
|
||||
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
|
||||
$paramwithsearch = $param;
|
||||
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
|
||||
if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
|
||||
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
|
||||
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Title of lines
|
||||
print '<tr class="liste_titre liste_titre_add">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield=1; // By defaut
|
||||
$align="left";
|
||||
$sortable=1;
|
||||
$valuetoshow='';
|
||||
/*
|
||||
$tmparray=getLabelOfField($fieldlist[$field]);
|
||||
$showfield=$tmp['showfield'];
|
||||
$valuetoshow=$tmp['valuetoshow'];
|
||||
$align=$tmp['align'];
|
||||
$sortable=$tmp['sortable'];
|
||||
*/
|
||||
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
|
||||
$valuetoshow=$langs->trans($valuetoshow); // try to translate
|
||||
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
|
||||
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
|
||||
if ($fieldlist[$field]=='taux') {
|
||||
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate");
|
||||
else $valuetoshow=$langs->trans("Amount");
|
||||
$align='center';
|
||||
}
|
||||
if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $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') { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; $sortable=0; }
|
||||
if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
|
||||
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
|
||||
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
|
||||
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
|
||||
{
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
if ($id != 25) $valuetoshow.="*";
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
|
||||
if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); }
|
||||
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
|
||||
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
|
||||
if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
|
||||
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
|
||||
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
|
||||
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
|
||||
if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); }
|
||||
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
|
||||
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
|
||||
if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; }
|
||||
if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; }
|
||||
if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
|
||||
if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); }
|
||||
if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); }
|
||||
if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); }
|
||||
if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); }
|
||||
if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); }
|
||||
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
|
||||
if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); }
|
||||
if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); }
|
||||
if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); }
|
||||
if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); }
|
||||
|
||||
// Affiche nom du champ
|
||||
if ($showfield)
|
||||
{
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
// Favorite - Only activated on country dictionary
|
||||
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.'&':''), $param, 'align="center"', $sortfield, $sortorder);
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
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)
|
||||
{
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
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 '</td></tr>';
|
||||
}
|
||||
|
||||
// Title of lines
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield=1; // Par defaut
|
||||
$align="left";
|
||||
$sortable=1;
|
||||
$valuetoshow='';
|
||||
/*
|
||||
$tmparray=getLabelOfField($fieldlist[$field]);
|
||||
$showfield=$tmp['showfield'];
|
||||
$valuetoshow=$tmp['valuetoshow'];
|
||||
$align=$tmp['align'];
|
||||
$sortable=$tmp['sortable'];
|
||||
*/
|
||||
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
|
||||
$valuetoshow=$langs->trans($valuetoshow); // try to translate
|
||||
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
|
||||
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
|
||||
if ($fieldlist[$field]=='taux') {
|
||||
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate");
|
||||
else $valuetoshow=$langs->trans("Amount");
|
||||
$align='right';
|
||||
}
|
||||
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]=='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]=='organization') { $valuetoshow=$langs->trans("Organization"); }
|
||||
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
|
||||
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
|
||||
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
|
||||
{
|
||||
$valuetoshow=$langs->trans("Label");
|
||||
if ($id != 25) $valuetoshow.="*";
|
||||
}
|
||||
if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
|
||||
if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); }
|
||||
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
|
||||
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
|
||||
if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); }
|
||||
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
|
||||
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
|
||||
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
|
||||
if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); }
|
||||
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
|
||||
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
|
||||
if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; }
|
||||
if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; }
|
||||
if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
|
||||
if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); }
|
||||
if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); }
|
||||
if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); }
|
||||
if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); }
|
||||
if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); }
|
||||
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
|
||||
if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); }
|
||||
if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); }
|
||||
if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); }
|
||||
if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); }
|
||||
|
||||
// Affiche nom du champ
|
||||
if ($showfield)
|
||||
{
|
||||
print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
|
||||
print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
||||
// Lines with values
|
||||
while ($i < $num)
|
||||
{
|
||||
@ -1223,8 +1298,11 @@ if ($id)
|
||||
|
||||
if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
|
||||
|
||||
print '<td colspan="3" align="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"> </a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
||||
print ' <input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
print '<td colspan="3" align="center">';
|
||||
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
|
||||
{
|
||||
@ -1268,10 +1346,16 @@ if ($id)
|
||||
$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);
|
||||
$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])) {
|
||||
$valuetoshow=price($valuetoshow);
|
||||
}
|
||||
@ -1369,24 +1453,26 @@ if ($id)
|
||||
$key = $langs->trans('SizeUnit'.strtolower($obj->unit));
|
||||
$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') {
|
||||
if ($obj->localtax1 != 0)
|
||||
if ($obj->localtax1 != 0)
|
||||
$valuetoshow=$localtax_typeList[$valuetoshow];
|
||||
else
|
||||
$valuetoshow = '';
|
||||
$align="right";
|
||||
$align="center";
|
||||
}
|
||||
else if ($fieldlist[$field]=='localtax2_type') {
|
||||
if ($obj->localtax2 != 0)
|
||||
$valuetoshow=$localtax_typeList[$valuetoshow];
|
||||
else
|
||||
$valuetoshow = '';
|
||||
$align="right";
|
||||
$align="center";
|
||||
}
|
||||
else if ($fieldlist[$field]=='taux') {
|
||||
$valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
|
||||
$align="right";
|
||||
$align="center";
|
||||
}
|
||||
else if (in_array($fieldlist[$field],array('recuperableonly')))
|
||||
{
|
||||
@ -1417,7 +1503,9 @@ if ($id)
|
||||
$canbemodified=$iserasable;
|
||||
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:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&';
|
||||
$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
|
||||
// Only activated on country dictionary
|
||||
@ -1446,7 +1534,13 @@ if ($id)
|
||||
else print '<td> </td>';
|
||||
|
||||
// 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> </td>';
|
||||
|
||||
print "</tr>\n";
|
||||
@ -1625,16 +1719,21 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
print 'user<input type="hidden" name="type" value="user">';
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
|
||||
print '<td>';
|
||||
print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1);
|
||||
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
|
||||
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 '</td>';
|
||||
}
|
||||
elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) {
|
||||
$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 '<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>';
|
||||
}
|
||||
elseif (in_array($fieldlist[$field], array('libelle_facture'))) {
|
||||
@ -1687,12 +1786,14 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
print '<td>';
|
||||
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');
|
||||
}
|
||||
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>';
|
||||
}
|
||||
@ -1702,10 +1803,10 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
$size=''; $class='';
|
||||
if ($fieldlist[$field]=='code') $size='size="8" ';
|
||||
if ($fieldlist[$field]=='position') $size='size="4" ';
|
||||
if ($fieldlist[$field]=='libelle') $size='centpercent';
|
||||
if ($fieldlist[$field]=='tracking') $class='centpercent';
|
||||
if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
|
||||
if ($fieldlist[$field]=='tracking') $class='quatrevingtpercent';
|
||||
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>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 '</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;
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
|
||||
|
||||
@ -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);
|
||||
|
||||
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_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);
|
||||
@ -225,7 +225,7 @@ if ($action == 'edit') // Edit
|
||||
|
||||
// Max size of short lists on customer card
|
||||
$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"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -408,7 +408,7 @@ else // Show
|
||||
print "</tr>";
|
||||
|
||||
$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"> </td>';
|
||||
print "</tr>";
|
||||
|
||||
|
||||
@ -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_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_DEFAULT_FROMTYPE',GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'),'chaine',0,'',$conf->entity);
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
|
||||
exit;
|
||||
@ -89,6 +90,7 @@ $actiontypecode='';
|
||||
$trigger_name='';
|
||||
$paramname='id';
|
||||
$mode='emailfortest';
|
||||
$trackid=(($action == 'testhtml')?"testhtml":"test");
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
|
||||
if ($action == 'presend' && GETPOST('trackid') == 'test') $action='test';
|
||||
@ -391,13 +393,27 @@ if ($action == 'edit')
|
||||
// Separator
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td colspan="2"> </td></tr>';
|
||||
|
||||
|
||||
// From
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td>';
|
||||
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>';
|
||||
|
||||
// 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"> </td></tr>';
|
||||
|
||||
// From
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
|
||||
@ -409,13 +425,14 @@ if ($action == 'edit')
|
||||
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></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
@ -517,7 +534,22 @@ else
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail"));
|
||||
print '</td></tr>';
|
||||
|
||||
// Errors To
|
||||
// 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"> </td></tr>';
|
||||
|
||||
// Errors To
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
|
||||
print '<td>'.$conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
@ -539,6 +571,7 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
// Boutons actions
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
||||
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -33,10 +34,14 @@ $langs->load('other');
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
$dirstandard = "/core/menus/standard";
|
||||
$dirsmartphone = "/core/menus/smartphone";
|
||||
|
||||
$dirmenu = array($dirstandard,$dirsmartphone);
|
||||
$dirstandard = array();
|
||||
$dirsmartphone = array();
|
||||
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$dirstandard[]=$dirmenu.'standard';
|
||||
$dirsmartphone[]=$dirmenu.'smartphone';
|
||||
}
|
||||
|
||||
$action=GETPOST('action');
|
||||
|
||||
@ -244,7 +249,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
|
||||
$db->query($sql);
|
||||
$result=$db->query($sql);
|
||||
|
||||
if ($result == 0)
|
||||
{
|
||||
@ -331,7 +336,7 @@ if ($action == 'create')
|
||||
// Handler
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</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>'.$langs->trans('DetailMenuHandler').'</td></tr>';
|
||||
|
||||
|
||||
@ -319,7 +319,7 @@ print '<input type="hidden" name="action" value="add_currency">';
|
||||
print '<td>'.$form->selectCurrency('', 'code').'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="right" width="300">';
|
||||
print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('rate').'" /> ';
|
||||
print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('Rate').'" /> ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
print '</td></form></tr>';
|
||||
|
||||
|
||||
@ -24,9 +24,8 @@
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
|
||||
// required Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php';
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
@ -44,224 +43,6 @@ if (!$user->admin)
|
||||
|
||||
$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
|
||||
@ -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="action" value="update">';
|
||||
|
||||
/*
|
||||
* Parameters
|
||||
*/
|
||||
dol_fiche_head(array(), '', '', 0, 'technic');
|
||||
$head = oauthadmin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'services', '', 0, 'technic');
|
||||
|
||||
|
||||
print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
|
||||
@ -314,14 +94,17 @@ print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
$var = true;
|
||||
$i=0;
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
$supported=0;
|
||||
if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1;
|
||||
if (! $supported) continue; // show only supported
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
$i++;
|
||||
|
||||
print '<tr class="liste_titre'.($i > 1 ?' liste_titre_add':'').'">';
|
||||
// Api Name
|
||||
$label = $langs->trans($key[0]);
|
||||
print '<td>'.$label.'</td>';
|
||||
|
||||
275
htdocs/admin/oauthlogintokens.php
Normal file
275
htdocs/admin/oauthlogintokens.php
Normal 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&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> </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();
|
||||
@ -69,7 +69,7 @@ if ($action == 'setmod')
|
||||
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
|
||||
|
||||
@ -77,16 +77,31 @@ if ($action == 'set_FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS')
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
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)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -235,6 +250,10 @@ print "<br />";
|
||||
|
||||
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 '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Parameter").'</td>';
|
||||
@ -244,20 +263,32 @@ print "</tr>\n";
|
||||
|
||||
// Allow payments on different thirdparties bills but same parent company
|
||||
$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 $langs->trans("PaymentOnDifferentThirdBills");
|
||||
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 '</td><td align="right">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
|
||||
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 '<center>';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
|
||||
print '</center>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
144
htdocs/admin/resource.php
Normal file
144
htdocs/admin/resource.php
Normal 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();
|
||||
122
htdocs/admin/resource_extrafields.php
Normal file
122
htdocs/admin/resource_extrafields.php
Normal 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();
|
||||
@ -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
|
||||
@ -487,6 +504,38 @@ $var=false;
|
||||
$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> </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&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&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> </td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
|
||||
}
|
||||
*/
|
||||
|
||||
print '<tr '.$bc[$var].'><td colspan="2">';
|
||||
print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>';
|
||||
$variablename='SUPPLIER_ORDER_FREE_TEXT';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?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-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
|
||||
$langs->load("admin");
|
||||
|
||||
@ -77,32 +78,37 @@ $file_list = array('missing' => array(), 'updated' => array());
|
||||
$xmlshortfile = '/install/filelist-'.DOL_VERSION.'.xml';
|
||||
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
|
||||
$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 $langs->trans("MakeIntegrityAnalysisFrom").':<br>';
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
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 '</form>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
if (GETPOST('local'))
|
||||
if (GETPOST('target') == 'local')
|
||||
{
|
||||
if (dol_is_file($xmlfile))
|
||||
{
|
||||
@ -114,17 +120,20 @@ if (GETPOST('local'))
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if (GETPOST('remote'))
|
||||
if (GETPOST('target') == 'remote')
|
||||
{
|
||||
// TODO
|
||||
//$xmlfile = ;
|
||||
if (1 == 1)
|
||||
$xmlarray = getURLContent($xmlremote);
|
||||
|
||||
// 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
|
||||
{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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("Key"),$_SERVER["PHP_SELF"],'transkey','',$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 "</tr>\n";
|
||||
|
||||
@ -222,7 +222,7 @@ if ($mode == 'overwrite')
|
||||
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="">';
|
||||
print '</td>';
|
||||
// Limit to superadmin
|
||||
if (! empty($conf->multicompany->enabled) && !$user->entity)
|
||||
/*if (! empty($conf->multicompany->enabled) && !$user->entity)
|
||||
{
|
||||
print '<td>';
|
||||
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
|
||||
@ -230,10 +230,10 @@ if ($mode == 'overwrite')
|
||||
print '<td align="center">';
|
||||
}
|
||||
else
|
||||
{
|
||||
{*/
|
||||
print '<td align="center">';
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
|
||||
}
|
||||
//}
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="add">';
|
||||
print "</td>\n";
|
||||
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("Key"),$_SERVER["PHP_SELF"],'transkey','',$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 "</tr>\n";
|
||||
|
||||
@ -388,18 +388,18 @@ if ($mode == 'searchkey')
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$transvalue.'">';
|
||||
// Limit to superadmin
|
||||
if (! empty($conf->multicompany->enabled) && !$user->entity)
|
||||
/*if (! empty($conf->multicompany->enabled) && !$user->entity)
|
||||
{
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
{*/
|
||||
print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">';
|
||||
}
|
||||
//}
|
||||
print '</td>';
|
||||
// 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);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
@ -427,6 +427,10 @@ if ($mode == 'searchkey')
|
||||
$htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]);
|
||||
print $form->textwithpicto('', $htmltext, 1, 'warning');
|
||||
}
|
||||
/*if (! empty($conf->multicompany->enabled) && !$user->entity)
|
||||
{
|
||||
print $val;
|
||||
}*/
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
|
||||
@ -535,7 +535,8 @@ if ($id)
|
||||
{
|
||||
$showfield=1;
|
||||
$align="left";
|
||||
$valuetoshow=$obj->$fieldlist[$field];
|
||||
$fieldname=$fieldlist[$field];
|
||||
$valuetoshow=$obj->$fieldname;
|
||||
|
||||
// Show value for field
|
||||
if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
|
||||
@ -613,14 +614,15 @@ function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='')
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$fieldname = $fieldlist[$field];
|
||||
if ($fieldlist[$field] == 'lang')
|
||||
{
|
||||
print '<td>';
|
||||
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang');
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) {
|
||||
print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
|
||||
elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
|
||||
print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldname)?$obj->$fieldname:'').'" size="10" name="'.$fieldlist[$field].'"></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -631,7 +633,7 @@ function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='')
|
||||
if ($fieldlist[$field]=='libelle') $size='size="32" ';
|
||||
if ($fieldlist[$field]=='tracking') $size='size="92" ';
|
||||
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>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* 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>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -73,8 +73,10 @@ print '<table class="noborder" width="100%">'."\n";
|
||||
clearstatcache();
|
||||
|
||||
$workflowcodes=array(
|
||||
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
|
||||
// Automatic creation
|
||||
'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'),
|
||||
// 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_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.
|
||||
@ -108,7 +110,11 @@ foreach($workflowcodes as $key => $params)
|
||||
if ($oldfamily != $family)
|
||||
{
|
||||
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 "</tr>\n";
|
||||
$oldfamily = $family;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$langs->load("admin");
|
||||
|
||||
@ -42,8 +43,16 @@ if ($action == 'setproductionmode')
|
||||
|
||||
if (dolibarr_set_const($db, 'API_PRODUCTION_MODE', $status, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
$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"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -70,7 +79,7 @@ print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print "<td>".$langs->trans("Parameter")."</td>";
|
||||
print "<td>".$langs->trans("Value")."</td>";
|
||||
print '<td align="center">'.$langs->trans("Value")."</td>";
|
||||
print "<td> </td>";
|
||||
print "</tr>";
|
||||
|
||||
@ -111,9 +120,15 @@ print '<br>';
|
||||
|
||||
// Explorer
|
||||
print '<u>'.$langs->trans("ApiExporerIs").':</u><br>';
|
||||
$url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
|
||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
|
||||
if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/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";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("NotAvailableWithThisDistribution");
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -162,4 +162,60 @@ class DolibarrApi
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,27 +54,31 @@ class DictionnaryCountries extends DolibarrApi
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @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 $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
|
||||
*
|
||||
* @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();
|
||||
|
||||
// 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.
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country";
|
||||
|
||||
$nbtotalofrecords = 0;
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
|
||||
$sql.=" WHERE 1 = 1";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
$result = $this->db->query($sql);
|
||||
$nbtotalofrecords = $this->db->num_rows($result);
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
|
||||
@ -47,27 +47,32 @@ class DictionnaryTowns extends DolibarrApi
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $zipcode To filter on zipcode
|
||||
* @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
|
||||
*
|
||||
* @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();
|
||||
|
||||
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown";
|
||||
$sql.= " WHERE active = 1";
|
||||
if ($zipcode) $sql.=" AND zip LIKE '%" . $this->db->escape($zipcode) . "%'";
|
||||
if ($town) $sql.=" AND town LIKE '%" . $this->db->escape($town) . "%'";
|
||||
|
||||
$nbtotalofrecords = 0;
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
|
||||
$sql.= " WHERE t.active = 1";
|
||||
if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
|
||||
if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
$result = $this->db->query($sql);
|
||||
$nbtotalofrecords = $this->db->num_rows($result);
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
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);
|
||||
|
||||
if ($limit) {
|
||||
|
||||
@ -98,11 +98,12 @@ class Categories extends DolibarrApi
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @return array Array of category objects
|
||||
* @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
|
||||
*
|
||||
* @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;
|
||||
|
||||
$obj_ret = array();
|
||||
@ -111,21 +112,24 @@ class Categories extends DolibarrApi
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT s.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||
$sql.= ' WHERE s.entity IN ('.getEntity('categorie', 1).')';
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('categorie', 1).')';
|
||||
if (!empty($type))
|
||||
{
|
||||
$sql.= ' AND s.type='.array_search($type,Categories::$TYPES);
|
||||
$sql.= ' AND t.type='.array_search($type,Categories::$TYPES);
|
||||
}
|
||||
|
||||
$nbtotalofrecords = 0;
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
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);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
@ -258,6 +262,7 @@ class Categories extends DolibarrApi
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
@ -337,7 +342,7 @@ class Categories extends DolibarrApi
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
* @param array $data Data to validate
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user