diff --git a/ChangeLog b/ChangeLog index a17879fcbdd..13346d43763 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,7 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. -***** ChangeLog for 3.9 compared to 3.8.* ***** +***** ChangeLog for 3.9.0 compared to 3.8.* ***** For users: NEW: A new and more modern look for "eldy" theme. NEW: Introduce a new theme called "Material Design". diff --git a/build/debian/dolibarr.desktop b/build/debian/dolibarr.desktop index f4b471edf13..dd59be792d2 100644 --- a/build/debian/dolibarr.desktop +++ b/build/debian/dolibarr.desktop @@ -22,5 +22,6 @@ Type=Application Categories=Office StartupNotify=true InitialPreference=5 +Keywords=erp,crm,billing,customer,supplier,stock,agenda,project,order,shipment #NoDisplay=true #OnlyShowIn=GNOME diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index 099aab0675a..57ab33464bc 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -26,7 +26,7 @@ $force_install_nophpinfo='1'; $force_install_lockinstall='444'; // Value to overwrite path to use shared libraries/fonts instead of embedded one. -// If we enable/disable libraries declaration during install, we must also check they are +// If during install, we enable/disable declaration to use non embedded libraries, we must also check they are // - not removed from package (see rm in rules file), // - declared into dependencies (see Depends in control file) //$force_dolibarr_lib_TCPDF_PATH=''; diff --git a/build/debian/patches/use-etc-dolibarr-conf.patch b/build/debian/patches/use-etc-dolibarr-conf.patch index f911ad18af0..3bca20ee66f 100644 --- a/build/debian/patches/use-etc-dolibarr-conf.patch +++ b/build/debian/patches/use-etc-dolibarr-conf.patch @@ -34,7 +34,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -69,8 +69,8 @@ $conffiletoshowshort = "conf.php"; @@ -47,4 +47,4 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index ac5529d7d8f..c8b3c7664e2 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -354,15 +354,18 @@ if ($nboftargetok) { chdir("$SOURCE"); # Test that the ChangeLog is ok - $ret=`grep "ChangeLog for $MAJOR.$MINOR\.$BUILD" "$SOURCE/ChangeLog" 2>&1`; + $TMPBUILDTOCHECKCHANGELOG=$BUILD; + $TMPBUILDTOCHECKCHANGELOG =~ s/\-rc//; + print "Check if ChangeLog is ok for version $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG\n"; + $ret=`grep "ChangeLog for $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG" "$SOURCE/ChangeLog" 2>&1`; if (! $ret) { - print "Error: The ChangeLogFile was not updated. Run the following command first:\n"; - if (! $BUILD) + 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`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; } - else + 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'; } @@ -523,25 +526,27 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/jqueryFileTree/connectors/jqueryFileTree.pl`; # Avoid errors into rpmlint $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/template`; # Package not valid for most linux distributions (errors reported into compile.js). Package should be embed by modules to avoid problems. $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpmailer`; # Package not valid for most linux distributions (errors reported into file LICENSE). Package should be embed by modules to avoid problems. - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/adapters`; # Keep this removal in case we embed libraries + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/adapters`; # Keep this removal in case we embed libraries + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries #$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/datatables/extras/TableTools/swf`; # Source of this flash is not available + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/datatables/extensions/TableTools/swf`; # Source of this flash is not available + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/datatables/extras/TableTools/swf`; # Source of this flash is not available $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/select2/release.sh`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/doc`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/example`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/test`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PCLZip`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/license.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/.gitattributes`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Classes/license.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PDF`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Examples`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/PHPExcel/Shared/PDF`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/PHPExcel/Shared/PCLZip`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/unitTests`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/license.md`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`; @@ -549,6 +554,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/savant`; } @@ -837,17 +843,28 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/rpm`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/zip`; # Removed duplicate license files - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/scayt/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/wsc/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/scayt/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/wsc/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source/plugins/scayt/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source/plugins/wsc/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/plugins/scayt/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/plugins/wsc/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/php-iban/LICENSE`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/flot/LICENSE.txt`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/freefont-20120503/COPYING`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/ColReorder/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/ColVis/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/FixedColumns/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/Responsive/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/license.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/select2/LICENSE`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mike42/escpos-php/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mobiledetect/mobiledetectlib/LICENSE.txt`; + + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-20120503/COPYING`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_2.0/COPYING`; # Removed files we don't need - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source`; # Rename upstream changelog to match debian rules $ret=`mv $BUILDROOT/$PROJECT.tmp/ChangeLog $BUILDROOT/$PROJECT.tmp/changelog`; @@ -909,8 +926,11 @@ if ($nboftargetok) { $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/modMyModule.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_api_class.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_card.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_class.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_page.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_list.php`; + $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_script.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_webservice_server.php`; $cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.php' -type f -exec chmod 755 {} \\; "; $ret=`$cmd`; @@ -1130,12 +1150,16 @@ if ($nboftargetok) { if ($target eq 'SF') { $destFolder="$NEWPUBLISH/$filestoscan{$file}/".$MAJOR.'.'.$MINOR.'.'.$BUILD; - print "Publish file ".$file." to $NEWPUBLISH/".$filestoscan{$file}."\n"; + print "Publish file ".$file." to $NEWPUBLISH/".$filestoscan{$file}."/".$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; } else { - $destFolder="$NEWPUBLISH"; - print "Publish file ".$file." to $NEWPUBLISH\n"; + $dirnameonly=$file; + $dirnameonly =~ s/.*\/([^\/]+)\/[^\/]+$/$1/; + $filenameonly=$file; + $filenameonly =~ s/.*\/[^\/]+\/([^\/])+$/$1/; + $destFolder="$NEWPUBLISH/$dirnameonly"; + print "Publish file ".$file." to $NEWPUBLISH/".$dirnameonly."\n"; } # mkdir @@ -1156,7 +1180,7 @@ if ($nboftargetok) { print "$command\n"; my $ret=`$command 2>&1`; - $command="rsync -s $OPTIONUPDATEDIST -e 'ssh' \"$file\" \"".$destFolder."\""; + $command="rsync -s -e 'ssh' \"$file\" \"".$destFolder."\""; print "$command\n"; my $ret=`$command 2>&1`; print "$ret\n"; diff --git a/build/rpm/dolibarr-forrpm.patch b/build/rpm/dolibarr-forrpm.patch index 41f27e3b791..6c484345be9 100644 --- a/build/rpm/dolibarr-forrpm.patch +++ b/build/rpm/dolibarr-forrpm.patch @@ -25,7 +25,7 @@ diff -up htdocs/install/inc.php.patch htdocs/install/inc.php +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined diff -up htdocs/support/inc.php.patch htdocs/support/inc.php --- htdocs/support/inc.php.patch 2011-09-03 02:34:39.606952000 +0200 +++ htdocs/support/inc.php 2011-09-03 02:33:59.814952000 +0200 @@ -39,4 +39,4 @@ diff -up htdocs/support/inc.php.patch htdocs/support/inc.php +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 7189b7b6dc2..0cd72f99cdd 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -183,6 +183,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -200,6 +201,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 0e28ff594ea..043088bf5d6 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -263,6 +263,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -280,6 +281,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 639ec2b52dd..3f439bb4a9a 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -180,6 +180,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -197,6 +198,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 23f42adaa0a..cc21d7083b3 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -191,6 +191,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -208,6 +209,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 80e3e38f438..28333b3edee 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -237,7 +237,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($conf->liste_limit+1, $offset); +$sql.= $db->plimit($limit+1, $offset); dol_syslog($script_file, LOG_DEBUG); @@ -257,9 +257,9 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - - print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$params,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies'); - + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + print '
'; if ($optioncss != '') print ''; @@ -359,7 +359,7 @@ if ($resql) $i = 0; - while ($i < $num) + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); if ($obj) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 8bb5befa991..b7d563c9621 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,6 +1,6 @@ - - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -20,13 +20,9 @@ */ /** - * \file htdocs/accountancy/admin/productaccount.php + * \file htdocs/accountancy/admin/productaccount.php * \ingroup Accounting Expert -<<<<<<< HEAD - * \brief To define accounting account on product / service -======= - * \brief Onglet de gestion de parametrages des ventilations ->>>>>>> refs/remotes/origin/3.9 + * \brief To define accounting account on product / service */ require '../../main.inc.php'; @@ -296,7 +292,7 @@ if ($result) { print ''; print ''; - print ' '; + print ' '; print ''; print ''; print ' '; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php new file mode 100644 index 00000000000..16027a42af4 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -0,0 +1,281 @@ + + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2015 Alexandre Spangaro + * + * 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 . + * + */ + +/** + * \file htdocs/accountancy/bookkeeping/balance.php + * \ingroup Accounting Expert + * \brief Balance of book keeping + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; + +// Langs +$langs->load("accountancy"); + +$page = GETPOST("page"); +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); +$action = GETPOST('action', 'alpha'); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); + +$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); +if ($search_accountancy_code_start == - 1) { + $search_accountancy_code_start = ''; +} +$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); +if ($search_accountancy_code_end == - 1) { + $search_accountancy_code_end = ''; +} + +if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { + $action = 'export_csv'; +} + +$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; + +$offset = $limit * $page; + +$object = new BookKeeping($db); + +$formventilation = new FormVentilation($db); +$formother = new FormOther($db); +$form = new Form($db); + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_date_start = ''; + $search_date_end = ''; +} + +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_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; +} + +/* + * Action + */ +if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $journal = 'bookkepping'; + + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + + $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + foreach ( $object->lines as $line ) { + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { + $sep = ";"; + // Model Cegid Expert Export + $date = dol_print_date($line->doc_date, '%d%m%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accountg($line->numero_compte) . $sep; + print ' ' . $sep; + print $line->sens . $sep; + print price($line->montant) . $sep; + print dol_trunc($line->label_compte, 32) . $sep; + print $line->doc_ref . $sep; + + /*print $line->piece_num . $sep; + print length_accounta($line->code_tiers) . $sep; + print . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep;*/ + + print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + + // Std export + $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); + print $date . $sep; + print $line->doc_ref . $sep; + print length_accounta($line->numero_compte) . $sep; + print length_accountg($line->code_tiers) . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + + /*print $line->piece_num . $sep; + print $line->label_compte . $sep; + print price($line->montant) . $sep; + print $line->sens . $sep;*/ + print $line->code_journal . $sep; + print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { + + // Coala export + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accounta($line->numero_compte) . $sep; + print $line->piece_num . $sep; + print $line->doc_ref . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + print 'E' . $sep; + print length_accountg($line->code_tiers) . $sep; + print "\n"; + } + } +} + +else { + + $title_page = $langs->trans("AccountBalance") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); + + llxHeader('', $title_page); + + /* + * List + */ + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); + + print ''; + print '
' . "\n"; + print '
'; + + print '
'; + + print '
'; + print $langs->trans('DateStart') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print $langs->trans('DateEnd') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + print '
'; + + print ''; + print ''; + print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_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, "", 'width="60" align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print "\n"; + + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + + print ''; + + $var = True; + + $total_debit = 0; + $total_credit = 0; + + foreach ( $object->lines as $line ) { + $var = ! $var; + + $total_debit += $line->debit; + $total_credit += $line->credit; + + print ""; + + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "
'; + print $langs->trans('From'); + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); + print '
'; + print $langs->trans('To'); + print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); + print '
   '; + print ''; + print ' '; + print ''; + print '
' . length_accountg($line->numero_compte) . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit - $line->debit) . ''; + print '
'; + print price($total_debit); + print ''; + print price($total_credit); + print '' . price($total_credit - $total_debit) . '
"; + print ''; + + llxFooter(); +} +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index e9751e0f12e..3ec0a704407 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -208,8 +208,8 @@ print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, "", $sortfield, $sortorder); -print ''; -print ''; +print ''; +print ''; print "\n"; print ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index dbca9aeddd9..0015dfbf9e9 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015-*2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -642,6 +642,86 @@ class BookKeeping extends CommonObject } } + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { + 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) { + foreach ( $filter as $key => $value ) { + if ($key == 't.doc_date') { + $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { + $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { + $sqlwhere[] = $key . '=' . $value; + } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + } else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + } + + $sql .= ' GROUP BY t.numero_compte'; + + 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); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ( $obj = $this->db->fetch_object($resql) ) { + $line = new BookKeepingLine(); + + $line->numero_compte = $obj->numero_compte; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $this->lines[] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + /** * Update object into database * diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 86232bb2029..7d9778f72b8 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -94,6 +94,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " 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) . ")"; } diff --git a/htdocs/adherents/cotisations.php b/htdocs/adherents/cotisations.php index 7ff98ceb503..301664fab83 100644 --- a/htdocs/adherents/cotisations.php +++ b/htdocs/adherents/cotisations.php @@ -1,7 +1,7 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2016 Laurent Destailleur * * 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 @@ -32,19 +32,20 @@ $langs->load("members"); $filter=$_GET["filter"]; $statut=isset($_GET["statut"])?$_GET["statut"]:1; -$search_ref=GETPOST('search_ref'); -$search_lastname=GETPOST('search_lastname'); -$search_login=GETPOST('search_login'); -$search_note=GETPOST('search_note'); +$search_ref=GETPOST('search_ref','alpha'); +$search_lastname=GETPOST('search_lastname','alpha'); +$search_login=GETPOST('search_login','alpha'); +$search_note=GETPOST('search_note','alpha'); $search_account=GETPOST('search_account','int'); -$search_amount=GETPOST('search_amount','int'); +$search_amount=GETPOST('search_amount','alpha'); $optioncss = GETPOST('optioncss','alpha'); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0 ; } -$offset = $conf->liste_limit * $page ; +$offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } @@ -101,28 +102,21 @@ if ($search_ref) if (is_numeric($search_ref)) $sql.= " AND (c.rowid = ".$db->escape($search_ref).")"; else $sql.=" AND 1 = 2"; // Always wrong } -if ($search_lastname) -{ - $sql.= " AND (d.firstname LIKE '%".$db->escape($search_lastname)."%' OR d.lastname LIKE '%".$db->escape($search_lastname)."%' OR d.societe LIKE '%".$db->escape($search_lastname)."%')"; -} -if ($search_login) -{ - $sql.= " AND d.login LIKE '%".$db->escape($search_login)."%'"; -} -if ($search_note) -{ - $sql.= " AND c.note LIKE '%".$db->escape($search_note)."%'"; -} -if ($search_account > 0) -{ - $sql.= " AND b.fk_account = ".$search_account; -} -if ($search_amount) -{ - $sql.=" AND c.cotisation = ".$db->escape($search_amount); -} +if ($search_lastname) $sql.= natural_search(array('d.firstname','d.lastname','d.societe'), $search_lastname); +if ($search_login) $sql.= natural_search('c.cotisation', $search_login); +if ($search_note) $sql.= natural_search('c.note', $search_note); +if ($search_account > 0) $sql.= " AND b.fk_account = ".$search_account; +if ($search_amount) $sql.= natural_search('c.cotisation', $search_amount, 1); $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($conf->liste_limit+1, $offset); + +$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); $result = $db->query($sql); if ($result) @@ -133,24 +127,29 @@ if ($result) $title=$langs->trans("ListOfSubscriptions"); if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; - $param=""; + $param=''; $param.="&statut=$statut&date_select=$date_select"; - if ($search_lastname) $param.="&search_lastname=".$search_lastname; if ($search_login) $param.="&search_login=".$search_login; if ($search_acount) $param.="&search_account=".$search_account; if ($search_amount) $param.="&search_amount=".$search_amount; if ($optioncss != '') $param.='&optioncss='.$optioncss; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num); + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); if ($sall) { print $langs->trans("Filter")." (".$langs->trans("Ref").", ".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; } - - print ''; - if ($optioncss != '') print ''; print ''; print ''; @@ -164,7 +163,8 @@ if ($result) } print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"c.dateadh",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"c.datef",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"c.cotisation",$param,"",'colspan="2" align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"c.cotisation",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre(''); print "\n"; @@ -199,7 +199,7 @@ if ($result) print ''; // Action column - print ''; @@ -270,7 +270,9 @@ if ($result) print '\n"; // Price - print ''; + print ''; + + print ''; print ""; @@ -290,7 +292,8 @@ if ($result) } print ''; print ''; - print '\n"; + print '\n"; + print ''; print "\n"; print "
'; + print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; print ''.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->cotisation).''.price($objp->cotisation).'
  '.price($total)."'.price($total)."
"; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index b19c6b2e35d..aea09f73124 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -50,14 +50,15 @@ $catid = GETPOST("catid",'int'); $sall=GETPOST("sall"); $optioncss = GETPOST('optioncss','alpha'); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page ; +$offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder=($filter=='outofdate'?"ASC":"DESC"); } +if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers @@ -143,6 +144,7 @@ if ($filter == 'outofdate') $sql.=" AND (datefin IS NULL OR datefin < '".$db->id $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql.= $db->order($sortfield,$sortorder); // Count total nb of records with no order and no limits $nbtotalofrecords = 0; @@ -152,9 +154,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if ($resql) $nbtotalofrecords = $db->num_rows($resql); else dol_print_error($db); } -// Add order and limit -$sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($conf->liste_limit+1, $offset); +// Add limit +$sql.= $db->plimit($limit+1, $offset); dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); @@ -185,7 +186,8 @@ if ($resql) $titre.=" (".$membertype->libelle.")"; } - $param=""; + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($statut != "") $param.="&statut=".$statut; if ($search_nom) $param.="&search_nom=".$search_nom; if ($search_login) $param.="&search_login=".$search_login; @@ -193,12 +195,17 @@ if ($resql) if ($filter) $param.="&filter=".$filter; if ($type > 0) $param.="&type=".$type; if ($optioncss != '') $param.='&optioncss='.$optioncss; - print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); - - print ''; + + print ''; if ($optioncss != '') print ''; print ''; + print ''; + print ''; + print ''; + print ''; + print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -227,6 +234,10 @@ if ($resql) print ''; print ''; + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + { + print ''; + } print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); @@ -245,6 +256,8 @@ if ($resql) // Line for filters fields print ''; + + print ''; print ''; @@ -303,6 +316,11 @@ if ($resql) $var=!$var; print ""; + + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + { + print ''; + } // Ref print "
 
 '; print '
'.($i+1).'"; @@ -396,10 +414,7 @@ if ($resql) print "
\n"; print '
'; - if ($num > $conf->liste_limit) - { - print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); - } + if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1); } else { diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index ea05c683ef7..85682960df9 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -2,8 +2,8 @@ /* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2011-2015 Juanjo Menent ù - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2011-2016 Juanjo Menent ù + * Copyright (C) 2015 Claudio Aschieri * * 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 @@ -38,21 +38,34 @@ if (!$user->admin) $action=GETPOST('action','alpha'); + +/* + * Actions + */ + // Shipment note +if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) +{ + // This option should always be set to on when module is on. + dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); +} +/* if ($action == 'activate_sending') { dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); header("Location: confexped.php"); exit; } -else if ($action == 'disable_sending') +if ($action == 'disable_sending') { dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity); header("Location: confexped.php"); exit; } +*/ + // Delivery note -else if ($action == 'activate_delivery') +if ($action == 'activate_delivery') { dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); // We must also enable this dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1",'chaine',0,'',$conf->entity); @@ -68,8 +81,9 @@ else if ($action == 'disable_delivery') /* - * Affiche page + * View */ + $dir = DOL_DOCUMENT_ROOT."/core/modules/expedition/"; $form=new Form($db); @@ -102,16 +116,15 @@ print ''.$langs->trans("SendingsAbility").''; print ''; print ''; print ''; - -if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) +print $langs->trans("Required"); +/*if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } else { print ''.img_picto($langs->trans("Enabled"),'switch_on').''; -} - +}*/ print ""; print ''; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 0a744a047a5..14332ceee63 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005 Simon Tosser - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2001-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005 Simon Tosser + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2016 Raphaël Doursenaud * * 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 @@ -164,7 +165,7 @@ if ($action == 'edit') foreach($delays as $delay) { $var=!$var; - $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print ''; print ''.img_object('',$delay['img']).''; print ''.$langs->trans('Delays_'.$delay['code']).''; @@ -211,7 +212,7 @@ else foreach($delays as $delay) { $var=!$var; - $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print ''; print ''.img_object('',$delay['img']).''; print ''.$langs->trans('Delays_'.$delay['code']).''; @@ -261,24 +262,24 @@ $text=''; $options='height="60px"'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 18c112f987f..aac782cb37b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1,15 +1,16 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand - * Copyright (C) 2011 Remy Younes - * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2015 Alexandre Spangaro - * Copyright (C) 2015 Ferran Marcet +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011 Remy Younes + * Copyright (C) 2012-2015 Marcos García + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2011-2015 Alexandre Spangaro + * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2016 Raphaël Doursenaud * * 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 @@ -1162,7 +1163,7 @@ if ($id) { $showfield=1; $align="left"; - $valuetoshow=$obj->$fieldlist[$field]; + $valuetoshow=$obj->{$fieldlist[$field]}; if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; @@ -1199,77 +1200,77 @@ if ($id) else if ($fieldlist[$field]=='libelle_facture') { $langs->load("bills"); $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=nl2br($valuetoshow); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { $langs->load("propal"); $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { $langs->load('agenda'); $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { $langs->load("bills"); $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { $langs->load("orders"); $key=$langs->trans($obj->code); - $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]}; } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { $langs->load("sendings"); $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; @@ -1279,16 +1280,16 @@ if ($id) } else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow=$langs->trans($obj->$fieldlist[$field]); + $valuetoshow=$langs->trans($obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->$fieldlist[$field]); + $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='localtax1_type') { @@ -1504,7 +1505,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { if (! in_array('country',$fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { - $country_id = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); + $country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); print ''; @@ -1518,7 +1519,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } elseif ($fieldlist[$field] == 'region_id') { - $region_id = (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:0); + $region_id = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:0); print ''; @@ -1533,21 +1534,21 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') elseif ($fieldlist[$field] == 'type_template') { print ''; } // Le type de l'element (pour les type de contact) elseif ($fieldlist[$field] == 'element') { print ''; } // La source de l'element (pour les type de contact) elseif ($fieldlist[$field] == 'source') { print ''; } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") @@ -1558,18 +1559,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') { print ''; } 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 print ''; } elseif (in_array($fieldlist[$field], array('libelle_facture'))) { - print ''; + print ''; } elseif (in_array($fieldlist[$field], array('content'))) { @@ -1580,18 +1581,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') else print ''; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { - print ''; + print ''; } - elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { - print ''; + elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { + print ''; } elseif ($fieldlist[$field]=='unit') { print ''; } // Le type de taxe locale elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') { print ''; } elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') @@ -1634,7 +1635,7 @@ function fieldList($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 ''; + print ''; print ''; } } diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index b5485392816..c721f63a050 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -85,7 +85,7 @@ if ($action == 'add_currency') if ($currency->create($user) > 0) { - if ($currency->addRate($rate)) setEventMessages($langs->trans('SuccessAddRate'), array()); + if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array()); else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors'); } else setEventMessages($langs->trans('ErrorAddCurrencyFail'), array()); @@ -112,7 +112,7 @@ elseif ($action == 'update_currency') if ($currency->fetch($fk_multicurrency) > 0) { - if ($currency->delete() > 0) setEventMessages($langs->trans('SuccessDeleteCurrency'), array()); + if ($currency->delete() > 0) setEventMessages($langs->trans('RecordDeleted'), array()); else setEventMessages($langs->trans('ErrorDeleteCurrencyFail'), array(), 'errors'); } } @@ -131,10 +131,13 @@ if ($resql) } } + /* * View */ -$page_name = "multicurrency"; + +$page_name = "MultiCurrency"; + llxHeader('', $langs->trans($page_name)); // Subheader @@ -147,7 +150,7 @@ $head = multicurrencyAdminPrepareHead(); dol_fiche_head( $head, 'settings', - $langs->trans("Module500000Name"), + $langs->trans("ModuleSetup"), 0, "multicurrency" ); diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 2adf79a6174..2100230fdb4 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -1,5 +1,6 @@ + * Copyright (C) 2016 Raphaël Doursenaud * * 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,7 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); -// Supported OAUTH (a provider is supported when a file xxx_oauth2callback.php is available into htdocs/core/modules/oauth) +// 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 @@ -346,14 +347,14 @@ foreach ($list as $key) $var = !$var; print ''; print ''; - print ''; // Api Secret $var = !$var; print ''; print ''; - print ''; } @@ -368,4 +369,4 @@ print ''; llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php new file mode 100644 index 00000000000..41737f7a9d5 --- /dev/null +++ b/htdocs/admin/supplier_payment.php @@ -0,0 +1,220 @@ + + * + * 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 . + */ + +/** + * \file htdocs/admin/payment.php + * \ingroup facture + * \brief Page to setup invoices payments + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + +$langs->load("admin"); +$langs->load("errors"); +$langs->load('other'); +$langs->load('bills'); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scandir','alpha'); + + +/* + * Actions + */ + +if ($action == 'updateMask') +{ + $maskconstsupplierpayment=GETPOST('maskconstsupplierpayment','alpha'); + $masksupplierpayment=GETPOST('masksupplierpayment','alpha'); + if ($maskconstsupplierpayment) $res = dolibarr_set_const($db,$maskconstsupplierpayment,$masksupplierpayment,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + if ($action == 'setmod') +{ + dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity); +} + +/* + * View + */ + +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + +llxHeader("",$langs->trans("SupplierPaymentSetup"),'EN:Supplier_Payment_Configuration|FR:Configuration_module_paiement_fournisseur'); + +$form=new Form($db); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("SupplierPaymentSetup"),$linkback,'title_setup'); + +print "
"; + +$head = supplierorder_admin_prepare_head(); +dol_fiche_head($head, 'supplierpayment', $langs->trans("SupplierPayment"), 0, 'invoice'); + +/* + * Numbering module + */ + +print load_fiche_titre($langs->trans("SupplierPaymentsNumberingModule")); + +print '
'; -print img_picto_common($text,'weather/weather-clear.png',$options); +print img_weather($text,'weather-clear.png',$options); print '= '.$level0.'         '; -print img_picto_common($text,'weather/weather-few-clouds.png',$options); +print img_weather($text,'weather-few-clouds.png',$options); print '<= '.$level1.'         '; -print img_picto_common($text,'weather/weather-clouds.png',$options); +print img_weather($text,'weather-clouds.png',$options); print '<= '.$level2.'
'; -print img_picto_common($text,'weather/weather-many-clouds.png',$options); +print img_weather($text,'weather-many-clouds.png',$options); print '<= '.$level3.'         '; -print img_picto_common($text,'weather/weather-storm.png',$options); +print img_weather($text,'weather-storm.png',$options); print '> '.$level3.'                 '; print ''; print ''; print ''; print ''; - print $form->selectarray('type_template', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('type_template', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectarray('element', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('element', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectarray('source', $sourceList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('source', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectyesno($fieldlist[$field],(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),1); + print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1); print ''; - print ''; + print ''; print ''; if ($context != 'hide') { - //print ''; - $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); + //print ''; + $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); print $doleditor->Create(1); } else print ' '; print ''; @@ -1601,14 +1602,14 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') 'point' => $langs->trans('SizeUnitpoint'), 'inch' => $langs->trans('SizeUnitinch') ); - print $form->selectarray('unit', $units, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), 0, 0, 0); + print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0); print ''; - print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print '
'; + print ''; print '
'; + print ''; print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; + + while (($file = readdir($handle))!==false) + { + if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/','',$file); + // For compatibility + if (! is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_supplier_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/',$classname,$reg); + if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + + $classname = preg_replace('/\-.*$/','',$classname); + if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; + + $module = new $classname($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $var = !$var; + print ''; + + // Show example of numbering module + print ''."\n"; + + print ''; + + $payment=new PaiementFourn($db); + $payment->initAsSpecimen(); + + // Example + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$payment); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; + + } + } + } + } + closedir($handle); + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'; + echo preg_replace('/\-.*$/','',preg_replace('/mod_supplier_payment_/','',preg_replace('/\.php$/','',$file))); + print "\n"; + + print $module->info(); + + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; + if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (! empty($module->error)) dol_htmloutput_mesg($module->error,'','error',1); + } + + print '
'; + +dol_fiche_end(); + + +llxFooter(); + +$db->close(); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index bdd84a50a7f..28feb8ab23e 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -69,21 +69,16 @@ print "
"; // List of workflow we can enable print ''."\n"; -print ''."\n"; -print ' '; -print ' '; -print "\n"; clearstatcache(); $workflowcodes=array( - 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'), - 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), + 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), + 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->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. - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'), - + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>40, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>50, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'), ); if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) @@ -94,16 +89,30 @@ if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts[' } } +// TODO We must sort on position here + $nbqualified=0; +$oldfamily=''; foreach($workflowcodes as $key => $params) { $picto=$params['picto']; $enabled=$params['enabled']; + $family=$params['family']; if (! verifCond($enabled)) continue; $nbqualified++; - $var = !$var; + + if ($oldfamily != $family) + { + print ''."\n"; + print ' '; + print ' '; + print "\n"; + $oldfamily = $family; + } + + $var = !$var; print "\n"; print "'; // Status - print ''; + print ''; // Nb of distinct emails print '
'.$langs->trans("Description").''.$langs->trans("Status").'
'.$langs->trans("Description").''.$langs->trans("Status").'
".img_object('', $picto).$langs->trans('desc'.$key); if (! empty($params['warning'])) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 7b42637ed7b..c894647bb29 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -305,28 +305,28 @@ $param.="&maxprint=".$maxprint; // Show navigation bar if (empty($action) || $action=='show_month') { - $nav ="".img_previous($langs->trans("Previous"))."\n"; + $nav ="".img_previous($langs->trans("Previous"), 'class="valignbottom"')."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%b %Y"); $nav.=" \n"; - $nav.="".img_next($langs->trans("Next"))."\n"; + $nav.="".img_next($langs->trans("Next"), 'class="valignbottom"')."\n"; $nav.="   (".$langs->trans("Today").")"; $picto='calendar'; } if ($action=='show_week') { - $nav ="".img_previous($langs->trans("Previous"))."\n"; + $nav ="".img_previous($langs->trans("Previous"), 'class="valignbottom"')."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week; $nav.=" \n"; - $nav.="".img_next($langs->trans("Next"))."\n"; + $nav.="".img_next($langs->trans("Next"), 'class="valignbottom"')."\n"; $nav.="   (".$langs->trans("Today").")"; $picto='calendarweek'; } if ($action=='show_day') { - $nav ="".img_previous($langs->trans("Previous"))."\n"; + $nav ="".img_previous($langs->trans("Previous"), 'class="valignbottom"')."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,$day,$year),"daytextshort"); $nav.=" \n"; - $nav.="".img_next($langs->trans("Next"))."\n"; + $nav.="".img_next($langs->trans("Next"), 'class="valignbottom"')."\n"; $nav.="   (".$langs->trans("Today").")"; $picto='calendarday'; } diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 447a247ad56..ed8227a1cb8 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -72,11 +72,11 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) $filtert=$user->id; } +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0 ; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; if (! $sortorder) { @@ -142,20 +142,8 @@ $form=new Form($db); $userstatic=new User($db); $nav=''; -$nav.='
'; -if ($optioncss != '') $nav.= ''; -if ($actioncode) $nav.=''; -if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.=''; -if ($filter) $nav.=''; -if ($filtert) $nav.=''; -if ($socid) $nav.=''; -if ($showbirthday) $nav.=''; -if ($pid) $nav.=''; -if ($type) $nav.=''; -if ($usergroup) $nav.=''; $nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1); $nav.=' '; -$nav.='
'; $now=dol_now(); @@ -166,6 +154,7 @@ llxHeader('',$langs->trans("Agenda"),$help_url); $listofextcals=array(); $param=''; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($actioncode != '') $param.="&actioncode=".$actioncode; if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; if ($filter) $param.="&filter=".$filter; @@ -220,6 +209,14 @@ if ($dateselect > 0) $sql.= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AN if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'"; if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'"; $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); //print $sql; @@ -279,13 +276,30 @@ if ($resql) $s = $hookmanager->resPrint; } - print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $link, $num, 0, '', 0, $nav); - - print '
'."\n"; + print ''."\n"; if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $nav=''; + if ($optioncss != '') $nav.= ''; + if ($actioncode) $nav.=''; + if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.=''; + if ($filter) $nav.=''; + if ($filtert) $nav.=''; + if ($socid) $nav.=''; + if ($showbirthday) $nav.=''; + if ($pid) $nav.=''; + if ($usergroup) $nav.=''; + print $nav; + + print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $link, $num, -1 * $nbtotalofrecords, '', 0, $nav, '', $limit); - $i = 0; + $i = 0; print ''; print ''; print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 318e96f7122..35b89ff129d 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -242,10 +242,10 @@ $max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); $tmpday = $first_day; -$nav ="".img_previous($langs->trans("Previous"))."\n"; +$nav ="".img_previous($langs->trans("Previous"), 'class="valignbottom"')."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week; $nav.=" \n"; -$nav.="".img_next($langs->trans("Next"))."\n"; +$nav.="".img_next($langs->trans("Next"), 'class="valignbottom"')."\n"; $nav.="   (".$langs->trans("Today").")"; $picto='calendarweek'; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 6a33e83e585..e62af271c49 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Eric Seigne - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -37,11 +37,11 @@ $action=GETPOST('action','alpha'); $month=GETPOST('month'); $year=GETPOST('year'); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0 ; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="a.datep"; @@ -84,6 +84,14 @@ $sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; //$sql.= " AND percent = 100"; $sql.= " GROUP BY year, month, df"; $sql.= " ORDER BY year DESC, month DESC, df DESC"; + +$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); //print $sql; @@ -93,7 +101,18 @@ if ($resql) { $num = $db->num_rows($resql); - print_barre_liste($langs->trans("Actions"), $page, $_SERVER["PHP_SELF"],'',$sortfield,$sortorder,'',$num); + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("Actions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); $i = 0; print '
'; @@ -143,6 +162,9 @@ if ($resql) $i++; } print "
"; + + print '
'; + $db->free($resql); } else diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 93f9b243624..727e9904fef 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; @@ -66,6 +67,7 @@ $form = new Form($db); $formfile = new FormFile($db); $companystatic=new Societe($db); if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); +if (! empty($conf->supplier_proposal->enabled)) $supplierproposalstatic=new SupplierProposal($db); if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); @@ -208,6 +210,86 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) } + +/* + * Draft supplier proposals + */ +if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) +{ + $langs->load("supplier_proposal"); + + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql.= ", s.code_client"; + $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.fk_statut = 0"; + $sql.= " AND p.fk_soc = s.rowid"; + $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND s.rowid = ".$socid; + + $resql=$db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num > 0) + { + $i = 0; + $var=true; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print ''; + print ''; + print ''; + $i++; + $total += $obj->total_ht; + } + if ($total>0) + { + $var=!$var; + print '"; + } + } + else + { + $var=!$var; + print ''; + } + print "
'.$langs->trans("SupplierProposalsDraft").($num?' '.$num.'':'').'
'; + $supplierproposalstatic->id=$obj->rowid; + $supplierproposalstatic->ref=$obj->ref; + $supplierproposalstatic->total_ht = $obj->total_ht; + $supplierproposalstatic->total_tva = $obj->total_tva; + $supplierproposalstatic->total_ttc = $obj->total_ttc; + print $supplierproposalstatic->getNomUrl(1); + print ''; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1,'customer',16); + print ''.price($obj->total_ht).'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoProposal").'

"; + + $db->free($resql); + } + else + { + dol_print_error($db); + } +} + + /* * Draft orders */ diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e54aeb1c8a5..b5f33b5f689 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * * 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 @@ -222,6 +222,8 @@ if (empty($reshook)) $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); + // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) $substitutionarray=array( '__ID__' => $obj->source_id, @@ -234,6 +236,7 @@ if (empty($reshook)) '__OTHER3__' => $other3, '__OTHER4__' => $other4, '__OTHER5__' => $other5, + '__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter) '__CHECK_READ__' => '', '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' ); @@ -818,7 +821,9 @@ else print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4); + if ($object->statut == 2) print ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.')'; + print'
'; @@ -1093,10 +1098,10 @@ else } print '
'; - + dol_fiche_end(); - - + + print "\n"; print '
'."\n"; @@ -1108,7 +1113,7 @@ else print load_fiche_titre($langs->trans("EMail"),'',''); dol_fiche_head(); - + print ''; // Subject @@ -1175,7 +1180,7 @@ else print '
'; dol_fiche_end(); - + print '
'; print ''; print '     '; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index d3aa3557c89..0c133fac6df 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -38,11 +38,12 @@ $langs->load("mails"); if (! $user->rights->mailing->lire || $user->societe_id > 0) accessforbidden(); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; @@ -95,6 +96,7 @@ if ($action == 'add') // Add targets into database $obj = new $classname($db); + dol_syslog("Call add_to_target on class ".$classname); $result=$obj->add_to_target($id,$filtersarray); } } @@ -194,7 +196,9 @@ if ($object->fetch($id) >= 0) print ''; // Status - print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; + print ''.$langs->trans("Status").''.$object->getLibStatut(4); + if ($object->statut == 2) print ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.')'; + print ''; // Nb of distinct emails print ''; @@ -366,11 +370,21 @@ if ($object->fetch($id) >= 0) if ($search_email) $sql.= " AND mc.email LIKE '%".$db->escape($search_email)."%'"; if (!empty($search_dest_status)) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." "; $sql .= $db->order($sortfield,$sortorder); - $sql .= $db->plimit($conf->liste_limit+1, $offset); + + // Count total nb of records + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets + $sql .= $db->plimit($limit+1, $offset); $resql=$db->query($sql); if ($resql) { + $num = $db->num_rows($resql); $param = "&id=".$object->id; @@ -388,7 +402,7 @@ if ($object->fetch($id) >= 0) $cleartext='
'.$langs->trans("ToClearAllRecipientsClickHere").': '.''; } - print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$object->nbemail,''); + print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$nbtotalofrecords,'',0,'','',$limit); print ''; @@ -398,7 +412,8 @@ if ($object->fetch($id) >= 0) print ''; print ''; print ''; - + print ''; + if ($page) $param.= "&page=".$page; print ''; @@ -541,7 +556,12 @@ if ($object->fetch($id) >= 0) } else { - print ''; + if ($object->statut < 2) + { + print ''; + } } print "
'.$langs->trans("NoTargetYet").'
'; + print $langs->trans("NoTargetYet"); + print '

"; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 7ac91d1ab31..d9cc6f31d23 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -80,7 +80,7 @@ class Mailing extends CommonObject $this->statut_dest[-1] = 'MailingStatusError'; $this->statut_dest[1] = 'MailingStatusSent'; $this->statut_dest[2] = 'MailingStatusRead'; - $this->statut_dest[3] = 'MailingStatusNotContact'; + $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore } @@ -477,6 +477,38 @@ class Mailing extends CommonObject } } + + /** + * Count number of target with status + * + * @param string $mode Mode ('alreadysent' = Sent success or error) + * @return int Nb of target with status + */ + function countNbOfTargets($mode) + { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.= " WHERE fk_mailing = ".$this->id; + if ($mode == 'alreadysent') $sql.= " AND statut <> 0"; + else + { + $this->error='BadValueForParameterMode'; + return -2; + } + + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) return $obj->nb; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + return 0; + } + /** * Retourne le libelle du statut d'un mailing (brouillon, validee, ... diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index d4956377543..07c51e76916 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -288,7 +288,7 @@ if (empty($reshook)) { $db->begin(); - // Si on a selectionne une propal a copier, on realise la copie + // If we select proposal to clone during creation (when option PROPAL_CLONE_ON_CREATE_PAGE is on) if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { if ($object->fetch(GETPOST('copie_propal')) > 0) { @@ -316,7 +316,8 @@ if (empty($reshook)) $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - $id = $object->create_from($user); + // the create is done below and further more the existing create_from function is quite hilarating + //$id = $object->create_from($user); } else { setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 26e65e09464..a5b048d9719 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1064,6 +1064,7 @@ class Propal extends CommonObject */ function create_from($user) { + // i love this function because $this->products is not used in create function... $this->products=$this->lines; return $this->create($user); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 55d8b49fa46..74ac2fdd7ea 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2013 Regis Houssin @@ -67,6 +67,18 @@ $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); $year=GETPOST("year"); $month=GETPOST("month"); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$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; +if (! $sortfield) $sortfield='p.ref'; +if (! $sortorder) $sortorder='DESC'; + + // Nombre de ligne pour choix de produit/service predefinis $NBLINES=4; @@ -144,19 +156,6 @@ $companystatic=new Societe($db); $now=dol_now(); -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -if (! $sortfield) $sortfield='p.datep'; -if (! $sortorder) $sortorder='DESC'; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; - - $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.rowid, s.nom as name, s.town, s.client, s.code_client,'; @@ -227,8 +226,6 @@ if ($search_user > 0) { $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; } - - $sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC'; $nbtotalofrecords = 0; @@ -255,6 +252,7 @@ if ($result) } $param='&socid='.$socid.'&viewstatut='.$viewstatut; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($month) $param.='&month='.$month; if ($year) $param.='&year='.$year; if ($search_ref) $param.='&search_ref=' .$search_ref; @@ -267,17 +265,17 @@ if ($result) if ($search_town) $param.='&search_town='.$search_town; if ($optioncss != '') $param.='&optioncss='.$optioncss; - print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_commercial.png'); - // Lignes des champs de filtre - print '
'; + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; - if ($sall) + print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_commercial.png', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); //sort($fieldstosearchall); diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index a08e0a66a6f..a5c0a89f29d 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -30,6 +30,8 @@ $langs->load("companies"); $langs->load("orders"); $langs->load("bills"); +$id=GETPOST("id",'int'); + $socid = GETPOST('id','int'); // Security check if ($user->societe_id > 0) @@ -53,8 +55,8 @@ if (GETPOST('cancel') && ! empty($backtopage)) if (GETPOST("action") == 'setremise') { $object = new Societe($db); - $object->fetch($_GET["id"]); - $result=$object->set_remise_client($_POST["remise"],$_POST["note"],$user); + $object->fetch($id); + $result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user); if ($result > 0) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index bfc1001ea1b..08e2981a060 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1178,7 +1178,16 @@ if (empty($reshook)) $action = 'edit_extras'; } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + if ($action == 'set_thirdparty' && $user->rights->commande->creer) + { + $object->fetch($id); + $object->setValueFrom('fk_soc', $socid); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + exit(); + } + + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; /* @@ -1926,8 +1935,19 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; // Third party - print '' . $langs->trans('Company') . ''; - print '' . $soc->getNomUrl(1) . ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans('Company') . ''; + if (! empty($conf->global->COMMANDE_CHANGE_THIRDPARTY) && $action != 'editthirdparty' && $object->brouillon && $user->rights->commande->creer) + print 'id . '">' . img_edit($langs->trans('SetLinkToThirdParty'), 1) . '
'; + print ''; + if ($action == 'editthirdparty') { + $form->form_thirdparty($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, 'socid','client>0'); + } else { + print '  ' . $soc->getNomUrl(1, 'compta'); + } print ''; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index bc5a0767aff..7f12328089e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3418,14 +3418,14 @@ class Commande extends CommonOrder /** * Is the customer order delayed? * - * @return bool + * @return bool true if late, false if not */ public function hasDelay() { global $conf; - if (!($this->statut > Commande::STATUS_DRAFT) && ($this->statut < Commande::STATUS_CLOSED)) { - return false; + if (! ($this->statut > Commande::STATUS_DRAFT && $this->statut < Commande::STATUS_CLOSED)) { + return false; // Never late if not inside this status range } $now = dol_now(); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 5a112e60861..ce6df0524c4 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -64,10 +64,10 @@ $id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int')); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande', $id,''); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -90,6 +90,19 @@ $fieldstosearchall = array( ); if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +$arrayfields=array( +); +// Extra fields +/* + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } + } + */ + /* * Actions @@ -257,6 +270,7 @@ if ($resql) $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($socid > 0) $param.='&socid='.$socid; if ($viewstatut != '') $param.='&viewstatut='.$viewstatut; if ($ordermonth) $param.='&ordermonth='.$ordermonth; @@ -272,7 +286,6 @@ if ($resql) if ($optioncss != '') $param.='&optioncss='.$optioncss; $num = $db->num_rows($resql); - print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_commercial.png'); // Lignes des champs de filtre print ''; @@ -283,7 +296,9 @@ if ($resql) print ''; print ''; - if ($sall) + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 6e91a180e50..11cd92cdbbc 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -147,6 +148,7 @@ $memberstatic=new Adherent($db); $paymentstatic=new Paiement($db); $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); +$remisestatic = new RemiseCheque($db); $acct = new Account($db); $acct->fetch($id); @@ -155,7 +157,9 @@ $now=dol_now(); $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 as type"; $sql.= ", b.fk_bordereau"; +$sql.= ", bc.number"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; $sql.= " WHERE rappro=0 AND fk_account=".$acct->id; $sql.= " ORDER BY dateo ASC"; $sql.= " LIMIT 1000"; // Limit to avoid page overload @@ -292,7 +296,13 @@ if ($resql) // Type + Number $label=($langs->trans("PaymentType".$objp->type)!="PaymentType".$objp->type)?$langs->trans("PaymentType".$objp->type):$objp->type; // $objp->type is a code if ($label=='SOLD') $label=''; - print ''.$label.($objp->num_chq?' '.$objp->num_chq:'').($objp->fk_bordereau>0?' ('.$objp->fk_bordereau.')':'').''; + $link=''; + if ($objp->fk_bordereau>0) { + $remisestatic->id = $objp->fk_bordereau; + $remisestatic->ref = $objp->number; + $link = ' '.$remisestatic->getNomUrl(1); + } + print ''.$label.($objp->num_chq?' '.$objp->num_chq:'').$link.''; // Description print ''; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 0025fb62fd8..43587cfa6a0 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -91,7 +92,7 @@ $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); $bankstatic=new Account($db); $banklinestatic=new AccountLine($db); - +$remisestatic = new RemiseCheque($db); // Load account $object = new Account($db); @@ -328,9 +329,11 @@ else $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql.= " b.fk_bordereau,"; + $sql.= " bc.number,"; $sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank as b"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; $sql.= " WHERE b.num_releve='".$db->escape($num)."'"; if (!isset($num)) $sql.= " OR b.num_releve is null"; $sql.= " AND b.fk_account = ".$object->id; @@ -374,7 +377,13 @@ else } else { $type_label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; } - print ''.$type_label.' '.($objp->num_chq?$objp->num_chq:'').($objp->fk_bordereau>0?' ('.$objp->fk_bordereau.')':'').''; + $link=''; + if ($objp->fk_bordereau>0) { + $remisestatic->id = $objp->fk_bordereau; + $remisestatic->ref = $objp->number; + $link = ' '.$remisestatic->getNomUrl(1); + } + print ''.$type_label.' '.($objp->num_chq?$objp->num_chq:'').$link.''; // Description print ''; diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index f5231a87ef8..e3b121065ef 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -42,14 +42,16 @@ $langs->load("margins"); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'banque'); -$description=GETPOST("description"); -$debit=GETPOST("debit"); -$credit=GETPOST("credit"); -$type=GETPOST("type"); -$account=GETPOST("account"); +$description=GETPOST("description",'alpha'); +$debit=GETPOST("debit",'alpha'); +$credit=GETPOST("credit",'alpha'); +$type=GETPOST("type",'alpha'); +$account=GETPOST("account",'alpha'); $bid=GETPOST("bid","int"); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); +$search_thirdparty=GETPOST("thirdparty",'alpha'); +$search_req_nb=GETPOST("req_nb",'alpha'); $param=''; if (!empty($description)) $param.='&description='.$description; @@ -63,14 +65,14 @@ if (dol_strlen($search_dt_start) > 0) if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='b.dateo'; @@ -82,6 +84,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $credit=""; $account=""; $bid=""; + $search_req_nb=''; + $search_thirdparty=''; } /* @@ -111,15 +115,15 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; $sql.= " WHERE b.fk_account = ba.rowid"; $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; -if (GETPOST("req_nb")) +if ($search_req_nb) { - $sql.= " AND b.num_chq LIKE '%".$db->escape(GETPOST("req_nb"))."%'"; - $param.='&req_nb='.urlencode(GETPOST("req_nb")); + $sql.= " AND b.num_chq LIKE '%".$db->escape($search_req_nb)."%'"; + $param.='&req_nb='.urlencode($search_req_nb); } -if (GETPOST("thirdparty")) +if ($search_thirdparty) { - $sql.=" AND s.nom LIKE '%".$db->escape(GETPOST("thirdparty"))."%'"; - $param.='&thirdparty='.urlencode(GETPOST("thirdparty")); + $sql.=" AND s.nom LIKE '%".$db->escape($search_thirdparty)."%'"; + $param.='&thirdparty='.urlencode($search_thirdparty); } if ($bid) { @@ -137,22 +141,19 @@ if (dol_strlen($search_dt_end)>0) { $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; } // Search criteria amount -$si=0; $debit = price2num(str_replace('-','',$debit)); $credit = price2num(str_replace('-','',$credit)); -if (is_numeric($debit)) { - $si++; - $sqlw[$si] .= " b.amount = -" . $debit; -} -if (is_numeric($credit)) { - $si++; - $sqlw[$si] .= " b.amount = " . $credit; -} -// Other search criteria -for ($i = 1 ; $i <= $si; $i++) { - $sql .= " AND " . $sqlw[$i]; -} +if ($debit) $sql.= natural_search('- b.amount', $debit, 1); +if ($credit) $sql.= natural_search('b.amount', $credit, 1); $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); //print $sql; @@ -164,25 +165,30 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + print ''."\n"; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + if (! empty($_REQUEST['bid'])) print ''; + // Title $bankcateg=new BankCateg($db); if (GETPOST("bid")) { $result=$bankcateg->fetch(GETPOST("bid")); - print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,'', 'title_bank.png'); + print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', 0, '', '', $limit); } else { - print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', 'title_bank.png'); + print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', 0, '', '', $limit); } - - print ''."\n"; - print ''."\n"; - print ''; - if (! empty($_REQUEST['bid'])) print ''; $moreforfilter = ''; - $moreforfilter.='
'; $moreforfilter .= $langs->trans('Period') . ' ('.$langs->trans('DateOperationShort').') : ' . $langs->trans('StartDate') . ' '; $moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1); @@ -209,6 +215,7 @@ if ($resql) print_liste_field_titre($langs->trans("Debit"),$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Credit"),$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Account"),$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre(''); print "\n"; print ''; @@ -218,17 +225,18 @@ if ($resql) print ''; $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 8); print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print ''; print ''; + print ''; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; @@ -325,6 +333,9 @@ if ($resql) $bankaccountstatic->label=$objp->bankref; print $bankaccountstatic->getNomUrl(1); print "\n"; + + print ''; + print ""; } $i++; @@ -336,6 +347,7 @@ if ($resql) print '' . price($total_debit * - 1) . ''; print '' . price($total_credit) . ''; print ''; + print ''; print ''; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 88be9bab0ba..2ce51ad3afd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2346,7 +2346,7 @@ if ($action == 'create') { print ''; print ''; - print ''; + print ''; print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:'')); print ''; } @@ -2361,7 +2361,7 @@ if ($action == 'create') // Template to use by default print '' . $langs->trans('Model') . ''; - print ''; + print ''; include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; $liste = ModelePDFFactures::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF); @@ -2372,7 +2372,7 @@ if ($action == 'create') { print ''; print ''.fieldLabel('Currency','multicurrency_code').''; - print ''; + print ''; print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print ''; } @@ -3074,7 +3074,9 @@ else if ($id > 0 || ! empty($ref)) $nbrows ++; if ($selleruserevenustamp) $nbrows ++; - + if (! empty($conf->multicurrency->enabled)) $nbrows+=5; + if (! empty($conf->incoterm->enabled)) $nbrows+=1; + print ''; if ($object->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) @@ -3443,14 +3445,14 @@ else if ($id > 0 || ! empty($ref)) { // Multicurrency code print ''; - print ''; + print ''; print ''; if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) print ''; print '
'; print fieldLabel('Currency','multicurrency_code'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print ''; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -3460,14 +3462,14 @@ else if ($id > 0 || ! empty($ref)) // Multicurrency rate print ''; - print ''; + print ''; print ''; if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) print ''; print '
'; print fieldLabel('Rate','multicurrency_tx'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print ''; + print ''; if ($action == 'editmulticurrencyrate') { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); } else { @@ -3507,7 +3509,9 @@ else if ($id > 0 || ! empty($ref)) print ' '; print $prevsits[0]->situation_counter; - for ($i = 1; $i < count($prevsits); $i++) { + $cprevsits = count($prevsits); + + for ($i = 1; $i < $cprevsits; $i++) { print ' + '; print $prevsits[$i]->situation_counter; } @@ -3528,7 +3532,7 @@ else if ($id > 0 || ! empty($ref)) print '' . $langs->trans('Currency' . $conf->currency) . ''; // Previous situation(s) deduction(s) - for ($i = 0; $i < count($prevsits); $i++) { + for ($i = 0; $i < $cprevsits; $i++) { print ''; print '
'; print $langs->trans('SituationDeduction'); @@ -3841,6 +3845,7 @@ else if ($id > 0 || ! empty($ref)) } } + // deprecated. Useless because now we can use templates if (! empty($conf->global->FACTURE_SHOW_SEND_REMINDER)) // For backward compatibility { if (($object->statut == 1 || $object->statut == 2) && $resteapayer > 0) { @@ -3896,7 +3901,7 @@ else if ($id > 0 || ! empty($ref)) // Classify paid if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0)) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) + || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) ) { print ''; @@ -3926,10 +3931,10 @@ else if ($id > 0 || ! empty($ref)) print ''; } - // Clone as predefined + // Clone as predefined / Create template if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $user->rights->facture->creer) { - if (! $objectidnext) + if (! $objectidnext && count($object->lines) > 0) { print ''; } @@ -3944,7 +3949,7 @@ else if ($id > 0 || ! empty($ref)) } } - //Create next situation invoice + // Create next situation invoice if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { if ($object->is_last_in_cycle() && $object->situation_final != 1) { print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index f2ef90677c5..b0a7bab2899 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -83,7 +84,20 @@ class FactureRec extends Facture // Clean parameters $this->titre=trim($this->titre); $this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice; - + + // No frequency defined then no next date to execution + if (empty($this->frequency)) + { + $this->frequency=0; + $this->date_when=NULL; + } + + + $this->frequency=abs($this->frequency); + $this->nb_gen_done=0; + $this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max; + $this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate; + $this->db->begin(); // Charge facture modele @@ -105,9 +119,17 @@ class FactureRec extends Facture $sql.= ", note_public"; $sql.= ", fk_user_author"; $sql.= ", fk_projet"; + $sql.= ", fk_account"; $sql.= ", fk_cond_reglement"; $sql.= ", fk_mode_reglement"; $sql.= ", usenewprice"; + $sql.= ", frequency"; + $sql.= ", unit_frequency"; + $sql.= ", date_when"; + $sql.= ", date_last_gen"; + $sql.= ", nb_gen_done"; + $sql.= ", nb_gen_max"; + $sql.= ", auto_validate"; $sql.= ") VALUES ("; $sql.= "'".$this->titre."'"; $sql.= ", ".$facsrc->socid; @@ -119,9 +141,17 @@ class FactureRec extends Facture $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); $sql.= ", '".$user->id."'"; $sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null"); + $sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null"); $sql.= ", '".$facsrc->cond_reglement_id."'"; $sql.= ", '".$facsrc->mode_reglement_id."'"; $sql.= ", ".$this->usenewprice; + $sql.= ", ".$this->frequency; + $sql.= ", '".$this->db->escape($this->unit_frequency)."'"; + $sql.= ", ".(!empty($this->date_when)?"'".$this->db->idate($this->date_when)."'":'NULL'); + $sql.= ", ".(!empty($this->date_last_gen)?"'".$this->db->idate($this->date_last_gen)."'":'NULL'); + $sql.= ", ".$this->nb_gen_done; + $sql.= ", ".$this->nb_gen_max; + $sql.= ", ".$this->auto_validate; $sql.= ")"; if ($this->db->query($sql)) @@ -197,7 +227,9 @@ class FactureRec extends Facture $sql = 'SELECT f.titre,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; $sql.= ', f.date_lim_reglement as dlr'; $sql.= ', f.note_private, f.note_public, f.fk_user_author'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement'; + $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; + $sql.= ', f.fk_account'; + $sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', el.fk_source'; @@ -248,6 +280,7 @@ class FactureRec extends Facture $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->fk_project = $obj->fk_projet; + $this->fk_account = $obj->fk_account; $this->fk_facture_source = $obj->fk_facture_source; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; @@ -255,6 +288,14 @@ class FactureRec extends Facture $this->modelpdf = $obj->model_pdf; $this->rang = $obj->rang; $this->special_code = $obj->special_code; + $this->frequency = $obj->frequency; + $this->unit_frequency = $obj->unit_frequency; + $this->date_when = $obj->date_when; + $this->date_last_gen = $obj->date_last_gen; + $this->nb_gen_done = $obj->nb_gen_done; + $this->nb_gen_max = $obj->nb_gen_max; + $this->usenewprice = $obj->usenewprice; + $this->auto_validate = $obj->auto_validate; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; @@ -468,7 +509,7 @@ class FactureRec extends Facture $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - + $product_type=$type; if ($fk_product) { @@ -529,6 +570,63 @@ class FactureRec extends Facture } } + /** + * Return the next date of + * + * @return timestamp false if KO, timestamp if OK + */ + function getNextDate() + { + if (empty($this->date_when)) return false; + return dol_time_plus_duree(strtotime($this->date_when), $this->frequency, $this->unit_frequency); + } + + /** + * Create all recurrents invoices + * + * @return int number of created invoices + */ + function createRecurringInvoices() + { + global $db,$user; + + $nb_create=0; + + $today = date('Y-m-d 23:59:59'); + + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; + $sql.= ' WHERE date_when IS NOT NULL AND frequency > 0'; + $sql.= ' AND date_when <= "'.$db->escape($today).'"'; + $sql.= ' AND nb_gen_done < nb_gen_max'; + + $resql = $db->query($sql); + if ($resql) + { + while ($line = $db->fetch_object($resql)) + { + $facturerec = new FactureRec($db); + $facturerec->fetch($line->rowid); + + $facture = new Facture($db); + $result = $facture->createFromRec($user, $facturerec); + + // >0 create and validate if auto_validate + // =0 create but not validate if auto_validate + // <0 broken + if ($result >= 0) + { + $next_date = $facturerec->getNextDate(); + $facturerec->setNextDate($next_date,1); + + $nb_create++; + } + + } + } + + return $nb_create; + } + /** * Return clicable name (with picto eventually) * @@ -601,4 +699,143 @@ class FactureRec extends Facture return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Update frequency and unit + * + * @param int $frequency value of frequency + * @param string $unit unit of frequency (d, m, y) + * @return int <0 if KO, >0 if OK + */ + function setFrequencyAndUnit($frequency,$unit) + { + if (! $this->table_element) + { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined",LOG_ERR); + return -1; + } + + if (!empty($frequency) && empty($unit)) + { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined",LOG_ERR); + return -2; + } + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); + if (!empty($unit)) + { + $sql.= ', unit_frequency = "'.$this->db->escape($unit).'"'; + } + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->frequency = $frequency; + if (!empty($unit)) $this->unit_frequency = $unit; + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Update the next date of execution + * + * @param datetime $date date of execution + * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done + * @return int <0 if KO, >0 if OK + */ + function setNextDate($date, $increment_nb_gen_done=0) + { + if (! $this->table_element) + { + dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined",LOG_ERR); + return -1; + } + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql.= ' SET date_when = "'.$this->db->idate($date).'"'; + if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1'; + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->date_when = $date; + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Update the maximum period + * + * @param int $nb number of maximum period + * @return int <0 if KO, >0 if OK + */ + function setMaxPeriod($nb) + { + if (! $this->table_element) + { + dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined",LOG_ERR); + return -1; + } + + if (empty($nb)) $nb=0; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql.= ' SET nb_gen_max = '.$nb; + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->nb_gen_max = $nb; + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Update the auto validate invoice + * + * @param int $validate 0 to create in draft, 1 to create and validate invoice + * @return int <0 if KO, >0 if OK + */ + function setAutoValidate($validate) + { + if (! $this->table_element) + { + dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined",LOG_ERR); + return -1; + } + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql.= ' SET auto_validate = '.$validate; + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->auto_validate = $validate; + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 78ca830a191..18a41145c21 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -278,6 +278,8 @@ class Facture extends CommonInvoice $result=$_facrec->fetch($this->fac_rec); $this->fk_project = $_facrec->fk_project; + $this->fk_account = $_facrec->fk_account; + $this->note_private = $_facrec->note_private; $this->cond_reglement_id = $_facrec->cond_reglement_id; $this->mode_reglement_id = $_facrec->mode_reglement_id; $this->remise_absolue = $_facrec->remise_absolue; @@ -917,6 +919,60 @@ class Facture extends CommonInvoice else return -1; } + /** + * Create a new invoice in database from facturerec + * + * @param User $user Object user that ask creation + * @param FactureRec $facturerec Object facturerec source + * @return int <0 if KO, 0 if not validate, >0 if OK + */ + function createFromRec($user, $facturerec) + { + + // Clean parameters + $this->type = self::TYPE_STANDARD; + $this->brouillon = 1; + + // Charge facture source + $facture=new Facture($facturerec->db); + + $facture->socid = $facturerec->socid; + $facture->date = dol_mktime(12, 0, 0, date('m'), date('d'), date('Y')); + $facture->note_public = $facturerec->note_public; + $facture->note_private = $facturerec->note_private; + $facture->fk_project = $facturerec->fk_project; + $facture->fk_account = $facturerec->fk_account; + $facture->cond_reglement_id = $facturerec->cond_reglement_id; + $facture->mode_reglement_id = $facturerec->mode_reglement_id; + + $new_date_lim_reglement = $facture->calculate_date_lim_reglement(); + $facture->date_lim_reglement = $new_date_lim_reglement; + + $facture->remise_absolue = $facturerec->remise_absolue; + $facture->remise_percent = $facturerec->remise_percent; + + $facture->lines = $facturerec->lines; // Tableau des lignes de factures + + // Loop on each line of new invoice + foreach($facture->lines as $i => $line) + { + $facture->lines[$i]->fk_prev_id = $facturerec->lines[$i]->rowid; + } + + dol_syslog(get_class($this)."::createFromRec socid=".$this->socid." nboflines=".count($facture->lines)); + + $facid = $facture->create($user); + if ($facid <= 0) return -1; + + if ($facturerec->auto_validate) + { + $result = $facture->validate($user); + if ($result<=0) return 0; + } + + return $facid; + } + /** * Return clicable link of object (with eventually picto) * diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 5f17c5d49bb..42c82a1642d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -58,7 +58,14 @@ if ($sortfield == "") $sortfield="f.datef"; $object = new FactureRec($db); - +if ($id > 0 && $action != 'create' && $action != 'add') +{ + $ret = $object->fetch($id); + if (!$ret) + { + setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors'); + } +} /* * Actions @@ -75,16 +82,50 @@ if ($action == 'add') $error++; } + $frequency=GETPOST('frequency', 'int'); + $reyear=GETPOST('reyear'); + $remonth=GETPOST('remonth'); + $reday=GETPOST('reday'); + $rehour=GETPOST('rehour'); + $remin=GETPOST('remin'); + $nb_gen_max=GETPOST('nb_gen_max', 'int'); + if (empty($nb_gen_max)) $nb_gen_max =0; + + if (GETPOST('frequency')) + { + if (empty($reyear) || empty($remonth) || empty($reday)) + { + setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors'); + $action = "create"; + $error++; + } + if ($nb_gen_max == '') + { + setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); + $action = "create"; + $error++; + } + } + if (! $error) { $object->titre = GETPOST('titre', 'alpha'); $object->note_private = GETPOST('note_private'); $object->usenewprice = GETPOST('usenewprice'); - + + $object->frequency = $frequency; + $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); + $object->nb_gen_max = $nb_gen_max; + $object->auto_validate = GETPOST('auto_validate', 'int'); + + $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); + $object->date_when = $date_next_execution; + if ($object->create($user, $id) > 0) { $id = $object->id; - $action = ''; + header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $id); + exit; } else { @@ -97,12 +138,59 @@ if ($action == 'add') // Delete if ($action == 'delete' && $user->rights->facture->supprimer) { - $object->fetch($id); $object->delete(); - $id = 0 ; + header("Location: " . $_SERVER['PHP_SELF'] ); + exit; } +// Update field +// Set condition +if ($action == 'setconditions' && $user->rights->facture->creer) +{ + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + +} +// Set mode +elseif ($action == 'setmode' && $user->rights->facture->creer) +{ + $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); +} +// Set project +elseif ($action == 'classin' && $user->rights->facture->creer) +{ + $object->setProject(GETPOST('projectid', 'int')); +} +// Set bank account +elseif ($action == 'setbankaccount' && $user->rights->facture->creer) +{ + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); +} +// Set frequency and unit frequency +elseif ($action == 'setfrequency' && $user->rights->facture->creer) +{ + $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); +} +// Set next date of execution +elseif ($action == 'setdate_when' && $user->rights->facture->creer) +{ + $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); + if (!empty($date)) $object->setNextDate($date); +} +// Set max period +elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) +{ + $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); +} +// Set auto validate +elseif ($action == 'setauto_validate' && $user->rights->facture->creer) +{ + $object->setAutoValidate(GETPOST('auto_validate', 'int')); +} +// Set note +$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + /* * View @@ -133,7 +221,8 @@ if ($action == 'create') dol_fiche_head(); $rowspan=4; - if (! empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++; + if (! empty($conf->projet->enabled)) $rowspan++; + if ($object->fk_account > 0) $rowspan++; print ''; @@ -152,7 +241,7 @@ if ($action == 'create') // Note print ''; // Author @@ -169,21 +258,61 @@ if ($action == 'create') print ""; // Project - if (! empty($conf->projet->enabled) && $object->fk_project > 0) + if (! empty($conf->projet->enabled)) { print ""; } + // Bank account + if ($object->fk_account > 0) + { + print ""; + } + print "
'; - print ''; + print ''; print '
".$langs->trans("Project").""; if ($object->fk_project > 0) { $project = new Project($db); $project->fetch($object->fk_project); - print $project->title; + print $project->getNomUrl(1); } print "
".$langs->trans('BankAccount').""; + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + print "
"; - print '
'; + print '

'; + + + // Autogeneration + $title = $langs->trans("Recurrence"); + print load_fiche_titre($title, '', 'calendar'); + + print ''; + + // Frequency + print ""; + + // First date of execution for cron + print ""; + + // Number max of generation + print ""; + + // Auto validate the invoice + print ""; + + print "
".$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency')).""; + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); + print "
".$langs->trans('NextDateToExecution').""; + $date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1); + print $form->select_date($date_next_execution, '', 1, 1, '', "add", 1, 1, 1); + print "
".$langs->trans("MaxPeriodNumber").""; + print ""; + print "
".$langs->trans("InvoiceAutoValidate").""; + print $form->selectyesno('auto_validate', 0, 1); + print "
"; + + print '

'; $title = $langs->trans("ProductsAndServices"); if (empty($conf->service->enabled)) @@ -191,7 +320,7 @@ if ($action == 'create') else if (empty($conf->product->enabled)) $title = $langs->trans("Services"); - print load_fiche_titre($title); + print load_fiche_titre($title, '', ''); /* * Invoice lines @@ -394,178 +523,346 @@ else /* * View mode */ - if ($id > 0) + if ($object->id > 0) { - if ($object->fetch($id) > 0) + $object->fetch_thirdparty(); + + $author = new User($db); + $author->fetch($object->user_author); + + $head=array(); + $h=0; + $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id; + $head[$h][1] = $langs->trans("CardBill"); + $head[$h][2] = 'card'; + + dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"),0,'bill'); // Add a div + + print ''; + + $linkback = '' . $langs->trans("BackToList") . ''; + + // Ref + print ''; + print ''; + + + print ''; + print ''; + + print ""; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + // Payment term + print ''; + + + print ''; + print ''; + + // Project + if (! empty($conf->projet->enabled)) { + $langs->load('projects'); + print ''; + print ''; + print ''; + } + + // Bank Account + print '"; + print ''; + + + print "
' . $langs->trans('Ref') . ''; + $morehtmlref = ''; + /* + require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + $discount = new DiscountAbsolute($db); + $result = $discount->fetch(0, $object->id); + if ($result > 0) { + $morehtmlref = ' (' . $langs->trans("CreditNoteConvertedIntoDiscount", $discount->getNomUrl(1, 'discount')) . ')'; + } + if ($result < 0) { + dol_print_error('', $discount->error); + }*/ + print $form->showrefnav($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref); + print '
'.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').'
".$langs->trans("Author").''.$author->getFullName($langs)."
'.$langs->trans("AmountHT").''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'
'.$langs->trans("AmountVAT").''.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'
'.$langs->trans("AmountTTC").''.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'
'; + print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) + print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . '
'; + print '
'; + if ($object->type != Facture::TYPE_CREDIT_NOTE) { - $object->fetch_thirdparty(); - - $author = new User($db); - $author->fetch($object->user_author); - - $head=array(); - $h=0; - $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id; - $head[$h][1] = $langs->trans("CardBill"); - $head[$h][2] = 'card'; - - dol_fiche_head($head, 'card', $langs->trans("PredefinedInvoices"),0,'bill'); // Add a div - - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ""; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - // Payment term - print '"; - - // Payment mode - print '"; - - print '"; - - print "
'.$langs->trans("Ref").''.$object->titre.'
'.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').'
".$langs->trans("Author").''.$author->getFullName($langs)."
'.$langs->trans("AmountHT").''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'
'.$langs->trans("AmountVAT").''.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'
'.$langs->trans("AmountTTC").''.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'
'.$langs->trans("PaymentConditions").''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none'); - print "
'.$langs->trans("PaymentMode").''; - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id,'none'); - print "
'.$langs->trans("Comment").''.nl2br($object->note_private)."
"; - - print ''; - - /* - * Lines - */ - - $title = $langs->trans("ProductsAndServices"); - if (empty($conf->service->enabled)) - $title = $langs->trans("Products"); - else if (empty($conf->product->enabled)) - $title = $langs->trans("Services"); - - print load_fiche_titre($title); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; + if ($action == 'editconditions') { + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); } - print ''; + } else { + print ' '; + } + print ''; - $num = count($object->lines); - $i = 0; - $var=true; - while ($i < $num) - { - $var=!$var; - - $product_static=new Product($db); - - // Show product and description - $type=(isset($object->lines[$i]->product_type)?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type); - // Try to enhance type detection using date_start and date_end for free lines when type - // was not saved. - if (! empty($objp->date_start)) $type=1; - if (! empty($objp->date_end)) $type=1; - - // Show line - print ""; - if ($object->lines[$i]->fk_product > 0) - { - print ''; - } - else - { - print ''; - } - print ''; - print ''; - print ''; - if ($conf->global->PRODUCT_USE_UNITS) { - print ""; - } - print "\n"; - $i++; - } - print '
'.$langs->trans("Description").''.$langs->trans("Price").''.$langs->trans("ReductionShort").''.$langs->trans("Qty").''.$langs->trans("Unit").'
'; - print ''; // ancre pour retourner sur la ligne - - // Show product and description - $product_static->type=$object->lines[$i]->fk_product_type; - $product_static->id=$object->lines[$i]->fk_product; - $product_static->ref=$object->lines[$i]->product_ref; - $text=$product_static->getNomUrl(1); - $text.= ' - '.(! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label); - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->desc)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - print (! empty($object->lines[$i]->desc) && $object->lines[$i]->desc!=$fac->lines[$i]->product_label)?'
'.dol_htmlentitiesbr($object->lines[$i]->desc):''; - - print '
'; - - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - - if (! empty($object->lines[$i]->label)) { - - $text.= ' '.$object->lines[$i]->label.''; - print $form->textwithtooltip($text,dol_htmlentitiesbr($object->lines[$i]->desc),3,'','',$i); - - } else { - - print $text.' '.nl2br($object->lines[$i]->desc); - } - - // Show range - print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); - - print ''.price($object->lines[$i]->price).''.$object->lines[$i]->remise_percent.' %'.$object->lines[$i]->qty.'".$object->lines[$i]->getLabelOfUnit()."
'; - - - - /** - * Barre d'actions - */ - print '
'; - - if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer) - { - echo ''; - } - - if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer) - { - print ''; - } - - print '
'; + // Payment mode + print '
'; + print ''; + if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) + print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . '
'; + print '
'; + if ($action == 'editmode') + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); } else { - print $langs->trans("ErrorRecordNotFound"); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); } + print '
'; + print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer); + print ''; + print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60'); + print '
'; + + print ''; + if ($action != 'classify') { + print ''; + } + print '
'; + print $langs->trans('Project'); + print 'id . '">'; + print img_edit($langs->trans('SetProject'), 1); + print '
'; + + print '
'; + if ($action == 'classify') { + $form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1); + } else { + $form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0); + } + print '
'; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print '
'; + if ($action == 'editbankaccount') + { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } + else + { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print "
"; + + print '
'; + + /* + * Recurrence + */ + $title = $langs->trans("Recurrence"); + print load_fiche_titre($title, '', 'calendar'); + + print ''; + + // if "frequency" is empty or = 0, the reccurence is disabled + print ''; + + //if (! empty($object->frequency)) // If no frequency defined, it is not a recurring template invoice + //{ + // Date when + print ''; + print ''; + + + // Max period / Rest period + print ''; + print ''; + print ''; + print ''; + + // Auto validate + print ''; + print ''; + //} + + print '
'; + print ''; + if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer) + print ''; + print '
'; + print $langs->trans('Frequency'); + print 'id . '">' . img_edit($langs->trans('Edit'), 1) . '
'; + print '
'; + if ($action == 'editfrequency') + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); + print '
'; + } + else + { + if ($object->frequency > 0) + { + print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); + } + else + { + print $langs->trans("NotARecurringInvoiceTemplate"); + } + } + print '
'; + print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'dayhour'); + print ''; + print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'dayhour'); + print '
'; + print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + print ''; + print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + print '
'.$langs->trans("RestPeriodNumber").''; + print ($object->nb_gen_max-$object->nb_gen_done); + print '
'; + print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); + print ''; + $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); + print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); + print '
'; + + print '
'; + + /* + * Lines + */ + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->global->PRODUCT_USE_UNITS) { + print ''; + } + print ''; + + $num = count($object->lines); + $i = 0; + $var=true; + while ($i < $num) + { + $var=!$var; + + $product_static=new Product($db); + + // Show product and description + $type=(isset($object->lines[$i]->product_type)?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type); + // Try to enhance type detection using date_start and date_end for free lines when type + // was not saved. + if (! empty($objp->date_start)) $type=1; + if (! empty($objp->date_end)) $type=1; + + // Show line + print ""; + if ($object->lines[$i]->fk_product > 0) + { + print ''; + } + else + { + print ''; + } + print ''; + print ''; + print ''; + print ''; + if ($conf->global->PRODUCT_USE_UNITS) { + print ""; + } + print "\n"; + $i++; + } + print '
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").''.$langs->trans("Unit").'
'; + print ''; // ancre pour retourner sur la ligne + + // Show product and description + $product_static->type=$object->lines[$i]->fk_product_type; + $product_static->id=$object->lines[$i]->fk_product; + $product_static->ref=$object->lines[$i]->product_ref; + $text=$product_static->getNomUrl(1); + $text.= ' - '.(! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label); + $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->desc)); + print $form->textwithtooltip($text,$description,3,'','',$i); + + // Show range + print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + print (! empty($object->lines[$i]->desc) && $object->lines[$i]->desc!=$fac->lines[$i]->product_label)?'
'.dol_htmlentitiesbr($object->lines[$i]->desc):''; + + print '
'; + + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + + if (! empty($object->lines[$i]->label)) { + + $text.= ' '.$object->lines[$i]->label.''; + print $form->textwithtooltip($text,dol_htmlentitiesbr($object->lines[$i]->desc),3,'','',$i); + + } else { + + print $text.' '.nl2br($object->lines[$i]->desc); + } + + // Show range + print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); + + print ''.vatrate($object->lines[$i]->tva_tx, 1).''.price($object->lines[$i]->price).''.$object->lines[$i]->qty.''.$object->lines[$i]->remise_percent.' %".$object->lines[$i]->getLabelOfUnit()."
'; + + dol_fiche_end(); + + + /** + * Barre d'actions + */ + print '
'; + + if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer) + { + echo ''; + } + + if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer) + { + print ''; + } + + print '
'; + } else { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index af0376fef0e..38d1ce96f59 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -695,6 +695,7 @@ if ($resql) } $param='&socid='.$socid; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; if ($search_ref) $param.='&search_ref=' .$search_ref; @@ -712,8 +713,7 @@ if ($resql) $i = 0; print '
'."\n"; - - print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$massactionbutton,$num,$nbtotalofrecords,'title_accountancy.png'); + print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$massactionbutton,$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); if ($massaction == 'presend') { diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 2b3a7153793..5b4929ae42b 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -38,12 +38,13 @@ $langs->load("bills"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'banque', '',''); -$search_ref = GETPOST('search_ref','int'); +$search_ref = GETPOST('search_ref','alpha'); $search_account = GETPOST('search_account','int'); $search_amount = GETPOST('search_amount','alpha'); + +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $limit * $page; @@ -101,6 +102,7 @@ else if ($year > 0) { $sql.= " AND bc.date_bordereau BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } +$sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -109,29 +111,36 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= " ORDER BY $sortfield $sortorder"; $sql.= $db->plimit($limit+1, $offset); //print "$sql"; $resql = $db->query($sql); - if ($resql) { $num = $db->num_rows($resql); $i = 0; - $params=''; + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - - print ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', '', '', $limit); + print ''; print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bc.number","",$params,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"dp","",$params,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$params,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("NbOfCheques"),$_SERVER["PHP_SELF"],"bc.nbcheque","",$params,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"bc.amount","",$params,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"bc.statut","",$params,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bc.number","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"dp","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("NbOfCheques"),$_SERVER["PHP_SELF"],"bc.nbcheque","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"bc.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"bc.statut","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre(''); print "\n"; // Lignes des champs de filtre @@ -151,6 +160,7 @@ if ($resql) print ''; + print ''; print '\n"; + print ''; + + print ''; + + print "\n"; $i++; } } @@ -200,7 +214,7 @@ if ($resql) { $var=!$var; print ""; - print '"; + print '"; print ''; } print "
'; print ''; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; @@ -192,7 +202,11 @@ if ($resql) // Statut print ''; print $checkdepositstatic->LibStatut($objp->statut,5); - print "
'.$langs->trans("None")."'.$langs->trans("None")."
"; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 33576328786..bcca56ed645 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -57,9 +57,9 @@ $search_amount=GETPOST("search_amount",'alpha'); // alpha because we must be $search_company=GETPOST("search_company",'alpha'); $search_payment_num=GETPOST('search_payment_num','alpha'); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $limit * $page; @@ -184,6 +184,7 @@ else $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; } +$sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -192,12 +193,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); //print "$sql"; $resql = $db->query($sql); - if ($resql) { $num = $db->num_rows($resql); @@ -211,9 +210,16 @@ if ($resql) $paramlist.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); if ($optioncss != '') $paramlist.='&optioncss='.urlencode($optioncss); - print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, $nbtotalofrecords,'title_accountancy.png'); - - print ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, $nbtotalofrecords,'title_accountancy.png', 0, '', '', $limit); + print ''; print ''; print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"p.rowid","",$paramlist,"",$sortfield,$sortorder); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 6445eb09f02..4090f2904b7 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -113,8 +113,8 @@ llxHeader(); $tva = new Tva($db); -$textprevyear="".img_previous().""; -$textnextyear=" ".img_next().""; +$textprevyear="".img_previous($langs->trans("Previous"), 'class="valignbottom"').""; +$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; print load_fiche_titre($langs->trans("VAT"),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear"); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b319072dc68..8db9b90ff49 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -67,16 +67,15 @@ $optioncss = GETPOST('optioncss','alpha'); $type=GETPOST("type"); $view=GETPOST("view"); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); $userid=GETPOST('userid','int'); $begin=GETPOST('begin'); - if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.lastname"; if ($page < 0) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; $langs->load("companies"); @@ -333,6 +332,16 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +// Add order +if($view == "recent") +{ + $sql.= $db->order("p.datec","DESC"); +} +else +{ + $sql.= $db->order($sortfield,$sortorder); +} + // Count total nb of records $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -341,16 +350,14 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -// Add order and limit +// Add limit if($view == "recent") { - $sql.= $db->order("p.datec","DESC"); - $sql.= $db->plimit($conf->liste_limit+1, $offset); + $sql.= $db->plimit($limit+1, $offset); } else { - $sql.= $db->order($sortfield,$sortorder); - $sql.= $db->plimit($conf->liste_limit+1, $offset); + $sql.= $db->plimit($limit+1, $offset); } //print $sql; @@ -361,11 +368,14 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); - $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email); + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param.='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); + $param.='&type='.urlencode($type).'&view='.urlencode($view); if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname); if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname); + if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); if ($search_town != '') $param.='&search_town='.urlencode($search_town); if ($search_job != '') $param.='&search_job='.urlencode($search_job); @@ -385,8 +395,6 @@ if ($result) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords,'title_companies.png'); - print ''; if ($optioncss != '') print ''; print ''; @@ -395,6 +403,8 @@ if ($result) print ''; print ''; + print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit); + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -739,10 +749,10 @@ if ($result) print "
"; + if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1); + print '
'; - - if ($num > $limit) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - + $db->free($result); } else diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index f9e7351ed87..df6e0007023 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -36,13 +36,6 @@ $langs->load("products"); $langs->load("companies"); $langs->load("compta"); -$sortfield=GETPOST('sortfield','alpha'); -$sortorder=GETPOST('sortorder','alpha'); -$page=GETPOST('page','int'); -if ($page == -1) { $page = 0 ; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page ; - $search_name=GETPOST('search_name'); $search_contract=GETPOST('search_contract'); $search_ref_supplier=GETPOST('search_ref_supplier','alpha'); @@ -55,8 +48,16 @@ $search_product_category=GETPOST('search_product_category','int'); $optioncss = GETPOST('optioncss','alpha'); -if (! $sortfield) $sortfield="c.rowid"; -if (! $sortorder) $sortorder="DESC"; +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$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; +if (! $sortfield) $sortfield='c.ref'; +if (! $sortorder) $sortorder='DESC'; // Security check $id=GETPOST('id','int'); @@ -152,7 +153,15 @@ if ($result) $totalnboflines = $db->num_rows($result); } $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($conf->liste_limit + 1, $offset); + +$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); $resql=$db->query($sql); if ($resql) @@ -160,8 +169,14 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], '&search_contract='.$search_contract.'&search_name='.$search_name, $sortfield, $sortorder,'',$num,$totalnboflines,'title_commercial.png'); - + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param.='&search_contract='.$search_contract; + $param.='&search_name='.$search_name; + $param.='&search_ref_supplier='.$search_ref_supplier; + $param.='&search_sale=' .$search_sale; + if ($optioncss != '') $param.='&optioncss='.$optioncss; + print '
'; if ($optioncss != '') print ''; print ''; @@ -169,7 +184,9 @@ if ($resql) print ''; print ''; - if ($sall) + print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num,$totalnboflines,'title_commercial.png', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); @@ -218,13 +235,7 @@ if ($resql) print ''; print ''; - $param='&search_contract='.$search_contract; - $param.='&search_name='.$search_name; - $param.='&search_ref_supplier='.$search_ref_supplier; - $param.='&search_sale=' .$search_sale; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.ref","","$param",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefCustomer"), $_SERVER["PHP_SELF"], "c.ref_customer","","$param",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefSupplier"), $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ThirdParty"), $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder); @@ -280,8 +291,14 @@ if ($resql) print ''; } // State - if (! empty($arrayfields['state.state_name']['checked'])) + if (! empty($arrayfields['state.nom']['checked'])) { print '\n"; } // State - if (! empty($arrayfields['state.state_name']['checked'])) + if (! empty($arrayfields['state.nom']['checked'])) { print "\n"; } diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 7ac093ca7dd..f9b924c9240 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -42,6 +42,7 @@ $langs->load("companies"); $langs->load("bills"); $action = GETPOST('action', 'alpha'); +$search_prod = GETPOST('search_prod'); // Security check $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); @@ -66,6 +67,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers + { + $search_prod = ''; + } + if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { $update_child_soc = GETPOST('updatechildprice'); @@ -212,9 +218,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { 't.fk_soc' => $object->id ); - $search_soc = GETPOST('search_soc'); - if (! empty($search_soc)) { - $filter['soc.nom'] = $search_soc; + if (! empty($search_prod)) { + $filter ['prod.ref'] = $search_prod; } if ($action == 'add_customer_price') { @@ -479,7 +484,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - $option = '&search_soc=' . $search_soc . '&id=' . $object->id; + $option = '&search_prod=' . $search_prod . '&id=' . $object->id; print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); @@ -501,11 +506,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; - if (count($prodcustprice->lines) > 0) + if (count($prodcustprice->lines) > 0 || $search_prod) { - print ''; - print ''; + print ''; print ''; // Print the search button print ''; print ''; - + } + + if (count($prodcustprice->lines) > 0) + { $var = False; foreach ($prodcustprice->lines as $line) @@ -540,7 +547,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print $userstatic->getLoginUrl(1); print ''; - // Todo Edit or delete button // Action if ($user->rights->produit->creer || $user->rights->service->creer) { @@ -561,9 +567,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "\n"; } - } else + } + else { - print ''; + $colspan=9; + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1; + print ''; } print "
'; if($obj->socid) { - $socstatic->fetch($obj->socid); + $result=$socstatic->fetch($obj->socid); + if ($result < 0) + { + dol_print_error($db); + exit; + } $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) dol_print_error($db); $nbofsalesrepresentative=count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php new file mode 100644 index 00000000000..609eabdbc7a --- /dev/null +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -0,0 +1,168 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Charlie Benke + * + * 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 . + */ + +/** + * \file htdocs/core/boxes/box_clients.php + * \ingroup societes + * \brief Module de generation de l'affichage de la box clients + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last thirdparties + */ +class box_goodcustomers extends ModeleBoxes +{ + var $boxcode="goodcustomers"; + var $boximg="object_company"; + var $boxlabel="BoxGoodCustomers"; + var $depends = array("societe"); + + var $db; + var $enabled = 1; + + var $info_box_head = array(); + var $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param='') + { + global $conf, $user; + + $this->db = $db; + + // disable box for such cases + if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + function loadBox($max=5) + { + global $user, $langs, $db, $conf; + $langs->load("boxes"); + + $this->max=$max; + + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic=new Societe($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers",$max)); + + if ($user->rights->societe->lire) + { + + $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; + $sql.= " count(*) as nbfact, sum(". $db->if('f.paye=1','1','0').") as nbfactpaye"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; + $sql.= ' AND s.rowid = f.fk_soc'; + $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; + $sql.= $db->order("nbfact","DESC"); + $sql.= $db->plimit($max,0); + + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + + $line = 0; + while ($line < $num) + { + $objp = $db->fetch_object($result); + $datem=$db->jdate($objp->tms); + $thirdpartystatic->id = $objp->rowid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $nbfact = $objp->nbfact; + $nbimpaye = $objp->nbfact - $objp->nbfactpaye; + + $this->info_box_contents[$line][] = array( + 'td' => 'align="left"', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($datem, "day") + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'align="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status,3) + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); + + $db->free($result); + } + else { + $this->info_box_contents[0][0] = array( 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql)); + } + } + else { + $this->info_box_contents[0][0] = array('align' => 'left', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } +} + diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 82d1444ff73..39d28b55311 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -37,10 +37,11 @@ class CMailFile { var $subject; // Topic: Subject of email - var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or '') + var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. + var $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) var $errors_to; // Errors-To: Email where to send errors. var $addr_to; var $addr_cc; @@ -190,6 +191,7 @@ class CMailFile // Define smtp_headers $this->subject = $subject; $this->addr_from = $from; + $this->reply_to = $from; // Set this property after constructor if you want to use another value $this->errors_to = $errors_to; $this->addr_to = $to; $this->addr_cc = $addr_cc; @@ -256,7 +258,8 @@ class CMailFile $smtps->setTO($this->getValidAddress($to,0,1)); $smtps->setFrom($this->getValidAddress($from,0,1)); $smtps->setTrackId($trackid); - + $smtps->setReplyTo($this->getValidAddress($from,0,1)); // Set property with this->smtps->setReplyTo after constructor if you want to use another value than the From + if (! empty($this->html)) { if (!empty($css)) @@ -308,6 +311,7 @@ class CMailFile $this->phpmailer->Subject($this->encodetorfc2822($subject)); $this->phpmailer->setTO($this->getValidAddress($to,0,1)); $this->phpmailer->SetFrom($this->getValidAddress($from,0,1)); + $this->phpmailer->SetReplyTo($this->getValidAddress($from,0,1)); // Set property with this->phpmailer->setReplyTo after constructor if you want to use another value than the From // TODO Add trackid into smtp header if (! empty($this->html)) @@ -341,12 +345,10 @@ class CMailFile } } - $smtps->setCC($addr_cc); - $smtps->setBCC($addr_bcc); - $smtps->setErrorsTo($errors_to); - $smtps->setDeliveryReceipt($deliveryreceipt); - - $this->smtps=$smtps; + $this->phpmailer->setCC($addr_cc); + $this->phpmailer->setBCC($addr_bcc); + $this->phpmailer->setErrorsTo($errors_to); + $this->phpmailer->setDeliveryReceipt($deliveryreceipt); } else { @@ -375,7 +377,7 @@ class CMailFile if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { - dol_include_once('/core/class/hookmanager.class.php'); + require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array( 'maildao' diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f7cb1ff7881..27a1b3c30d4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -384,7 +384,7 @@ abstract class CommonObject */ function errorsToString() { - return $this->error.(is_array($this->errors)?(($this->error!=''?' ':'').join(',',$this->errors)):''); + return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):''); } /** @@ -1001,26 +1001,30 @@ abstract class CommonObject { global $conf; - if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) return 0; + if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) + return 0; - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - $idtofetch=isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty); - if ($force_thirdparty_id) $idtofetch=$force_thirdparty_id; + $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty); + if ($force_thirdparty_id) + $idtofetch = $force_thirdparty_id; - $thirdparty = new Societe($this->db); - $result=$thirdparty->fetch($idtofetch); - $this->client = $thirdparty; // deprecated - $this->thirdparty = $thirdparty; + if ($idtofetch) { + $thirdparty = new Societe($this->db); + $result = $thirdparty->fetch($idtofetch); + $this->client = $thirdparty; // deprecated + $this->thirdparty = $thirdparty; - // Use first price level if level not defined for third party - if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level)) - { - $this->client->price_level=1; // deprecated - $this->thirdparty->price_level=1; - } + // Use first price level if level not defined for third party + if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level)) { + $this->client->price_level = 1; // deprecated + $this->thirdparty->price_level = 1; + } - return $result; + return $result; + } else + return -1; } @@ -2322,7 +2326,7 @@ abstract class CommonObject { $error++; $this->error=$this->db->lasterror(); - $this->error[]=$this->db->lasterror(); + $this->errors[]=$this->db->lasterror(); } } @@ -3347,6 +3351,8 @@ abstract class CommonObject $text.= ' - '.(! empty($line->label)?$line->label:$label); $description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. } + + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer @@ -3370,7 +3376,7 @@ abstract class CommonObject if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"'; else $placeholder=' title="'.$langs->trans("Label").'"'; - $pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 5bcbab5934a..94c7b7bf860 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -66,8 +66,6 @@ abstract class CommonObjectLine extends CommonObject $langs->load('products'); - $this->db->begin(); - $label_type = 'label'; if ($type == 'short') diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 828483db3c7..97645487d45 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1,12 +1,13 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2009-2012 Laurent Destailleur - * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Charles-Fr BENKE +/* Copyright (C) 2002-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2009-2012 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Charles-Fr BENKE + * Copyright (C) 2016 Raphaël Doursenaud * * 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 @@ -878,7 +879,7 @@ class ExtraFields } else { - $labeltoshow=$obj->$InfoFieldList[1]; + $labeltoshow=$obj->{$InfoFieldList[1]}; } $labeltoshow=dol_trunc($labeltoshow,45); @@ -899,12 +900,12 @@ class ExtraFields { if(!$notrans) { - $translabel=$langs->trans($obj->$InfoFieldList[1]); - if ($translabel!=$obj->$InfoFieldList[1]) { + $translabel=$langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel!=$obj->{$InfoFieldList[1]}) { $labeltoshow=dol_trunc($translabel,18); } else { - $labeltoshow=dol_trunc($obj->$InfoFieldList[1],18); + $labeltoshow=dol_trunc($obj->{$InfoFieldList[1]},18); } } if (empty($labeltoshow)) $labeltoshow='(not defined)'; @@ -1055,7 +1056,7 @@ class ExtraFields $labeltoshow .= $obj->$field_toshow . ' '; } } else { - $labeltoshow = $obj->$InfoFieldList[1]; + $labeltoshow = $obj->{$InfoFieldList[1]}; } $labeltoshow = dol_trunc($labeltoshow, 45); @@ -1076,11 +1077,11 @@ class ExtraFields $out .= '/>' . $labeltoshow . '
'; } else { if (! $notrans) { - $translabel = $langs->trans($obj->$InfoFieldList[1]); - if ($translabel != $obj->$InfoFieldList[1]) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel != $obj->{$InfoFieldList[1]}) { $labeltoshow = dol_trunc($translabel, 18); } else { - $labeltoshow = dol_trunc($obj->$InfoFieldList[1], 18); + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); } } if (empty($labeltoshow)) @@ -1274,13 +1275,13 @@ class ExtraFields else { $translabel=''; - if (!empty($obj->$InfoFieldList[1])) { - $translabel=$langs->trans($obj->$InfoFieldList[1]); + if (!empty($obj->{$InfoFieldList[1]})) { + $translabel=$langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel!=$obj->$InfoFieldList[1]) { + if ($translabel!=$obj->{$InfoFieldList[1]}) { $value=dol_trunc($translabel,18); }else { - $value=$obj->$InfoFieldList[1]; + $value=$obj->{$InfoFieldList[1]}; } } } @@ -1354,13 +1355,13 @@ class ExtraFields } } else { $translabel = ''; - if (! empty($obj->$InfoFieldList[1])) { - $translabel = $langs->trans($obj->$InfoFieldList[1]); + if (! empty($obj->{$InfoFieldList[1]})) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel != $obj->$InfoFieldList[1]) { + if ($translabel != $obj->{$InfoFieldList[1]}) { $value .= dol_trunc($translabel, 18) . '
'; } else { - $value .= $obj->$InfoFieldList[1] . '
'; + $value .= $obj->{$InfoFieldList[1]} . '
'; } } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7ad26f99dd5..4480fe7dd9a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -122,7 +122,7 @@ class Form * @param string $value Value to show/edit * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'dayhour' or 'datepickerhour', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...) * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value * @param object $extObject External object * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') @@ -503,7 +503,8 @@ class Form $ret.=''; } $ret.=''; - $ret.=''; + // Warning: if you set submit button to disabled, post using Enter will no more work + $ret.=''; $ret.=''; $ret.=' @@ -515,7 +516,6 @@ class Form /* console.log( index + ": " + $( this ).text() ); */ if ($(this).is(\':checked\')) atleastoneselected++; }); - console.log(atleastoneselected); if (atleastoneselected) { jQuery(".massaction").show(); @@ -531,6 +531,7 @@ class Form jQuery(".checkforselect").click(function() { initCheckForSelect(); }); + /* Warning: if you set submit button to disabled, post using Enter will no more work jQuery(".massactionselect").change(function() { console.log( $( this ).val() ); if ($(this).val() != \'0\') @@ -542,6 +543,7 @@ class Form jQuery(".massactionconfirmed").prop(\'disabled\', true); } }); + */ }); '; @@ -893,7 +895,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') - * @param int $showempty Add an empty field + * @param string $showempty Add an empty field (Can be '1' or text to use on empty line) * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -902,7 +904,7 @@ class Form * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @return string HTML string with select box for thirdparty. */ - function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='') + function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='') { $out=''; @@ -948,7 +950,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client in (1,3)') - * @param int $showempty Add an empty field + * @param string $showempty Add an empty field (Can be '1' or text to use on empty line) * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -959,7 +961,7 @@ class Form * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @return string HTML string with */ - function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='') + function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='') { global $conf,$user,$langs; @@ -1016,10 +1018,13 @@ class Form $out.= ''; print ''; print ''; print ''; print '
'; - print ''; + print ''; print '
'; } else { - print !empty($rate) ? $rate : 1; + print !empty($rate) ? price(price2num($rate), 1, $langs) : 1; } } @@ -4995,7 +5000,10 @@ class Form else { $(\'.'.$htmlname.'\').val( $(\'.'.$htmlname.'\').val().replace(title, \'\') ) } - }); + // Now, we submit page + $(this).parents(\'form:first\').submit(); + }); + '; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index e91184ede12..40276b6205d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -564,16 +564,21 @@ class FormCompany } } - // Refresh contacts list on thirdparty list change - $htmloption=''; $events=array(); + // Add an entry 'method' to say 'yes, we must execute url with param action = method'; + // Add an entry 'url' to say which url to execute + // Add an entry htmlname to say which element we must change once url is called + // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines + // To refresh contacts list on thirdparty list change $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events { print ' + '; + } + print ''; + } if ($page > 0) { if (empty($conf->dol_use_jmobile)) print ''; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 35c2810d47b..bdc18205001 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -4,7 +4,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Ferran Marcet - * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2015-2016 Raphaël Doursenaud * * 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 @@ -1910,7 +1910,7 @@ function fetchObjectByElement($element_id, $element_type) global $db,$conf; $element_prop = getElementProperties($element_type); - if (is_array($element_prop) && $conf->$element_prop['module']->enabled) + if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled) { dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 83c67509dcc..bc40cfde976 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -54,7 +54,8 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Dolibarr geturl function'); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation?true:false)); + @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation?true:false)); // We use @ here because this may return warning if safe mode is on or open_basedir is on + if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e0da649e53b..65b35014376 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -986,6 +986,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // General Ledger if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=accountancy_bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); + if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php?leftmenu=accountancy_bookkeeping",$langs->trans("AccountBalance"),2,$user->rights->accounting->mouvements->lire); if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php?leftmenu=accountancy_bookkeeping",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire); if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php?leftmenu=accountancy_bookkeeping",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e9307e1e3d4..05967be09d6 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1258,7 +1258,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1); diff --git a/htdocs/core/modules/facture/doc/pdf_crevette.modules.php b/htdocs/core/modules/facture/doc/pdf_crevette.modules.php deleted file mode 100644 index 6cac6b47f92..00000000000 --- a/htdocs/core/modules/facture/doc/pdf_crevette.modules.php +++ /dev/null @@ -1,2040 +0,0 @@ - - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2012-2014 Raphaël Doursenaud - * Copyright (C) 2015 Marcos García - * - * 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 . - * or see http://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/facture/doc/pdf_crabe.modules.php - * \ingroup facture - * \brief File of class to generate customers invoices from crabe model - */ - -require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; - - -/** - * Class to manage PDF invoice template Crabe - */ -class pdf_crevette extends ModelePDFFactures -{ - var $db; - var $name; - var $description; - var $type; - - var $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; - - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; - - var $emetteur; // Objet societe qui emet - - /** - * @var bool Situation invoice type - */ - public $situationinvoice; - - /** - * @var float X position for the situation progress column - */ - public $posxprogress; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("bills"); - - $this->db = $db; - $this->name = "crevette"; - $this->description = $langs->trans('PDFCrevetteDescription'); - - // Dimension page pour format A4 - $this->type = 'pdf'; - $formatarray=pdf_getFormat(); - $this->page_largeur = $formatarray['width']; - $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 1; // Affiche si il y a eu escompte - $this->option_credit_note = 1; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts - - $this->franchise=!$mysoc->tva_assuj; - - // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined - - // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - if($conf->global->PRODUCT_USE_UNITS) - { - $this->posxtva=99; - $this->posxup=114; - $this->posxqty=133; - $this->posxunit=150; - } - else - { - $this->posxtva=112; - $this->posxup=126; - $this->posxqty=145; - } - $this->posxdiscount=162; - $this->posxprogress=162; // Only displayed for situation invoices - $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_UNITPRICE)) $this->posxup = $this->posxqty; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - if ($this->page_largeur < 210) // To work with US executive format - { - $this->posxpicture-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->posxdiscount-=20; - $this->postotalht-=20; - } - - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; - $this->situationinvoice=False; - } - - - /** - * Function to build pdf onto disk - * - * @param Object $object Object to generate - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return int 1=OK, 0=KO - */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) - { - global $user,$langs,$conf,$mysoc,$db,$hookmanager; - - if (! is_object($outputlangs)) $outputlangs=$langs; - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - - $nblignes = count($object->lines); - - // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) - { - for ($i = 0 ; $i < $nblignes ; $i++) - { - if (empty($object->lines[$i]->fk_product)) continue; - - $objphoto = new Product($this->db); - $objphoto->fetch($object->lines[$i]->fk_product); - - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,'product') . $object->lines[$i]->fk_product ."/photos/"; - $dir = $conf->product->dir_output.'/'.$pdir; - - $realpath=''; - foreach ($objphoto->liste_photos($dir,1) as $key => $obj) - { - $filename=$obj['photo']; - //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; - $realpath = $dir.$filename; - break; - } - - if ($realpath) $realpatharray[$i]=$realpath; - } - } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - - if ($conf->facture->dir_output) - { - $object->fetch_thirdparty(); - - $deja_regle = $object->getSommePaiement(); - $amount_credit_notes_included = $object->getSumCreditNotesUsed(); - $amount_deposits_included = $object->getSumDepositsUsed(); - - // Definition of $dir and $file - if ($object->specimen) - { - $dir = $conf->facture->dir_output; - $file = $dir . "/SPECIMEN.pdf"; - } - else - { - $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->facture->dir_output . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; - } - if (! file_exists($dir)) - { - if (dol_mkdir($dir) < 0) - { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); - return 0; - } - } - - if (file_exists($dir)) - { - // Add pdfgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } - $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - - // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - $pdf->SetAutoPageBreak(1,0); - - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - - // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) - { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); - $tplidx = $pdf->importPage(1); - } - - $pdf->Open(); - $pagenb=0; - $pdf->SetDrawColor(128,128,128); - - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Invoice")); - $pdf->SetCreator("Dolibarr ".DOL_VERSION); - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice")); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - - // Positionne $this->atleastonediscount si on a au moins une remise - for ($i = 0 ; $i < $nblignes ; $i++) - { - if ($object->lines[$i]->remise_percent) - { - $this->atleastonediscount++; - } - } - if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) - { - $this->posxpicture+=($this->postotalht - $this->posxdiscount); - $this->posxtva+=($this->postotalht - $this->posxdiscount); - $this->posxup+=($this->postotalht - $this->posxdiscount); - $this->posxqty+=($this->postotalht - $this->posxdiscount); - $this->posxdiscount+=($this->postotalht - $this->posxdiscount); - //$this->postotalht; - } - - // Situation invoice handling - if ($object->situation_cycle_ref) - { - $this->situationinvoice = True; - $progress_width = 14; - $this->posxtva -= $progress_width; - $this->posxup -= $progress_width; - $this->posxqty -= $progress_width; - $this->posxdiscount -= $progress_width; - $this->posxunit -= $progress_width; - //$this->posxprogress -= $progress_width; - $this->posxpicture -= $progress_width; - $this->postotalht += 8; - } - - // New page - $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pagenb++; - - $this->_pagehead($pdf, $object, 1, $outputlangs); - $pdf->SetFont('','', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetTextColor(0,0,0); - - $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); - $tab_height = 130; - $tab_height_newpage = 150; - - // Incoterm - $height_incoterms = 0; - if ($conf->incoterm->enabled) - { - $desc_incoterms = $object->getIncotermsForPDF(); - if ($desc_incoterms) - { - $tab_top = 88; - - $pdf->SetFont('','', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); - $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; - - // Rect prend une longueur en 3eme param - $pdf->SetDrawColor(192,192,192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - - $tab_top = $nexY+6; - $height_incoterms += 4; - } - } - - // Affiche notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) - { - // Get first sale rep - if (is_object($object->thirdparty)) - { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); - $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); - } - } - if ($notetoshow) - { - $tab_top = 88 + $height_incoterms; - - $pdf->SetFont('','', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); - $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; - - // Rect prend une longueur en 3eme param - $pdf->SetDrawColor(192,192,192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - - $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; - } - else - { - $height_note=0; - } - - if ($this->situationinvoice) - { - $object->fetchPreviousNextSituationInvoice(); - - $total_decompte = $object->total_ht; - - if (count($object->tab_previous_situation_invoice) > 0) - { - foreach ($object->tab_previous_situation_invoice as $prev_invoice) - { - $total_decompte += $prev_invoice->total_ht; - } - } - - $top = $tab_top; - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, $langs->trans('PDFCrevetteSituationInvoiceTitle'), 0, 1); - - $pdf->SetFont('','', $default_font_size - 2); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency)); - $pdf->writeHTMLCell(90, 3, $this->posxdesc+100, $tab_top, $titre, 0, 1, false, true, 'R'); - $pdf->SetFont('','', $default_font_size); - - $pdf->Line($this->posxdesc-1, $pdf->GetY(), $this->page_largeur-$this->marge_droite, $pdf->GetY()); - - $nexY = $pdf->GetY(); - $tab_top = $nexY+1; - $pdf->writeHTMLCell(90, 3, $this->posxdesc-1, $tab_top, $langs->trans('PDFCrevetteSituationInvoiceLineDecompte'), 0, 1); - $price_display = price(abs($total_decompte)); - $pdf->writeHTMLCell(90, 3, $this->posxdesc+100, $tab_top, $price_display, 0, 1, false, true, 'R'); - - if (count($object->tab_previous_situation_invoice) > 0) - { - $object->totalTCCPreviousSitutationInvoice = 0; - - foreach ($object->tab_previous_situation_invoice as $prev_invoice) - { - $nexY = $pdf->GetY(); - $tab_top = $nexY+1; - $pdf->writeHTMLCell(90, 3, $this->posxdesc-1, $tab_top, $langs->trans('PDFCrevetteSituationInvoiceLine', $prev_invoice->situation_counter, $prev_invoice->ref, dol_print_date($prev_invoice->date)), 0, 1); - - $price_display = -1 * abs($prev_invoice->total_ht); - $price_display = price($price_display); - $pdf->writeHTMLCell(90, 3, $this->posxdesc+100, $tab_top, $price_display, 0, 1, false, true, 'R'); - - $object->totalTCCPreviousSitutationInvoice += $prev_invoice->total_ttc; - } - - $nexY = $pdf->GetY(); - $height_situation=$nexY-$top; - - $tab_height = $tab_height - $height_situation; - $tab_top = $nexY+7; - } - - $this->page =1; - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; - - // Affiche zone infos - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - - // Affiche zone totaux - foreach ($object->lines as $line) - { - $vatrate=(string) $line->tva_tx; - - $prev_progress = $line->get_prev_progress(); - if ($prev_progress > 0) $tvaligne = $line->total_tva * ($line->situation_percent - $prev_progress) / $line->situation_percent; - else $tvaligne = $line->total_tva; - - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - - if (($line->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; - $this->tva[$vatrate] += $tvaligne; - } - - $posy=$this->_tableau_tot_situation($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - $this->tva = array(); - - // Pied de page - $this->_pagefoot($pdf,$object,$outputlangs,1); - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); - - // Page break - $pageposbefore=$pdf->getPage(); - $pdf->AddPage(); - $pagenb++; - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); - $showpricebeforepagebreak=0; - - $iniY = $tab_top_newpage+10; - $curY = $tab_top_newpage+10; - $nexY = $tab_top_newpage+10; - } - else - { - $iniY = $tab_top + 7; - $curY = $tab_top + 7; - $nexY = $tab_top + 7; - } - - // Loop on each lines - for ($i = 0; $i < $nblignes; $i++) - { - $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - $pdf->SetTextColor(0,0,0); - - // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); - - $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); - - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; - - // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page - { - $pdf->AddPage('','',true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); - - $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; - } - - if (isset($imglinesize['width']) && isset($imglinesize['height'])) - { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi - // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; - } - - // Description of product line - $curX = $this->posxdesc-1; - - $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); - $pageposafter=$pdf->getPage(); - if ($pageposafter > $pageposbefore) // There is a pagebreak - { - $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text - { - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page - { - $pdf->AddPage('','',true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); - } - } - else - { - // We found a page break - $showpricebeforepagebreak=0; - } - } - else // No pagebreak - { - $pdf->commitTransaction(); - } - $posYAfterDescription=$pdf->GetY(); - - $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); - - $pdf->setPage($pageposbefore); - $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - - // We suppose that a too long description or photo were moved completely on next page - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; - } - - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut - - // VAT Rate - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); - } - - // Unit price before discount - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_UNITPRICE)) - { - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); - } - - // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxqty, $curY); - // Enough for 6 chars - if($conf->global->PRODUCT_USE_UNITS) - { - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); - } - else - { - $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); - } - - // Unit - if($conf->global->PRODUCT_USE_UNITS) - { - if ($this->situationinvoice) - { - $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); - $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxprogress-$this->posxunit-0.8, 4, $unit, 0, 'L'); - } - else - { - $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); - $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); - } - } - - // Discount on line - if ($object->lines[$i]->remise_percent) - { - $pdf->SetXY($this->posxdiscount-2, $curY); - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); - $pdf->MultiCell($this->posxprogress-$this->posxdiscount, 3, $remise_percent, 0, 'R'); - } - - if ($this->situationinvoice) - { - // Situation progress - $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxprogress, $curY); - $pdf->MultiCell($this->postotalht-$this->posxprogress, 3, $progress, 0, 'R'); - } - - // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); - - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $prev_progress = $object->lines[$i]->get_prev_progress(); - if ($prev_progress > 0) // Compute progress from previous situation - { - $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; - } else { - $tvaligne = $object->lines[$i]->total_tva; - } - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; - - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; - - $vatrate=(string) $object->lines[$i]->tva_tx; - - // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax - { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc); - $localtax1_type = $localtaxtmp_array[0]; - $localtax2_type = $localtaxtmp_array[2]; - } - - // retrieve global local tax - if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; - if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; - - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; - $this->tva[$vatrate] += $tvaligne; - - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; - - // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) - { - $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); - //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); - $pdf->SetLineStyle(array('dash'=>0)); - } - - $nexY+=2; // Passe espace entre les lignes - - // Detect if some page were added automatically and output _tableau for past pages - while ($pagenb < $pageposafter) - { - $pdf->setPage($pagenb); - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); - } - $this->_pagefoot($pdf,$object,$outputlangs,1); - $pagenb++; - $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) - { - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); - } - $this->_pagefoot($pdf,$object,$outputlangs,1); - // New page - $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - } - } - - // Show square - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } - elseif ($this->situationinvoice && $pagenb == 2) - { - $this->_tableau($pdf, $tab_top_newpage+4, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter - 4, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } - - // Affiche zone infos - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - - // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - - // Affiche zone versements - if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) - { - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); - } - - // Pied de page - $this->_pagefoot($pdf,$object,$outputlangs); - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); - - $pdf->Close(); - - $pdf->Output($file,'F'); - - // Add pdfgeneration hook - $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - - return 1; // Pas d'erreur - } - else - { - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); - return 0; - } - } - else - { - $this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR"); - return 0; - } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut - } - - - /** - * Show payments table - * - * @param PDF $pdf Object PDF - * @param Object $object Object invoice - * @param int $posy Position y in PDF - * @param Translate $outputlangs Object langs for output - * @return int <0 if KO, >0 if OK - */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) - { - global $conf; - - $sign=1; - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; - - $tab3_posx = 120; - $tab3_top = $posy + 8; - $tab3_width = 80; - $tab3_height = 4; - if ($this->page_largeur < 210) // To work with US executive format - { - $tab3_posx -= 20; - } - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); - if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); - - $pdf->SetFont('','', $default_font_size - 3); - $pdf->SetXY($tab3_posx, $tab3_top - 4); - $pdf->MultiCell(60, 3, $title, 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); - - $pdf->SetFont('','', $default_font_size - 4); - $pdf->SetXY($tab3_posx, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); - - $y=0; - - $pdf->SetFont('','', $default_font_size - 4); - - // Loop on each deposits and credit notes included - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql.= " re.description, re.fk_facture_source,"; - $sql.= " f.type, f.datef"; - $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; - $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id; - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i=0; - $invoice=new Facture($this->db); - while ($i < $num) - { - $y+=3; - $obj = $this->db->fetch_object($resql); - - if ($obj->type == 2) $text=$outputlangs->trans("CreditNote"); - elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit"); - else $text=$outputlangs->trans("UnknownType"); - - $invoice->fetch($obj->fk_facture_source); - - $pdf->SetXY($tab3_posx, $tab3_top+$y); - $pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); - $pdf->MultiCell(20, 3, $text, 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); - $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); - - $i++; - } - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - - // Loop on each payment - $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; - $sql.= " cp.code"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; - $sql.= " ORDER BY p.datep"; - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i=0; - while ($i < $num) { - $y+=3; - $row = $this->db->fetch_object($resql); - - $pdf->SetXY($tab3_posx, $tab3_top+$y); - $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); - - $pdf->MultiCell(20, 3, $oper, 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); - $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); - - $i++; - } - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - - } - - - /** - * Show miscellaneous information (payment mode, payment term, ...) - * - * @param PDF $pdf Object PDF - * @param Object $object Object to show - * @param int $posy Y - * @param Translate $outputlangs Langs object - * @return void - */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) - { - global $conf; - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - $pdf->SetFont('','', $default_font_size - 1); - - // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) - { - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - - $posy=$pdf->GetY()+4; - } - - $posxval=52; - - // Show payments conditions - if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) - { - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentConditions").':'; - $pdf->MultiCell(80, 4, $titre, 0, 'L'); - - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); - $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); - $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); - - $posy=$pdf->GetY()+3; - } - - if ($object->type != 2) - { - // Check a payment mode is defined - if (empty($object->mode_reglement_code) - && empty($conf->global->FACTURE_CHQ_NUMBER) - && empty($conf->global->FACTURE_RIB_NUMBER)) - { - $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"); - } - // Avoid having any valid PDF with setup that is not complete - elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER)) - || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER))) - { - $outputlangs->load("errors"); - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B', $default_font_size - 2); - $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup",$object->mode_reglement_code); - $pdf->MultiCell(80, 3, $this->error,0,'L',0); - $pdf->SetTextColor(0,0,0); - - $posy=$pdf->GetY()+1; - } - - // Show payment mode - if ($object->mode_reglement_code - && $object->mode_reglement_code != 'CHQ' - && $object->mode_reglement_code != 'VIR') - { - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentMode").':'; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); - - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posxval, $posy); - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); - - $posy=$pdf->GetY()+2; - } - - // Show payment mode CHQ - if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') - { - // Si mode reglement non force ou si force a CHQ - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) - { - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); - - if ($conf->global->FACTURE_CHQ_NUMBER > 0) - { - $account = new Account($this->db); - $account->fetch($conf->global->FACTURE_CHQ_NUMBER); - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','B', $default_font_size - $diffsizetitle); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0); - $posy=$pdf->GetY()+1; - - if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) - { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','', $default_font_size - $diffsizetitle); - $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); - $posy=$pdf->GetY()+2; - } - } - if ($conf->global->FACTURE_CHQ_NUMBER == -1) - { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','B', $default_font_size - $diffsizetitle); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0); - $posy=$pdf->GetY()+1; - - if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) - { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','', $default_font_size - $diffsizetitle); - $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); - $posy=$pdf->GetY()+2; - } - } - } - } - - // If payment mode not forced or forced to VIR, show payment with BAN - if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') - { - if (! empty($object->fk_account) || ! empty($conf->global->FACTURE_RIB_NUMBER)) - { - $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); - $account = new Account($this->db); - $account->fetch($bankid); - - $curx=$this->marge_gauche; - $cury=$posy; - - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); - - $posy+=2; - } - } - } - - return $posy; - } - - - /** - * Show total to pay - * - * @param PDF $pdf Object PDF - * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart - * @param Translate $outputlangs Objet langs - * @return int Position pour suite - */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) - { - global $conf,$mysoc; - - $sign=1; - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - $tab2_top = $posy; - $tab2_hl = 4; - $pdf->SetFont('','', $default_font_size - 1); - - // Tableau total - $col1x = 120; $col2x = 170; - if ($this->page_largeur < 210) // To work with US executive format - { - $col2x-=20; - } - $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - - $useborder=0; - $index = 0; - - // Total HT - $pdf->SetFillColor(255,255,255); - $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); - - // Show VAT by rates and total - $pdf->SetFillColor(248,248,248); - - $this->atleastoneratenotnull=0; - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) - { - // Nothing to do - } - else - { - //Local tax 1 before VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') - //{ - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - if ($tvakey!=0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - } - //} - //Local tax 2 before VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - //{ - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - if ($tvakey!=0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - - } - } - } - //} - // VAT - foreach($this->tva as $tvakey => $tvaval) - { - if ($tvakey > 0) // On affiche pas taux 0 - { - $this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; - $totalvat.=vatrate($tvakey,1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - - //Local tax 1 after VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') - //{ - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - if ($tvakey != 0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - } - //} - //Local tax 2 after VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - //{ - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - // retrieve global local tax - if ($tvakey != 0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - //} - } - - // Revenue stamp - if (price2num($object->revenuestamp) != 0) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1); - } - - // Total TTC - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); - } - } - - $pdf->SetTextColor(0,0,0); - - $creditnoteamount=$object->getSumCreditNotesUsed(); - $depositsamount=$object->getSumDepositsUsed(); - //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if ($object->paye) $resteapayer=0; - - if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) - { - // Already paid + Deposits - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0); - - // Credit note - if ($creditnoteamount) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0); - } - - // Escompte - if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) - { - $index++; - $pdf->SetFillColor(255,255,255); - - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1); - - $resteapayer=0; - } - - $index++; - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); - - $pdf->SetFont('','', $default_font_size - 1); - $pdf->SetTextColor(0,0,0); - } - - $index++; - return ($tab2_top + ($tab2_hl * $index)); - } - - /** - * Show total to pay - * - * @param PDF $pdf Object PDF - * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart - * @param Translate $outputlangs Objet langs - * @return int Position pour suite - */ - function _tableau_tot_situation(&$pdf, $object, $deja_regle, $posy, $outputlangs) - { - global $conf,$mysoc; - - $pdf->Line($this->posxdesc-1, $posy-2, $this->page_largeur-$this->marge_droite, $posy-2); - - $sign=1; - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - $tab2_top = $posy; - $tab2_hl = 4; - $pdf->SetFont('','', $default_font_size - 1); - - // Tableau total - $col1x = 120; $col2x = 170; - if ($this->page_largeur < 210) // To work with US executive format - { - $col2x-=20; - } - $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - - $useborder=0; - $index = 0; - - // Total HT - $pdf->SetFillColor(255,255,255); - $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); - - // Show VAT by rates and total - $pdf->SetFillColor(248,248,248); - - $this->atleastoneratenotnull=0; - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) - { - // Nothing to do - } - else - { - //Local tax 1 before VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') - //{ - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - if ($tvakey!=0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - } - //} - //Local tax 2 before VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - //{ - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - if ($tvakey!=0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - - } - } - } - //} - // VAT - foreach($this->tva as $tvakey => $tvaval) - { - if ($tvakey > 0) // On affiche pas taux 0 - { - $this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; - $totalvat.=vatrate($tvakey,1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - - //Local tax 1 after VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') - //{ - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - if ($tvakey != 0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - } - //} - //Local tax 2 after VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - //{ - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) - { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) - { - // retrieve global local tax - if ($tvakey != 0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - //} - } - - // Revenue stamp - if (price2num($object->revenuestamp) != 0) - { - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1); - } - - // Total TTC - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); - } - } - - $index++; - return ($tab2_top + ($tab2_hl * $index)); - } - - - /** - * Show table for lines - * - * @param PDF $pdf Object PDF - * @param string $tab_top Top position of table - * @param string $tab_height Height of table (rectangle) - * @param int $nexY Y (not used) - * @param Translate $outputlangs Langs object - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title - * @param int $hidebottom Hide bottom bar of array - * @return void - */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) - { - global $conf; - - // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - // Amount in (at tab_top - 1) - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','', $default_font_size - 2); - - if (empty($hidetop)) - { - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); - } - - $pdf->SetDrawColor(128,128,128); - $pdf->SetFont('','', $default_font_size - 1); - - // Output Rect - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param - - if (empty($hidetop)) - { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param - - $pdf->SetXY($this->posxdesc-1, $tab_top+1); - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); - } - - if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) - { - $pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height); - if (empty($hidetop)) - { - //$pdf->SetXY($this->posxpicture-1, $tab_top+1); - //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C'); - } - } - - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) - { - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); - if (empty($hidetop)) - { - $pdf->SetXY($this->posxtva-3, $tab_top+1); - $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); - } - } - - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_UNITPRICE)) - { - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); - if (empty($hidetop)) - { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); - } - } - - - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); - if (empty($hidetop)) - { - $pdf->SetXY($this->posxqty-1, $tab_top+1); - if($conf->global->PRODUCT_USE_UNITS) - { - $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); - } - else - { - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); - } - } - - if($conf->global->PRODUCT_USE_UNITS) { - $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); - if (empty($hidetop)) { - $pdf->SetXY($this->posxunit - 1, $tab_top + 1); - $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', - 'C'); - } - } - - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); - if (empty($hidetop)) - { - if ($this->atleastonediscount) - { - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); - $pdf->MultiCell($this->posxprogress-$this->posxdiscount,2, $outputlangs->transnoentities("ReductionShort"),'','C'); - } - } - - if ($this->situationinvoice) - { - if ($this->atleastonediscount) $pdf->line($this->posxprogress - 2, $tab_top, $this->posxprogress - 2, $tab_top + $tab_height); - else $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); - - if (empty($hidetop)) { - $pdf->SetXY($this->posxprogress-1, $tab_top + 1); - if($conf->global->PRODUCT_USE_UNITS) - { - $pdf->MultiCell(20, 2, $outputlangs->transnoentities("Progress"), '', 'C'); - } - else - { - $pdf->MultiCell(20, 2, $outputlangs->transnoentities("Progress"), '', 'C'); - } - } - } - - if ($this->atleastonediscount) - { - $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); - } - if (empty($hidetop)) - { - $pdf->SetXY($this->postotalht-1, $tab_top+1); - $pdf->MultiCell(22,2, $outputlangs->transnoentities("TotalHT"),'','C'); - } - } - - /** - * Show top header of page. - * - * @param PDF $pdf Object PDF - * @param Object $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @return void - */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) - { - global $conf,$langs; - - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("companies"); - - $default_font_size = pdf_getPDFFontSize($outputlangs); - - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); - - // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) - { - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK); - } - - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('','B', $default_font_size + 3); - - $w = 110; - - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-$w; - - $pdf->SetXY($this->marge_gauche,$posy); - - // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) - { - if (is_readable($logo)) - { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } - else - { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B',$default_font_size - 2); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } - - $pdf->SetFont('','B', $default_font_size + 3); - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $title=$outputlangs->transnoentities("Invoice"); - if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); - if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); - if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); - if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat"); - $pdf->MultiCell($w, 3, $title, '', 'R'); - - $pdf->SetFont('','B',$default_font_size); - - $posy+=5; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); - - $posy+=1; - $pdf->SetFont('','', $default_font_size - 2); - - if ($object->ref_client) - { - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); - } - - $objectidnext=$object->getIdReplacingInvoice('validated'); - if ($object->type == 0 && $objectidnext) - { - $objectreplacing=new Facture($this->db); - $objectreplacing->fetch($objectidnext); - - $posy+=3; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R'); - } - if ($object->type == 1) - { - $objectreplaced=new Facture($this->db); - $objectreplaced->fetch($object->fk_facture_source); - - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); - } - if ($object->type == 2) - { - $objectreplaced=new Facture($this->db); - $objectreplaced->fetch($object->fk_facture_source); - - $posy+=3; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); - } - - - if ($this->situationinvoice) - { - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("PDFCrevetteSituationNumber", $object->situation_counter), '', 'R'); - } - - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date,"day",false,$outputlangs), '', 'R'); - - if ($object->type != 2) - { - $posy+=3; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R'); - } - - if ($object->thirdparty->code_client) - { - $posy+=3; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); - } - - $posy+=1; - - // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); - - if ($showaddress) - { - // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); - - // Show sender - $posy=42; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; - - // Show sender frame - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posx,$posy-5); - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); - $pdf->SetXY($posx,$posy); - $pdf->SetFillColor(230,230,230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); - $pdf->SetTextColor(0,0,60); - - // Show sender name - $pdf->SetXY($posx+2,$posy+3); - $pdf->SetFont('','B', $default_font_size); - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); - - // Show sender information - $pdf->SetXY($posx+2,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - - - - // If BILLING contact defined on invoice, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external','BILLING'); - if (count($arrayidcontact) > 0) - { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); - } - - //Recipient name - // On peut utiliser le nom de la societe du contact - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { - $thirdparty = $object->contact; - } else { - $thirdparty = $object->client; - } - - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); - - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); - - // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; - - // Show recipient frame - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posx+2,$posy-5); - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); - - // Show recipient name - $pdf->SetXY($posx+2,$posy+3); - $pdf->SetFont('','B', $default_font_size); - $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); - - $posy = $pdf->getY(); - - // Show recipient information - $pdf->SetFont('','', $default_font_size - 1); - $pdf->SetXY($posx+2,$posy); - $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); - } - - $pdf->SetTextColor(0,0,0); - } - - /** - * Show footer of page. Need this->emetteur object - * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) - { - $showdetails=0; - return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); - } - -} - diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index ca9f2b11f0d..42f59e7c2fb 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -123,7 +123,7 @@ class mailing_fraise extends MailingTargets $s.=''; $s.=' '; $s.=$langs->trans("Type").': '; - $s.=''; $sql = "SELECT rowid, libelle, statut"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; $sql.= " WHERE entity = ".$conf->entity; @@ -212,7 +212,7 @@ class mailing_fraise extends MailingTargets if ($dateendsubscriptionafter > 0) $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'"; if ($dateendsubscriptionbefore > 0) $sql.=" AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'"; $sql.= " AND a.fk_adherent_type = ta.rowid"; - if ($_POST['filter']) $sql.= " AND ta.rowid='".$_POST['filter']."'"; + if ($_POST['filtertype']) $sql.= " AND ta.rowid='".$_POST['filtertype']."'"; $sql.= " ORDER BY a.email"; //print $sql; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 314536c28b5..6d29a426afd 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -83,7 +83,7 @@ class modExpedition extends DolibarrModules // Constants $this->const = array(); $r=0; - + $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "rouget"; @@ -124,7 +124,15 @@ class modExpedition extends DolibarrModules $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/delivery"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; - + $r++; + + $this->const[$r][0] = "MAIN_SUBMODULE_EXPEDITION"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "1"; + $this->const[$r][3] = "Enable shipments"; + $this->const[$r][4] = 0; + $r++; + // Boxes $this->boxes = array(); diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 6642e33719f..48ce8bc3bc0 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -46,7 +46,7 @@ class modMultiCurrency extends DolibarrModules // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page http://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + $this->numero = 40000; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'multicurrency'; @@ -54,14 +54,12 @@ class modMultiCurrency extends DolibarrModules // It is used to group modules in module setup page $this->family = "financial"; // Module position in the family - $this->module_position = 500; - // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - $this->familyinfo = array('financial' => array('position'=>'009', 'label'=>$langs->trans("ModuleFamilyFinancial"))); + $this->module_position = 555; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Description of module MyModule"; + $this->description = "Module to enter elements with a foreign currency"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version $this->version = 'development'; diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 0ccab13e2b5..dc19839011b 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -139,8 +139,8 @@ class modOauth extends DolibarrModules $this->remove($options); $sql = array( - "CREATE TABLE IF NOT EXISTS llx_oauth_state (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), state varchar(128), fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", - "CREATE TABLE IF NOT EXISTS llx_oauth_token (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), token text, fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."oauth_state (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), state varchar(128), fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."oauth_token (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), token text, fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", ); return $this->_init($sql,$options); diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 41fd00e5463..311971264f4 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -131,7 +131,9 @@ class modSociete extends DolibarrModules $this->boxes[$r][1] = "box_activity.php"; $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; $r++; - + $this->boxes[$r][1] = "box_goodcustomers.php"; + $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; + $r++; // Permissions $this->rights = array(); $this->rights_class = 'societe'; @@ -284,7 +286,11 @@ class modSociete extends DolibarrModules case 'sellist': $tmp=''; $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); + if ($tmpparam['options'] && is_array($tmpparam['options'])) + { + $stack=array_keys($tmpparam['options']); + $tmp=array_shift($stack); + } if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; break; } diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 43232ed92f2..623c131086b 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -45,7 +45,7 @@ $backtourl = GETPOST('backtourl', 'alpha'); $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri->setQuery(''); -$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/google_oauthcallback.php'); /** diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 7c6e965f778..5177e108f40 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -75,7 +75,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - $urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php' + $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' ); $access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken'); $serviceFactory = new \OAuth\ServiceFactory(); @@ -113,7 +113,7 @@ class printing_printgcp extends PrintingDriver if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); - $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); + $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); if ($token_ok) { $refreshtoken = $token->getRefreshToken(); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); @@ -122,10 +122,10 @@ class printing_printgcp extends PrintingDriver } /* if ($storage->hasAccessToken('Google')) { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); - $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); } else { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); }*/ } else { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info'); @@ -200,7 +200,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); @@ -338,7 +338,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getoauthcallback.php?service=google' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php?service=google' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); @@ -387,7 +387,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 5c77944843c..a67f78185d6 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1187,7 +1187,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1); diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php new file mode 100644 index 00000000000..fb06c028aed --- /dev/null +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -0,0 +1,140 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php + * \ingroup supplier_payment + * \brief File containing class for numbering module Brodator + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; + + +/** + * Class to manage customer payment numbering rules Ant + */ +class mod_supplier_payment_brodator extends ModeleNumRefPayments +{ + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + var $error = ''; + var $nom = 'Brodator'; + + + /** + * Renvoi la description du modele de numerotation + * + * @return string Texte descripif + */ + function info() + { + global $conf,$langs; + + $langs->load("bills"); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte.= ''; + $texte.= ''; + + $texte.= ''; + + $texte.= ''; + + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('',$tooltip,1,1).' 
'; + $texte.= '
'; + + return $texte; + } + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + global $conf,$langs,$mysoc; + + $old_code_client=$mysoc->code_client; + $mysoc->code_client='CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc,''); + $mysoc->code_client=$old_code_client; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + function getNextValue($objsoc,$object) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask=$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $numFinal=get_next_value($db,$mask,'paiementfourn','ref','',$objsoc,$object->datepaye); + + return $numFinal; + } + + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @return string Next free value + */ + function commande_get_num($objsoc,$objforref) + { + return $this->getNextValue($objsoc,$objforref); + } + +} + diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php new file mode 100644 index 00000000000..e7146e2e1fd --- /dev/null +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -0,0 +1,150 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/payment/mod_payment_bronan.php + * \ingroup supplier_payment + * \brief File containing class for numbering module Bronan + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; + +/** + * Class to manage customer payment numbering rules Cicada + */ +class mod_supplier_payment_bronan extends ModeleNumRefPayments +{ + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + var $prefix='SPAY'; + var $error=''; + var $nom='Bronan'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); + } + + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Test si les numeros deje en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + global $conf,$langs,$db; + + $payyymm=''; $max=''; + + $posindice=9; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; + $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } + } + if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + function getNextValue($objsoc,$object) + { + global $db,$conf; + + // D'abord on recupere la valeur max + $posindice=10; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; + $sql.= " WHERE ref like '".$this->prefix."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog(__METHOD__, LOG_DEBUG); + return -1; + } + + //$date=time(); + $date=$object->datepaye; + $yymm = strftime("%y%m",$date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); + + dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } + + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @return string Next free value + */ + function payment_get_num($objsoc,$objforref) + { + return $this->getNextValue($objsoc,$objforref); + } + +} diff --git a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php new file mode 100644 index 00000000000..c9023a9fc65 --- /dev/null +++ b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php @@ -0,0 +1,101 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \class ModeleNumRefPayments + * \brief Payment numbering references mother class + */ + +abstract class ModeleNumRefPayments +{ + var $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + function isEnabled() + { + return true; + } + + /** + * Return the default description of numbering module + * + * @return string Texte descripif + */ + function info() + { + global $langs; + $langs->load("bills"); + return $langs->trans("NoDescription"); + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $langs; + $langs->load("bills"); + return $langs->trans("NoExample"); + } + + /** + * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + return true; + } + + /** + * Returns the next value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Valeur + */ + function getNextValue($objsoc,$object) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Returns the module numbering version + * + * @return string Value + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 4a14998d0c4..cc7123bba7e 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1051,7 +1051,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1); diff --git a/htdocs/core/search.php b/htdocs/core/search.php index ccb8838e42f..05b03064096 100644 --- a/htdocs/core/search.php +++ b/htdocs/core/search.php @@ -126,8 +126,19 @@ if (GETPOST('search_project') != '') } if (GETPOST('search_task') != '') { - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php?mode=search&search_all='.urlencode(GETPOST('search_task'))); - exit; + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php?mode=search&search_all='.urlencode(GETPOST('search_task'))); + exit; +} + +if (GETPOST('search_user') != '') +{ + header("Location: ".DOL_URL_ROOT.'/user/index.php?mode=search&sall='.urlencode(GETPOST('search_user'))); + exit; +} +if (GETPOST('search_group') != '') +{ + header("Location: ".DOL_URL_ROOT.'/user/group/index.php?mode=search&sall='.urlencode(GETPOST('search_group'))); + exit; } diff --git a/htdocs/custom/README.md b/htdocs/custom/README.md index e46934902cb..5f15148f685 100644 --- a/htdocs/custom/README.md +++ b/htdocs/custom/README.md @@ -9,7 +9,7 @@ of the module. For example on Linux OS: Get the module from the command mkdir ~/git; cd ~/git -git clone https://git.doliforge.org/p/newmodule/newmodule.git +git clone https://git.framasoft.org/p/newmodule/newmodule.git Then create the symbolic link ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f543f265d40..f3a2a1928b4 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Francis Appels * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -199,7 +200,7 @@ if (empty($reshook)) $batch="batchl".$i."_0"; $stockLocation="ent1".$i."_0"; $qty = "qtyl".$i; - + if (isset($_POST[$batch])) { //shipment line with batch-enable product @@ -242,7 +243,8 @@ if (empty($reshook)) } else { - //shipment line for product with no batch management + //var_dump($_POST); var_dump($batch); + //shipment line for product with no batch management and no multiple stock location if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); } @@ -277,7 +279,7 @@ if (empty($reshook)) { if ($stockLine[$i][$j]['qty']>0) { - $ret=$object->addline($stockLine[$i][$j]['warehouse_id'], $stockLine[$i][$j]['ix_l'], $stockLine[$i][$j]['qty']); + $ret=$object->addline($stockLine[$i][$j]['warehouse_id'], $stockLine[$i][$j]['ix_l'], $stockLine[$i][$j]['qty'], $array_options[$i]); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -286,19 +288,22 @@ if (empty($reshook)) } } } - if (GETPOST($qty,'int') > 0 || (GETPOST($qty,'int') == 0 && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) + else { - $ent = "entl".$i; - $idl = "idl".$i; - $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); - if ($entrepot_id < 0) $entrepot_id=''; - if (! ($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0; - - $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int'),$array_options[$i]); - if ($ret < 0) + if (GETPOST($qty,'int') > 0 || (GETPOST($qty,'int') == 0 && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; + $ent = "entl".$i; + $idl = "idl".$i; + $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); + if ($entrepot_id < 0) $entrepot_id=''; + if (! ($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0; + + $ret=$object->addline($entrepot_id, GETPOST($idl,'int'), GETPOST($qty,'int'), $array_options[$i]); + if ($ret < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } } } @@ -549,7 +554,7 @@ if ($action == 'create2') $action=''; $id=''; $ref=''; } -// Mode creation. TODO This part seems to not be used at all. Receipt record is created by the action "create_delivery" not from a form. +// Mode creation. if ($action == 'create') { $expe = new Expedition($db); @@ -577,9 +582,6 @@ if ($action == 'create') if (! empty($conf->stock->enabled)) $entrepot = new Entrepot($db); - /* - * Document source - */ print '
'; print ''; print ''; @@ -711,9 +713,7 @@ if ($action == 'create') dol_fiche_end(); - /* - * Expedition Lines - */ + // Shipment lines $numAsked = count($object->lines); @@ -745,9 +745,9 @@ if ($action == 'create') print ''; - /* Lecture des expeditions deja effectuees */ + // Lecture des expeditions deja effectuees $object->loadExpeditions(); - + if ($numAsked) { print ''; @@ -792,9 +792,9 @@ if ($action == 'create') if (! empty($line->date_end)) $type=1; print "\n"; - + // Product label - if ($line->fk_product > 0) + if ($line->fk_product > 0) // If predefined product { $product->fetch($line->fk_product); $product->load_stock(); @@ -819,12 +819,12 @@ if ($action == 'create') { print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; } - + print ''; } else { - print "'; $qtyProdCom=$line->qty; - // Qty already sent + // Qty already shipped print ''; // end line and start a new one for lot/serial $staticwarehouse=new Entrepot($db); - $staticwarehouse->fetch($warehouse_id); + if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); $subj=0; print ''; @@ -970,16 +970,18 @@ if ($action == 'create') $quantityToBeDelivered = 0; } $subj++; + print ''; } } else { - print ''; print ''; } } } @@ -988,13 +990,16 @@ if ($action == 'create') // ship from multiple locations if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { - print ''; // end line and start a new one for each warehouse + print ''; // end line and start a new one for each warehouse + print ''; $subj=0; - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { $warehouseObject=new Entrepot($db); $warehouseObject->fetch($warehouse_id); - if ($stock_warehouse->real > 0) { + if ($stock_warehouse->real > 0) + { $stock = + $stock_warehouse->real; // Convert it to number $deliverableQty = min($quantityToBeDelivered,$stock); // Quantity to send @@ -1039,7 +1044,7 @@ if ($action == 'create') { $product->get_sousproduits_arbo(); $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if(count($prods_arbo) > 0) + if (count($prods_arbo) > 0) { foreach($prods_arbo as $key => $value) { @@ -1049,10 +1054,12 @@ if ($action == 'create') { $img=img_warning($langs->trans("StockTooLow")); } - print " - "; + "; + print ""; } } } @@ -1060,11 +1067,12 @@ if ($action == 'create') else { print ''; // end line and start a new one for lot/serial - + $subj=0; print ''; - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + { $warehouseObject=new Entrepot($db); $warehouseObject->fetch($warehouse_id); if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { @@ -1073,7 +1081,7 @@ if ($action == 'create') //var_dump($dbatch); $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered,$batchStock); - print ''; @@ -1091,25 +1099,44 @@ if ($action == 'create') } //dol_syslog('deliverableQty = '.$deliverableQty.' batchStock = '.$batchStock); $subj++; + print ''; } } } } - if ($subj == 0) + if ($subj == 0) // Line not shown yet { print ''; - - print ''; + + print ''; + print ''; } } @@ -1576,6 +1603,7 @@ else if ($id || $ref) { print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?'
'.dol_htmlentitiesbr($lines[$i]->description):''; } + print "\n"; } else { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 6427e8e3fb6..78e50b27741 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -8,7 +8,8 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2014-2015 Francis Appels - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -870,13 +871,23 @@ class Expedition extends CommonObject return -1; } - if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) // FIXME Check is done for stock of product, it must be done for stock of product into warehouse if $entrepot_id defined + if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { + // Check must be done for stock of product into warehouse if $entrepot_id defined $product=new Product($this->db); $result=$product->fetch($fk_product); - $product_type=$product->type; - if ($product_type == 0 && $product->stock_reel < $qty) + $product_type=$product->type; + if ($entrepot_id > 0) { + $product->load_stock(); + $product_stock = $product->stock_warehouse[$entrepot_id]->real; + } + else + { + $product_stock = $product->stock_reel; + } + + if ($product_type == 0 && $product_stock < $qty) { $this->error=$langs->trans('ErrorStockIsNotEnough'); $this->db->rollback(); @@ -901,8 +912,8 @@ class Expedition extends CommonObject */ function addline_batch($dbatch,$array_options=0) { - global $conf; - + global $conf,$langs; + $num = count($this->lines); if ($dbatch['qty']>0) { @@ -928,7 +939,17 @@ class Expedition extends CommonObject if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { - // TODO + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $prod_batch = new Productbatch($this->db); + $prod_batch->fetch($value['id_batch']); + + if ($prod_batch->qty < $linebatch->dluo_qty) + { + $this->errors[] = $langs->trans('ErrorStockIsNotEnough'); + dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR); + $this->db->rollback(); + return -1; + } } //var_dump($linebatch); @@ -945,6 +966,7 @@ class Expedition extends CommonObject //var_dump($line); $this->lines[$num] = $line; + return 1; } } diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index c8dd6445ae2..5e7fe3b6a1e 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -42,17 +42,16 @@ $search_company = GETPOST("search_company"); $sall = GETPOST('sall'); $optioncss = GETPOST('optioncss','alpha'); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; - +if (! $sortfield) $sortfield="e.ref"; +if (! $sortorder) $sortorder="DESC"; if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="DESC"; $viewstatut=GETPOST('viewstatut'); @@ -71,6 +70,19 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty" ); +$arrayfields=array( +); +// Extra fields +/* +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} +*/ + /* * View @@ -129,18 +141,22 @@ if ($resql) $expedition = new Expedition($db); - $param=""; + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_ref_exp) $param.= "&search_ref_exp=".$search_ref_exp; if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv; if ($search_company) $param.= "&search_company=".$search_company; if ($optioncss != '') $param.='&optioncss='.$optioncss; - print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords); - - $i = 0; - print ''."\n"; + print ''."\n"; if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, '', '', $limit); if ($sall) { @@ -149,6 +165,18 @@ if ($resql) } $moreforfilter=''; + if (! empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + $parameters=array('type'=>$type); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
"; + print ""; if ($type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); @@ -846,7 +846,7 @@ if ($action == 'create') print ''; $quantityDelivered = $object->expeditions[$line->id]; print $quantityDelivered; @@ -863,9 +863,9 @@ if ($action == 'create') $quantityToBeDelivered = $quantityAsked - $quantityDelivered; } $warehouse_id = GETPOST('entrepot_id','int'); - + $warehouseObject = null; - if ($warehouse_id > 0) + if ($warehouse_id > 0 || ! ($line->fk_product > 0)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection { //ship from preselected location $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number @@ -942,7 +942,7 @@ if ($action == 'create') print '
'; + print '
'; print ' '; print ''; print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); + print '
      -> + print "
"; + print "      -> ".$value['fullpath']." (".$value['nb'].") ".$value['nb_total']."  ".$value['stock']." ".$img."
".$value['stock']." ".$img."
'; + print '
'; print ''; print '
'; - print ' '; - print ''; - if ($warehouseObject) + if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); + //$disabled='disabled="disabled"'; + print ' '; } else { - print img_warning().' '.$langs->trans("StockTooLow"); + print $langs->trans("NA"); } + print ''; + if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + if ($warehouseObject) + { + print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); + } + else + { + if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow"); + else print ''; + } + } + else + { + print $langs->trans("Service"); + } + print '
'; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 3a3436c71a9..7912b4f189f 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -1,7 +1,8 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Charles-Fr BENKE +/* Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Charles-Fr BENKE + * Copyright (C) 2016 Raphaël Doursenaud * * 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 @@ -131,11 +132,11 @@ class Export //print_r("$perm[0]-$perm[1]-$perm[2]
"); if (! empty($perm[2])) { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]}; } else { - $bool=$user->rights->$perm[0]->$perm[1]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}; } if ($perm[0]=='user' && $user->admin) $bool=true; if (! $bool) break; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index cf40a285996..f919ad0d9d1 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -42,9 +42,9 @@ $fichinterid = GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $fichinterid,'fichinter'); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST('page','int'); if ($page == -1) { $page = 0; } $offset = $limit * $page; @@ -123,13 +123,15 @@ if ($socid) if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } +$sql.= $db->order($sortfield,$sortorder); + $totalnboflines=0; $result=$db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); } -$sql.= $db->order($sortfield,$sortorder); + $sql.= $db->plimit($limit+1, $offset); //print $sql; @@ -138,15 +140,14 @@ if ($result) { $num = $db->num_rows($result); - $urlparam=''; - if ($socid) $urlparam.="&socid=".$socid; - if ($search_ref) $urlparam.="&search_ref=".urlencode($search_ref); - if ($search_company) $urlparam.="&search_company=".urlencode($search_company); - if ($search_desc) $urlparam.="&search_desc=".urlencode($search_desc); - if ($search_status != '' && $search_status > -1) $urlparam.="&search_status=".urlencode($search_status); - if ($optioncss != '') $urlparam.='&optioncss='.$optioncss; - - print_barre_liste($langs->trans("ListOfInterventions"), $page, $_SERVER['PHP_SELF'], $urlparam, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_commercial.png'); + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($socid) $param.="&socid=".$socid; + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_company) $param.="&search_company=".urlencode($search_company); + if ($search_desc) $param.="&search_desc=".urlencode($search_desc); + if ($search_status != '' && $search_status > -1) $param.="&search_status=".urlencode($search_status); + if ($optioncss != '') $param.='&optioncss='.$optioncss; print ''."\n"; if ($optioncss != '') print ''; @@ -155,7 +156,9 @@ if ($result) print ''; print ''; - if ($sall) + print_barre_liste($langs->trans("ListOfInterventions"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); @@ -164,16 +167,16 @@ if ($result) print '
'; print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.ref","",$urlparam,'width="15%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$urlparam,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"f.description","",$urlparam,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.ref","",$param,'width="15%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"f.description","",$param,'',$sortfield,$sortorder); if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { print_liste_field_titre('',$_SERVER["PHP_SELF"],''); - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fd.date","",$urlparam,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],"fd.duree","",$urlparam,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fd.date","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],"fd.duree","",$param,'align="right"',$sortfield,$sortorder); } - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$urlparam,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 4865eac6951..41da86cd9bf 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -51,6 +51,7 @@ class ProductFournisseur extends Product var $ref_supplier; // ref supplier (can be set by get_buyprice) var $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) + var $fourn_id; //supplier id var $fourn_qty; // quantity for price (can be set by get_buyprice) var $fourn_pu; // unit price for quantity (can be set by get_buyprice) @@ -367,6 +368,7 @@ class ProductFournisseur extends Product if ($obj) { $this->product_fourn_price_id = $rowid; + $this->fourn_id = $obj->fk_soc; $this->fourn_ref = $obj->ref_fourn; // deprecated $this->ref_supplier = $obj->ref_fourn; $this->fourn_price = $obj->price; @@ -379,6 +381,7 @@ class ProductFournisseur extends Product $this->fourn_tva_tx = $obj->tva_tx; $this->product_id = $obj->fk_product; // deprecated $this->fk_product = $obj->fk_product; + $this->id = $obj->fk_product; $this->fk_availability = $obj->fk_availability; $this->delivery_time_days = $obj->delivery_time_days; //$this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ? diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index bfdfea41fe4..bb84f8ca917 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -74,7 +74,7 @@ class PaiementFourn extends Paiement { $error=0; - $sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,'; + $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank,'; $sql.= ' c.code as paiement_code, c.libelle as paiement_type,'; $sql.= ' p.num_paiement, p.note, b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiementfourn as p'; @@ -95,7 +95,8 @@ class PaiementFourn extends Paiement { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->ref = $obj->ref; + $this->entity = $obj->entity; $this->date = $this->db->jdate($obj->dp); $this->numero = $obj->num_paiement; $this->bank_account = $obj->fk_account; @@ -149,11 +150,12 @@ class PaiementFourn extends Paiement if ($this->total <> 0) // On accepte les montants negatifs { + $ref = $this->getNextNumRef(''); $now=dol_now(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn ('; - $sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; - $sql.= " VALUES ('".$this->db->idate($now)."',"; + $sql.= 'ref, entity, datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; + $sql.= " VALUES ('".$this->db->escape($ref)."', ".$conf->entity.", '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaye)."', '".$this->total."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.", 0)"; dol_syslog("PaiementFourn::create", LOG_DEBUG); @@ -513,4 +515,114 @@ class PaiementFourn extends Paiement if ($withpicto != 2) $result.=$link.$text.$linkend; return $result; } + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines + * @return void + */ + function initAsSpecimen($option='') + { + global $user,$langs,$conf; + + $now=dol_now(); + $arraynow=dol_getdate($now); + $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + + // Initialize parameters + $this->id=0; + $this->ref = 'SPECIMEN'; + $this->specimen=1; + $this->facid = 1; + $this->datepaye = $nownotime; + } + + /** + * Return next reference of supplier invoice not already used (or last reference) + * according to numbering module defined into constant SUPPLIER_PAYMENT_ADDON + * + * @param Societe $soc object company + * @param string $mode 'next' for next value or 'last' for last value + * @return string free ref or last ref + */ + function getNextNumRef($soc,$mode='next') + { + global $conf, $db, $langs; + $langs->load("bills"); + + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMENT_ADDON='mod_supplier_payment_bronan'; + else if ($conf->global->SUPPLIER_PAYMENT_ADDON=='brodator') $conf->global->SUPPLIER_PAYMENT_ADDON='mod_supplier_payment_brodator'; + else if ($conf->global->SUPPLIER_PAYMENT_ADDON=='bronan') $conf->global->SUPPLIER_PAYMENT_ADDON='mod_supplier_payment_bronan'; + + if (! empty($conf->global->SUPPLIER_PAYMENT_ADDON)) + { + $mybool=false; + + $file = $conf->global->SUPPLIER_PAYMENT_ADDON.".php"; + $classname = $conf->global->SUPPLIER_PAYMENT_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); + + // Load file with numbering class (if found) + if (is_file($dir.$file) && is_readable($dir.$file)) + { + $mybool |= include_once $dir . $file; + } + } + + // For compatibility + if (! $mybool) + { + $file = $conf->global->SUPPLIER_PAYMENT_ADDON.".php"; + $classname = "mod_supplier_payment_".$conf->global->SUPPLIER_PAYMENT_ADDON; + $classname = preg_replace('/\-.*$/','',$classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot."/core/modules/supplier_payment/"; + + // Load file with numbering class (if found) + if (is_file($dir.$file) && is_readable($dir.$file)) { + $mybool |= include_once $dir . $file; + } + } + } + + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } + + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this); + + /** + * $numref can be empty in case we ask for the last value because if there is no invoice created with the + * set up mask. + */ + if ($mode != 'last' && !$numref) { + dol_print_error($db,"SupplierPayment::getNextNumRef ".$obj->error); + return ""; + } + + return $numref; + } + else + { + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; + } + } } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3f4aee09bcd..14e28b9fe9f 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -197,7 +197,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($conf->liste_limit+1, $offset); +$sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); if ($resql) @@ -217,7 +217,6 @@ if ($resql) if ($billed != '') $param.="billed=".$billed; if ($optioncss != '') $param.='&optioncss='.$optioncss; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); print ''; if ($optioncss != '') print ''; print ''; @@ -226,7 +225,9 @@ if ($resql) print ''; print ''; - if ($sall) + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 3c238a2f6f8..5a8760eafa8 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry @@ -60,8 +60,8 @@ $page=GETPOST("page",'int'); $sortorder = GETPOST("sortorder",'alpha'); $sortfield = GETPOST("sortfield",'alpha'); -if ($page == -1) { $page = 0 ; } $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +if ($page == -1) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; @@ -233,7 +233,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } - $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); @@ -261,9 +260,7 @@ if ($resql) if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($search_status >= 0) $param.="&search_status=".$search_status; - print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->name.":""),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy'); - - print ''; + print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -271,7 +268,9 @@ if ($resql) print ''; print ''; - if ($search_all) + print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->name.":""),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy',0,'','',$limit); + + if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 3753001cf23..80e584efc4d 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -304,10 +304,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; + dol_fiche_head(''); + print '
'; - print ''; - print ''; } print '
'.$langs->trans('Payment').'
'.$langs->trans('Company').''; + print '
'.$langs->trans('Company').''; $supplierstatic->id=$obj->socid; $supplierstatic->name=$obj->name; print $supplierstatic->getNomUrl(1,'supplier'); @@ -333,7 +334,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
 
'; - + dol_fiche_end(); $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -360,7 +361,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $i = 0; print '
'; - print $langs->trans('Invoices').'
'; if(!empty($conf->global->FAC_AUTO_FILLJS)){ //Add js for AutoFill @@ -372,15 +372,15 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ' });'."\n"; print ' '."\n"; } - print ''; + print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; $var=True; @@ -446,7 +446,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($action != 'add_paiement') { print '
'.$langs->trans("ClosePaidInvoicesAutomatically"); - print '
'; + print '
'; } // Form to confirm payment diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 2c17dd44f02..9a4d58aa65f 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2016 Raphaël Doursenaud * * 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 @@ -106,11 +107,11 @@ class Import //print_r("$perm[0]-$perm[1]-$perm[2]
"); if ($perm[2]) { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]}; } else { - $bool=$user->rights->$perm[0]->$perm[1]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}; } if ($perm[0]=='user' && $user->admin) $bool=true; //print $bool." $perm[0]"."
"; diff --git a/htdocs/includes/jquery/plugins/select2/release.sh b/htdocs/includes/jquery/plugins/select2/release.sh old mode 100644 new mode 100755 diff --git a/htdocs/index.php b/htdocs/index.php index 0bb3b41ffb2..af3636f2b99 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -618,10 +618,10 @@ function showWeather($totallate,$text,$options) $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; - if ($totallate <= $level0) $out.=img_picto_common($text,'weather/weather-clear.png',$options); - if ($totallate > $level0 && $totallate <= $level1) $out.=img_picto_common($text,'weather/weather-few-clouds.png',$options); - if ($totallate > $level1 && $totallate <= $level2) $out.=img_picto_common($text,'weather/weather-clouds.png',$options); - if ($totallate > $level2 && $totallate <= $level3) $out.=img_picto_common($text,'weather/weather-many-clouds.png',$options); - if ($totallate > $level3) $out.=img_picto_common($text,'weather/weather-storm.png',$options); + if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); + if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); + if ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options); + if ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options); + if ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options); return $out; } diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index b6bdbcba2d8..408b7555d5b 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -77,7 +77,8 @@ $conffiletoshow = "htdocs/conf/conf.php"; //$conffiletoshow = "/etc/dolibarr/conf.php"; -if (! defined('DONOTLOADCONF') && file_exists($conffile)) +// Load conf file if it is already defined +if (! defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just +-- Copyright (C) 2016 Laurent Destailleur -- -- 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 @@ -22,7 +23,6 @@ CREATE TABLE llx_multicurrency date_create datetime DEFAULT NULL, code varchar(255) DEFAULT NULL, name varchar(255) DEFAULT NULL, - entity integer DEFAULT NULL, - fk_user integer DEFAULT NULL, - KEY code (code) + entity integer DEFAULT 1, + fk_user integer DEFAULT NULL ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql index a403071930c..e6b90382dcd 100644 --- a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql +++ b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql @@ -1,5 +1,6 @@ -- ======================================================================== -- Copyright (C) 2016 Pierre-Henry Favre +-- Copyright (C) 2016 Laurent Destailleur -- -- 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 @@ -20,9 +21,7 @@ CREATE TABLE llx_multicurrency_rate ( rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, - rate double NOT NULL DEFAULT '0', - fk_multicurrency integer NOT NULL DEFAULT '0', - entity integer NOT NULL DEFAULT '0', - KEY fk_multicurrency (fk_multicurrency), - KEY entity (entity) + rate double NOT NULL DEFAULT 0, + fk_multicurrency integer NOT NULL, + entity integer DEFAULT 1 ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 701899d5a2f..cbcc93d9b0f 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -20,6 +20,8 @@ create table llx_paiementfourn ( rowid integer AUTO_INCREMENT PRIMARY KEY, + ref varchar(30), + entity integer DEFAULT 1, tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 921a3f30ff3..383adb93f47 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -104,6 +104,7 @@ Code_tiers=Thirdparty Labelcompte=Label account Sens=Sens Codejournal=Journal +NumPiece=Piece number DelBookKeeping=Delete the records of the general ledger @@ -152,6 +153,8 @@ MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = % FicheVentilation=Breakdown card GeneralLedgerIsWritten=Operations are written in the general ledger +MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s + ##Export Journal Feature ExportFormat=Format of Export Prefixname=Prefix of export File @@ -164,7 +167,8 @@ Type=Type of fields Param=Additionnal parameters EnabledProduct=In Product EnabledTiers=In third party -EnabledVat=In Vat +EnabledVat=In VAT + ## Tools - Init accounting account on product / service InitAccountancy=Init accountancy InitAccountancyDesc=This page can be used to initialize an accounting account on products and services that does not have accountancy account defined for sales and purchases. Check before that setup of module accountancy is complete. diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 8f8b92e108f..3009a691c26 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -107,6 +107,7 @@ EnterPaymentDueToCustomer=Make payment due to customer DisabledBecauseRemainderToPayIsZero=Disabled because remaining unpaid is zero PriceBase=Price base BillStatus=Invoice status +StatusOfGeneratedInvoices=Status of generated invoices BillStatusDraft=Draft (needs to be validated) BillStatusPaid=Paid BillStatusPaidBackOrConverted=Paid or converted into discount @@ -140,6 +141,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t BillFrom=From BillTo=To ActionsOnBill=Actions on invoice +NotARecurringInvoiceTemplate=Not a recurring template invoice NewBill=New invoice LastBills=Last %s invoices LastCustomersBills=Last %s customers invoices @@ -200,6 +202,7 @@ Rest=Pending AmountExpected=Amount claimed ExcessReceived=Excess received EscompteOffered=Discount offered (payment before term) +EscompteOfferedShort=Discount SendBillRef=Submission of invoice %s SendReminderBillRef=Submission of invoice %s (reminder) StandingOrders=Standing orders @@ -306,7 +309,14 @@ AmountPaymentDistributedOnInvoice=Payment amount distributed on invoice PaymentNote=Payment note ListOfPreviousSituationInvoices=List of previous situation invoices ListOfNextSituationInvoices=List of next situation invoices - +FrequencyPer_d=Every %s days +FrequencyPer_m=Every %s months +FrequencyPer_y=Every %s years +toolTipFrequency=Examples:
Set 7 / day: give a new invoice every 7 days
Set 3 / month: give a new invoice every 3 month +NextDateToExecution=Next date to execution +MaxPeriodNumber=Max period number +RestPeriodNumber=Rest period number +InvoiceAutoValidate=Automatically validate invoice # PaymentConditions PaymentConditionShortRECEP=Immediate PaymentConditionRECEP=Immediate diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 796c058e3b5..57bfc174ec5 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -60,6 +60,8 @@ BoxTitleLastContracts=Last %s contracts BoxTitleLastModifiedDonations=Last %s modified donations BoxTitleLastModifiedExpenses=Last %s modified expense reports BoxGlobalActivity=Global activity (invoices, proposals, orders) +BoxGoodCustomers=Good Customers +BoxTitleGoodCustomers=%s Good Customers FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s LastRefreshDate=Last refresh date NoRecordedBookmarks=No bookmarks defined. @@ -95,4 +97,4 @@ ForCustomersInvoices=Customers invoices ForCustomersOrders=Customers orders ForProposals=Proposals LastXMonthRolling=The last %s month rolling -ChooseBoxToAdd=Add a box to your dashboard... \ No newline at end of file +ChooseBoxToAdd=Add a box to your dashboard... diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 94a74604901..a5f620c7a7a 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -47,6 +47,7 @@ MailingSuccessfullyValidated=EMailing successfully validated MailUnsubcribe=Unsubscribe Unsuscribe=Unsubscribe MailingStatusNotContact=Don't contact anymore +MailingStatusReadAndUnsubscribe=Read and unsubscribe ErrorMailRecipientIsEmpty=Email recipient is empty WarningNoEMailsAdded=No new Email to add to recipient's list. ConfirmValidMailing=Are you sure you want to validate this emailing ? diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 3e782fdbeaf..2f12874fbb5 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -310,7 +310,7 @@ UnitPrice=Unit price UnitPriceHT=Unit price (net) UnitPriceTTC=Unit price PriceU=U.P. -PriceUHT=U.P. (net in currency) +PriceUHT=U.P. (net) PriceUHTCurrency=U.P (currency) SupplierProposalUHT=U.P. net Requested PriceUTTC=U.P. (inc. tax) @@ -322,6 +322,9 @@ AmountTTCShort=Amount (inc. tax) AmountHT=Amount (net of tax) AmountTTC=Amount (inc. tax) AmountVAT=Amount tax +MulticurrencyAmountHT=Amount (net of tax), original currency +MulticurrencyAmountTTC=Amount (inc. of tax), original currency +MulticurrencyAmountVAT=Amount tax, original currency AmountLT1=Amount tax 2 AmountLT2=Amount tax 3 AmountLT1ES=Amount RE diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b8a7d377904..3dfabdc124d 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -295,7 +295,9 @@ ComposedProductIncDecStock=Increase/Decrease stock on parent change ComposedProduct=Sub-product MinSupplierPrice=Minimum supplier price DynamicPriceConfiguration=Dynamic price configuration +DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value. GlobalVariables=Global variables +VariableToUpdate=Variable to update GlobalVariableUpdaters=Global variable updaters GlobalVariableUpdaterType0=JSON data GlobalVariableUpdaterHelp0=Parses JSON data from specified URL, VALUE specifies the location of relevant value, diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang index 99a5753a665..69f765391ff 100644 --- a/htdocs/langs/en_US/supplier_proposal.lang +++ b/htdocs/langs/en_US/supplier_proposal.lang @@ -7,6 +7,7 @@ CommRequest=Price request CommRequests=Price requests SearchRequest=Find a request DraftRequests=Draft requests +SupplierProposalsDraft=Draft supplier proposals LastModifiedRequests=Last %s modified price requests RequestsOpened=Open price requests SupplierProposalArea=Supplier proposals area diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index b3cee6853c8..4d8d4a021b0 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -186,11 +186,7 @@ ShowInvoice=Afficher facture ShowInvoiceReplace=Afficher facture de remplacement ShowInvoiceAvoir=Afficher facture d'avoir ShowInvoiceDeposit=Afficher facture d'acompte -<<<<<<< HEAD ShowInvoiceSituation=Afficher facture de situation -======= -ShowInvoiceSituation=Show situation invoice ->>>>>>> refs/remotes/origin/3.9 ShowPayment=Afficher règlement AlreadyPaid=Déjà réglé AlreadyPaidBack=Déjà remboursé @@ -203,6 +199,7 @@ Rest=Créance AmountExpected=Montant réclamé ExcessReceived=Trop perçu EscompteOffered=Escompte (règlement avant échéance) +EscompteOfferedShort=Escompte SendBillRef=Envoi de la facture %s SendReminderBillRef=Relance de la facture %s (rappel) StandingOrders=Prélèvements @@ -305,16 +302,10 @@ RelatedSupplierInvoices=Factures fournisseurs liées LatestRelatedBill=Dernière facture en rapport WarningBillExist=Attention, une ou plusieurs factures existent déjà MergingPDFTool=Outil de fusion de PDF -<<<<<<< HEAD -ListOfPreviousSituationInvoices=Liste des précédentes factures de situation -ListOfNextSituationInvoices=Liste des factures suivantes de situation -======= AmountPaymentDistributedOnInvoice=Montant paiement affecté à la facture PaymentNote=Note du paiement ListOfPreviousSituationInvoices=List of previous situation invoices ListOfNextSituationInvoices=List of next situation invoices ->>>>>>> refs/remotes/origin/3.9 - # PaymentConditions PaymentConditionShortRECEP=À réception PaymentConditionRECEP=À réception de facture @@ -423,11 +414,7 @@ NoteListOfYourUnpaidInvoices=Remarque: Cette liste ne contient que les factures RevenueStamp=Timbre fiscal YouMustCreateInvoiceFromThird=Cette option n'est disponible que lorsqu'on accède à la création de facture depuis l'onglet "Client" d'un Tiers. PDFCrabeDescription=Modèle de facture PDF complet (modèle recommandé par défaut) -<<<<<<< HEAD -PDFCrevetteDescription=Modèle de facture PDF pour les factures de situations -======= PDFCrevetteDescription=Invoice PDF template Crevette. A complete invoice template for invoice situation ->>>>>>> refs/remotes/origin/3.9 TerreNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn pour les factures et factures de remplacement, %syymm-nnnn pour les avoirs et %syymm-nnnn pour les acomptes où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0 MarsNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn pour les factures, %syymm-nnnn pour les factures de remplacement, %syymm-nnnn pour les acomptes et %syymm-nnnn pour les avoirs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0 TerreNumRefModelError=Une facture commençant par $syymm existe déjà et est incompatible avec cet modèle de numérotation. Supprimez-la ou renommez-la pour activer ce module. @@ -458,15 +445,6 @@ CantBeLessThanMinPercent=La progression ne peut être inférieure à la valeur d NoSituations=Pas de situations ouvertes InvoiceSituationLast=Dernière facture PDFCrevetteSituationNumber=Situation N°%s -<<<<<<< HEAD -PDFCrevetteSituationOrderTitle=Commande d'origine -PDFCrevetteSituationInvoiceTitle=Facture de situation -PDFCrevetteSituationInvoiceLineDecompte=Facture de situation - DECOMPTE -PDFCrevetteSituationInvoiceLine=Situation N°%s : Fact. N°%s au %s -TotalSituationInvoice=Total Situtation -invoiceLineProgressError=La progression de la ligne de situation ne peut être égale ou supérieure à la ligne de situation suivante -updatePriceNextInvoiceErrorUpdateline=Erreur de mise à jour d'un prix sur la facture : %s -======= PDFCrevetteSituationInvoiceLineDecompte=Situation invoice - COUNT PDFCrevetteSituationInvoiceTitle=Situation invoice PDFCrevetteDescription=Invoice PDF template Crevette. A complete invoice template for invoice situation @@ -474,4 +452,3 @@ PDFCrevetteSituationInvoiceLine=Situation N°%s : Inv. N°%s on %s TotalSituationInvoice=Total situation invoiceLineProgressError=Invoice line progress can't be egal or upper the next invoice line updatePriceNextInvoiceErrorUpdateline=Error : update price on invoice line : %s ->>>>>>> refs/remotes/origin/3.9 diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index f08618e2313..3d13c9c82fa 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -1,7 +1,8 @@ * Copyright (C) 2015 Frederic France - * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2016 Laurent Destailleur * * 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 @@ -61,6 +62,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_amount=""; } + /* * View */ @@ -83,12 +85,14 @@ if ($filtre) { } $sql.= " GROUP BY l.rowid, l.label, l.capital, l.datestart, l.dateend"; $sql.= $db->order($sortfield,$sortorder); -$numall = 0; + +$nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); - $numall = $db->num_rows($result); + $nbtotalofrecords = $db->num_rows($result); } + $sql.= $db->plimit($limit+1, $offset); //print $sql; @@ -105,9 +109,15 @@ if ($resql) if ($search_amount) $param.="&search_amount=".$search_amount_ht; if ($optioncss != '') $param.='&optioncss='.$optioncss; - print ''."\n"; + print ''."\n"; if ($optioncss != '') print ''; - print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $numall,'title_generic.png'); + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); print '
'.$langs->trans('Ref').''.$langs->trans('Invoice').''.$langs->trans('RefSupplier').''.$langs->trans('Date').''.$langs->trans('AmountTTC').''.$langs->trans('AlreadyPaid').''.$langs->trans('RemainderToPay').''.$langs->trans('Amount').''.$langs->trans('PaymentAmount').'
'; print ''; @@ -116,6 +126,7 @@ if ($resql) print_liste_field_titre($langs->trans("Capital"),$_SERVER["PHP_SELF"],"l.capital","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"l.datestart","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"l.paid","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre(''); print "\n"; // Filters lines @@ -124,6 +135,7 @@ if ($resql) print ''; print ''; print ''; + print ''; print ''; + print ''; + print "\n"; $i++; @@ -167,6 +181,7 @@ else { dol_print_error($db); } + llxFooter(); $db->close(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 349e2c3cabd..88782e7ff71 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1580,7 +1580,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a /** * Show left menu bar * - * @param array $menu_array_before Table of menu entries to show before entries of menu handler + * @param array $menu_array_before Table of menu entries to show before entries of menu handler. This param is deprectaed and must be provided to ''. * @param string $helppagename Name of wiki page for help ('' by default). * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage * For other external page: http://server/url @@ -1599,6 +1599,8 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra $searchform=''; $bookmarks=''; + if (! empty($menu_array_before)) dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING); + if (empty($conf->dol_hide_leftmenu)) { // Instantiate hooks of thirdparty module diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php new file mode 100644 index 00000000000..ac53d079298 --- /dev/null +++ b/htdocs/margin/checkMargins.php @@ -0,0 +1,254 @@ + + * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Florian Henry + * + * 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 . + */ + +/** + * \file htdocs/margin/checkMargins.php + * \ingroup margin + * \brief Check margins + */ +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php'; + +$langs->load("companies"); +$langs->load("bills"); +$langs->load("products"); +$langs->load("margins"); + +// Security check + +if ($user->rights->margins->creer) { + $agentid = $user->id; +} else { + accessforbidden(); +} + +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (! $sortorder) + $sortorder = "DESC"; +if (! $sortfield) { + $sortfield = 'f.rowid'; +} +$page = GETPOST("page", 'int'); +if ($page == - 1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Both test are required to be compatible with all browsers +if (GETPOST("button_search_x") || GETPOST("button_search")) { + $action = 'search'; +} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { + $action = 'update'; +} + +if ($action == 'update') { + $datapost = $_POST; + + foreach ( $datapost as $key => $value ) { + if (strpos($key, 'buyingprice_') !== false) { + $tmp_array = explode('_', $key); + if (count($tmp_array) > 0) { + $invoicedet_id = $tmp_array[1]; + if (! empty($invoicedet_id)) { + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; + $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; + $sql .= ' WHERE rowid=' . $invoicedet_id; + $result = $db->query($sql); + if (!$result) { + setEventMessages($db->lasterror, null, 'errors'); + } + } + } + } + } +} + +$startdate = $enddate = ''; + +$startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); +$enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear', 'int')); + +if (! empty($startdate)) { + $options .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); +} +if (! empty($enddate)) { + $options .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); +} + +/* + * View + */ + +$userstatic = new User($db); +$companystatic = new Societe($db); +$invoicestatic = new Facture($db); +$productstatic = new Product($db); + +$form = new Form($db); + +$title = $langs->trans("CheckMargins"); + +llxHeader('', $title); + +// print_fiche_titre($text); + +// Show tabs +$head = marges_prepare_head($user); +$picto = 'margin'; +dol_fiche_head($head, 'checkMargins', $title, 0, $picto); + +print ''; +print '
 '; print ''; print ''; @@ -154,6 +166,8 @@ if ($resql) print ''.$loan_static->LibStatut($obj->paid,5,$obj->alreadypayed).'
'; + +// Start date +print ''; +print ''; +print ''; +print ''; +print ''; +print "
' . $langs->trans('StartDate') . ' (' . $langs->trans("DateValidation") . ')'; +$form->select_date($startdate, 'startdate', '', '', 1, "sel", 1, 1); +print '' . $langs->trans('EndDate') . ' (' . $langs->trans("DateValidation") . ')'; +$form->select_date($enddate, 'enddate', '', '', 1, "sel", 1, 1); +print ''; +print ''; +print '
"; + +$sql = "SELECT"; +$sql .= " f.facnumber, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty"; +$sql .= " ,d.fk_product"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f "; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as d ON d.fk_facture = f.rowid"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid"; +$sql .= " WHERE f.fk_statut > 0"; +$sql .= " AND f.entity = " . getEntity('facture', 1); +if (! empty($startdate)) + $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'"; +if (! empty($enddate)) + $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'"; +$sql .= " AND d.buy_price_ht IS NOT NULL"; +$sql .= $db->order($sortfield, $sortorder); + +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + dol_syslog(__FILE__, LOG_DEBUG); + $result = $db->query($sql); + if ($result) { + $nbtotalofrecords = $db->num_rows($result); + } else { + setEventMessages($db->lasterror, null, 'errors'); + } +} + +$sql .= $db->plimit($conf->liste_limit + 1, $offset); + +dol_syslog(__FILE__, LOG_DEBUG); +$result = $db->query($sql); +if ($result) { + $num = $db->num_rows($result); + + print '
'; + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + + print ""; + + print ''; + + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.ref", "", $options, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $options, 'width=20%', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $options, 'align="right"', $sortfield, $sortorder); + if ($conf->global->MARGIN_TYPE == "1") { + print_liste_field_titre($langs->trans("BuyingPrice"), $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder); + } else { + print_liste_field_titre($langs->trans("CostPrice"), $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder); + } + print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $options, 'align="right"', $sortfield, $sortorder); + + print "\n"; + + if ($num > 0) { + $var = true; + + while ( $objp = $db->fetch_object($result) ) { + $var = ! $var; + + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "\n"; + + $i ++; + } + } + print "
'; + $result_inner = $invoicestatic->fetch($objp->invoiceid); + if ($result_inner < 0) { + setEventMessages($invoicestatic->error, null, 'errors'); + } else { + print $invoicestatic->getNomUrl(1); + } + print ''; + if (! empty($objp->fk_product)) { + $result_inner = $productstatic->fetch($objp->fk_product); + if ($result_inner < 0) { + setEventMessages($productstatic->error, null, 'errors'); + } else { + print $productstatic->getNomUrl(1); + } + } else { + print $objp->label; + print ' '; + print $objp->description; + } + print ''; + print price($objp->subprice); + print ''; + print ''; + print ''; + print $objp->qty; + print ''; + print price($objp->total_ht); + print '
"; +} else { + dol_print_error($db); +} + +print '
' . "\n"; +print '
'; +print '
'; +print '
'; + +$db->free($result); + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index ce100d49390..2a3d0775eaa 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2016 Florian Henry * * 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 @@ -87,6 +88,14 @@ function marges_prepare_head() $head[$h][1] = $langs->trans($title); $head[$h][2] = 'agentMargins'; + + if ($user->rights->margins->creer) { + $h++; + $head[$h][0] = DOL_URL_ROOT."/margin/checkMargins.php"; + $head[$h][1] = $langs->trans('CheckMargins'); + $head[$h][2] = 'checkMargins'; + } + return $head; } diff --git a/htdocs/product/admin/dynamic_prices.php b/htdocs/product/admin/dynamic_prices.php index 45086630c47..84ec54433cd 100644 --- a/htdocs/product/admin/dynamic_prices.php +++ b/htdocs/product/admin/dynamic_prices.php @@ -142,17 +142,20 @@ if (!empty($action) && empty($cancel)) { * View */ -//Header llxHeader("","",$langs->trans("CardProduct".$product->type)); + print load_fiche_titre($langs->trans("DynamicPriceConfiguration")); $form = new Form($db); +print $langs->trans("DynamicPriceDesc").'
'; +print '
'; + //Global variables table if ($action != 'create_updater' && $action != 'edit_updater') { print $langs->trans("GlobalVariables"); print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; //Space for buttons @@ -184,7 +187,7 @@ if ($action == 'create_variable' || $action == 'edit_variable') { print '
'.$langs->trans("Code").''.$langs->trans("Variable").''.$langs->trans("Description").''.$langs->trans("Value").' 
'; //Code print ''; - print ''; + print ''; print ''; print ''; //Description @@ -205,7 +208,7 @@ if ($action == 'create_variable' || $action == 'edit_variable') { print ''; print ''; print ''; -} else { +} else if ($action != 'create_updater') { //Action Buttons print '
'; print ''.$langs->trans("Add").''; @@ -219,7 +222,7 @@ if ($action != 'create_variable' && $action != 'edit_variable') { print $langs->trans("GlobalVariableUpdaters"); print '
'.$langs->trans("Code").''.$langs->trans("Variable").'
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -264,7 +267,7 @@ if ($action == 'create_updater' || $action == 'edit_updater') { print '
'.$langs->trans("Code").''.$langs->trans("VariableToUpdate").''.$langs->trans("Description").''.$langs->trans("Type").''.$langs->trans("Parameters").'
'; //Code print ''; - print '
'.$langs->trans("Code").''; + print ''.$langs->trans("VariableToUpdate").''; $globals_list = array(); foreach ($price_globals->listGlobalVariables() as $entry) { $globals_list[$entry->id]=$entry->code; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 283d94b97bd..46e91e9f120 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -378,10 +378,14 @@ if (empty($reshook)) $object->status = GETPOST('statut'); $object->status_buy = GETPOST('statut_buy'); $object->status_batch = GETPOST('status_batch'); + // removed from update view so GETPOST always empty + /* $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $object->desiredstock = GETPOST('desiredstock'); - $object->duration_value = $duration_value; - $object->duration_unit = $duration_unit; + */ + $object->duration_value = GETPOST('duration_value'); + $object->duration_unit = GETPOST('duration_unit'); + $object->canvas = GETPOST('canvas'); $object->weight = GETPOST('weight'); $object->weight_units = GETPOST('weight_units'); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index c96d99cba9a..41eb7ffb2c5 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -341,6 +341,8 @@ class Productcustomerprice extends CommonObject $sql .= ' AND ' . $key . ' = \'' . $value . '\''; } elseif ($key == 'soc.nom') { $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + } elseif ($key == 'prod.ref') { + $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; } else { $sql .= ' AND ' . $key . ' = ' . $value; } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 088f7e73c66..c25c4c1ce0a 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -314,6 +314,8 @@ else setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); } + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_categ > 0) $param.="&search_categ=".$search_categ; if ($sref) $param="&sref=".$sref; if ($search_ref_supplier) $param="&search_ref_supplier=".$search_ref_supplier; @@ -337,7 +339,16 @@ else if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords,'title_products.png'); + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_products.png', 0, '', '', $limit); if (! empty($catid)) { @@ -368,15 +379,6 @@ else } else { - print ''; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -781,8 +783,8 @@ else $db->free($resql); print "
"; - print ''; } + print ''; } else { diff --git a/htdocs/product/price.php b/htdocs/product/price.php index b8c9222fab6..5537de7480f 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -44,6 +44,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $langs->load("products"); $langs->load("bills"); +$langs->load("companies"); $mesg=''; $error=0; $errors=array(); @@ -346,8 +347,16 @@ if (empty($reshook)) $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); + if (! ($prodcustprice->fk_soc > 0)) + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ThirdParty")), null, 'errors'); + $error++; + $action='add_customer_price'; + } if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min<$maxpricesupplier) { + $langs->load("errors"); setEventMessages($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')), null, 'errors'); $error++; $action='add_customer_price'; @@ -548,7 +557,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print '
' . $langs->trans("PriceByQuantity") . ' ' . $i; print ''; - if ($object->prices_by_qty [$i] == 1) { + if ($object->prices_by_qty[$i] == 1) { print ''; print ''; @@ -558,7 +567,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; print ''; - foreach ($object->prices_by_qty_list [$i] as $ii => $prices) { + foreach ($object->prices_by_qty_list[$i] as $ii => $prices) { if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print ''; print ''; @@ -574,7 +583,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; } else { print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -1177,7 +1186,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if ($action == 'add_customer_price') { - // Create mode + // Form to add a new customer price $maxpricesupplier = $object->min_recommended_price(); print load_fiche_titre($langs->trans('PriceByCustomer')); @@ -1188,19 +1197,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print '
' . $langs->trans("Discount") . ' 
' . $prices ['quantity'] . '' . $prices['quantity'] . '' . price($prices['price']) . '' . price($prices['unitprice']) . '' . price($prices['remise_percent']) . ' %
'; print ''; - print ''; + print ''; print ''; print ''; // VAT - print ''; // Price base - print ''; print ''; // Price - print ''; + print ''; } if (! empty($arrayfields['p.fk_opp_status']['checked'])) { @@ -482,8 +480,9 @@ if ($resql) } if (! empty($arrayfields['p.opp_percent']['checked'])) { - print ''; + print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 98bbff88483..d258dbb1e38 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -74,10 +74,10 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -300,7 +300,8 @@ if ($resql) $num = $db->num_rows($resql); $param=''; - if ($sday) $param.='&sday='.$day; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sday) $param.='&sday='.$day; if ($smonth) $param.='&smonth='.$smonth; if ($syear) $param.='&syear=' .$syear; if ($day) $param.='&day='.$day; @@ -327,8 +328,6 @@ if ($resql) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); - print ''; if ($optioncss != '') print ''; print ''; @@ -338,6 +337,8 @@ if ($resql) print ''; print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); + // Show description of content if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'

'; else diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index ac4d9eb3c54..a6e08d02524 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -144,7 +144,8 @@ $nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1); $nav.=' '; $nav.=''; -print_barre_liste('Title of my list', 3, $_SERVER["PHP_SELF"], '', '', '', 'Text in middle', 20, 5000, '', 0, $nav); +$limit=10; +print_barre_liste('Title of my list', 12, $_SERVER["PHP_SELF"], '', '', '', 'Text in middle', 20, 500, '', 0, $nav, '', $limit); $moreforfilter.='
'; @@ -190,6 +191,7 @@ if (! empty($moreforfilter))
+
' . $langs->trans('ThirdParty') . '' . $langs->trans('ThirdParty') . ''; - print $form->select_company('', 'socid', 's.client in (1,2,3) AND s.rowid NOT IN (SELECT fk_soc FROM ' . MAIN_DB_PREFIX . 'product_customer_price WHERE fk_product='.$object->id.')', 1, 0, 0, array(), 0, 'minwidth300'); + print $form->select_company('', 'socid', 's.client in (1,2,3) AND s.rowid NOT IN (SELECT fk_soc FROM ' . MAIN_DB_PREFIX . 'product_customer_price WHERE fk_product='.$object->id.')', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); print '
' . $langs->trans("VATRate") . ''; + print '
' . $langs->trans("VATRate") . ''; print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr); print '
'; + print '
'; print $langs->trans('PriceBase'); print ''; @@ -1209,7 +1218,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
'; + print '
'; $text = $langs->trans('SellingPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 75dca94540b..627bb67ff53 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -50,12 +50,12 @@ if ($socid > 0) if (!$user->rights->projet->lire) accessforbidden(); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; - if (! $sortfield) $sortfield="p.ref"; if (! $sortorder) $sortorder="ASC"; $offset = $conf->liste_limit * $page ; @@ -71,6 +71,7 @@ $search_all=GETPOST("search_all"); $search_status=GETPOST("search_status",'int'); $search_opp_status=GETPOST("search_opp_status",'alpha'); $search_opp_percent=GETPOST("search_opp_percent",'alpha'); +$search_opp_amount=GETPOST("search_opp_amount",'alpha'); $search_public=GETPOST("search_public",'int'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); @@ -88,16 +89,6 @@ $year = GETPOST('year','int'); if ($search_status == '') $search_status=-1; // -1 or 1 -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -if ($page == -1) { $page = 0; } -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortfield) $sortfield='p.ref'; -if (! $sortorder) $sortorder='DESC'; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $contextpage='projectlist'; @@ -160,6 +151,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_year=""; $search_status=-1; $search_opp_status=-1; + $search_opp_amount=''; + $search_opp_percent=''; $search_public=""; $search_sale=""; $search_user=''; @@ -237,6 +230,8 @@ if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$soc if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.title', $search_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +if ($search_opp_amount) $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); +if ($search_opp_percent) $sql .= natural_search('p.opp_percent', $search_opp_percent, 1); if ($smonth > 0) { if ($syear > 0 && empty($sday)) @@ -301,6 +296,7 @@ if ($resql) $num = $db->num_rows($resql); $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sday) $param.='&sday='.$day; if ($smonth) $param.='&smonth='.$smonth; if ($syear) $param.='&syear=' .$syear; @@ -329,7 +325,6 @@ if ($resql) $text=$langs->trans("Projects"); if ($search_user == $user->id) $text=$langs->trans('MyProjects'); - print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num,'','title_project'); print '
'; if ($optioncss != '') print ''; @@ -340,7 +335,9 @@ if ($resql) print ''; print ''; - // Show description of content + print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); + + // Show description of content if ($search_user == $user->id) print $langs->trans("MyProjectsDesc").'

'; else { @@ -471,8 +468,9 @@ if ($resql) } if (! empty($arrayfields['p.opp_amount']['checked'])) { - print '
'; - print ''; + print ''; + print ''; - print ''; + print ''; + print '
getNomUrl(1); ?>b1c1
a2b2c2
a3b3c3

diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7cfc07918fd..d263e37573e 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -83,7 +83,7 @@ $page=GETPOST("page",'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="s.nom"; if ($page == -1) { $page = 0 ; } -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -149,7 +149,7 @@ $arrayfields=array( 's.code_compta_fournisseur'=>array('label'=>$langs->trans("SupplierAccountancyCodeShort"), 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), - 'state.state_name'=>array('label'=>$langs->trans("State"), 'checked'=>0), + 'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0), 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), 's.siren'=>array('label'=>$langs->trans("ProfId1Short"), 'checked'=>$checkedprofid1), @@ -418,6 +418,8 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql.= $db->order($sortfield,$sortorder); + // Count total nb of records $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -426,8 +428,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($conf->liste_limit+1, $offset); +$sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); if ($resql) @@ -435,7 +436,9 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - if ($sall != '') $param = "&sall=".urlencode($sall); + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall != '') $param .= "&sall=".urlencode($sall); if ($search_categ != '') $param.='&search_categ='.urlencode($search_categ); if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); @@ -470,14 +473,21 @@ if ($resql) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies'); - // Show delete result message if (GETPOST('delsoc')) { setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs'); } + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + $langs->load("other"); $textprofid=array(); foreach(array(1,2,3,4,5,6) as $key) @@ -491,13 +501,6 @@ if ($resql) } } - print ''; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -560,7 +563,7 @@ if ($resql) if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['state.state_name']['checked'])) print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.state_name","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); @@ -653,7 +656,7 @@ if ($resql) print '
'; print ''; @@ -813,7 +816,7 @@ if ($resql) $var=True; - while ($i < min($num,$conf->liste_limit)) + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $var=!$var; @@ -872,7 +875,7 @@ if ($resql) print "".$obj->zip."".$obj->state_name." 
 '; @@ -513,7 +517,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print $searchpitco; print '
' . $langs->trans('NoPriceSpecificToCustomer') . '
' . $langs->trans('None') . '
"; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 8852f22686f..1d269753536 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -108,7 +108,7 @@ if (empty($reshook)) exit; } } - + if ($action == 'confirm_merge' && $confirm == 'yes') { $object->fetch($socid); @@ -1921,8 +1921,9 @@ else dol_htmloutput_errors($error,$errors); + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
'; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 82eeb323a36..c03d3edadaa 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -222,7 +222,7 @@ if (empty($reshook)) $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); if ($socid < 1) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors'); $action = 'create'; $error ++; } diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 31589bad334..30c56182380 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -78,6 +78,17 @@ if (! empty($socid)) } $result = restrictedArea($user, $module, $objectid, $dbtable); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$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; +if (! $sortfield) $sortfield='p.date_livraison'; +if (! $sortorder) $sortorder='DESC'; + if (GETPOST("button_removefilter") || GETPOST("button_removefilter_x")) // Both tests are required to be compatible with all browsers { $search_categ=''; @@ -137,19 +148,6 @@ $companystatic=new Societe($db); $now=dol_now(); -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -if (! $sortfield) $sortfield='p.date_livraison'; -if (! $sortorder) $sortorder='DESC'; - - $sql = 'SELECT s.rowid, s.nom as name, s.town, s.client, s.code_client,'; $sql.= ' p.rowid as supplier_proposalid, p.note_private, p.total_ht, p.ref, p.fk_statut, p.fk_user_author, p.date_livraison as dp,'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -221,10 +219,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($limit + 1,$offset); $result=$db->query($sql); - if ($result) { $objectstatic=new SupplierProposal($db); @@ -238,6 +234,7 @@ if ($result) } $param='&socid='.$socid.'&viewstatut='.$viewstatut; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($month) $param.='&month='.$month; if ($year) $param.='&year='.$year; if ($search_ref) $param.='&search_ref=' .$search_ref; @@ -246,7 +243,6 @@ if ($result) if ($search_sale > 0) $param.='&search_sale='.$search_sale; if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; if ($search_author) $param.='&search_author='.$search_author; - print_barre_liste($langs->trans('ListOfSupplierProposal').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); // Lignes des champs de filtre print ''; @@ -256,6 +252,8 @@ if ($result) print ''; print ''; + print_barre_liste($langs->trans('ListOfSupplierProposal').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index c5f74469faa..36566b0d3f5 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -62,7 +62,8 @@ $conffiletoshow = "htdocs/conf/conf.php"; //$conffiletoshow = "/etc/dolibarr/conf.php"; -if (! defined('DONOTLOADCONF') && file_exists($conffile)) +// Load conf file if it is already defined +if (! defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Ari Elbaz (elarifr) * @@ -1065,7 +1065,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print "\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ''.$langs->trans("AccountancyCode").''; print ''; @@ -1402,7 +1402,7 @@ else print "\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ''.$langs->trans("AccountancyCode").''; print ''.$object->accountancy_code.''; @@ -2173,7 +2173,7 @@ else print "\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ""; print ''.$langs->trans("AccountancyCode").''; diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index f515c8307e7..af46fd39d21 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -49,6 +49,12 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="g.nom"; if (! $sortorder) $sortorder="ASC"; +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'g.nom'=>"Group", + 'g.note'=>"Note" +); + /* * View @@ -85,7 +91,19 @@ if ($resql) $param="&search_group=".urlencode($search_group)."&sall=".urlencode($sall); if ($optioncss != '') $param.='&optioncss='.$optioncss; - print ''; + + if ($sall) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + } + + $moreforfilter=''; + + //$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; print ''; print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder); //multicompany diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 22b6d54adda..e9d9fb6c489 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2015 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -63,31 +63,23 @@ print '
'; // Search User $var=false; -print ''; +print ''; print ''; print '
'; -print ''; +print ''; print ''; -print ''; -print "
'.$langs->trans("SearchAUser").'
'.$langs->trans("Search").'
'; -print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; -print ''; +print $langs->trans("User").':'; // Search Group if ($canreadperms) { $var=false; - print '
'; - print ''; - print ''; - print ''; print ''; - print ''; - print "
'.$langs->trans("SearchAGroup").'
'; - print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; - print '
'; + print $langs->trans("Group").':'; } +print "
\n"; +print ''; //print ''; print '
'; diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index cfe26e3d2a4..98455b2a233 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -1,8 +1,9 @@ #!/usr/bin/env php - * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2005-2016 Regis Houssin * * 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 @@ -68,7 +69,7 @@ if (! empty($login)) $user->fetch('',$login); $sql = "SELECT m.rowid, m.titre, m.sujet, m.body,"; $sql.= " m.email_from, m.email_replyto, m.email_errorsto"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; -$sql.= " WHERE m.statut = 1"; +$sql.= " WHERE m.statut IN (1,2)"; if ($id != 'all') { $sql.= " AND m.rowid= ".$id; @@ -142,17 +143,17 @@ if ($resql) // Make subtsitutions on topic and body $other=explode(';',$obj2->other); - $other1=$other[0]; - $other2=$other[1]; - $other3=$other[2]; - $other4=$other[3]; - $other5=$other[4]; - // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) - $signature = (!empty($user->signature))?$user->signature:''; - + $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); + + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray=array( - '__ID__' => $obj->source_id, - '__EMAIL__' => $obj->email, + '__ID__' => $obj2->source_id, + '__EMAIL__' => $obj2->email, '__LASTNAME__' => $obj2->lastname, '__FIRSTNAME__' => $obj2->firstname, '__MAILTOEMAIL__' => ''.$obj2->email.'', @@ -251,7 +252,7 @@ if ($resql) $error++; } } - + if (!empty($conf->global->MAILING_DELAY)) { sleep($conf->global->MAILING_DELAY); } diff --git a/test/phpunit/SqlTest.php b/test/phpunit/SqlTest.php index 2587ff5e178..887d2aa89bb 100644 --- a/test/phpunit/SqlTest.php +++ b/test/phpunit/SqlTest.php @@ -143,13 +143,16 @@ class SqlTest extends PHPUnit_Framework_TestCase $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); - foreach ($listofsqldir as $dir) { + foreach ($listofsqldir as $dir) + { print 'Process dir '.$dir."\n"; $filesarray = scandir($dir); - foreach($filesarray as $key => $file) { + + foreach($filesarray as $key => $file) + { if (! preg_match('/\.sql$/',$file)) continue; - + print 'Check sql file '.$file."\n"; $filecontent=file_get_contents($dir.'/'.$file); @@ -164,6 +167,27 @@ class SqlTest extends PHPUnit_Framework_TestCase $result=strpos($filecontent,'ON DELETE CASCADE'); print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n"; $this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.'); + + if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') + { + // Test for migration files only + + } + else + { + if (preg_match('/\.key\.sql$/',$file)) + { + // Test for files key files only + + } + else + { + // Test for files non key files only + $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY ') == 0); + print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; + $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.'); + } + } } }