Browse Source

Merge remote-tracking branch 'uptream/develop' into 6.0-multijournal

# Conflicts:
#	htdocs/install/mysql/migration/5.0.0-6.0.0.sql
Alexandre SPANGARO 8 years ago
parent
commit
aa924bf010
100 changed files with 3875 additions and 1558 deletions
  1. 1 1
      .github/CONTRIBUTING.md
  2. 4 6
      COPYRIGHT
  3. 9 0
      ChangeLog
  4. 3 2
      README.md
  5. 6 4
      build/debian/README.howto
  6. 22 11
      build/generate_filelist_xml.php
  7. 2 8
      build/makepack-dolibarr.pl
  8. 6 23
      dev/dolibarr_changes.txt
  9. 2 2
      dev/examples/ldap/ldapsearch_sample1.txt
  10. 87 33
      dev/initdata/generate-invoice.php
  11. 101 92
      dev/initdata/generate-order.php
  12. 84 26
      dev/initdata/generate-proposal.php
  13. 12 6
      dev/initdemo/README
  14. BIN
      dev/initdemo/documents_demo/societe/19/SEPA Mandate 19-Morgan Bank-RUM1301-0008-0.pdf
  15. 2 2
      dev/initdemo/mysqldump_dolibarr_5.0.0.sql
  16. 0 0
      dev/tools/dolibarr-mysql2pgsql.pl
  17. 15 9
      dev/translation/txpull.sh
  18. 13 25
      htdocs/accountancy/admin/account.php
  19. 4 4
      htdocs/accountancy/admin/accountmodel.php
  20. 29 11
      htdocs/accountancy/admin/card.php
  21. 16 11
      htdocs/accountancy/admin/categories.php
  22. 1324 0
      htdocs/accountancy/admin/categories_list.php
  23. 1 0
      htdocs/accountancy/admin/defaultaccounts.php
  24. 32 28
      htdocs/accountancy/admin/index.php
  25. 6 6
      htdocs/accountancy/bookkeeping/balance.php
  26. 12 8
      htdocs/accountancy/bookkeeping/card.php
  27. 76 77
      htdocs/accountancy/bookkeeping/list.php
  28. 50 5
      htdocs/accountancy/class/accountancycategory.class.php
  29. 49 0
      htdocs/accountancy/class/accountancysystem.class.php
  30. 32 16
      htdocs/accountancy/class/accountingaccount.class.php
  31. 16 7
      htdocs/accountancy/class/html.formventilation.class.php
  32. 1 1
      htdocs/accountancy/customer/card.php
  33. 12 12
      htdocs/accountancy/customer/lines.php
  34. 4 4
      htdocs/accountancy/customer/list.php
  35. 4 4
      htdocs/accountancy/expensereport/card.php
  36. 5 5
      htdocs/accountancy/expensereport/lines.php
  37. 10 10
      htdocs/accountancy/expensereport/list.php
  38. 2 2
      htdocs/accountancy/index.php
  39. 1 0
      htdocs/accountancy/journal/expensereportsjournal.php
  40. 1 1
      htdocs/accountancy/supplier/card.php
  41. 11 11
      htdocs/accountancy/supplier/lines.php
  42. 4 4
      htdocs/accountancy/supplier/list.php
  43. 1 0
      htdocs/adherents/agenda.php
  44. 35 34
      htdocs/adherents/class/adherent.class.php
  45. 97 95
      htdocs/adherents/index.php
  46. 1 1
      htdocs/adherents/list.php
  47. 1 1
      htdocs/adherents/stats/byproperties.php
  48. 5 5
      htdocs/adherents/type.php
  49. 10 16
      htdocs/admin/confexped.php
  50. 31 19
      htdocs/admin/dict.php
  51. 1 1
      htdocs/admin/events.php
  52. 29 44
      htdocs/admin/expedition.php
  53. 1 1
      htdocs/admin/expedition_extrafields.php
  54. 1 1
      htdocs/admin/expeditiondet_extrafields.php
  55. 1 1
      htdocs/admin/fckeditor.php
  56. 103 107
      htdocs/admin/ihm.php
  57. 1 1
      htdocs/admin/index.php
  58. 2 4
      htdocs/admin/livraison.php
  59. 1 1
      htdocs/admin/livraison_extrafields.php
  60. 1 1
      htdocs/admin/livraisondet_extrafields.php
  61. 2 2
      htdocs/admin/mails.php
  62. 1 1
      htdocs/admin/mails_templates.php
  63. 44 24
      htdocs/admin/modulehelp.php
  64. 52 11
      htdocs/admin/modules.php
  65. 2 2
      htdocs/admin/multicurrency.php
  66. 1 1
      htdocs/admin/perms.php
  67. 1 1
      htdocs/admin/proxy.php
  68. 1 1
      htdocs/admin/security.php
  69. 1 1
      htdocs/admin/security_file.php
  70. 1 1
      htdocs/admin/security_other.php
  71. 247 3
      htdocs/admin/supplier_payment.php
  72. 45 64
      htdocs/admin/system/about.php
  73. 73 10
      htdocs/admin/system/dolibarr.php
  74. 3 3
      htdocs/admin/system/filecheck.php
  75. 5 4
      htdocs/admin/tools/dolibarr_export.php
  76. 2 2
      htdocs/admin/tools/index.php
  77. 3 1
      htdocs/admin/tools/update.php
  78. 1 1
      htdocs/admin/translation.php
  79. 229 4
      htdocs/admin/user.php
  80. 316 0
      htdocs/admin/usergroup.php
  81. 7 3
      htdocs/bookmarks/card.php
  82. 1 1
      htdocs/cashdesk/tpl/validation2.tpl.php
  83. 42 3
      htdocs/categories/class/api_categories.class.php
  84. 1 1
      htdocs/categories/class/api_deprecated_category.class.php
  85. 23 2
      htdocs/categories/class/categorie.class.php
  86. 76 31
      htdocs/comm/action/card.php
  87. 24 78
      htdocs/comm/action/document.php
  88. 27 8
      htdocs/comm/action/index.php
  89. 27 1
      htdocs/comm/action/info.php
  90. 9 8
      htdocs/comm/card.php
  91. 63 61
      htdocs/comm/index.php
  92. 12 19
      htdocs/comm/mailing/card.php
  93. 16 13
      htdocs/comm/mailing/index.php
  94. 0 224
      htdocs/comm/propal/apercu.php
  95. 107 130
      htdocs/comm/propal/card.php
  96. 3 14
      htdocs/comm/propal/class/propal.class.php
  97. 1 1
      htdocs/comm/propal/contact.php
  98. 1 1
      htdocs/comm/propal/document.php
  99. 11 11
      htdocs/comm/propal/index.php
  100. 1 1
      htdocs/comm/propal/info.php

+ 1 - 1
.github/CONTRIBUTING.md

@@ -6,7 +6,7 @@ Bug reports and feature requests
 
 <a name="not-a-support-forum"></a>*Note*: Issues are not a support forum. If you need help using the software, please use [the forums](http://www.dolibarr.org/forum).
 
-Issues are managed on [GitHub](https://github.com/Dolibarr/dolibarr/Issues).
+Issues are managed on [GitHub](https://github.com/Dolibarr/dolibarr/issues).
 
 1. Please [use the search engine](https://help.github.com/articles/searching-issues) to check if nobody's already reported your problem.
 2. [Create an issue](https://help.github.com/articles/creating-an-issue). Choose an appropriate title. Prepend appropriately with Bug or Feature Request.

+ 4 - 6
COPYRIGHT

@@ -14,15 +14,15 @@ Component              Version       License                     GPL Compatible
 PHP libraries:
 AdoDb-Date             0.36          Modified BSD License        Yes             Date convertion (not into rpm package)
 ChromePHP              4.1.0         Apache Software License 2.0 Yes             Return server log to chrome browser console
-CKEditor               4.5.8         LGPL-2.1+                   Yes             Editor WYSIWYG
+CKEditor               4.6.2         LGPL-2.1+                   Yes             Editor WYSIWYG
 EvalMath               1.0           BSD                         Yes             Safe math expressions evaluation
 Escpos-php                           MIT License                 Yes             Thermal receipt printer library, for use with ESC/POS compatible printers
-FPDI                   1.5.2         Apache Software License 2.0 Yes             PDF templates management
 GeoIP                  1.4           LGPL-2.1+                   Yes             Sample code to make geoip convert (not into deb package)
 Mobiledetect           2.8.17        MIT License                 Yes             Detect mobile devices browsers
 NuSoap                 0.9.5         LGPL 2.1+                   Yes             Library to develop SOAP Web services (not into rpm and deb package)
 PEAR Mail_MIME         1.8.9         BSD                         Yes             NuSoap dependency
 odtPHP                 1.0.1         GPL-2+  b                   Yes             Library to build/edit ODT files
+ParseDown              1.6           MIT License                 Yes             Markdown parser
 PHPExcel               1.8.1         LGPL-2.1+                   Yes             Read/Write XLS files, read ODS files
 php-iban               1.4.7         LGPL-3+                     Yes             Parse and validate IBAN (and IIBAN) bank account information in PHP
 PHPoAuthLib            0.8.2         MIT License                 Yes             Library to provide oauth1 and oauth2 to different service
@@ -44,10 +44,8 @@ jQuery JCrop           0.9.8         GPL and MIT License         Yes
 jQuery Jeditable       1.7.1         GPL and MIT License         Yes             JS library plugin jeditable (to edit in place)
 jQuery jNotify         1.1.00        Apache Software License 2.0 Yes             JS library plugin jNotify (to use ajax popups)
 jQuery jPicker         1.1.6         GPL and MIT License         Yes             JS library for color picker with not defined list of colors
-jQuery jqueryFileTree  1.0.1         GPL and MIT License         Yes             JS library for color picker with not defined list of colors
-jQuery jquerytreeview  1.4.1         MIT License                 Yes             JS library for color picker with not defined list of colors
-jQuery Layout          1.4.3         GPL and MIT License         Yes             JS library plugin Layout
-jQuery Mobile          1.3.0         GPL and MIT License         Yes             JS library for smartphone (not used)
+jQuery jqueryFileTree  1.0.1         GPL and MIT License         Yes             JS library for filetree
+jQuery jquerytreeview  1.4.1         MIT License                 Yes             JS library for filetree
 jQuery TableDnD        0.6           GPL and MIT License         Yes             JS library plugin TableDnD (to reorder table rows)
 jQuery Timepicker      1.1.0         GPL and MIT License         Yes             JS library Timepicker addon for Datepicker
 jQuery Tiptip          1.3           GPL and MIT License         Yes             JS library for tooltips

+ 9 - 0
ChangeLog

@@ -2,6 +2,15 @@
 English Dolibarr ChangeLog
 --------------------------------------------------------------
 
+***** ChangeLog for 6.0.0 compared to 5.0.* *****
+
+WARNING: 
+
+Following changes may create regression for some external modules, but were necessary to make Dolibarr better:
+* The hook getNodeList has been replaced by a normalized 'addreplace' hook getDirList.
+* The trigger USER_SETINGROUP and USER_REMOVEFROMGROUP has been replaced with trigger USER_MODIFY.
+* The page societe/soc.php was renamed into societe/card.php to match page naming conventions.
+* The page compta/facture.php was renamed into compta/facture/card.php to match page naming conventions.
 
 
 ***** ChangeLog for 5.0.0 compared to 4.0.* *****

+ 3 - 2
README.md

@@ -91,14 +91,15 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
 - Standing orders management (European SEPA)
 - Bank accounts management
 - Shared calendar/agenda (with ical and vcal export for third party tools integration)
-- Opportunities and/or project management (following project benefit including invoices, expense reports, time spent, ...)
+- Opportunities and/or project management
 - Projects management
 - Contracts management
 - Stock management
 - Shipping management
 - Interventions management
 - Employee's leave requests management
-- Expense report management
+- Expense reports
+- Timesheets
 - Electronic Document Management (EDM)
 - Foundations members management
 - Mass emailing

+ 6 - 4
build/debian/README.howto

@@ -339,18 +339,20 @@ To update dolibarr debian package when only files into debian has changed:
 
 To update dolibarr debian package when only files not into debian has changed:
 
-* Manually, add patches into debian/patches and update file debian/series, or do the 2 steps with "quilt import filepatch.patch"
+* Checkout the branch you want to work on: master of debian/...  
+* Manually, add patches into debian/patches and update the file debian/series, or do the 2 steps with "quilt import filepatch.patch"
 * You can test patching of serie with "quilt push" (autant de fois que de patch). Avec "quilt pop -a", on revient a l'état du upstream sans les patch.
+* Update the debian/changelog to add entry of change.
 
 Once files has been prepared, it's time to test:
 
 * Try to build package
 > rm -fr ../build-area;
-> git-buildpackage -us -uc --git-debian-branch=[master|jessie] --git-upstream-branch=[upstream|upstream-3.5.x|3.5.5]
+> git-buildpackage -us -uc --git-debian-branch=[master|jessie] --git-upstream-branch=[upstream|upstream-jessie|upstream-3.5.x|3.5.5]
 ou
-> git-buildpackage -us -uc --git-ignore-branch --git-upstream-branch=[upstream|upstream-3.5.x|3.5.5]
+> git-buildpackage -us -uc --git-ignore-branch --git-upstream-branch=[upstream|upstream-jessie|upstream-3.5.x|3.5.5]
 
-Note: To build an old version, do: git checkout oldtagname -b newbranchname; git-buildpackage -us -uc --git-debian-branch=newbranchname --git-upstream-branch=[upstream|upstream-3.5.x]
+Note: To build an old version, do: git checkout oldtagname -b newbranchname; git-buildpackage -us -uc --git-debian-branch=newbranchname --git-upstream-branch=[upstream|upstream-jessie|upstream-3.5.x|3.5.5]
 Note: You can use git-buildpackage -us -uc --git-ignore-new  if you want to test build with uncommited file
 Note: You can use git-buildpackage -us -uc -d                if you want to test build when dependencies does not match 
 Note: Package is built into directory ../build-area

+ 22 - 11
build/generate_filelist_xml.php

@@ -40,6 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
  * Main
  */
 
+$includecustom=0;
 $includeconstants=array();
 
 if (empty($argv[1])) 
@@ -67,8 +68,6 @@ while ($i < $argc)
 
 if (empty($includecustom))
 {
-    $includecustom=0;
-
     if (DOL_VERSION != $release)
     {
         print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$release.')'."\n";
@@ -80,7 +79,7 @@ else
 {
     if (! preg_match('/'.preg_quote(DOL_VERSION,'/').'-/',$release))
     {
-        print 'Error: When parameter "includecustom" is not set, version declared into ('.DOL_VERSION.') must be used with a suffix into "release" parmater (ex: '.DOL_VERSION.'-mydistrib).'."\n";
+        print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parmater (ex: '.DOL_VERSION.'-mydistrib).'."\n";
         print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n";
         exit -1;
     }
@@ -124,16 +123,21 @@ foreach ($includeconstants as $countrycode => $tmp)
 
 fputs($fp, '<dolibarr_htdocs_dir includecustom="'.$includecustom.'">'."\n");
 
-// TODO Replace RecursiveDirectoryIterator with dol_dir_list
-$dir_iterator1 = new RecursiveDirectoryIterator(dirname(__FILE__).'/../htdocs/');
+/*$dir_iterator1 = new RecursiveDirectoryIterator(dirname(__FILE__).'/../htdocs/');
 $iterator1 = new RecursiveIteratorIterator($dir_iterator1);
 // Need to ignore document custom etc. Note: this also ignore natively symbolic links.
 $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom?'':'custom\/|').'documents\/|conf\/|install\/))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
+*/
+$regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$';
+$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install)$';  // Exclude dirs
+$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
 $dir='';
 $needtoclose=0;
-foreach ($files as $file) {
-    $newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
-    if ($newdir!=$dir) {
+foreach ($files as $filetmp) {
+	$file = $filetmp['fullname'];
+	//$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
+	$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
+	if ($newdir!=$dir) {
         if ($needtoclose)
             fputs($fp, '  </dir>'."\n");
         fputs($fp, '  <dir name="'.$newdir.'" >'."\n");
@@ -161,14 +165,21 @@ $checksumconcat=array();
 fputs($fp, '<dolibarr_script_dir version="'.$release.'">'."\n");
 
 // TODO Replace RecursiveDirectoryIterator with dol_dir_list
-$dir_iterator2 = new RecursiveDirectoryIterator(dirname(__FILE__).'/../scripts/');
+/*$dir_iterator2 = new RecursiveDirectoryIterator(dirname(__FILE__).'/../scripts/');
 $iterator2 = new RecursiveIteratorIterator($dir_iterator2);
 // Need to ignore document custom etc. Note: this also ignore natively symbolic links.
 $files = new RegexIterator($iterator2, '#^(?:[A-Z]:)?(?:/(?!(?:custom|documents|conf|install))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
+*/
+$regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$';
+$regextoexclude='(custom|documents|conf|install)$';  // Exclude dirs
+$files = dol_dir_list(dirname(__FILE__).'/../scripts/', 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
 $dir='';
 $needtoclose=0;
-foreach ($files as $file) {
-    $newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
+foreach ($files as $filetmp) {
+	$file = $filetmp['fullname'];
+	//$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
+	$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
+	$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
     if ($newdir!=$dir) {
         if ($needtoclose)
             fputs($fp, '  </dir>'."\n");

+ 2 - 8
build/makepack-dolibarr.pl

@@ -532,8 +532,6 @@ if ($nboftargetok) {
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`;
 		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`;
 		# Removed other test files
-		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/eldy/*.new`;
-		$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/api/explorer`;				# This is a dev tool
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/test`;
 	    $ret=`rm -fr $BUILDROOT/$PROJECT/Thumbs.db $BUILDROOT/$PROJECT/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/*/Thumbs.db`;
@@ -547,8 +545,6 @@ if ($nboftargetok) {
         $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/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`;
@@ -566,14 +562,15 @@ if ($nboftargetok) {
         $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/ae_fonts_*`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`;
         $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/LICENSE.TXT`;
         $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/ae_fonts_*`;
         $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`;
 	}
 
 	# Build package for each target
@@ -892,9 +889,6 @@ if ($nboftargetok) {
 			$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/ckeditor/_source`;
 			

+ 6 - 23
dev/dolibarr_changes.txt

@@ -3,20 +3,18 @@ This file describe changes made on external library after beeing included
 in Dolibarr root.
 
 
-
 ALL:
 ----
-Replace "& new" by "new"
-
+Check "DOL_CHANGE"
 
 
-CKEDITOR:
----------
+CKEDITOR (4.6.2):
+-----------------
 * In ckeditor/ckeditor/contents.css
 Replace:
-	margin: 20px;
+	body { ... margin: 20px;
 With
-	margin: 5px;
+	body { ... margin: 5px;
 
 
 
@@ -33,21 +31,6 @@ Replace call to serialize_val with no bugged value
 
 
 
-FPDI:
------
-Replace:
-	$this->_readXref($this->_xref, $this->_findXref());
-with:
-    try {
-	        $this->_readXref($this->_xref, $this->_findXref());
-    }
-    catch(Exception $e)
-    {
-        	print $e->getMessage();
-        	exit;
-    }
-
-
 
 TCPDF:
 ------
@@ -56,7 +39,7 @@ define('QR_FIND_FROM_RANDOM', 2);
 with
 define('QR_FIND_FROM_RANDOM', false);
 
-* Removed useless directories (examples, tools)
+* Removed useless directories ("examples", "tools")
 
 * Fix
  	// initialize subsetchars

+ 2 - 2
dev/examples/ldap/ldapsearch_sample1.txt

@@ -5,5 +5,5 @@
 #
 # ldapsearch -h hostname -x
 # ldapsearch -h hostname -x -b "ou=people,dc=teclib,dc=infra"
-# ldapsearch -h hostname -x -z 0 -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -W "(objectclass=*)"
-# ldapsearch -h hostname -x -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -W "(objectclass=*)"
+# ldapsearch -h hostname -x -z 0 -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -w password "(objectclass=*)"
+# ldapsearch -h hostname -x -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -w password "(objectclass=*)"

+ 87 - 33
dev/initdata/generate-invoice.php

@@ -41,8 +41,59 @@ require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
  * Parameters
  */
 
-define(GEN_NUMBER_FACTURE, 5);
-
+define(GEN_NUMBER_FACTURE, 1);
+$year = 2016;
+$dates = array (mktime(12,0,0,1,3,$year),
+    mktime(12,0,0,1,9,$year),
+    mktime(12,0,0,2,13,$year),
+    mktime(12,0,0,2,23,$year),
+    mktime(12,0,0,3,30,$year),
+    mktime(12,0,0,4,3,$year),
+    mktime(12,0,0,4,3,$year),
+    mktime(12,0,0,5,9,$year),
+    mktime(12,0,0,5,1,$year),
+    mktime(12,0,0,5,13,$year),
+    mktime(12,0,0,5,19,$year),
+    mktime(12,0,0,5,23,$year),
+    mktime(12,0,0,6,3,$year),
+    mktime(12,0,0,6,19,$year),
+    mktime(12,0,0,6,24,$year),
+    mktime(12,0,0,7,3,$year),
+    mktime(12,0,0,7,9,$year),
+    mktime(12,0,0,7,23,$year),
+    mktime(12,0,0,7,30,$year),
+    mktime(12,0,0,8,9,$year),
+    mktime(12,0,0,9,23,$year),
+    mktime(12,0,0,10,3,$year),
+    mktime(12,0,0,11,12,$year),
+    mktime(12,0,0,11,13,$year),
+    mktime(12,0,0,1,3,($year - 1)),
+    mktime(12,0,0,1,9,($year - 1)),
+    mktime(12,0,0,2,13,($year - 1)),
+    mktime(12,0,0,2,23,($year - 1)),
+    mktime(12,0,0,3,30,($year - 1)),
+    mktime(12,0,0,4,3,($year - 1)),
+    mktime(12,0,0,4,3,($year - 1)),
+    mktime(12,0,0,5,9,($year - 1)),
+    mktime(12,0,0,5,1,($year - 1)),
+    mktime(12,0,0,5,13,($year - 1)),
+    mktime(12,0,0,5,19,($year - 1)),
+    mktime(12,0,0,5,23,($year - 1)),
+    mktime(12,0,0,6,3,($year - 1)),
+    mktime(12,0,0,6,19,($year - 1)),
+    mktime(12,0,0,6,24,($year - 1)),
+    mktime(12,0,0,7,3,($year - 1)),
+    mktime(12,0,0,7,9,($year - 1)),
+    mktime(12,0,0,7,23,($year - 1)),
+    mktime(12,0,0,7,30,($year - 1)),
+    mktime(12,0,0,8,9,($year - 1)),
+    mktime(12,0,0,9,23,($year - 1)),
+    mktime(12,0,0,10,3,($year - 1)),
+    mktime(12,0,0,11,12,$year),
+    mktime(12,0,0,11,13,$year),
+    mktime(12,0,0,12,12,$year),
+    mktime(12,0,0,12,13,$year),
+);
 
 $ret=$user->fetch('','admin');
 if (! $ret > 0)
@@ -54,16 +105,15 @@ $user->getrights();
 
 
 $socids = array();
-$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
+$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1, 3)";
 $resql = $db->query($sql);
 if ($resql)
 {
-	$num_socs = $db->num_rows($resql);
+	$num_thirdparties = $db->num_rows($resql);
 	$i = 0;
-	while ($i < $num_socs)
+	while ($i < $num_thirdparties)
 	{
 		$i++;
-
 		$row = $db->fetch_row($resql);
 		$socids[$i] = $row[0];
 	}
@@ -79,7 +129,6 @@ if ($resql)
 	while ($i < $num_prods)
 	{
 		$i++;
-
 		$row = $db->fetch_row($resql);
 		$prodids[$i] = $row[0];
 	}
@@ -90,46 +139,51 @@ $result=0;
 while ($i < GEN_NUMBER_FACTURE && $result >= 0)
 {
 	$i++;
-	$socid = mt_rand(1, $num_socs);
+	$socid = mt_rand(1, $num_thirdparties);
 
 	print "Invoice ".$i." for socid ".$socid;
 
-	$facture = new Facture($db);
-	$facture->date = time();
-	$facture->cond_reglement_id = 3;
-	$facture->mode_reglement_id = 3;
-
-	$result=$facture->create($user);
+	$object = new Facture($db);
+	$object->socid = $socids[$socid];
+	$object->date = $dates[mt_rand(1, count($dates)-1)];
+	$object->cond_reglement_id = 3;
+	$object->mode_reglement_id = 3;
+
+    $fuser = new User($db);
+    $fuser->fetch(mt_rand(1,2));
+    $fuser->getRights();
+    
+	$result=$object->create($fuser);
 	if ($result >= 0)
 	{
-		$result=$facture->validate($user);
+		$nbp = mt_rand(2, 5);
+		$xnbp = 0;
+		while ($xnbp < $nbp)
+		{
+			$prodid = mt_rand(1, $num_prods);
+			$product=new Product($db);
+			$result=$product->fetch($prodids[$prodid]);
+			$result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
+		    if ($result < 0)
+            {
+                dol_print_error($db,$propal->error);
+            }
+            $xnbp++;
+		}
+
+	    $result=$object->validate($fuser);
 		if ($result)
 		{
-			$nbp = mt_rand(2, 5);
-			$xnbp = 0;
-			while ($xnbp < $nbp)
-			{
-				$prodid = mt_rand(1, $num_prods);
-				$product=new Product($db);
-				$result=$product->fetch($prodids[$prodid]);
-				$result=$facture->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
-			    if ($result < 0)
-                {
-                    dol_print_error($db,$propal->error);
-                }
-                $xnbp++;
-			}
-
-			print " OK with ref ".$facture->ref."\n";;
+			print " OK with ref ".$object->ref."\n";;
 		}
 		else
 		{
-			dol_print_error($db,$facture->error);
+			dol_print_error($db,$object->error);
 		}
 	}
 	else
 	{
-		dol_print_error($db,$facture->error);
+		dol_print_error($db,$object->error);
 	}
 
 }

+ 101 - 92
dev/initdata/generate-order.php

@@ -40,6 +40,7 @@ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
 include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
 
 
 /*
@@ -47,7 +48,58 @@ include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  */
 
 define(GEN_NUMBER_COMMANDE, 10);
-
+$year = 2016;
+$dates = array (mktime(12,0,0,1,3,$year),
+    mktime(12,0,0,1,9,$year),
+    mktime(12,0,0,2,13,$year),
+    mktime(12,0,0,2,23,$year),
+    mktime(12,0,0,3,30,$year),
+    mktime(12,0,0,4,3,$year),
+    mktime(12,0,0,4,3,$year),
+    mktime(12,0,0,5,9,$year),
+    mktime(12,0,0,5,1,$year),
+    mktime(12,0,0,5,13,$year),
+    mktime(12,0,0,5,19,$year),
+    mktime(12,0,0,5,23,$year),
+    mktime(12,0,0,6,3,$year),
+    mktime(12,0,0,6,19,$year),
+    mktime(12,0,0,6,24,$year),
+    mktime(12,0,0,7,3,$year),
+    mktime(12,0,0,7,9,$year),
+    mktime(12,0,0,7,23,$year),
+    mktime(12,0,0,7,30,$year),
+    mktime(12,0,0,8,9,$year),
+    mktime(12,0,0,9,23,$year),
+    mktime(12,0,0,10,3,$year),
+    mktime(12,0,0,11,12,$year),
+    mktime(12,0,0,11,13,$year),
+    mktime(12,0,0,1,3,($year - 1)),
+    mktime(12,0,0,1,9,($year - 1)),
+    mktime(12,0,0,2,13,($year - 1)),
+    mktime(12,0,0,2,23,($year - 1)),
+    mktime(12,0,0,3,30,($year - 1)),
+    mktime(12,0,0,4,3,($year - 1)),
+    mktime(12,0,0,4,3,($year - 1)),
+    mktime(12,0,0,5,9,($year - 1)),
+    mktime(12,0,0,5,1,($year - 1)),
+    mktime(12,0,0,5,13,($year - 1)),
+    mktime(12,0,0,5,19,($year - 1)),
+    mktime(12,0,0,5,23,($year - 1)),
+    mktime(12,0,0,6,3,($year - 1)),
+    mktime(12,0,0,6,19,($year - 1)),
+    mktime(12,0,0,6,24,($year - 1)),
+    mktime(12,0,0,7,3,($year - 1)),
+    mktime(12,0,0,7,9,($year - 1)),
+    mktime(12,0,0,7,23,($year - 1)),
+    mktime(12,0,0,7,30,($year - 1)),
+    mktime(12,0,0,8,9,($year - 1)),
+    mktime(12,0,0,9,23,($year - 1)),
+    mktime(12,0,0,10,3,($year - 1)),
+    mktime(12,0,0,11,12,$year),
+    mktime(12,0,0,11,13,$year),
+    mktime(12,0,0,12,12,$year),
+    mktime(12,0,0,12,13,$year),
+);
 
 $ret=$user->fetch('','admin');
 if ($ret <= 0)
@@ -57,34 +109,34 @@ if ($ret <= 0)
 }
 $user->getrights();
 
-
-$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
+$societesid = array();
+$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)";
 $resql=$db->query($sql);
 if ($resql) {
-	$num = $db->num_rows($resql);
+	$num_thirdparties = $db->num_rows($resql);
 	$i = 0;
-	while ($i < $num) {
-		$row = $db->fetch_row($resql);
-		$societesid[$i] = $row[0];
+	while ($i < $num_thirdparties) {
 		$i++;
+	    $row = $db->fetch_row($resql);
+		$societesid[$i] = $row[0];
 	}
 }
 else { print "err"; }
 
-$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
+$commandesid = array();
+$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
 $resql=$db->query($sql);
 if ($resql) {
 	$num = $db->num_rows($resql);
 	$i = 0;
 	while ($i < $num) {
-		$row = $db->fetch_row($resql);
-		$commandesid[$i] = $row[0];
 		$i++;
+	    $row = $db->fetch_row($resql);
+		$commandesid[$i] = $row[0];
 	}
 }
 else { print "err"; }
 
-
 $prodids = array();
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
 $resql = $db->query($sql);
@@ -102,59 +154,6 @@ if ($resql)
 }
 
 
-$dates = array (mktime(12,0,0,1,3,2003),
-	  mktime(12,0,0,1,9,2003),
-	  mktime(12,0,0,2,13,2003),
-	  mktime(12,0,0,2,23,2003),
-	  mktime(12,0,0,3,30,2003),
-	  mktime(12,0,0,4,3,2003),
-	  mktime(12,0,0,4,3,2003),
-	  mktime(12,0,0,5,9,2003),
-	  mktime(12,0,0,5,1,2003),
-	  mktime(12,0,0,5,13,2003),
-	  mktime(12,0,0,5,19,2003),
-	  mktime(12,0,0,5,23,2003),
-	  mktime(12,0,0,6,3,2003),
-	  mktime(12,0,0,6,19,2003),
-	  mktime(12,0,0,6,24,2003),
-	  mktime(12,0,0,7,3,2003),
-	  mktime(12,0,0,7,9,2003),
-	  mktime(12,0,0,7,23,2003),
-	  mktime(12,0,0,7,30,2003),
-	  mktime(12,0,0,8,9,2003),
-	  mktime(12,0,0,9,23,2003),
-	  mktime(12,0,0,10,3,2003),
-	  mktime(12,0,0,11,12,2003),
-	  mktime(12,0,0,11,13,2003),
-	  mktime(12,0,0,1,3,2002),
-	  mktime(12,0,0,1,9,2002),
-	  mktime(12,0,0,2,13,2002),
-	  mktime(12,0,0,2,23,2002),
-	  mktime(12,0,0,3,30,2002),
-	  mktime(12,0,0,4,3,2002),
-	  mktime(12,0,0,4,3,2002),
-	  mktime(12,0,0,5,9,2002),
-	  mktime(12,0,0,5,1,2002),
-	  mktime(12,0,0,5,13,2002),
-	  mktime(12,0,0,5,19,2002),
-	  mktime(12,0,0,5,23,2002),
-	  mktime(12,0,0,6,3,2002),
-	  mktime(12,0,0,6,19,2002),
-	  mktime(12,0,0,6,24,2002),
-	  mktime(12,0,0,7,3,2002),
-	  mktime(12,0,0,7,9,2002),
-	  mktime(12,0,0,7,23,2002),
-	  mktime(12,0,0,7,30,2002),
-	  mktime(12,0,0,8,9,2002),
-	  mktime(12,0,0,9,23,2002),
-	  mktime(12,0,0,10,3,2002),
-	  mktime(12,0,0,11,12,2003),
-	  mktime(12,0,0,11,13,2003),
-	  mktime(12,0,0,12,12,2003),
-	  mktime(12,0,0,12,13,2003),
-	  );
-
-require(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
 
 
 print "Build ".GEN_NUMBER_COMMANDE." orders\n";
@@ -162,53 +161,63 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
 {
     print "Process order ".$s."\n";
 
-    $com = new Commande($db);
-
-    $com->socid         = 4;
-    $com->date_commande  = $dates[mt_rand(1, count($dates)-1)];
-    $com->note           = 'A comment';
-    $com->source         = 1;
-    $com->fk_project     = 0;
-    $com->remise_percent = 0;
-
+    $object = new Commande($db);
+
+    $object->socid          = $societesid[mt_rand(1, $num_thirdparties)];
+    $object->date_commande  = $dates[mt_rand(1, count($dates)-1)];
+    $object->note           = 'My small comment about this order. Hum. Nothing.';
+    $object->source         = 1;
+    $object->fk_project     = 0;
+    $object->remise_percent = 0;
+    $object->shipping_method_id = mt_rand(1, 2);
+    $object->cond_reglement_id = mt_rand(0, 2);
+    $object->more_reglement_id = mt_rand(0, 7);
+    $object->availability_id = mt_rand(0, 1);
+    
+    $listofuserid=array(12,13,16);
+    
+    $fuser = new User($db);
+    $fuser->fetch($listofuserid[mt_rand(0,2)]);
+    $fuser->getRights();
+    
     $db->begin();
 
-    $result=$com->create($user);
+    $result=$object->create($fuser);
 	if ($result >= 0)
 	{
-		$result=$com->valid($user);
-		if ($result > 0)
-		{
-            $nbp = mt_rand(2, 5);
-            $xnbp = 0;
-            while ($xnbp < $nbp)
+        $nbp = mt_rand(2, 5);
+        $xnbp = 0;
+        while ($xnbp < $nbp)
+        {
+            $prodid = mt_rand(1, $num_prods);
+            $product=new Product($db);
+            $result=$product->fetch($prodids[$prodid]);
+            $result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0,  $product->price_base_type, $product->price_ttc, '', '', $product->type);
+            if ($result <= 0)
             {
-                $prodid = mt_rand(1, $num_prods);
-                $product=new Product($db);
-                $result=$product->fetch($prodids[$prodid]);
-                $result=$com->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0,  $product->price_base_type, $product->price_ttc, '', '', $product->type);
-                if ($result < 0)
-                {
-                    dol_print_error($db,$propal->error);
-                }
-                $xnbp++;
+                dol_print_error($db,$object->error);
             }
+            $xnbp++;
+        }
 
+	    $result=$object->valid($fuser);
+		if ($result > 0)
+		{
             $db->commit();
-            print " OK with ref ".$com->ref."\n";
+            print " OK with ref ".$object->ref."\n";
 		}
 		else
 		{
             print " KO\n";
 		    $db->rollback();
-		    dol_print_error($db,$com->error);
+		    dol_print_error($db,$object->error);
 		}
 	}
 	else
 	{
         print " KO\n";
 	    $db->rollback();
-	    dol_print_error($db,$com->error);
+	    dol_print_error($db,$object->error);
 	}
 }
 

+ 84 - 26
dev/initdata/generate-proposal.php

@@ -43,8 +43,59 @@ require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
  * Parameters
  */
 
-define(GEN_NUMBER_PROPAL, 5);
-
+define(GEN_NUMBER_PROPAL, 10);
+$year = 2016;
+$dates = array (mktime(12,0,0,1,3,$year),
+    mktime(12,0,0,1,9,$year),
+    mktime(12,0,0,2,13,$year),
+    mktime(12,0,0,2,23,$year),
+    mktime(12,0,0,3,30,$year),
+    mktime(12,0,0,4,3,$year),
+    mktime(12,0,0,4,3,$year),
+    mktime(12,0,0,5,9,$year),
+    mktime(12,0,0,5,1,$year),
+    mktime(12,0,0,5,13,$year),
+    mktime(12,0,0,5,19,$year),
+    mktime(12,0,0,5,23,$year),
+    mktime(12,0,0,6,3,$year),
+    mktime(12,0,0,6,19,$year),
+    mktime(12,0,0,6,24,$year),
+    mktime(12,0,0,7,3,$year),
+    mktime(12,0,0,7,9,$year),
+    mktime(12,0,0,7,23,$year),
+    mktime(12,0,0,7,30,$year),
+    mktime(12,0,0,8,9,$year),
+    mktime(12,0,0,9,23,$year),
+    mktime(12,0,0,10,3,$year),
+    mktime(12,0,0,11,12,$year),
+    mktime(12,0,0,11,13,$year),
+    mktime(12,0,0,1,3,($year - 1)),
+    mktime(12,0,0,1,9,($year - 1)),
+    mktime(12,0,0,2,13,($year - 1)),
+    mktime(12,0,0,2,23,($year - 1)),
+    mktime(12,0,0,3,30,($year - 1)),
+    mktime(12,0,0,4,3,($year - 1)),
+    mktime(12,0,0,4,3,($year - 1)),
+    mktime(12,0,0,5,9,($year - 1)),
+    mktime(12,0,0,5,1,($year - 1)),
+    mktime(12,0,0,5,13,($year - 1)),
+    mktime(12,0,0,5,19,($year - 1)),
+    mktime(12,0,0,5,23,($year - 1)),
+    mktime(12,0,0,6,3,($year - 1)),
+    mktime(12,0,0,6,19,($year - 1)),
+    mktime(12,0,0,6,24,($year - 1)),
+    mktime(12,0,0,7,3,($year - 1)),
+    mktime(12,0,0,7,9,($year - 1)),
+    mktime(12,0,0,7,23,($year - 1)),
+    mktime(12,0,0,7,30,($year - 1)),
+    mktime(12,0,0,8,9,($year - 1)),
+    mktime(12,0,0,9,23,($year - 1)),
+    mktime(12,0,0,10,3,($year - 1)),
+    mktime(12,0,0,11,12,$year),
+    mktime(12,0,0,11,13,$year),
+    mktime(12,0,0,12,12,$year),
+    mktime(12,0,0,12,13,$year),
+);
 
 $ret=$user->fetch('','admin');
 if (! $ret > 0)
@@ -56,16 +107,15 @@ $user->getrights();
 
 
 $socids = array();
-$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
+$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1,3)";
 $resql = $db->query($sql);
 if ($resql)
 {
-	$num_socs = $db->num_rows($resql);
+	$num_thirdparties = $db->num_rows($resql);
 	$i = 0;
-	while ($i < $num_socs)
+	while ($i < $num_thirdparties)
 	{
 		$i++;
-
 		$row = $db->fetch_row($resql);
 		$socids[$i] = $row[0];
 	}
@@ -81,7 +131,6 @@ if ($resql)
 	while ($i < $num_conts)
 	{
 		$i++;
-
 		$row = $db->fetch_row($resql);
 		$contids[$row[1]][0] = $row[0]; // A ameliorer
 	}
@@ -97,7 +146,6 @@ if ($resql)
 	while ($i < $num_prods)
 	{
 		$i++;
-
 		$row = $db->fetch_row($resql);
 		$prodids[$i] = $row[0];
 	}
@@ -117,27 +165,25 @@ $result=0;
 while ($i < GEN_NUMBER_PROPAL && $result >= 0)
 {
 	$i++;
-	$socid = mt_rand(1, $num_socs);
+	$socid = mt_rand(1, $num_thirdparties);
 	print "Proposal ".$i." for socid ".$socid;
 
 	$soc = new Societe($db);
 
 
-	$propal = new Propal($db);
-
-	$obj = $conf->global->PROPALE_ADDON;
-	$modPropale = new $obj;
-	$numpr = $modPropale->getNextValue($soc,$propal);
+	$object = new Propal($db);
 
-	$propal->ref = $numpr;
-	$propal->contactid = $contids[$socids[$socid]][0];
-	$propal->socid = $socids[$socid];
-	$propal->datep = time();
-	$propal->cond_reglement_id = 3;
-	$propal->mode_reglement_id = 3;
-	$propal->author = $user->id;
+    $fuser = new User($db);
+    $fuser->fetch(mt_rand(1,2));
+    $fuser->getRights();
+    
+	$object->contactid = $contids[$socids[$socid]][0];
+	$object->socid = $socids[$socid];
+	$object->datep = $dates[mt_rand(1, count($dates)-1)];
+	$object->cond_reglement_id = 3;
+	$object->mode_reglement_id = 3;
 
-	$result=$propal->create($user);
+	$result=$object->create($fuser);
 	if ($result >= 0)
 	{
 		$nbp = mt_rand(2, 5);
@@ -147,18 +193,30 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
 			$prodid = mt_rand(1, $num_prods);
 			$product=new Product($db);
 			$result=$product->fetch($prodids[$prodid]);
-			$result=$propal->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0);
+			$result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0);
 			if ($result < 0)
 			{
-				dol_print_error($db,$propal->error);
+				dol_print_error($db,$object->error);
 			}
 			$xnbp++;
 		}
-		print " OK with ref ".$propal->ref."\n";
+		
+		$result=$object->valid($fuser);
+		if ($result > 0)
+		{
+		    $db->commit();
+		    print " OK with ref ".$object->ref."\n";
+		}
+		else
+		{
+		    print " KO\n";
+		    $db->rollback();
+		    dol_print_error($db,$object->error);
+		}
 	}
 	else
 	{
-		dol_print_error($db,$propal->error);
+		dol_print_error($db,$object->error);
 	}
 
 }

+ 12 - 6
dev/initdemo/README

@@ -1,17 +1,23 @@
 README
 ------
 
-*** Demo
+Scripts in this directory can be used to reload or save a demo database.
+Install of package "dialog" is required.
+
+
+*** Init demo
 
-Scripts in this directory can be used to reinit a demo database.
-WARNING: This will erase current database with data into initdemo.sql.
+The script initdemo.sh will erase current database with data into mysqldump_dolibarr_x.y.z.sql and copy files into documents_demo into officiel document directory.
 
 Do a chmod 700 initdemo.sh
 then run ./initdemo.sh to launch Graphic User Interface.
 
-Install of package "dialog" is required.
+
+*** Save demo
+
+The script savedemo.sh will save current database into a database dump file.
 
 
-*** Other
+*** Update demo
 
-Other scripts into initdata can be used to load data test.
+The goal of script updatedemo.php is to update dates into the demo data so samples are up to date.

BIN
dev/initdemo/documents_demo/societe/19/SEPA Mandate 19-Morgan Bank-RUM1301-0008-0.pdf


File diff suppressed because it is too large
+ 2 - 2
dev/initdemo/mysqldump_dolibarr_5.0.0.sql


+ 0 - 0
dev/initdemo/dolibarr-mysql2pgsql.pl → dev/tools/dolibarr-mysql2pgsql.pl


+ 15 - 9
dev/translation/txpull.sh

@@ -26,15 +26,21 @@ fi
 
 if [ "x$1" = "xall" ]
 then
-	for dir in `find htdocs/langs/* -type d`
-	do
-	    fic=`basename $dir`
-	    if [ $fic != "en_US" ]
-	    then
-		    echo "tx pull -l $fic $2 $3"
-		    tx pull -l $fic $2 $3
-		fi
-	done
+	if [ "x$2" = "x" ]
+	then
+	    echo "tx pull"
+	    tx pull
+	else
+		for dir in `find htdocs/langs/* -type d`
+		do
+		    fic=`basename $dir`
+		    if [ $fic != "en_US" ]
+		    then
+			    echo "tx pull -l $fic $2 $3"
+			    tx pull -l $fic $2 $3
+			fi
+		done
+	fi
 	cd -
 else
 	echo "tx pull -l $1 $2 $3 $4 $5"

+ 13 - 25
htdocs/accountancy/admin/account.php

@@ -161,7 +161,9 @@ $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.acco
 $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
 $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON aa.account_parent = a2.rowid";
+// Dirty hack wainting that foreign key account_parent is an integer to be compared correctly with rowid
+if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)";
+else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)";
 $sql .= " WHERE asy.rowid = " . $pcgver;
 
 if (strlen(trim($search_account)))			$sql .= natural_search("aa.account_number", $search_account);
@@ -196,12 +198,15 @@ if ($resql)
 	if ($search_accountparent) $params.= '&amp;search_accountparent='.urlencode($search_accountparent);
 	if ($search_pcgtype) $params.= '&amp;search_pcgtype='.urlencode($search_pcgtype);
 	if ($search_pcgsubtype) $params.= '&amp;search_pcgsubtype='.urlencode($search_pcgsubtype);
-    if ($optioncss) $param.='&optioncss='.$optioncss;
+    if ($optioncss != '') $param.='&optioncss='.$optioncss;
+
 
-	print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy');
-	
 	print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">';
 	
+	$htmlbuttonadd = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
+	
+    print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $htmlbuttonadd);
+	
 	// Box to select active chart of account
     $var = ! $var;
     print $langs->trans("Selectchartofaccounts") . " : ";
@@ -229,24 +234,7 @@ if ($resql)
     print "</select>";
     print '<input type="submit" class="button" name="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
     print '<br>';    
-    print "<br>\n";
-
-	print '</form>';
-	
-	$i = 0;
-    print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
-    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
-    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-    print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
-    print '<input type="hidden" name="action" value="list">';
-    print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
-    print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
-
-	print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
-	print '<a class="butAction" href="./categories.php">' . $langs->trans("ApplyMassCategories") . '</a>';
-	// print '<a class="butAction" href="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
-	// print '<a class="butAction" href="./productaccount.php">' . $langs->trans("CheckProductAccountancyCode") . '</a>';
-	print '<br><br>';
+	print '<br>';
 	
 	$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
     $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
@@ -371,12 +359,12 @@ if ($resql)
 
 		// Action
 		print '<td align="center">';
-		if ($user->admin) {
-			print '<a href="./card.php?action=update&id=' . $obj->rowid . '">';
+		if ($user->rights->accounting->chartofaccount) {
+			print '<a href="./card.php?action=update&id=' . $obj->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">';
 			print img_edit();
 			print '</a>';
 			print '&nbsp;';
-			print '<a href="./card.php?action=delete&id=' . $obj->rowid . '">';
+			print '<a href="./card.php?action=delete&id=' . $obj->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id). '">';
 			print img_delete();
 			print '</a>';
 		}

+ 4 - 4
htdocs/accountancy/admin/accountmodel.php

@@ -736,11 +736,11 @@ if ($id)
         {
         	if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit')
         	{
-				fieldList($fieldlist,$obj,$tabname[$id],'hide');
+				fieldListAccountModel($fieldlist,$obj,$tabname[$id],'hide');
         	}
         	else
         	{
-        		fieldList($fieldlist,$obj,$tabname[$id],'add');
+        		fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add');
         	}
         }
 
@@ -928,7 +928,7 @@ if ($id)
                     $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
                     $error=$hookmanager->error; $errors=$hookmanager->errors;
 
-                    if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
+                    if (empty($reshook)) fieldListAccountModel($fieldlist,$obj,$tabname[$id],'edit');
 
                     print '<td colspan="3" align="right"><a name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
                     print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
@@ -1252,7 +1252,7 @@ $db->close();
  *  @param		string	$context		'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
  *	@return		void
  */
-function fieldList($fieldlist, $obj='', $tabname='', $context='')
+function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
 {
 	global $conf,$langs,$db;
 	global $form;

+ 29 - 11
htdocs/accountancy/admin/card.php

@@ -26,6 +26,7 @@
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
+require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
 
@@ -159,13 +160,15 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
 		$result = $object->update($user);
 		
 		if ($result > 0) {
-			header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+		    $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
+		    header("Location: " . $urltogo);
 			exit();
 		} else {
 			$mesg = $object->error;
 		}
 	} else {
-		header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+	    $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
+	    header("Location: " . $urltogo);
 		exit();
 	}
 } else if ($action == 'delete' && $user->rights->accounting->chartofaccount) {
@@ -196,6 +199,9 @@ $form = new Form($db);
 $htmlacc = new FormVentilation($db);
 $formaccounting = new FormAccounting($db);
 
+$accountsystem = new AccountancySystem($db);
+$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
+
 // Create mode
 if ($action == 'create') {
 	print load_fiche_titre($langs->trans('NewAccountingAccount'));
@@ -208,36 +214,45 @@ if ($action == 'create') {
 	
 	print '<table class="border" width="100%">';
 
+	// Chart of account
+	print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("Chartofaccounts") . '</span></td>';
+	print '<td>';
+	print $accountsystem->ref;
+	print '</td></tr>';
+	
+	
 	// Account number
 	print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
-	print '<td><input name="account_number" size="30" value="' . $object->account_number . '"</td></tr>';
+	print '<td><input name="account_number" size="30" value="' . $object->account_number . '"></td></tr>';
 
 	// Label
 	print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
-	print '<td><input name="label" size="70" value="' . $object->label . '"</td></tr>';
+	print '<td><input name="label" size="70" value="' . $object->label . '"></td></tr>';
 
 	// Account parent
 	print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
 	print '<td>';
-	print $htmlacc->select_account($object->account_parent, 'account_parent', 1);
+	print $htmlacc->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
 	print '</td></tr>';
 
 	// Category
 	print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
 	print '<td>';
-	$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
+	$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
 	print '</td></tr>';
 
 	// Chart of accounts type
 	print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
 	print '<td>';
-	print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type');
+	print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type','alpha'):$object->pcg_type).'">';
+	//print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type', 1);
 	print '</td></tr>';
 
 	// Chart of acounts subtype
 	print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
 	print '<td>';
-	print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype');
+	print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype','alpha'):$object->pcg_subtype).'">';
+	//print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype', 1);
 	print '</td></tr>';
 	
 	print '</table>';
@@ -268,7 +283,8 @@ if ($action == 'create') {
 			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
 			print '<input type="hidden" name="action" value="edit">';
 			print '<input type="hidden" name="id" value="' . $id . '">';
-			
+			print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
+				
 			print '<table class="border" width="100%">';
 			
 			// Account number
@@ -294,13 +310,15 @@ if ($action == 'create') {
 			// Chart of accounts type
 			print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
 			print '<td>';
-			print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type');
+			//print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type', 1);
+			print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type','alpha'):$object->pcg_type).'">';
 			print '</td></tr>';
 
 			// Chart of accounts subtype
 			print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
 			print '<td>';
-			print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype');
+			print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype','alpha'):$object->pcg_subtype).'">';
+			//print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype', 1);
 			print '</td></tr>';
 			
 			print '</table>';

+ 16 - 11
htdocs/accountancy/admin/categories.php

@@ -21,6 +21,7 @@
  * \ingroup Advanced accountancy
  * \brief	Page to assign mass categories to accounts
  */
+
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
@@ -45,7 +46,10 @@ if ($cat_id == 0) {
 }
 
 // Security check
-if (! $user->admin) accessforbidden();
+if (! empty($user->rights->accountancy->chartofaccount))
+{
+	accessforbidden();
+}
 
 $accountingcategory = new AccountancyCategory($db);
 
@@ -84,7 +88,7 @@ $formaccounting = new FormAccounting($db);
 
 llxheader('', $langs->trans('AccountAccounting'));
 
-print load_fiche_titre($langs->trans('Categories'));
+print load_fiche_titre($langs->trans('AccountingCategory'));
 
 print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
 print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
@@ -96,23 +100,24 @@ print '<table class="border" width="100%">';
 // Category
 print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
 print '<td>';
-$formaccounting->select_accounting_category($cat_id, 'account_category', 1);
-print '<input class="button" type="submit" value="' . $langs->trans("Show") . '">';
+$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1);
+print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">';
 print '</td></tr>';
 
-if (! empty($cat_id)) {
-	$return = $accountingcategory->getCptBK($cat_id);
+if (! empty($cat_id)) 
+{
+	$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
 	if ($return < 0) {
 		setEventMessages(null, $accountingcategory->errors, 'errors');
 	}
 	print '<tr><td>' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . '</td>';
 	print '<td>';
 	if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
-		print '<select size="' . count($obj) . '" name="cpt_bk[]" multiple>';
+		print '<select class="flat minwidth200" size="' . count($obj) . '" name="cpt_bk[]" multiple>';
 		foreach ( $accountingcategory->lines_cptbk as $cpt ) {
 			print '<option value="' . length_accountg($cpt->numero_compte) . '">' . length_accountg($cpt->numero_compte) . ' (' . $cpt->label_compte . ' ' . $cpt->doc_ref . ')</option>';
 		}
-		print '</select>';
+		print '</select><br>';
 		print '<input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("Add") . '"> ';
 	}
 	print '</td></tr>';
@@ -129,8 +134,8 @@ if ($action == 'display' || $action == 'delete') {
 
     print "<table class='noborder' width='100%'>\n";
     print '<tr class="liste_titre">';
-	print '<td>'.$langs->trans("AccountAccounting")."</td>";
-	print '<td colspan="2">'.$langs->trans("Label")."</td>";
+	print '<td class="liste_titre">'.$langs->trans("AccountAccounting")."</td>";
+	print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>";
 	print "</tr>\n";
 
 	if (! empty($cat_id)) {
@@ -142,7 +147,7 @@ if ($action == 'display' || $action == 'delete') {
 		if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
 			foreach ( $accountingcategory->lines_display as $cpt ) {
 				$var = ! $var;
-				print '<tr' . $bc[$var] . '>';
+				print '<tr ' . $bc[$var] . '>';
 				print '<td>' . length_accountg($cpt->account_number) . '</td>';
 				print '<td>' . $cpt->label . '</td>';
 				print '<td align="right">';

+ 1324 - 0
htdocs/accountancy/admin/categories_list.php

@@ -0,0 +1,1324 @@
+<?php
+/* Copyright (C) 2004       Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2015  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2004       Benoit Mortier          <benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2010-2016  Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2011-2015  Philippe Grand          <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011       Remy Younes             <ryounes@gmail.com>
+ * Copyright (C) 2012-2015  Marcos García           <marcosgdf@gmail.com>
+ * Copyright (C) 2012       Christophe Battarel     <christophe.battarel@ltairis.fr>
+ * Copyright (C) 2011-2016  Alexandre Spangaro      <aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2015       Ferran Marcet           <fmarcet@2byte.es>
+ * Copyright (C) 2016       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/accountancy/admin/categories_list.php
+ *		\ingroup    setup
+ *		\brief      Page to administer data tables
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
+
+$langs->load("errors");
+$langs->load("admin");
+$langs->load("main");
+$langs->load("companies");
+$langs->load("resource");
+$langs->load("holiday");
+$langs->load("accountancy");
+$langs->load("hrm");
+
+$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
+$confirm=GETPOST('confirm','alpha');
+$id=GETPOST('id','int');
+$rowid=GETPOST('rowid','alpha');
+
+// Security access
+if (! empty($user->rights->accountancy->chartofaccount))
+{
+	accessforbidden();
+}
+
+$acts[0] = "activate";
+$acts[1] = "disable";
+$actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
+$actl[1] = img_picto($langs->trans("Activated"),'switch_on');
+
+$listoffset=GETPOST('listoffset');
+$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
+$active = 1;
+
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0 ; }
+$offset = $listlimit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+$search_country_id = GETPOST('search_country_id','int');
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('admin'));
+
+// This page is a generic page to edit dictionaries
+// Put here declaration of dictionaries properties
+
+// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
+$taborder=array(32);
+
+// Name of SQL tables of dictionaries
+$tabname=array();
+$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
+
+// Dictionary labels
+$tablib=array();
+$tablib[32]= "DictionaryAccountancyCategory";
+
+// Requests to extract data
+$tabsql=array();
+$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
+
+// Criteria to sort dictionaries
+$tabsqlsort=array();
+$tabsqlsort[32]="position ASC";
+
+// Nom des champs en resultat de select pour affichage du dictionnaire
+$tabfield=array();
+$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country";
+
+// Nom des champs d'edition pour modification d'un enregistrement
+$tabfieldvalue=array();
+$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country";
+
+// Nom des champs dans la table pour insertion d'un enregistrement
+$tabfieldinsert=array();
+$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country";
+
+// Nom du rowid si le champ n'est pas de type autoincrement
+// Example: "" if id field is "rowid" and has autoincrement on
+//          "nameoffield" if id field is not "rowid" or has not autoincrement on
+$tabrowid=array();
+$tabrowid[32]= "";
+
+// Condition to show dictionary in setup page
+$tabcond=array();
+$tabcond[32]= ! empty($conf->accounting->enabled);
+
+// List of help for fields
+$tabhelp=array();
+$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"));
+
+// List of check for fields (NOT USED YET)
+$tabfieldcheck=array();
+$tabfieldcheck[32] = array();
+
+// Complete all arrays with entries found into modules
+complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);
+
+
+// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
+$elementList = array();
+$sourceList=array();
+
+
+
+/*
+ * Actions
+ */
+
+if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
+{
+    $search_country_id = '';    
+}
+
+// Actions add or modify an entry into a dictionary
+if (GETPOST('actionadd') || GETPOST('actionmodify'))
+{
+    $listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
+    $listfieldinsert=explode(',',$tabfieldinsert[$id]);
+    $listfieldmodify=explode(',',$tabfieldinsert[$id]);
+    $listfieldvalue=explode(',',$tabfieldvalue[$id]);
+
+    // Check that all fields are filled
+    $ok=1;
+    foreach ($listfield as $f => $value)
+    {
+        if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancysystem','DictionaryAccountancyCategory'))) continue;		// For some pages, country is not mandatory
+    	if ($value == 'country' && in_array($tablib[$id],array('DictionaryCanton','DictionaryCompanyType','DictionaryRevenueStamp'))) continue;		// For some pages, country is not mandatory
+        if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
+        if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
+        if ($value == 'color' && empty($_POST['color'])) continue;
+		if ($value == 'formula' && empty($_POST['formula'])) continue;
+        if ((! isset($_POST[$value]) || $_POST[$value]=='')
+        	&& (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy'))  // Fields that are not mandatory
+        	&& (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10
+        	)
+		)
+        {
+            $ok=0;
+            $fieldnamekey=$listfield[$f];
+            // We take translate key of field
+            if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label'))  $fieldnamekey='Label';
+            if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
+            if ($fieldnamekey == 'nbjour')   $fieldnamekey='NbOfDays';
+            if ($fieldnamekey == 'decalage') $fieldnamekey='Offset';
+            if ($fieldnamekey == 'module')   $fieldnamekey='Module';
+            if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
+            if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
+            if ($fieldnamekey == 'taux') $fieldnamekey = 'Rate';
+            if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
+            if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
+            if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode';
+            if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
+            if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
+			if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated';
+
+            setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
+        }
+    }
+    // Other checks
+    if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"],array('system','systemauto'))) {
+        $ok=0;
+        setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
+    }
+    if (isset($_POST["code"]))
+    {
+    	if ($_POST["code"]=='0')
+    	{
+        	$ok=0;
+    		setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
+        }
+        /*if (!is_numeric($_POST['code']))	// disabled, code may not be in numeric base
+    	{
+	    	$ok = 0;
+	    	$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br />';
+	    }*/
+    }
+    if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2))
+    {
+    	if (in_array($tablib[$id],array('DictionaryCompanyType','DictionaryHolidayTypes')))	// Field country is no mandatory for such dictionaries
+    	{
+    		$_POST["country"]='';
+    	}
+    	else
+    	{
+        	$ok=0;
+        	setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors');
+    	}
+    }
+    if ($id == 3 && ! is_numeric($_POST["code"]))
+    {
+       	$ok=0;
+       	setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors');
+    }
+
+	// Clean some parameters
+    if ((! empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) $_POST["localtax1"]='0';	// If empty, we force to 0
+    if ((! empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) $_POST["localtax2"]='0';	// If empty, we force to 0
+	if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]='';	// If empty, we force to null
+	if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]='';	// If empty, we force to null
+	if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]='';	// If empty, we force to null
+
+    // Si verif ok et action add, on ajoute la ligne
+    if ($ok && GETPOST('actionadd'))
+    {
+        if ($tabrowid[$id])
+        {
+            // Recupere id libre pour insertion
+            $newid=0;
+            $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
+            $result = $db->query($sql);
+            if ($result)
+            {
+                $obj = $db->fetch_object($result);
+                $newid=($obj->newid + 1);
+
+            } else {
+                dol_print_error($db);
+            }
+        }
+
+        // Add new entry
+        $sql = "INSERT INTO ".$tabname[$id]." (";
+        // List of fields
+        if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
+        	$sql.= $tabrowid[$id].",";
+        $sql.= $tabfieldinsert[$id];
+        $sql.=",active)";
+        $sql.= " VALUES(";
+
+        // List of values
+        if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
+        	$sql.= $newid.",";
+        $i=0;
+        foreach ($listfieldinsert as $f => $value)
+        {
+            if ($value == 'price' || preg_match('/^amount/i',$value) || $value == 'taux') {
+            	$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
+            }
+            else if ($value == 'entity') {
+            	$_POST[$listfieldvalue[$i]] = $conf->entity;
+            }
+            if ($i) $sql.=",";
+            if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null";  // For vat, we want/accept code = ''
+            else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+            $i++;
+        }
+        $sql.=",1)";
+
+        dol_syslog("actionadd", LOG_DEBUG);
+        $result = $db->query($sql);
+        if ($result)	// Add is ok
+        {
+            setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
+        	$_POST=array('id'=>$id);	// Clean $_POST array, we keep only
+        }
+        else
+        {
+            if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
+                setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
+            }
+            else {
+                dol_print_error($db);
+            }
+        }
+    }
+
+    // Si verif ok et action modify, on modifie la ligne
+    if ($ok && GETPOST('actionmodify'))
+    {
+        if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+        else { $rowidcol="rowid"; }
+
+        // Modify entry
+        $sql = "UPDATE ".$tabname[$id]." SET ";
+        // Modifie valeur des champs
+        if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
+        {
+            $sql.= $tabrowid[$id]."=";
+            $sql.= "'".$db->escape($rowid)."', ";
+        }
+        $i = 0;
+        foreach ($listfieldmodify as $field)
+        {
+            if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
+            	$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
+            }
+            else if ($field == 'entity') {
+            	$_POST[$listfieldvalue[$i]] = $conf->entity;
+            }
+            if ($i) $sql.=",";
+            $sql.= $field."=";
+            if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null";  // For vat, we want/accept code = ''
+            else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+            $i++;
+        }
+        $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
+
+        dol_syslog("actionmodify", LOG_DEBUG);
+        //print $sql;
+        $resql = $db->query($sql);
+        if (! $resql)
+        {
+            setEventMessages($db->error(), null, 'errors');
+        }
+    }
+    //$_GET["id"]=GETPOST('id', 'int');       // Force affichage dictionnaire en cours d'edition
+}
+
+if (GETPOST('actioncancel'))
+{
+    //$_GET["id"]=GETPOST('id', 'int');       // Force affichage dictionnaire en cours d'edition
+}
+
+if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
+
+    dol_syslog("delete", LOG_DEBUG);
+    $result = $db->query($sql);
+    if (! $result)
+    {
+        if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
+        {
+            setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
+        }
+        else
+        {
+            dol_print_error($db);
+        }
+    }
+}
+
+// activate
+if ($action == $acts[0])
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    if ($rowid) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
+    }
+    elseif ($_GET["code"]) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'";
+    }
+
+    $result = $db->query($sql);
+    if (!$result)
+    {
+        dol_print_error($db);
+    }
+}
+
+// disable
+if ($action == $acts[1])
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    if ($rowid) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
+    }
+    elseif ($_GET["code"]) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'";
+    }
+
+    $result = $db->query($sql);
+    if (!$result)
+    {
+        dol_print_error($db);
+    }
+}
+
+// favorite
+if ($action == 'activate_favorite')
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    if ($rowid) {
+        $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
+    }
+    elseif ($_GET["code"]) {
+        $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$_GET["code"]."'";
+    }
+
+    $result = $db->query($sql);
+    if (!$result)
+    {
+        dol_print_error($db);
+    }
+}
+
+// disable favorite
+if ($action == 'disable_favorite')
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    if ($rowid) {
+        $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
+    }
+    elseif ($_GET["code"]) {
+        $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$_GET["code"]."'";
+    }
+
+    $result = $db->query($sql);
+    if (!$result)
+    {
+        dol_print_error($db);
+    }
+}
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formadmin=new FormAdmin($db);
+
+llxHeader();
+
+$titre=$langs->trans("DictionarySetup");
+$linkback='';
+if ($id)
+{
+    $titre.=' - '.$langs->trans($tablib[$id]);
+    $linkback='<a href="'.$_SERVER['PHP_SELF'].'">'.$langs->trans("BackToDictionaryList").'</a>';
+}
+$titlepicto='title_setup';
+if ($id == 10 && GETPOST('from') == 'accountancy')
+{
+    $titre=$langs->trans("MenuVatAccounts");
+    $titlepicto='title_accountancy';
+}
+if ($id == 7 && GETPOST('from') == 'accountancy')
+{
+    $titre=$langs->trans("MenuTaxAccounts");
+    $titlepicto='title_accountancy';
+}
+
+print load_fiche_titre($titre,$linkback,$titlepicto);
+
+if (empty($id))
+{
+    print $langs->trans("DictionaryDesc");
+    print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
+}
+print "<br>\n";
+
+
+// Confirmation de la suppression de la ligne
+if ($action == 'delete')
+{
+    print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
+}
+//var_dump($elementList);
+
+/*
+ * Show a dictionary
+ */
+if ($id)
+{
+    // Complete requete recherche valeurs avec critere de tri
+    $sql=$tabsql[$id];
+
+    if ($search_country_id > 0)
+    {
+        if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
+        else $sql.=" WHERE ";
+        $sql.= " c.rowid = ".$search_country_id;
+    }
+    
+    if ($sortfield)
+    {
+        // If sort order is "country", we use country_code instead
+    	if ($sortfield == 'country') $sortfield='country_code';
+        $sql.= " ORDER BY ".$sortfield;
+        if ($sortorder)
+        {
+            $sql.=" ".strtoupper($sortorder);
+        }
+        $sql.=", ";
+        // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
+        $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
+        $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
+    }
+    else {
+        $sql.=" ORDER BY ";
+    }
+    $sql.=$tabsqlsort[$id];
+    $sql.=$db->plimit($listlimit+1,$offset);
+    //print $sql;
+
+    $fieldlist=explode(',',$tabfield[$id]);
+
+    print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
+    
+    print '<table class="noborder" width="100%">';
+
+    // Form to add a new line
+    if ($tabname[$id])
+    {
+        $alabelisused=0;
+        $var=false;
+
+        $fieldlist=explode(',',$tabfield[$id]);
+
+        // Line for title
+        print '<tr class="liste_titre">';
+        foreach ($fieldlist as $field => $value)
+        {
+            // Determine le nom du champ par rapport aux noms possibles
+            // dans les dictionnaires de donnees
+            $valuetoshow=ucfirst($fieldlist[$field]);   // Par defaut
+            $valuetoshow=$langs->trans($valuetoshow);   // try to translate
+            $align="left";
+            if ($fieldlist[$field]=='source')          { $valuetoshow=$langs->trans("Contact"); }
+            if ($fieldlist[$field]=='price')           { $valuetoshow=$langs->trans("PriceUHT"); }
+            if ($fieldlist[$field]=='taux')            {
+				if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate");
+				else $valuetoshow=$langs->trans("Amount");
+				$align='center';
+            }
+            if ($fieldlist[$field]=='localtax1_type')  { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; }
+            if ($fieldlist[$field]=='localtax1')       { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; }
+            if ($fieldlist[$field]=='localtax2_type')  { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; }
+            if ($fieldlist[$field]=='localtax2')       { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; }
+            if ($fieldlist[$field]=='organization')    { $valuetoshow=$langs->trans("Organization"); }
+            if ($fieldlist[$field]=='lang')            { $valuetoshow=$langs->trans("Language"); }
+            if ($fieldlist[$field]=='type')            {
+				if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"),$langs->trans("TypePaymentDesc"),2,1,img_help(1,''));
+				else $valuetoshow=$langs->trans("Type");
+            }
+            if ($fieldlist[$field]=='code')            { $valuetoshow=$langs->trans("Code"); }
+            if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
+            {
+            	$valuetoshow=$langs->trans("Label");
+            	if ($id != 25) $valuetoshow.="*";
+            }
+            if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
+            if ($fieldlist[$field]=='country')         {
+                if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; }		// For region page, we do not show the country input
+                $valuetoshow=$langs->trans("Country");
+            }
+            if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
+            if ($fieldlist[$field]=='nbjour')          { $valuetoshow=$langs->trans("NbOfDays"); }
+            if ($fieldlist[$field]=='type_cdr')        { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
+            if ($fieldlist[$field]=='decalage')        { $valuetoshow=$langs->trans("Offset"); }
+            if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); }
+            if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); }
+            if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); }
+            if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $valuetoshow=''; }
+            if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
+            if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); }
+            if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); }
+            if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
+            if ($fieldlist[$field]=='account_parent')  { $valuetoshow=$langs->trans("Accountparent"); }
+            if ($fieldlist[$field]=='pcg_type')        { $valuetoshow=$langs->trans("Pcg_type"); }
+            if ($fieldlist[$field]=='pcg_subtype')     { $valuetoshow=$langs->trans("Pcg_subtype"); }
+            if ($fieldlist[$field]=='sortorder')       { $valuetoshow=$langs->trans("SortOrder"); }
+	        if ($fieldlist[$field]=='short_label')     { $valuetoshow=$langs->trans("ShortLabel"); }
+            if ($fieldlist[$field]=='type_template')   { $valuetoshow=$langs->trans("TypeOfTemplate"); }
+			if ($fieldlist[$field]=='range_account')   { $valuetoshow=$langs->trans("Range"); }
+			if ($fieldlist[$field]=='sens')            { $valuetoshow=$langs->trans("Sens"); }
+			if ($fieldlist[$field]=='category_type')   { $valuetoshow=$langs->trans("Calculated"); }
+			if ($fieldlist[$field]=='formula')         { $valuetoshow=$langs->trans("Formula"); }
+			if ($fieldlist[$field]=='paper_size')      { $valuetoshow=$langs->trans("PaperSize"); }
+			if ($fieldlist[$field]=='orientation')     { $valuetoshow=$langs->trans("Orientation"); }
+			if ($fieldlist[$field]=='leftmargin')      { $valuetoshow=$langs->trans("LeftMargin"); }
+			if ($fieldlist[$field]=='topmargin')       { $valuetoshow=$langs->trans("TopMargin"); }
+			if ($fieldlist[$field]=='spacex')          { $valuetoshow=$langs->trans("SpaceX"); }
+			if ($fieldlist[$field]=='spacey')          { $valuetoshow=$langs->trans("SpaceY"); }
+			if ($fieldlist[$field]=='font_size')       { $valuetoshow=$langs->trans("FontSize"); }
+			if ($fieldlist[$field]=='custom_x')        { $valuetoshow=$langs->trans("CustomX"); }
+			if ($fieldlist[$field]=='custom_y')        { $valuetoshow=$langs->trans("CustomY"); }
+			if ($fieldlist[$field]=='content')         { $valuetoshow=$langs->trans("Content"); }
+			if ($fieldlist[$field]=='percent')         { $valuetoshow=$langs->trans("Percentage"); }
+			if ($fieldlist[$field]=='affect')          { $valuetoshow=$langs->trans("Info"); }
+			if ($fieldlist[$field]=='delay')           { $valuetoshow=$langs->trans("NoticePeriod"); }
+			if ($fieldlist[$field]=='newbymonth')      { $valuetoshow=$langs->trans("NewByMonth"); }
+				
+            if ($valuetoshow != '')
+            {
+                print '<td align="'.$align.'">';
+            	if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
+            	else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
+            	else print $valuetoshow;
+                print '</td>';
+             }
+             if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
+        }
+
+        if ($id == 4) print '<td></td>';
+        print '<td>';
+        print '<input type="hidden" name="id" value="'.$id.'">';
+        print '</td>';
+        print '<td style="min-width: 26px;"></td>';
+        print '<td style="min-width: 26px;"></td>';
+        print '<td style="min-width: 26px;"></td>';
+        print '</tr>';
+
+        // Line to enter new values
+        print "<tr ".$bcnd[$var].">";
+
+        $obj = new stdClass();
+        // If data was already input, we define them in obj to populate input fields.
+        if (GETPOST('actionadd'))
+        {
+            foreach ($fieldlist as $key=>$val)
+            {
+                if (GETPOST($val) != '')
+                	$obj->$val=GETPOST($val);
+            }
+        }
+
+        $tmpaction = 'create';
+        $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
+        $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
+        $error=$hookmanager->error; $errors=$hookmanager->errors;
+
+        if (empty($reshook))
+        {
+       		fieldList($fieldlist,$obj,$tabname[$id],'add');
+        }
+
+        print '<td colspan="4" align="right">';
+       	print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
+        print '</td>';
+        print "</tr>";
+
+        $colspan=count($fieldlist)+3;
+
+        if (! empty($alabelisused))  // If there is one label among fields, we show legend of *
+        {
+        	print '<tr><td colspan="'.$colspan.'">* '.$langs->trans("LabelUsedByDefault").'.</td></tr>';
+        }
+        print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>';	// Keep &nbsp; to have a line with enough height
+    }
+
+
+
+    // List of available record in database
+    dol_syslog("htdocs/admin/dict", LOG_DEBUG);
+    $resql=$db->query($sql);
+    if ($resql)
+    {
+        $num = $db->num_rows($resql);
+        $i = 0;
+        $var=true;
+
+        $param = '&id='.$id;
+        if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
+        $paramwithsearch = $param;
+        if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
+        if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
+        if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
+        
+        // There is several pages
+        if ($num > $listlimit)
+        {
+            print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
+            print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
+            print '</td></tr>';
+        }
+
+        // Title of lines
+        print '<tr class="liste_titre liste_titre_add">';
+        foreach ($fieldlist as $field => $value)
+        {
+            // Determine le nom du champ par rapport aux noms possibles
+            // dans les dictionnaires de donnees
+            $showfield=1;							  	// By defaut
+            $align="left";
+            $sortable=1;
+            $valuetoshow='';
+            /*
+            $tmparray=getLabelOfField($fieldlist[$field]);
+            $showfield=$tmp['showfield'];
+            $valuetoshow=$tmp['valuetoshow'];
+            $align=$tmp['align'];
+            $sortable=$tmp['sortable'];
+			*/
+            $valuetoshow=ucfirst($fieldlist[$field]);   // By defaut
+            $valuetoshow=$langs->trans($valuetoshow);   // try to translate
+            if ($fieldlist[$field]=='source')          { $valuetoshow=$langs->trans("Contact"); }
+            if ($fieldlist[$field]=='price')           { $valuetoshow=$langs->trans("PriceUHT"); }
+            if ($fieldlist[$field]=='taux')            {
+				if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate");
+				else $valuetoshow=$langs->trans("Amount");
+				$align='center';
+            }
+            if ($fieldlist[$field]=='localtax1_type')  { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; }
+            if ($fieldlist[$field]=='localtax1')       { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; $sortable=0; }
+            if ($fieldlist[$field]=='localtax2_type')  { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; }
+            if ($fieldlist[$field]=='localtax2')       { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; $sortable=0; }
+            if ($fieldlist[$field]=='organization')    { $valuetoshow=$langs->trans("Organization"); }
+            if ($fieldlist[$field]=='lang')            { $valuetoshow=$langs->trans("Language"); }
+            if ($fieldlist[$field]=='type')            { $valuetoshow=$langs->trans("Type"); }
+            if ($fieldlist[$field]=='code')            { $valuetoshow=$langs->trans("Code"); }
+            if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
+            {
+            	$valuetoshow=$langs->trans("Label");
+               	if ($id != 25) $valuetoshow.="*";
+            }
+            if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
+            if ($fieldlist[$field]=='country')         { $valuetoshow=$langs->trans("Country"); }
+            if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
+            if ($fieldlist[$field]=='nbjour')          { $valuetoshow=$langs->trans("NbOfDays"); }
+            if ($fieldlist[$field]=='type_cdr')        { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
+            if ($fieldlist[$field]=='decalage')        { $valuetoshow=$langs->trans("Offset"); }
+            if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); }
+            if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); }
+            if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); }
+            if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
+            if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
+            if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; }
+            if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; }
+			if ($fieldlist[$field]=='fk_pcg_version')  { $valuetoshow=$langs->trans("Pcg_version"); }
+            if ($fieldlist[$field]=='account_parent')  { $valuetoshow=$langs->trans("Accountsparent"); }
+            if ($fieldlist[$field]=='pcg_type')        { $valuetoshow=$langs->trans("Pcg_type"); }
+            if ($fieldlist[$field]=='pcg_subtype')     { $valuetoshow=$langs->trans("Pcg_subtype"); }
+            if ($fieldlist[$field]=='sortorder')       { $valuetoshow=$langs->trans("SortOrder"); }
+            if ($fieldlist[$field]=='short_label')     { $valuetoshow=$langs->trans("ShortLabel"); }
+        	if ($fieldlist[$field]=='type_template')   { $valuetoshow=$langs->trans("TypeOfTemplate"); }
+			if ($fieldlist[$field]=='range_account')   { $valuetoshow=$langs->trans("Range"); }
+			if ($fieldlist[$field]=='sens')            { $valuetoshow=$langs->trans("Sens"); }
+			if ($fieldlist[$field]=='category_type')   { $valuetoshow=$langs->trans("Calculated"); }
+			if ($fieldlist[$field]=='formula')         { $valuetoshow=$langs->trans("Formula"); }
+			if ($fieldlist[$field]=='paper_size')      { $valuetoshow=$langs->trans("PaperSize"); }
+			if ($fieldlist[$field]=='orientation')     { $valuetoshow=$langs->trans("Orientation"); }
+			if ($fieldlist[$field]=='leftmargin')      { $valuetoshow=$langs->trans("LeftMargin"); }
+			if ($fieldlist[$field]=='topmargin')       { $valuetoshow=$langs->trans("TopMargin"); }
+			if ($fieldlist[$field]=='spacex')          { $valuetoshow=$langs->trans("SpaceX"); }
+			if ($fieldlist[$field]=='spacey')          { $valuetoshow=$langs->trans("SpaceY"); }
+			if ($fieldlist[$field]=='font_size')       { $valuetoshow=$langs->trans("FontSize"); }
+			if ($fieldlist[$field]=='custom_x')        { $valuetoshow=$langs->trans("CustomX"); }
+			if ($fieldlist[$field]=='custom_y')        { $valuetoshow=$langs->trans("CustomY"); }
+			if ($fieldlist[$field]=='content')         { $valuetoshow=$langs->trans("Content"); }
+			if ($fieldlist[$field]=='percent')         { $valuetoshow=$langs->trans("Percentage"); }
+			if ($fieldlist[$field]=='affect')          { $valuetoshow=$langs->trans("Info"); }
+			if ($fieldlist[$field]=='delay')           { $valuetoshow=$langs->trans("NoticePeriod"); }
+			if ($fieldlist[$field]=='newbymonth')      { $valuetoshow=$langs->trans("NewByMonth"); }
+
+            // Affiche nom du champ
+            if ($showfield)
+            {
+                print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
+            }
+        }
+		// Favorite - Only activated on country dictionary
+        if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
+
+		print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
+        print getTitleFieldOfList('');
+        print getTitleFieldOfList('');
+        print getTitleFieldOfList('');
+        print '</tr>';
+
+        // Title line with search boxes
+        print '<tr class="liste_titre">';
+        $filterfound=0;
+        foreach ($fieldlist as $field => $value)
+        {
+            $showfield=1;							  	// By defaut
+            
+            if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
+            
+            if ($showfield)
+            {
+                if ($value == 'country')
+                {
+                    print '<td class="liste_titre">';
+                    print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
+                    print '</td>';
+                    $filterfound++;
+                }
+                else
+                {
+                    print '<td class="liste_titre"></td>';
+                }
+            }
+        }
+        if ($id == 4) print '<td></td>';
+        print '<td class="liste_titre"></td>';
+    	print '<td class="liste_titre" colspan="3" align="center">';
+    	if ($filterfound)
+    	{
+        	$searchpitco=$form->showFilterAndCheckAddButtons(0);
+        	print $searchpitco;
+    	}
+    	print '</td>';
+        print '</tr>';
+            
+        if ($num)
+        {
+            // Lines with values
+            while ($i < $num)
+            {
+                $var = ! $var;
+
+                $obj = $db->fetch_object($resql);
+                //print_r($obj);
+                print '<tr '.$bc[$var].' id="rowid-'.$obj->rowid.'">';
+                if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
+                {
+                    $tmpaction='edit';
+                    $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
+                    $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
+                    $error=$hookmanager->error; $errors=$hookmanager->errors;
+
+                    // Show fields
+                    if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
+
+                    print '<td colspan="3" align="center">';
+                    print '<input type="hidden" name="page" value="'.$page.'">';
+                    print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+                    print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
+                    print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
+                    print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
+                    print '</td>';
+                }
+                else
+                {
+	              	$tmpaction = 'view';
+                    $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
+                    $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
+
+                    $error=$hookmanager->error; $errors=$hookmanager->errors;
+
+                    if (empty($reshook))
+                    {
+                        foreach ($fieldlist as $field => $value)
+                        {
+                            
+                            $showfield=1;
+                        	$align="left";
+                            $valuetoshow=$obj->{$fieldlist[$field]};
+                            if ($value == 'type_template')
+                            {
+                                $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
+                            }
+                            if ($value == 'element')
+                            {
+                                $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow;
+                            }
+                            else if ($value == 'source')
+                            {
+                                $valuetoshow = isset($sourceList[$valuetoshow])?$sourceList[$valuetoshow]:$valuetoshow;
+                            }
+                            else if ($valuetoshow=='all') {
+                                $valuetoshow=$langs->trans('All');
+                            }
+                            else if ($fieldlist[$field]=='country') {
+                                if (empty($obj->country_code))
+                                {
+                                    $valuetoshow='-';
+                                }
+                                else
+                                {
+                                    $key=$langs->trans("Country".strtoupper($obj->country_code));
+                                    $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country);
+                                }
+                            }
+                            else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
+                                $valuetoshow=yn($valuetoshow);
+                                $align="center";
+                            }
+                            else if ($fieldlist[$field]=='type_cdr') {
+                				if(empty($valuetoshow)) $valuetoshow = $langs->trans('None');
+                				elseif($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth');
+                				elseif($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext');
+                                $align="center";
+                            }
+                            else if ($fieldlist[$field]=='price' || preg_match('/^amount/i',$fieldlist[$field])) {
+                                $valuetoshow=price($valuetoshow);
+                            }
+                            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=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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]};
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            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]});
+                            }
+                            else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
+                                $showfield=0;
+                            }
+                            else if ($fieldlist[$field]=='unicode') {
+                            	$valuetoshow = $langs->getCurrencySymbol($obj->code,1);
+                            }
+                            else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') {
+	                            $langs->load("products");
+	                            $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]});
+                            }
+                            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]});
+                            }
+							else if ($fieldlist[$field]=='localtax1' || $fieldlist[$field]=='localtax2') {
+							    $align="center";
+							}
+							else if ($fieldlist[$field]=='localtax1_type') {
+                              if ($obj->localtax1 != 0)
+							    $valuetoshow=$localtax_typeList[$valuetoshow];
+							  else
+							    $valuetoshow = '';
+							  $align="center";
+							}
+							else if ($fieldlist[$field]=='localtax2_type') {
+							 if ($obj->localtax2 != 0)
+							    $valuetoshow=$localtax_typeList[$valuetoshow];
+							  else
+							    $valuetoshow = '';
+							  $align="center";
+							}
+							else if ($fieldlist[$field]=='taux') {
+                                $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
+							    $align="center";
+							}
+							else if (in_array($fieldlist[$field],array('recuperableonly')))
+							{
+								$align="center";
+							}
+							else if ($fieldlist[$field]=='accountancy_code' || $fieldlist[$field]=='accountancy_code_sell' || $fieldlist[$field]=='accountancy_code_buy') {
+                                $valuetoshow = length_accountg($valuetoshow);
+                            }
+
+                            $class='tddict';
+                            if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto';
+							// Show value for field
+							if ($showfield) print '<!-- '.$fieldlist[$field].' --><td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
+                        }
+                    }
+
+                    // Can an entry be erased or disabled ?
+                    $iserasable=1;$canbedisabled=1;$canbemodified=1;	// true by default
+                    if (isset($obj->code) && $id != 10)
+                    {
+                    	if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $canbedisabled = 0; }
+                    	else if ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; }
+                    	else if ($obj->code == 'EF0')   { $iserasable = 0; $canbedisabled = 0; }
+                    }
+
+                    if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; }
+                    if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; }
+                    $canbemodified=$iserasable;
+                    if ($obj->code == 'RECEP') $canbemodified=1;
+
+                    $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
+                    if ($param) $url .= '&'.$param;
+                    $url.='&';
+
+					// Favorite
+					// Only activated on country dictionary
+                    if ($id == 4)
+					{
+						print '<td align="center" class="nowrap">';
+						if ($iserasable) print '<a href="'.$url.'action='.$acts[$obj->favorite].'_favorite">'.$actl[$obj->favorite].'</a>';
+						else print $langs->trans("AlwaysActive");
+						print '</td>';
+					}
+
+                    // Active
+                    print '<td align="center" class="nowrap">';
+                    if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
+                    else
+                 	{
+                 		if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
+                 		else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
+                  		else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
+                    	else print $langs->trans("AlwaysActive");
+                    }
+                    print "</td>";
+
+                    // Modify link
+                    if ($canbemodified) print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
+                    else print '<td>&nbsp;</td>';
+
+                    // Delete link
+                    if ($iserasable)
+                    {
+                        print '<td align="center">';
+                        if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
+                        //else print '<a href="#">'.img_delete().'</a>';    // Some dictionnary can be edited by other profile than admin
+                        print '</td>';
+                    }
+                    else print '<td>&nbsp;</td>';
+
+                    // Link to setup the group
+                    print '<td>';
+                    if (empty($obj->formula))
+                    {
+                        print '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories.php?action=display&account_category='.$obj->rowid.'">'.$langs->trans("Setup").'</a>';
+                    }
+                    print '</td>';
+                    print "</tr>\n";
+                }
+                $i++;
+            }
+        }
+    }
+    else {
+        dol_print_error($db);
+    }
+
+    print '</table>';
+
+    print '</form>';
+}
+
+print '<br>';
+
+
+llxFooter();
+$db->close();
+
+
+/**
+ *	Show fields in insert/edit mode
+ *
+ * 	@param		array	$fieldlist		Array of fields
+ * 	@param		Object	$obj			If we show a particular record, obj is filled with record fields
+ *  @param		string	$tabname		Name of SQL table
+ *  @param		string	$context		'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
+ *	@return		void
+ */
+function fieldList($fieldlist, $obj='', $tabname='', $context='')
+{
+	global $conf,$langs,$db;
+	global $form, $mysoc;
+	global $region_id;
+	global $elementList,$sourceList,$localtax_typeList;
+	global $bc;
+
+	$formadmin = new FormAdmin($db);
+	$formcompany = new FormCompany($db);
+	if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db);
+
+	foreach ($fieldlist as $field => $value)
+	{
+		if ($fieldlist[$field] == 'country')
+		{
+			if (in_array('region_id',$fieldlist))
+			{
+				print '<td>';
+				//print join(',',$fieldlist);
+				print '</td>';
+				continue;
+			}	// For state page, we do not show the country input (we link to region, not country)
+			print '<td>';
+			$fieldname='country';
+			print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:$mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
+			print '</td>';
+		}
+		elseif ($fieldlist[$field] == 'country_id')
+		{
+			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);
+				print '<td>';
+				print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
+				print '</td>';
+			}
+		}
+		elseif ($fieldlist[$field] == 'region')
+		{
+			print '<td>';
+			$formcompany->select_region($region_id,'region');
+			print '</td>';
+		}
+		elseif ($fieldlist[$field] == 'region_id')
+		{
+			$region_id = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:0);
+			print '<td>';
+			print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">';
+			print '</td>';
+		}
+		elseif ($fieldlist[$field] == 'lang')
+		{
+			print '<td>';
+			print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang');
+			print '</td>';
+		}
+		// Le type de template
+		elseif ($fieldlist[$field] == 'type_template')
+		{
+			print '<td>';
+			print $form->selectarray('type_template', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
+			print '</td>';
+		}
+		// Le type de l'element (pour les type de contact)
+		elseif ($fieldlist[$field] == 'element')
+		{
+			print '<td>';
+			print $form->selectarray('element', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
+			print '</td>';
+		}
+		// La source de l'element (pour les type de contact)
+		elseif ($fieldlist[$field] == 'source')
+		{
+			print '<td>';
+			print $form->selectarray('source', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
+			print '</td>';
+		}
+		elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm")
+		{
+			print '<td>';
+			print 'user<input type="hidden" name="type" value="user">';
+			print '</td>';
+		}
+		elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
+		    if ($fieldlist[$field] == 'type_cdr') print '<td align="center">';
+		    else print '<td>';
+			if ($fieldlist[$field] == 'type_cdr') {
+				print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
+			} else {
+				print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1);
+			}
+			print '</td>';
+		}
+		elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) {
+			$align="left";
+			if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="center";	// Fields aligned on right
+			print '<td align="'.$align.'">';
+			print '<input type="text" class="flat" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" size="3" name="'.$fieldlist[$field].'">';
+			print '</td>';
+		}
+		elseif (in_array($fieldlist[$field], array('libelle_facture'))) {
+			print '<td><textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea></td>';
+		}
+		elseif (in_array($fieldlist[$field], array('content')))
+		{
+			if ($tabname == MAIN_DB_PREFIX.'c_email_templates')
+			{
+				print '<td colspan="4"></td></tr><tr class="pair nohover"><td colspan="5">';		// To create an artificial CR for the current tr we are on
+			}
+			else print '<td>';
+			if ($context != 'hide')
+			{
+				//print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>';
+				$okforextended=true;
+				if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false;
+				$doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_5, '90%');
+				print $doleditor->Create(1);
+			}
+			else print '&nbsp;';
+			print '</td>';
+		}
+		elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) {
+			print '<td><input type="text" class="flat minwidth75" value="'.price((! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')).'" name="'.$fieldlist[$field].'"></td>';
+		}
+		elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
+			print '<td><input type="text" class="flat minwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
+		}
+		elseif ($fieldlist[$field]=='unit') {
+			print '<td>';
+			$units = array(
+					'mm' => $langs->trans('SizeUnitmm'),
+					'cm' => $langs->trans('SizeUnitcm'),
+					'point' => $langs->trans('SizeUnitpoint'),
+					'inch' => $langs->trans('SizeUnitinch')
+			);
+			print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0);
+			print '</td>';
+		}
+		// Le type de taxe locale
+		elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type')
+		{
+			print '<td align="center">';
+			print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
+			print '</td>';
+		}
+		elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy')
+		{
+			print '<td>';
+			if (! empty($conf->accounting->enabled))
+			{
+			    $fieldname = $fieldlist[$field];
+				$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
+				print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
+			}
+			else
+			{
+			    $fieldname = $fieldlist[$field];
+			    print '<input type="text" size="10" class="flat" value="'.(isset($obj->$fieldname)?$obj->$fieldname:'').'" name="'.$fieldlist[$field].'">';
+			}
+			print '</td>';
+		}
+		else
+		{
+			print '<td>';
+			$size=''; $class='';
+			if ($fieldlist[$field]=='code') $class='maxwidth100';
+			if ($fieldlist[$field]=='position') $class='maxwidth50';
+			if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
+			if ($fieldlist[$field]=='tracking') $class='quatrevingtpercent';
+			if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
+			print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
+			print '</td>';
+		}
+	}
+}
+

+ 1 - 0
htdocs/accountancy/admin/defaultaccounts.php

@@ -39,6 +39,7 @@ $langs->load("bills");
 $langs->load("admin");
 $langs->load("accountancy");
 $langs->load("salaries");
+$langs->load("loan");
 
 // Security check
 if (! empty($user->rights->accountancy->chartofaccount))

+ 32 - 28
htdocs/accountancy/admin/index.php

@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2013-2014 Olivier Geffroy		<jeff@jeffinfo.com>
  * Copyright (C) 2013-2014 Florian Henry		<florian.henry@open-concept.pro>
- * Copyright (C) 2013-2016 Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2013-2017 Alexandre Spangaro	<aspangaro@zendsi.com>
  * Copyright (C) 2014-2015 Ari Elbaz (elarifr)	<github@accedinfo.com>
  * Copyright (C) 2014      Marcos García        <marcosgdf@gmail.com>
  * Copyright (C) 2014	   Juanjo Menent		<jmenent@2byte.es>
@@ -87,7 +87,8 @@ if ($action == 'update') {
 		setEventMessages($langs->trans("Error"), null, 'errors');
 	}
 
-    foreach ($list as $constname) {
+    foreach ($list as $constname) 
+    {
         $constvalue = GETPOST($constname, 'alpha');
 
         if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
@@ -141,18 +142,17 @@ if ($action == 'setmanagezero') {
 }
 
 if ($action == 'setdisabledirectinput') {
-    $setdisabledirectinput = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
-    if (! $res > 0)
-        $error ++;
-        if (! $error) {
-            setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-        } else {
-            setEventMessages($langs->trans("Error"), null, 'mesgs');
-        }
+	$setdisabledirectinput = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
+	if (! $res > 0)
+		$error ++;
+		if (! $error) {
+			setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+		} else {
+			setEventMessages($langs->trans("Error"), null, 'mesgs');
+		}
 }
 
-
 /*
  * View
  */
@@ -242,20 +242,20 @@ if (! empty($user->admin))
     }
     print '</tr>';
 
-    $var = ! $var;
-    print "<tr " . $bc[$var] . ">";
-    print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
-    if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
-        print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
-        print img_picto($langs->trans("Activated"), 'switch_on');
-        print '</a></td>';
-    } else {
-        print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
-        print img_picto($langs->trans("Disabled"), 'switch_off');
-        print '</a></td>';
-    }
-    print '</tr>';
-    
+	$var = ! $var;
+	print "<tr " . $bc[$var] . ">";
+	print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
+	if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
+		print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
+		print img_picto($langs->trans("Activated"), 'switch_on');
+		print '</a></td>';
+	} else {
+		print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
+		print img_picto($langs->trans("Disabled"), 'switch_off');
+		print '</a></td>';
+	}
+	print '</tr>';
+
     $var = ! $var;
     print "<tr " . $bc[$var] . ">";
     print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
@@ -278,13 +278,17 @@ foreach ($list as $key)
     $var = ! $var;
 
     print '<tr ' . $bc[$var] . ' class="value">';
+    
+    if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
+
     // Param
     $label = $langs->trans($key);
     print '<td>'.$label.'</td>';
     // Value
     print '<td align="right">';
-    print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
+    print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
     print '</td>';
+    
     print '</tr>';
 }
 
@@ -301,7 +305,7 @@ print '<div class="center"><input type="submit" class="button" value="' . $langs
 print '<br>';
 print '<br>';
 
-print $langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy"));
+print $langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy"));
 
 print '<br>';
 print '</form>';

+ 6 - 6
htdocs/accountancy/bookkeeping/balance.php

@@ -184,7 +184,7 @@ else {
     print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">';
     print '<tr class="liste_titre">';
     print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
-    print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder);
+    print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder);
@@ -192,7 +192,7 @@ else {
     print "</tr>\n";
     
     print '<tr class="liste_titre">';
-    print '<td class="liste_titre center" colspan="2">';
+    print '<td class="liste_titre" colspan="2">';
     print $langs->trans('From');
     print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
     print '<br>';
@@ -229,7 +229,7 @@ else {
         if (empty($description)) {
             $link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
         }
-        print '<tr' . $bc[$var] . '>';
+        print '<tr ' . $bc[$var] . '>';
         
         // Permet d'afficher le compte comptable
         if ($root_account_description != $displayed_account) {
@@ -255,9 +255,9 @@ else {
         
         print '<td>' . length_accountg($line->numero_compte) . '</td>';
         print '<td>' . $description . '</td>';
-        print '<td align="right">' . number_format($line->debit, 2, ',', ' ') . '</td>';
-        print '<td align="right">' . number_format($line->credit, 2, ',', ' ') . '</td>';
-        print '<td align="right">' . number_format($line->credit - $line->debit, 2, ',', ' ') . '</td>';
+        print '<td align="right">' . price($line->debit) . '</td>';
+        print '<td align="right">' . price($line->credit) . '</td>';
+        print '<td align="right">' . price($line->credit - $line->debit) . '</td>';
         print '<td align="center">' . $link;
         print '</td>';
         print "</tr>\n";

+ 12 - 8
htdocs/accountancy/bookkeeping/card.php

@@ -202,9 +202,11 @@ else if ($action == "confirm_create") {
 	}
 }
 
+
 /*
  * View
  */
+
 llxHeader();
 
 $html = new Form($db);
@@ -274,12 +276,12 @@ if ($action == 'create') {
 
 	print '<tr>';
 	print '<td>' . $langs->trans("Docref") . '</td>';
-	print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
+	print '<td><input type="text" class="minwidth200" name="doc_ref" value=""/></td>';
 	print '</tr>';
 
 	print '<tr>';
 	print '<td>' . $langs->trans("Doctype") . '</td>';
-	print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
+	print '<td><input type="text" class="minwidth200" name="doc_type" value=""/></td>';
 	print '</tr>';
 
 	print '</table>';
@@ -345,6 +347,8 @@ if ($action == 'create') {
 			print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
 			print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
 
+			$var=False;
+			
 			print "<table class=\"noborder\" width=\"100%\">";
 			if (count($book->linesmvt) > 0) {
 
@@ -356,17 +360,17 @@ if ($action == 'create') {
 				print_liste_field_titre($langs->trans("AccountAccountingShort"));
 				print_liste_field_titre($langs->trans("Code_tiers"));
 				print_liste_field_titre($langs->trans("Labelcompte"));
-				print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="center"');
-				print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="center"');
-				print_liste_field_titre($langs->trans("Amount"), "", "", "", "", 'align="center"');
+				print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"');
+				print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"');
+				print_liste_field_titre($langs->trans("Amount"), "", "", "", "", 'align="right"');
 				print_liste_field_titre($langs->trans("Sens"), "", "", "", "", 'align="center"');
 				print_liste_field_titre($langs->trans("Action"), "", "", "", "", 'width="60" align="center"');
 
 				print "</tr>\n";
 
-				foreach ( $book->linesmvt as $line ) {
+				foreach ($book->linesmvt as $line) {
 					$var = ! $var;
-					print '<tr' . $bc[$var] . '>';
+					print '<tr ' . $bc[$var] . '>';
 
 					$total_debit += $line->debit;
 					$total_credit += $line->credit;
@@ -417,7 +421,7 @@ if ($action == 'create') {
 
 				if ($action == "" || $action == 'add') {
 					$var = ! $var;
-					print '<tr' . $bc[$var] . '>';
+					print '<tr ' . $bc[$var] . '>';
 					print '<td>';
 					print $formventilation->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
 					print '</td>';

+ 76 - 77
htdocs/accountancy/bookkeeping/list.php

@@ -105,7 +105,6 @@ if ($action != 'export_csv' && ! isset($_POST['begin']) && ! isset($_GET['begin'
 
 
 
-
 /*
  * Action
  */
@@ -132,74 +131,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
 	$search_date_end = '';
 }
 
-if ($action == 'delbookkeeping') {
-
-	$import_key = GETPOST('importkey', 'alpha');
-
-	if (! empty($import_key)) {
-		$result = $object->deleteByImportkey($import_key);
-		if ($result < 0) {
-			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		Header("Location: list.php");
-		exit();
-	}
-}
-if ($action == 'delbookkeepingyearconfirm') {
-
-	$delyear = GETPOST('delyear', 'int');
-	if ($delyear==-1) {
-		$delyear=0;
-	}
-	$deljournal = GETPOST('deljournal','alpha');
-	if ($deljournal==-1) {
-		$deljournal=0;
-	}
-
-	if (! empty($delyear) || ! empty($deljournal)) 
-	{
-		$result = $object->deleteByYearAndJournal($delyear,$deljournal);
-		if ($result < 0) {
-			setEventMessages($object->error, $object->errors, 'errors');
-		}
-		else
-		{
-		    setEventMessages("RecordDeleted", null, 'mesgs');
-		}
-		Header("Location: list.php");
-		exit;
-	}
-	else
-	{
-	    setEventMessages("NoRecordDeleted", null, 'warnings');
-	    Header("Location: list.php");
-	    exit;
-	}
-}
-if ($action == 'delmouvconfirm') {
-
-	$mvt_num = GETPOST('mvt_num', 'int');
-
-	if (! empty($mvt_num)) {
-		$result = $object->deleteMvtNum($mvt_num);
-		if ($result < 0) {
-		    setEventMessages($object->error, $object->errors, 'errors');
-		}
-		else
-		{
-		    setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
-		}
-		Header("Location: list.php");
-		exit;
-	}
-}
-
-
-
-/*
- * View
- */
-
+// Must be after the remove filter action, before the export.
 $param = '';
 $filter = array ();
 if (! empty($search_date_start)) {
@@ -266,6 +198,68 @@ if (! empty($search_mvt_num)) {
     $param .= '&search_mvt_num=' . $search_mvt_num;
 }
 
+if ($action == 'delbookkeeping') {
+
+	$import_key = GETPOST('importkey', 'alpha');
+
+	if (! empty($import_key)) {
+		$result = $object->deleteByImportkey($import_key);
+		if ($result < 0) {
+			setEventMessages($object->error, $object->errors, 'errors');
+		}
+		Header("Location: list.php");
+		exit();
+	}
+}
+if ($action == 'delbookkeepingyearconfirm') {
+
+	$delyear = GETPOST('delyear', 'int');
+	if ($delyear==-1) {
+		$delyear=0;
+	}
+	$deljournal = GETPOST('deljournal','alpha');
+	if ($deljournal==-1) {
+		$deljournal=0;
+	}
+
+	if (! empty($delyear) || ! empty($deljournal)) 
+	{
+		$result = $object->deleteByYearAndJournal($delyear,$deljournal);
+		if ($result < 0) {
+			setEventMessages($object->error, $object->errors, 'errors');
+		}
+		else
+		{
+		    setEventMessages("RecordDeleted", null, 'mesgs');
+		}
+		Header("Location: list.php");
+		exit;
+	}
+	else
+	{
+	    setEventMessages("NoRecordDeleted", null, 'warnings');
+	    Header("Location: list.php");
+	    exit;
+	}
+}
+if ($action == 'delmouvconfirm') {
+
+	$mvt_num = GETPOST('mvt_num', 'int');
+
+	if (! empty($mvt_num)) {
+		$result = $object->deleteMvtNum($mvt_num);
+		if ($result < 0) {
+		    setEventMessages($object->error, $object->errors, 'errors');
+		}
+		else
+		{
+		    setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
+		}
+		Header("Location: list.php");
+		exit;
+	}
+}
+
 if ($action == 'export_csv') {
 
     include DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
@@ -287,6 +281,11 @@ if ($action == 'export_csv') {
     }
 }
 
+
+/*
+ * View
+ */
+
 $title_page = $langs->trans("Bookkeeping");
 
 llxHeader('', $title_page);
@@ -378,15 +377,15 @@ print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_d
 print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
 print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
 print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $param, "", $sortfield, $sortorder);
-print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder);
+print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder);
 print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder);
 print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder);
-print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="right"', $sortfield, $sortorder);
+print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder);
 print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
 print "</tr>\n";
 
 print '<tr class="liste_titre">';
-print '<td class="liste_titre center"><input type="text" name="search_mvt_num" size="6" value="' . $search_mvt_num . '"></td>';
+print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>';
 print '<td class="liste_titre center">';
 print $langs->trans('From') . ': ';
 print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
@@ -394,15 +393,15 @@ print '<br>';
 print $langs->trans('to') . ': ';
 print $form->select_date($search_date_end, 'date_end', 0, 0, 1);
 print '</td>';
-print '<td class="liste_titre center"><input type="text" name="search_doc_ref" size="8" value="' . $search_doc_ref . '"></td>';
-print '<td class="liste_titre center">';
+print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
+print '<td class="liste_titre">';
 print $langs->trans('From');
 print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
 print '<br>';
 print $langs->trans('to');
 print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
 print '</td>';
-print '<td class="liste_titre center">';
+print '<td class="liste_titre">';
 print $langs->trans('From');
 print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
 print '<br>';
@@ -414,8 +413,8 @@ print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'
 print '</td>';
 print '<td class="liste_titre center">&nbsp;</td>';
 print '<td class="liste_titre center">&nbsp;</td>';
-print '<td class="liste_titre center" align="right"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
-print '<td class="liste_titre center" align="right">';
+print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
+print '<td class="liste_titre center">';
 $searchpitco=$form->showFilterAndCheckAddButtons(0);
 print $searchpitco;
 print '</td>';

+ 50 - 5
htdocs/accountancy/class/accountancycategory.class.php

@@ -129,6 +129,47 @@ class AccountancyCategory
 		}
 	}
 
+	/**
+	 * Function to select accounting category of an accounting account present in chart of accounts
+	 *
+	 * @param int $id Id category
+	 *
+	 * @return int <0 if KO, 0 if not found, >0 if OK
+	 */
+	public function getAccountsWithNoCategory($id) {
+	    global $conf;
+	
+	    $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
+	    $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
+	    $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
+	    $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)";
+	    $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
+	    $sql .= " AND aa.active = 1";
+	    $sql .= " GROUP BY aa.account_number, aa.label";
+	    $sql .= " ORDER BY aa.account_number, aa.label";
+	
+	    $this->lines_CptBk = array ();
+	
+	    dol_syslog(__METHOD__, LOG_DEBUG);
+	    $resql = $this->db->query($sql);
+	    if ($resql) {
+	        $num = $this->db->num_rows($resql);
+	        if ($num) {
+	            while ( $obj = $this->db->fetch_object($resql) ) {
+	                $this->lines_cptbk[] = $obj;
+	            }
+	        }
+	
+	        return $num;
+	    } else {
+	        $this->error = "Error " . $this->db->lasterror();
+	        $this->errors[] = $this->error;
+	        dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
+	
+	        return - 1;
+	    }
+	}
+	
 	/**
 	 * Function to add an accounting account in an accounting category
 	 *
@@ -149,23 +190,27 @@ class AccountancyCategory
 		$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
 		$sql .= " AND aa.active = 1";
 
+		$this->db->begin();
+		
 		dol_syslog(__METHOD__, LOG_DEBUG);
 		$resql = $this->db->query($sql);
 		if (! $resql) {
 			$error ++;
 			$this->errors[] = "Error " . $this->db->lasterror();
+			$this->db->rollback();
 			return -1;
 		}
 
-		$this->db->begin();
-		while ( $obj = $this->db->fetch_object($resql)) {
-			if (array_key_exists(length_accountg($obj->account_number), $cpts)) {
+		while ( $obj = $this->db->fetch_object($resql)) 
+		{
+			if (array_key_exists(length_accountg($obj->account_number), $cpts)) 
+			{
 				$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account";
 				$sql .= " SET fk_accounting_category=" . $id_cat;
 				$sql .= " WHERE rowid=".$obj->rowid;
 				dol_syslog(__METHOD__, LOG_DEBUG);
-				$resql = $this->db->query($sql);
-				if (! $resql) {
+				$resqlupdate = $this->db->query($sql);
+				if (! $resqlupdate) {
 					$error ++;
 					$this->errors[] = "Error " . $this->db->lasterror();
 				}

+ 49 - 0
htdocs/accountancy/class/accountancysystem.class.php

@@ -47,6 +47,55 @@ class AccountancySystem
 		$this->db = $db;
 	}
 	
+	
+	/**
+	 * Load record in memory
+	 *
+	 * @param 	int 	$rowid 				   Id
+	 * @param 	string 	$ref             	   ref
+	 * @return 	int                            <0 if KO, Id of record if OK and found
+	 */
+	function fetch($rowid = 0, $ref = '') 
+	{
+	    global $conf;
+	
+	    if ($rowid > 0 || $ref) 
+	    {
+	        $sql  = "SELECT a.pcg_version, a.label, a.active";
+	        $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a";
+	        $sql .= " WHERE";
+	        if ($rowid) {
+	            $sql .= " a.rowid = '" . $rowid . "'";
+	        } elseif ($ref) {
+	            $sql .= " a.pcg_version = '" . $ref . "'";
+	        }
+	
+	        dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
+	        $result = $this->db->query($sql);
+	        if ($result) {
+	            $obj = $this->db->fetch_object($result);
+	
+	            if ($obj) {
+	                $this->id = $obj->rowid;
+	                $this->rowid = $obj->rowid;
+	                $this->pcg_version = $obj->pcg_version;
+	                $this->ref = $obj->pcg_version;
+	                $this->label = $obj->label;
+	                $this->active = $obj->active;
+	                	
+	                return $this->id;
+	            } else {
+	                return 0;
+	            }
+	        } else {
+	            $this->error = "Error " . $this->db->lasterror();
+	            $this->errors[] = "Error " . $this->db->lasterror();
+	        }
+	    }
+	    return - 1;
+	}
+	
+	
 	/**
 	 * Insert accountancy system name into database
 	 *

+ 32 - 16
htdocs/accountancy/class/accountingaccount.class.php

@@ -150,12 +150,19 @@ class AccountingAccount extends CommonObject
 		if (isset($this->active))
 			$this->active = trim($this->active);
 			
-			// Check parameters
-			// Put here code to add control on parameters values
+		if (empty($this->pcg_type) || $this->pcg_type == '-1')
+		{
+		    $this->pcg_type = 'XXXXXX';
+		}
+		if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
+		{
+		    $this->pcg_subtype = 'XXXXXX';
+		}
+		// Check parameters
+		// Put here code to add control on parameters values
 			
 		// Insert request
 		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account(";
-		
 		$sql .= "datec";
 		$sql .= ", entity";
 		$sql .= ", fk_pcg_version";
@@ -167,9 +174,7 @@ class AccountingAccount extends CommonObject
 		$sql .= ", fk_accounting_category";
 		$sql .= ", fk_user_author";
 		$sql .= ", active";
-		
 		$sql .= ") VALUES (";
-		
 		$sql .= " '" . $this->db->idate($now) . "'";
 		$sql .= ", " . $conf->entity;
 		$sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
@@ -225,11 +230,22 @@ class AccountingAccount extends CommonObject
 	/**
 	 * Update record
 	 *
-	 * @param User $user Use making update
-	 * @return int <0 if KO, >0 if OK
+	 * @param  User $user      Use making update
+	 * @return int             <0 if KO, >0 if OK
 	 */
-	function update($user) {
-		$this->db->begin();
+	function update($user) 
+	{
+	    // Check parameters
+	    if (empty($this->pcg_type) || $this->pcg_type == '-1')
+	    {
+	        $this->pcg_type = 'XXXXXX';
+	    }
+	    if (empty($this->pcg_subtype) || $this->pcg_subtype == '-1')
+	    {
+	        $this->pcg_subtype = 'XXXXXX';
+	    }
+	     
+	    $this->db->begin();
 		
 		$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
 		$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
@@ -241,7 +257,6 @@ class AccountingAccount extends CommonObject
 		$sql .= " , fk_accounting_category = '" . $this->account_category . "'";
 		$sql .= " , fk_user_modif = " . $user->id;
 		$sql .= " , active = '" . $this->active . "'";
-		
 		$sql .= " WHERE rowid = " . $this->id;
 		
 		dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
@@ -354,22 +369,23 @@ class AccountingAccount extends CommonObject
 	 */
 	function getNomUrl($withpicto = 0) {
 		global $langs;
-		
+
 		$result = '';
-		
+
 		$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id . '">';
 		$linkend = '</a>';
-		
+
 		$picto = 'billr';
-		
+
 		$label = $langs->trans("Show") . ': ' . $this->account_number . ' - ' . $this->label;
-		
+
 		if ($withpicto)
 			$result .= ($link . img_object($label, $picto) . $linkend);
 		if ($withpicto && $withpicto != 2)
 			$result .= ' ';
 		if ($withpicto != 2)
-			$result .= $link . $this->account_number . $linkend;
+			require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+			$result .= $link . length_accountg($this->account_number) . ' - ' . $this->label . $linkend;
 		return $result;
 	}
 	

+ 16 - 7
htdocs/accountancy/class/html.formventilation.class.php

@@ -182,11 +182,15 @@ class FormVentilation extends Form
 		$options = array();
 		$out = ajax_combobox($htmlname, $event);
 
-		while ($obj = $this->db->fetch_object($resql)) {
-			$options[$obj->pcg_type] = $obj->pcg_type;
+		while ($obj = $this->db->fetch_object($resql)) 
+		{
+		    if ($obj->pcg_type != '-1')
+		    {
+                $options[$obj->pcg_type] = $obj->pcg_type;
+		    }
 		}
 
-		$out .= Form::selectarray($htmlname, $options, $selectid, $showempty);
+		$out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth200');
 
 		$this->db->free($resql);
 		return $out;
@@ -202,7 +206,8 @@ class FormVentilation extends Form
 	 *
 	 * @return string String with HTML select
 	 */
-	function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) {
+	function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) 
+	{
 		global $conf;
 
 		$sql = "SELECT DISTINCT pcg_subtype ";
@@ -223,11 +228,15 @@ class FormVentilation extends Form
 		$options = array();
 		$out = ajax_combobox($htmlname, $event);
 
-		while ($obj = $this->db->fetch_object($resql)) {
-			$options[$obj->pcg_subtype] = $obj->pcg_subtype;
+		while ($obj = $this->db->fetch_object($resql)) 
+		{
+		    if ($obj->pcg_type != '-1')
+		    {
+                $options[$obj->pcg_subtype] = $obj->pcg_subtype;
+		    }
 		}
 
-		$out .= Form::selectarray($htmlname, $options, $selectid, $showempty);
+		$out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth200');
 
 		$this->db->free($resql);
 		return $out;

+ 1 - 1
htdocs/accountancy/customer/card.php

@@ -73,7 +73,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
  * View
  */
 
-llxHeader("", "", "FicheVentilation");
+llxHeader("", $langs->trans(FicheVentilation));
 
 if ($cancel == $langs->trans("Cancel")) {
 	$action = '';

+ 12 - 12
htdocs/accountancy/customer/lines.php

@@ -170,31 +170,31 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
 	$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
 }
 if (strlen(trim($search_invoice))) {
-	$sql .= " AND f.facnumber like '%" . $search_invoice . "%'";
+	$sql .= natural_search("f.facnumber", $search_invoice);
 }
 if (strlen(trim($search_ref))) {
-	$sql .= " AND p.ref like '%" . $search_ref . "%'";
+	$sql .= natural_search("p.ref", $search_ref);
 }
 if (strlen(trim($search_label))) {
-	$sql .= " AND p.label like '%" . $search_label . "%'";
+	$sql .= natural_search("p.label", $search_label);
 }
 if (strlen(trim($search_desc))) {
-	$sql .= " AND fd.description like '%" . $search_desc . "%'";
+	$sql .= natural_search("fd.description", $search_desc);
 }
 if (strlen(trim($search_amount))) {
-	$sql .= " AND fd.total_ht like '%" . $search_amount . "%'";
+	$sql .= natural_search("fd.total_ht", $search_amount, 1);
 }
 if (strlen(trim($search_account))) {
-	$sql .= " AND aa.account_number like '%" . $search_account . "%'";
+	$sql .= natural_search("aa.account_number", $search_account);
 }
 if (strlen(trim($search_vat))) {
-	$sql .= " AND (fd.tva_tx like '" . $search_vat . "%')";
+	$sql .= natural_search("fd.tva_tx", $search_vat);
 }
 if (strlen(trim($search_country))) {
-	$sql .= " AND (co.label like'" . $search_country . "%')";
+	$sql .= natural_search("co.label", $search_country);
 }
 if (strlen(trim($search_tvaintra))) {
-	$sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')";
+	$sql .= natural_search("s.tva_intra", $search_tva_intra);
 }
 $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")";    // We don't share object for accountancy
 $sql .= $db->order($sortfield, $sortorder);
@@ -278,12 +278,12 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
 	//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
-	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
+	print '<td class="liste_titre" align="center"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tavintra" value="' . dol_escape_htmltag($search_tavintra) . '"></td>';
-	print '<td class="liste_titre" align="right">';
+	print '<td class="liste_titre" align="center">';
 	$searchpitco=$form->showFilterAndCheckAddButtons(1);
 	print $searchpitco;
 	print "</td></tr>\n";

+ 4 - 4
htdocs/accountancy/customer/list.php

@@ -293,11 +293,11 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
 	//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '">%</td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"></td>';
-	print '<td align="right" class="liste_titre">';
+	print '<td align="center" class="liste_titre">';
 	$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
 	print $searchpitco;
 	print '</td>';
@@ -400,7 +400,7 @@ if ($result) {
 		print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
 		print '</td>';
 		
-		print '<td align="right">';
+		print '<td align="center">';
 		print '<input type="checkbox" class="flat checkforselect" name="toselect[]"  value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
 		print '</td>';
 		print '</tr>';

+ 4 - 4
htdocs/accountancy/expensereport/card.php

@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2004		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
  * Copyright (C) 2005		Simon TOSSER			<simon@kornog-computing.com>
- * Copyright (C) 2013-2016	Alexandre Spangaro		<aspangaro@zendsi.com>
+ * Copyright (C) 2013-2017	Alexandre Spangaro		<aspangaro@zendsi.com>
  * Copyright (C) 2013-2014	Olivier Geffroy			<jeff@jeffinfo.com>
  * Copyright (C) 2013-2014	Florian Henry			<florian.henry@open-concept.pro>
  * Copyright (C) 2014		Juanjo Menent			<jmenent@2byte.es>
@@ -76,7 +76,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
 /*
  * View
  */
-llxHeader("", "FicheVentilation");
+llxHeader("", $langs->trans(FicheVentilation));
 
 if ($cancel == $langs->trans("Cancel")) {
 	$action = '';
@@ -89,7 +89,7 @@ $formventilation = new FormVentilation($db);
 
 if (! empty($id)) {
 	$sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
-	$sql .= " f.id as fees_id, f.label as fees_label,";
+	$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
 	$sql .= " aa.account_number, aa.label";
 	$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
 	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
@@ -132,7 +132,7 @@ if (! empty($id)) {
 			print '<td>' . stripslashes(nl2br($objp->comments)) . '</td></tr>';
 
 			print '<tr><td>' . $langs->trans("TypeFees") . '</td>';
-			print '<td>' . dol_trunc($objp->fees_label, 24) . '</td>';
+			print '<td>' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '</td>';
 
 			print '<tr><td>' . $langs->trans("Account") . '</td><td>';
 			print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);

+ 5 - 5
htdocs/accountancy/expensereport/lines.php

@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2013-2016	Olivier Geffroy		<jeff@jeffinfo.com>
- * Copyright (C) 2013-2016	Alexandre Spangaro	<aspangaro@zendsi.com>
+ * Copyright (C) 2013-2017	Alexandre Spangaro	<aspangaro@zendsi.com>
  * Copyright (C) 2014-2015	Ari Elbaz (elarifr)	<github@accedinfo.com>  
  * Copyright (C) 2013-2016	Florian Henry		<florian.henry@open-concept.pro>
  * Copyright (C) 2014		Juanjo Menent		<jmenent@2byte.es>
@@ -148,7 +148,7 @@ print '<script type="text/javascript">
 $sql = "SELECT er.ref, er.rowid as erid,";
 $sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, erd.date,";
 $sql .= " aa.label, aa.account_number,";
-$sql .= " f.id as fees_id, f.label as fees_label";
+$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label";
 $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
 $sql .= " , " . MAIN_DB_PREFIX . "accounting_account as aa";
 $sql .= " , " . MAIN_DB_PREFIX . "expensereport_det as erd";
@@ -253,8 +253,8 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
 	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
-	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
-	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
+	print '<td class="liste_titre" align="center"><input type="text" class="right flat maxwidth50" name="search_vat" size="1" placeholder="%" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre" align="center"><input type="text" class="right flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
     print '<td class="liste_titre" align="right"></td>';
     print '<td class="liste_titre" align="right">';
     $searchpicto=$form->showFilterAndCheckAddButtons(1);
@@ -282,7 +282,7 @@ if ($result) {
 
 		print '<td align="center">' . dol_print_date($db->jdate($objp->date), 'day') . '</td>';
 		
-		print '<td class="tdoverflow">' . $objp->fees_label . '</td>';
+		print '<td class="tdoverflow">' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '</td>';
 
 		print '<td>';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));

+ 10 - 10
htdocs/accountancy/expensereport/list.php

@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2013-2014	Olivier Geffroy			<jeff@jeffinfo.com>
- * Copyright (C) 2013-2016	Alexandre Spangaro		<aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2013-2017	Alexandre Spangaro		<aspangaro@zendsi.com>
  * Copyright (C) 2014-2015	Ari Elbaz (elarifr)		<github@accedinfo.com>
  * Copyright (C) 2013-2014	Florian Henry			<florian.henry@open-concept.pro>
  * Copyright (C) 2014		Juanjo Menent			<jmenent@2byte.es>s
@@ -175,7 +175,7 @@ llxHeader('', $langs->trans("ExpenseReportsVentilation"));
 // Expense report lines
 $sql = "SELECT er.ref, er.rowid as erid, er.date_debut,";
 $sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.date,";
-$sql .= " f.id as fees_id, f.label as fees_label, f.accountancy_code as code_buy,";
+$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,";
 $sql .= " aa.rowid as aarowid";
 $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport";
@@ -279,11 +279,11 @@ if ($result) {
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"></td>';
-	print '<td align="right" class="liste_titre">';
+	print '<td align="center" class="liste_titre">';
 	$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
 	print $searchpicto;
 	print '</td>';
@@ -302,20 +302,20 @@ if ($result) {
 
 		$expensereport_static->ref = $objp->ref;
 		$expensereport_static->id = $objp->erid;
-		
+
 		print '<tr '. $bc[$var].'>';
 
 		// Line id
 		print '<td>' . $objp->rowid . '</td>';
 
-		print '<td align="center">' . dol_print_date($db->jdate($objp->date), 'day') . '</td>';
-		
 		// Ref Expense report
 		print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
 
+		print '<td align="center">' . dol_print_date($db->jdate($objp->date), 'day') . '</td>';
+
 		// Fees label
 		print '<td>';
-		print $objp->fees_label;
+		print ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code)));
 		print '</td>';
 
 		// Fees description -- Can be null
@@ -344,7 +344,7 @@ if ($result) {
 		print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
 		print '</td>';
 
-		print '<td align="right">';
+		print '<td align="center">';
 		print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
 		print '</td>';
 

+ 2 - 2
htdocs/accountancy/index.php

@@ -114,14 +114,14 @@ if (! empty($conf->expensereport->enabled))  // TODO Move this in the default ac
     print "<br>\n";
     print "<br>\n";
 }
-if (! empty($conf->loan->enabled))  // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
+/*
+if (! empty($conf->loan->enabled))
 {
     $step++;
     print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuSpecialExpenses").'-'.$langs->transnoentitiesnoconv("Loans").'</strong> '.$langs->transnoentitiesnoconv("or").' <strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
     print "<br>\n";
     print "<br>\n";
 }
-/*
 if (! empty($conf->don->enabled))
 {
     $step++;

+ 1 - 0
htdocs/accountancy/journal/expensereportsjournal.php

@@ -43,6 +43,7 @@ $langs->load("bills");
 $langs->load("other");
 $langs->load("main");
 $langs->load("accountancy");
+$langs->load("trips");
 
 $date_startmonth = GETPOST('date_startmonth');
 $date_startday = GETPOST('date_startday');

+ 1 - 1
htdocs/accountancy/supplier/card.php

@@ -76,7 +76,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
 /*
  * View
  */
-llxHeader("", "", "FicheVentilation");
+llxHeader("", $langs->trans(FicheVentilation));
 
 if ($cancel == $langs->trans("Cancel")) {
 	$action = '';

+ 11 - 11
htdocs/accountancy/supplier/lines.php

@@ -157,25 +157,25 @@ $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"
 $sql.= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
 $sql.= " AND aa.rowid = l.fk_code_ventilation";
 if (strlen(trim($search_invoice))) {
-	$sql .= " AND f.ref like '%" . $search_invoice . "%'";
+	$sql .= natural_search("f.ref", $search_invoice);
 }
 if (strlen(trim($search_ref))) {
-	$sql .= " AND p.ref like '%" . $search_ref . "%'";
+	$sql .= natural_search("p.ref", $search_ref);
 }
 if (strlen(trim($search_label))) {
-	$sql .= " AND p.label like '%" . $search_label . "%'";
+	$sql .= natural_search("p.label", $search_label);
 }
 if (strlen(trim($search_desc))) {
-	$sql .= " AND l.description like '%" . $search_desc . "%'";
+	$sql .= natural_search("l.description", $search_desc);
 }
 if (strlen(trim($search_amount))) {
-	$sql .= " AND l.total_ht like '%" . $search_amount . "%'";
+	$sql .= natural_search("l.total_ht", $search_amount, 1);
 }
 if (strlen(trim($search_account))) {
-	$sql .= " AND aa.account_number like '%" . $search_account . "%'";
+	$sql .= natural_search("aa.account_number", $search_account, 1);
 }
 if (strlen(trim($search_vat))) {
-	$sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
+	$sql .= natural_search("l.tva_tx", $search_vat, 1);
 }
 $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")";  // We don't share object for accountancy
 
@@ -255,16 +255,16 @@ if ($result) {
 	
 	print '<tr class="liste_titre">';
     print '<td class="liste_titre"></td>';
-	print '<td><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
 	//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
-	print '<td class="liste_titre" align="center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
+	print '<td class="liste_titre" align="center"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
-    print '<td class="liste_titre" align="right">';
+    print '<td class="liste_titre" align="center">';
     $searchpitco=$form->showFilterAndCheckAddButtons(1);
     print $searchpitco;
     print '</td>';

+ 4 - 4
htdocs/accountancy/supplier/list.php

@@ -292,11 +292,11 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
 	//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
-	print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
+	print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"></td>';
-	print '<td align="right" class="liste_titre">';
+	print '<td align="center" class="liste_titre">';
 	$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
 	print $searchpitco;
 	print '</td>';
@@ -406,7 +406,7 @@ if ($result) {
 		print '</td>';
 		
 		// Colonne choix ligne a ventiler
-		print '<td align="right">';
+		print '<td align="center">';
 		print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
 		print '</td>';
 

+ 1 - 0
htdocs/adherents/agenda.php

@@ -30,6 +30,7 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
 
 $langs->load("companies");

+ 35 - 34
htdocs/adherents/class/adherent.class.php

@@ -4,7 +4,7 @@
  * Copyright (C) 2004-2012	Laurent Destailleur		<eldy@users.sourceforge.net>
  * Copyright (C) 2004		Sebastien Di Cintio		<sdicintio@ressource-toi.org>
  * Copyright (C) 2004		Benoit Mortier			<benoit.mortier@opensides.be>
- * Copyright (C) 2009-2012	Regis Houssin			<regis.houssin@capnetworks.com>
+ * Copyright (C) 2009-2017	Regis Houssin			<regis.houssin@capnetworks.com>
  * Copyright (C) 2014-2016	Alexandre Spangaro		<aspangaro.dolibarr@gmail.com>
  * Copyright (C) 2015		Marcos García			<marcosgdf@gmail.com>
  * Copyright (C) 2015		Frederic France			<frederic.france@free.fr>
@@ -496,7 +496,7 @@ class Adherent extends CommonObject
                 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted)
                 {
                     $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1;
-                    
+
                     // If password to set differs from the one found into database
                     $result=$this->setPassword($user,$this->pass,$isencrypted,$notrigger,$nosyncuserpass);
                     if (! $nbrowsaffected) $nbrowsaffected++;
@@ -862,7 +862,7 @@ class Adherent extends CommonObject
                 $this->pass=$password;
                 $this->pass_indatabase=$password_indatabase;
                 $this->pass_indatabase_crypted=$password_crypted;
-                
+
                 if ($this->user_id && ! $nosyncuser)
                 {
                     require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -1122,7 +1122,7 @@ class Adherent extends CommonObject
                 $this->pass				= $obj->pass;
                 $this->pass_indatabase  = $obj->pass;
                 $this->pass_indatabase_crypted = $obj->pass_crypted;
-                
+
                 $this->state_id			= $obj->state_id;
                 $this->state_code		= $obj->state_id?$obj->state_code:'';
                 $this->state			= $obj->state_id?$obj->state:'';
@@ -1160,7 +1160,7 @@ class Adherent extends CommonObject
 
                 $this->user_id			= $obj->user_id;
                 $this->user_login		= $obj->user_login;
-                
+
                 $this->model_pdf        = $obj->model_pdf;
 
                 // Retreive all extrafield for thirdparty
@@ -1456,7 +1456,7 @@ class Adherent extends CommonObject
         if (! empty($conf->global->ADHERENT_USE_MAILMAN) && ! empty($conf->mailmanspip->enabled))
         {
             $result=$mailmanspip->add_to_mailman($this);
-         
+
             if ($result < 0)
             {
             	if (! empty($mailmanspip->error)) $this->errors[]=$mailmanspip->error;
@@ -1815,10 +1815,10 @@ class Adherent extends CommonObject
     public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
     {
         global $conf,$langs;
-    
+
         $langs->load("orders");
-    
-	    if (! dol_strlen($modele)) {
+
+		if (! dol_strlen($modele)) {
 
 		    $modele = 'standard';
 
@@ -1830,11 +1830,11 @@ class Adherent extends CommonObject
 	    }
     
         $modelpath = "core/modules/member/doc/";
-    
+
         return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
     }
-    
-    
+
+
     /**
      *  Initialise an instance with random values.
      *  Used to build previews or test instances.
@@ -1924,27 +1924,28 @@ class Adherent extends CommonObject
         $this->fullname=$this->getFullName($langs);
 
         // Member
-        if ($this->fullname && ! empty($conf->global->LDAP_MEMBER_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname;
-        if ($this->lastname && ! empty($conf->global->LDAP_MEMBER_FIELD_NAME))     $info[$conf->global->LDAP_MEMBER_FIELD_NAME] = $this->lastname;
-        if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
-        if ($this->login && ! empty($conf->global->LDAP_MEMBER_FIELD_LOGIN))      $info[$conf->global->LDAP_MEMBER_FIELD_LOGIN] = $this->login;
-        if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD))    $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;	// this->pass = mot de passe non crypte
-        if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE))      $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
-        if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS))  $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
-        if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP))           $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
-        if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN))        $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
-        if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY))     $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
-        if ($this->email && ! empty($conf->global->LDAP_MEMBER_FIELD_MAIL))       $info[$conf->global->LDAP_MEMBER_FIELD_MAIL] = $this->email;
-        if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE))       $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype;
-        if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE))      $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
-        if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
-        if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
-        if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX))	      $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
-        if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note_private;
-        if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = $this->note_public;
-        if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE))  $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap');
-        if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))  $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
-        if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION))  $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
+        if ($this->fullname && ! empty($conf->global->LDAP_MEMBER_FIELD_FULLNAME))				$info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname;
+        if ($this->lastname && ! empty($conf->global->LDAP_MEMBER_FIELD_NAME))					$info[$conf->global->LDAP_MEMBER_FIELD_NAME] = $this->lastname;
+        if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME))			$info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
+        if ($this->login && ! empty($conf->global->LDAP_MEMBER_FIELD_LOGIN))					$info[$conf->global->LDAP_MEMBER_FIELD_LOGIN] = $this->login;
+        if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD))					$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;	// this->pass = mot de passe non crypte
+        if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED))			$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // md5 for OpenLdap TODO add type of encryption
+        if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE))					$info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
+        if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS))				$info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
+        if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP))						$info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
+        if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN))						$info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
+        if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY))			$info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
+        if ($this->email && ! empty($conf->global->LDAP_MEMBER_FIELD_MAIL))						$info[$conf->global->LDAP_MEMBER_FIELD_MAIL] = $this->email;
+        if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE))					$info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype;
+        if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE))					$info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
+        if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO))		$info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
+        if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE))			$info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
+        if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX))						$info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
+        if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION))		$info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note_private;
+        if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC))		$info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = $this->note_public;
+        if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE))				$info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap');
+        if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))			$info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
+        if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION))	$info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
 
         // Subscriptions
         if ($this->first_subscription_date && ! empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE))     $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]  = dol_print_date($this->first_subscription_date,'dayhourldap');
@@ -2078,7 +2079,7 @@ class Adherent extends CommonObject
 
 	/**
 	 * Return if a member is late (subscription late) or not
-	 * 
+	 *
 	 * @return boolean     True if late, False if not late
 	 */
     public function hasDelay()

+ 97 - 95
htdocs/adherents/index.php

@@ -125,34 +125,37 @@ if ($result)
 //print '<tr><td width="30%" class="notopnoleft" valign="top">';
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
-// Search contact/address
-if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire)
-{
-	$listofsearchfields['search_member']=array('text'=>'Member');
-}
 
-if (count($listofsearchfields))
+if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
 {
-	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-	print '<table class="noborder nohover centpercent">';
-	$i=0;
-	foreach($listofsearchfields as $key => $value)
-	{
-		if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
-		print '<tr '.$bc[false].'>';
-		print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
-		if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
-		print '</tr>';
-		$i++;
-	}
-	print '</table>';	
-	print '</form>';
-	print '<br>';
+    // Search contact/address
+    if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire)
+    {
+    	$listofsearchfields['search_member']=array('text'=>'Member');
+    }
+    
+    if (count($listofsearchfields))
+    {
+    	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
+    	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    	print '<table class="noborder nohover centpercent">';
+    	$i=0;
+    	foreach($listofsearchfields as $key => $value)
+    	{
+    		if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
+    		print '<tr '.$bc[false].'>';
+    		print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
+    		if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
+    		print '</tr>';
+    		$i++;
+    	}
+    	print '</table>';	
+    	print '</form>';
+    	print '<br>';
+    }
 }
 
 
-
 /*
  * Statistics
  */
@@ -160,7 +163,7 @@ if (count($listofsearchfields))
 if ($conf->use_javascript_ajax)
 {
     print '<table class="noborder nohover" width="100%">';
-    print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</td></tr>';
+    print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
     print '<tr '.$bc[0].'><td align="center" colspan="2">';
 
     $SommeA=0;
@@ -198,8 +201,70 @@ if ($conf->use_javascript_ajax)
     print '</table>';
 }
 
+print '<br>';
+
+// List of subscription by year
+$Total=array();
+$Number=array();
+$tot=0;
+$numb=0;
+
+$sql = "SELECT c.subscription, c.dateadh as dateh";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
+$sql.= " WHERE d.entity IN (".getEntity().")";
+$sql.= " AND d.rowid = c.fk_adherent";
+if(isset($date_select) && $date_select != '')
+{
+    $sql .= " AND c.dateadh LIKE '".$date_select."%'";
+}
+$result = $db->query($sql);
+if ($result)
+{
+    $num = $db->num_rows($result);
+    $i = 0;
+    while ($i < $num)
+    {
+        $objp = $db->fetch_object($result);
+        $year=dol_print_date($db->jdate($objp->dateh),"%Y");
+        $Total[$year]=(isset($Total[$year])?$Total[$year]:0)+$objp->subscription;
+        $Number[$year]=(isset($Number[$year])?$Number[$year]:0)+1;
+        $tot+=$objp->subscription;
+        $numb+=1;
+        $i++;
+    }
+}
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<th>'.$langs->trans("Subscriptions").'</th>';
+print '<th align="right">'.$langs->trans("Number").'</th>';
+print '<th align="right">'.$langs->trans("AmountTotal").'</th>';
+print '<th align="right">'.$langs->trans("AmountAverage").'</th>';
+print "</tr>\n";
+
+$var=true;
+krsort($Total);
+foreach ($Total as $key=>$value)
+{
+    $var=!$var;
+    print "<tr ".$bc[$var].">";
+    print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
+    print "<td align=\"right\">".$Number[$key]."</td>";
+    print "<td align=\"right\">".price($value)."</td>";
+    print "<td align=\"right\">".price(price2num($value/$Number[$key],'MT'))."</td>";
+    print "</tr>\n";
+}
+
+// Total
+print '<tr class="liste_total">';
+print '<td>'.$langs->trans("Total").'</td>';
+print "<td align=\"right\">".$numb."</td>";
+print '<td align="right">'.price($tot)."</td>";
+print "<td align=\"right\">".price(price2num($numb>0?($tot/$numb):0,'MT'))."</td>";
+print "</tr>\n";
+print "</table><br>\n";
+
 
-//print '</td><td class="notopnoleftnoright" valign="top">';
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
 
@@ -224,7 +289,7 @@ if ($resql)
 {
 	print '<table class="noborder" width="100%">';
 	print '<tr class="liste_titre">';
-	print '<td colspan="4">'.$langs->trans("LastMembersModified",$max).'</td></tr>';
+	print '<th colspan="4">'.$langs->trans("LastMembersModified",$max).'</th></tr>';
 
 	$num = $db->num_rows($resql);
 	if ($num)
@@ -287,7 +352,7 @@ if ($resql)
 {
 	print '<table class="noborder" width="100%">';
 	print '<tr class="liste_titre">';
-	print '<td colspan="5">'.$langs->trans("LastSubscriptionsModified",$max).'</td></tr>';
+	print '<th colspan="5">'.$langs->trans("LastSubscriptionsModified",$max).'</th></tr>';
 
 	$num = $db->num_rows($resql);
 	if ($num)
@@ -333,11 +398,11 @@ else
 // Summary of members by type
 print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre">';
-print '<td>'.$langs->trans("MembersTypes").'</td>';
-print '<td align=right>'.$langs->trans("MembersStatusToValid").'</td>';
-print '<td align=right>'.$langs->trans("MenuMembersNotUpToDate").'</td>';
-print '<td align=right>'.$langs->trans("MenuMembersUpToDate").'</td>';
-print '<td align=right>'.$langs->trans("MembersStatusResiliated").'</td>';
+print '<th>'.$langs->trans("MembersTypes").'</th>';
+print '<th align=right>'.$langs->trans("MembersStatusToValid").'</th>';
+print '<th align=right>'.$langs->trans("MenuMembersNotUpToDate").'</th>';
+print '<th align=right>'.$langs->trans("MenuMembersUpToDate").'</th>';
+print '<th align=right>'.$langs->trans("MembersStatusResiliated").'</th>';
 print "</tr>\n";
 
 foreach ($AdherentType as $key => $adhtype)
@@ -360,71 +425,8 @@ print '<td class="liste_total" align="right">'.$SommeD.' '.$staticmember->LibSta
 print '</tr>';
 
 print "</table>\n";
-print "<br>\n";
 
 
-// List of subscription by year
-$Total=array();
-$Number=array();
-$tot=0;
-$numb=0;
-
-$sql = "SELECT c.subscription, c.dateadh as dateh";
-$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
-$sql.= " WHERE d.entity IN (".getEntity().")";
-$sql.= " AND d.rowid = c.fk_adherent";
-if(isset($date_select) && $date_select != '')
-{
-	$sql .= " AND c.dateadh LIKE '".$date_select."%'";
-}
-$result = $db->query($sql);
-if ($result)
-{
-	$num = $db->num_rows($result);
-	$i = 0;
-	while ($i < $num)
-	{
-		$objp = $db->fetch_object($result);
-		$year=dol_print_date($db->jdate($objp->dateh),"%Y");
-		$Total[$year]=(isset($Total[$year])?$Total[$year]:0)+$objp->subscription;
-		$Number[$year]=(isset($Number[$year])?$Number[$year]:0)+1;
-		$tot+=$objp->subscription;
-		$numb+=1;
-		$i++;
-	}
-}
-
-print '<table class="noborder" width="100%">';
-print '<tr class="liste_titre">';
-print '<td>'.$langs->trans("Subscriptions").'</td>';
-print '<td align="right">'.$langs->trans("Number").'</td>';
-print '<td align="right">'.$langs->trans("AmountTotal").'</td>';
-print '<td align="right">'.$langs->trans("AmountAverage").'</td>';
-print "</tr>\n";
-
-$var=true;
-krsort($Total);
-foreach ($Total as $key=>$value)
-{
-	$var=!$var;
-	print "<tr ".$bc[$var].">";
-	print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
-	print "<td align=\"right\">".$Number[$key]."</td>";
-	print "<td align=\"right\">".price($value)."</td>";
-	print "<td align=\"right\">".price(price2num($value/$Number[$key],'MT'))."</td>";
-	print "</tr>\n";
-}
-
-// Total
-print '<tr class="liste_total">';
-print '<td>'.$langs->trans("Total").'</td>';
-print "<td align=\"right\">".$numb."</td>";
-print '<td align="right">'.price($tot)."</td>";
-print "<td align=\"right\">".price(price2num($numb>0?($tot/$numb):0,'MT'))."</td>";
-print "</tr>\n";
-print "</table><br>\n";
-
-//print '</td></tr></table>';
 print '</div></div></div>';
 
 

+ 1 - 1
htdocs/adherents/list.php

@@ -375,7 +375,7 @@ if (! empty($moreforfilter))
 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
 $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
 
-print '<div class="div-table-responsive-no-min">';
+print '<div class="div-table-responsive">';
 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
 print '<tr class="liste_titre">';
 if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))

+ 1 - 1
htdocs/adherents/stats/byproperties.php

@@ -120,7 +120,7 @@ print '<table class="liste" width="100%">';
 print '<tr class="liste_titre">';
 print '<td>'.$langs->trans("Nature").'</td>';
 print '<td align="right">'.$langs->trans("NbOfMembers").'</td>';
-print '<td align="center">'.$langs->trans("LastMemberDate").'</td>';
+print '<td align="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
 print '</tr>';
 
 if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'');

+ 5 - 5
htdocs/adherents/type.php

@@ -199,11 +199,11 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 		print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
 		
 		print '<tr class="liste_titre">';
-		print '<td>'.$langs->trans("Ref").'</td>';
-		print '<td>'.$langs->trans("Label").'</td>';
-		print '<td align="center">'.$langs->trans("SubscriptionRequired").'</td>';
-		print '<td align="center">'.$langs->trans("VoteAllowed").'</td>';
-		print '<td>&nbsp;</td>';
+		print '<th>'.$langs->trans("Ref").'</th>';
+		print '<th>'.$langs->trans("Label").'</th>';
+		print '<th align="center">'.$langs->trans("SubscriptionRequired").'</th>';
+		print '<th align="center">'.$langs->trans("VoteAllowed").'</th>';
+		print '<th>&nbsp;</th>';
 		print "</tr>\n";
 
 		$var=True;

+ 10 - 16
htdocs/admin/confexped.php

@@ -94,28 +94,23 @@ print load_fiche_titre($langs->trans("SendingsSetup"),$linkback,'title_setup');
 print '<br>';
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'general', $langs->trans("Sendings"), 0, 'sending');
+dol_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'sending');
 
-/*
- * Formulaire parametres divers
- */
-
-$var=true;
+// Miscellaneous parameters
 
 print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre">';
 print '<td>'.$langs->trans("Feature").'</td>';
-print '<td align="center" width="20">&nbsp;</td>';
-print '<td align="center" width="100">'.$langs->trans("Status").'</td>';
+print '<td width="20">&nbsp;</td>';
+print '<td class="center">'.$langs->trans("Status").'</td>';
 print '</tr>'."\n";
 
 // expedition activation/desactivation
-$var=!$var;
-print "<tr ".$bc[$var].">";
+print "<tr>";
 print '<td>'.$langs->trans("SendingsAbility").'</td>';
-print '<td align="center" width="20">';
+print '<td>';
 print '</td>';
-print '<td align="center" width="100">';
+print '<td class="center">';
 print $langs->trans("Required");
 /*if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
 {
@@ -129,15 +124,14 @@ print "</td>";
 print '</tr>';
 
 // Bon de livraison activation/desactivation
-$var=!$var;
-print '<tr '.$bc[$var].'>';
+print '<tr>';
 print '<td>';
 print $langs->trans("DeliveriesOrderAbility");
 print '<br>'.info_admin($langs->trans("NoNeedForDeliveryReceipts"), 0, 1);
 print '</td>';
-print '<td align="center" width="20">';
+print '<td>';
 print '</td>';
-print '<td align="center" width="100">';
+print '<td class="center">';
 
 if (empty($conf->global->MAIN_SUBMODULE_LIVRAISON))
 {

+ 31 - 19
htdocs/admin/dict.php

@@ -86,7 +86,7 @@ $hookmanager->initHooks(array('admin'));
 // Put here declaration of dictionaries properties
 
 // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
-$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,32,0);
+$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0);
 
 // Name of SQL tables of dictionaries
 $tabname=array();
@@ -121,7 +121,7 @@ $tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
 $tabname[29]= MAIN_DB_PREFIX."c_lead_status";
 $tabname[30]= MAIN_DB_PREFIX."c_format_cards";
 //$tabname[31]= MAIN_DB_PREFIX."accounting_system";
-$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
+//$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
 $tabname[33]= MAIN_DB_PREFIX."c_hrm_department";
 $tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
 
@@ -158,7 +158,7 @@ $tablib[28]= "DictionaryHolidayTypes";
 $tablib[29]= "DictionaryOpportunityStatus";
 $tablib[30]= "DictionaryFormatCards";
 //$tablib[31]= "DictionaryAccountancysystem";
-$tablib[32]= "DictionaryAccountancyCategory";
+//$tablib[32]= "DictionaryAccountancyCategory";
 $tablib[33]= "DictionaryDepartment";
 $tablib[34]= "DictionaryFunction";
 
@@ -195,7 +195,7 @@ $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.new
 $tabsql[29]= "SELECT rowid   as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
 $tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
 //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s";
-$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
+//$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
 $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department";
 $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function";
 
@@ -232,7 +232,7 @@ $tabsqlsort[28]="country ASC, code ASC";
 $tabsqlsort[29]="position ASC";
 $tabsqlsort[30]="code ASC";
 //$tabsqlsort[31]="pcg_version ASC";
-$tabsqlsort[32]="position ASC";
+//$tabsqlsort[32]="position ASC";
 $tabsqlsort[33]="code ASC";
 $tabsqlsort[34]="code ASC";
 
@@ -269,7 +269,7 @@ $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country";
 $tabfield[29]= "code,label,percent,position";
 $tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
 //$tabfield[31]= "pcg_version,label";
-$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country";
+//$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country";
 $tabfield[33]= "code,label";
 $tabfield[34]= "code,label";
 
@@ -306,7 +306,7 @@ $tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country";
 $tabfieldvalue[29]= "code,label,percent,position";
 $tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
 //$tabfieldvalue[31]= "pcg_version,label";
-$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country";
+//$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country";
 $tabfieldvalue[33]= "code,label";
 $tabfieldvalue[34]= "code,label";
 
@@ -343,7 +343,7 @@ $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country";
 $tabfieldinsert[29]= "code,label,percent,position";
 $tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
 //$tabfieldinsert[31]= "pcg_version,label";
-$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country";
+//$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country";
 $tabfieldinsert[33]= "code,label";
 $tabfieldinsert[34]= "code,label";
 
@@ -382,7 +382,7 @@ $tabrowid[28]= "";
 $tabrowid[29]= "";
 $tabrowid[30]= "";
 //$tabrowid[31]= "";
-$tabrowid[32]= "";
+//$tabrowid[32]= "";
 $tabrowid[33]= "rowid";
 $tabrowid[34]= "rowid";
 
@@ -419,7 +419,7 @@ $tabcond[28]= ! empty($conf->holiday->enabled);
 $tabcond[29]= ! empty($conf->projet->enabled);
 $tabcond[30]= ! empty($conf->label->enabled);
 //$tabcond[31]= ! empty($conf->accounting->enabled);
-$tabcond[32]= ! empty($conf->accounting->enabled);
+//$tabcond[32]= ! empty($conf->accounting->enabled);
 $tabcond[33]= ! empty($conf->hrm->enabled);
 $tabcond[34]= ! empty($conf->hrm->enabled);
 
@@ -456,7 +456,7 @@ $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$lan
 $tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
 $tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
 //$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
-$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"));
+//$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"));
 $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
 $tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
 
@@ -493,7 +493,7 @@ $tabfieldcheck[28] = array();
 $tabfieldcheck[29] = array();
 $tabfieldcheck[30] = array();
 //$tabfieldcheck[31] = array();
-$tabfieldcheck[32] = array();
+//$tabfieldcheck[32] = array();
 $tabfieldcheck[33] = array();
 $tabfieldcheck[34] = array();
 
@@ -1012,13 +1012,13 @@ if ($id)
             if ($fieldlist[$field]=='nbjour')          { $valuetoshow=$langs->trans("NbOfDays"); }
             if ($fieldlist[$field]=='type_cdr')        { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
             if ($fieldlist[$field]=='decalage')        { $valuetoshow=$langs->trans("Offset"); }
-            if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); }
-            if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); }
+            if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx')    { $valuetoshow=$langs->trans("Width"); }
+            if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny')   { $valuetoshow=$langs->trans("Height"); }
             if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); }
             if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $valuetoshow=''; }
-            if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
-            if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); }
-            if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); }
+            if ($fieldlist[$field]=='accountancy_code') { $valuetoshow=$langs->trans("AccountancyCode"); }
+            if ($fieldlist[$field]=='accountancy_code_sell') { $valuetoshow=$langs->trans("AccountancyCodeSell"); }
+            if ($fieldlist[$field]=='accountancy_code_buy') { $valuetoshow=$langs->trans("AccountancyCodeBuy"); }
             if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); }
             if ($fieldlist[$field]=='account_parent')  { $valuetoshow=$langs->trans("Accountparent"); }
             if ($fieldlist[$field]=='pcg_type')        { $valuetoshow=$langs->trans("Pcg_type"); }
@@ -1039,7 +1039,7 @@ if ($id)
 			if ($fieldlist[$field]=='custom_x')        { $valuetoshow=$langs->trans("CustomX"); }
 			if ($fieldlist[$field]=='custom_y')        { $valuetoshow=$langs->trans("CustomY"); }
 			if ($fieldlist[$field]=='percent')         { $valuetoshow=$langs->trans("Percentage"); }
-			if ($fieldlist[$field]=='affect')          { $valuetoshow=$langs->trans("Info"); }
+			if ($fieldlist[$field]=='affect')          { $valuetoshow=$langs->trans("WithCounter"); }
 			if ($fieldlist[$field]=='delay')           { $valuetoshow=$langs->trans("NoticePeriod"); }
 			if ($fieldlist[$field]=='newbymonth')      { $valuetoshow=$langs->trans("NewByMonth"); }
 				
@@ -1211,7 +1211,7 @@ if ($id)
 			if ($fieldlist[$field]=='custom_x')        { $valuetoshow=$langs->trans("CustomX"); }
 			if ($fieldlist[$field]=='custom_y')        { $valuetoshow=$langs->trans("CustomY"); }
 			if ($fieldlist[$field]=='percent')         { $valuetoshow=$langs->trans("Percentage"); }
-			if ($fieldlist[$field]=='affect')          { $valuetoshow=$langs->trans("Info"); }
+			if ($fieldlist[$field]=='affect')          { $valuetoshow=$langs->trans("WithCounter"); }
 			if ($fieldlist[$field]=='delay')           { $valuetoshow=$langs->trans("NoticePeriod"); }
 			if ($fieldlist[$field]=='newbymonth')      { $valuetoshow=$langs->trans("NewByMonth"); }
 
@@ -1343,6 +1343,10 @@ if ($id)
                             else if ($fieldlist[$field]=='price' || preg_match('/^amount/i',$fieldlist[$field])) {
                                 $valuetoshow=price($valuetoshow);
                             }
+                            if ($value == 'private')
+                            {
+                                $valuetoshow = yn($elementList[$valuetoshow]);
+                            }				
                             else if ($fieldlist[$field]=='libelle_facture') {
                                 $langs->load("bills");
                                 $key=$langs->trans("PaymentCondition".strtoupper($obj->code));
@@ -1691,6 +1695,12 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
 			print $form->selectarray('source', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
 			print '</td>';
 		}
+		elseif ($fieldlist[$field] == 'private')
+		{
+			print '<td>';
+			print $form->selectyesno("private",(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
+			print '</td>';
+		}
 		elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm")
 		{
 			print '<td>';
@@ -1762,6 +1772,8 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
 			print '<td>';
 			$size=''; $class='';
 			if ($fieldlist[$field]=='code') $class='maxwidth100';
+			if ($fieldlist[$field]=='affect') $class='maxwidth50';
+			if ($fieldlist[$field]=='delay') $class='maxwidth50';
 			if ($fieldlist[$field]=='position') $class='maxwidth50';
 			if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
 			if ($fieldlist[$field]=='tracking') $class='quatrevingtpercent';

+ 1 - 1
htdocs/admin/events.php

@@ -86,7 +86,7 @@ print '<input type="hidden" name="action" value="save">';
 
 $head=security_prepare_head();
 
-dol_fiche_head($head, 'audit', $langs->trans("Security"));
+dol_fiche_head($head, 'audit', $langs->trans("Security"), -1);
 
 
 $var=true;

+ 29 - 44
htdocs/admin/expedition.php

@@ -72,26 +72,28 @@ if ($action == 'updateMask')
 	}
 }
 
-else if ($action == 'set_SHIPPING_FREE_TEXT')
+else if ($action == 'set_param')
 {
 	$freetext=GETPOST('SHIPPING_FREE_TEXT');	// No alpha here, we want exact string
 	$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
-
-	if ($res > 0)
-		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-	else
+	if ($res <= 0)
+	{
+		$error++;
 		setEventMessages($langs->trans("Error"), null, 'errors');
-}
-
-else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
-{
+	}
+	
 	$draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
 	$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
+	if ($res <= 0)
+	{
+		$error++;
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 
-	if ($res > 0)
+	if (! $error)
+	{
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-	else
-		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 else if ($action == 'specimen')
@@ -222,11 +224,9 @@ print load_fiche_titre($langs->trans("SendingsSetup"),$linkback,'title_setup');
 print '<br>';
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), 0, 'sending');
+dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), -1, 'sending');
 
-/*
- * Expedition numbering model
- */
+// Shipment numbering model
 
 print load_fiche_titre($langs->trans("SendingsNumberingModules"));
 
@@ -235,8 +235,8 @@ print '<tr class="liste_titre">';
 print '<td width="100">'.$langs->trans("Name").'</td>';
 print '<td>'.$langs->trans("Description").'</td>';
 print '<td>'.$langs->trans("Example").'</td>';
-print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
-print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
+print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
 print "</tr>\n";
 
 clearstatcache();
@@ -250,8 +250,6 @@ foreach ($dirmodels as $reldir)
 		$handle = opendir($dir);
 		if (is_resource($handle))
 		{
-			$var=true;
-
 			while (($file = readdir($handle))!==false)
 			{
 				if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
@@ -268,8 +266,7 @@ foreach ($dirmodels as $reldir)
 						if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
 						if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
 
-						$var=!$var;
-						print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
+						print '<tr><td>'.$module->nom."</td>\n";
 						print '<td>';
 						print $module->info();
 						print '</td>';
@@ -374,7 +371,6 @@ print "</tr>\n";
 
 clearstatcache();
 
-$var=true;
 foreach ($dirmodels as $reldir)
 {
     foreach (array('','/doc') as $valdir)
@@ -412,8 +408,7 @@ foreach ($dirmodels as $reldir)
 
 	                        if ($modulequalified)
 	                        {
-	                            $var = !$var;
-	                            print '<tr '.$bc[$var].'><td width="100">';
+	                            print '<tr><td width="100">';
 	                            print (empty($module->name)?$name:$module->name);
 	                            print "</td><td>\n";
 	                            if (method_exists($module,'info')) print $module->info($langs);
@@ -498,19 +493,16 @@ print '<br>';
  */
 print load_fiche_titre($langs->trans("OtherOptions"));
 
-$var=true;
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="set_param">';
+
 print "<table class=\"noborder\" width=\"100%\">";
 print "<tr class=\"liste_titre\">";
 print "<td>".$langs->trans("Parameter")."</td>\n";
-print '<td width="60" align="center">'.$langs->trans("Value")."</td>\n";
-print "<td>&nbsp;</td>\n";
 print "</tr>";
 
-$var=! $var;
-print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
-print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-print '<input type="hidden" name="action" value="set_SHIPPING_FREE_TEXT">';
-print '<tr '.$bc[$var].'><td colspan="2">';
+print '<tr><td>';
 print $langs->trans("FreeLegalTextOnShippings").' ('.$langs->trans("AddCRIfTooLong").')<br>';
 $variablename='SHIPPING_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
@@ -523,25 +515,18 @@ else
     $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details');
     print $doleditor->Create();
 }
-print '</td><td align="right">';
-print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 print "</td></tr>\n";
-print '</form>';
 
-$var=!$var;
-print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
-print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-print '<input type="hidden" name="action" value="set_SHIPPING_DRAFT_WATERMARK">';
-print '<tr '.$bc[$var].'><td colspan="2">';
+print '<tr><td>';
 print $langs->trans("WatermarkOnDraft").'<br>';
 print '<input size="50" class="flat" type="text" name="SHIPPING_DRAFT_WATERMARK" value="'.$conf->global->SHIPPING_DRAFT_WATERMARK.'">';
-print '</td><td align="right">';
-print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 print "</td></tr>\n";
-print '</form>';
 
 print '</table>';
 
+print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
+
+print '</form>';
 
 llxFooter();
 $db->close();

+ 1 - 1
htdocs/admin/expedition_extrafields.php

@@ -78,7 +78,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributes_shipment', $langs->trans("Sendings"), 0, 'sending');
+dol_fiche_head($head, 'attributes_shipment', $langs->trans("Sendings"), -1, 'sending');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 1 - 1
htdocs/admin/expeditiondet_extrafields.php

@@ -78,7 +78,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributeslines_shipment', $langs->trans("Sendings"), 0, 'sending');
+dol_fiche_head($head, 'attributeslines_shipment', $langs->trans("Sendings"), -1, 'sending');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 1 - 1
htdocs/admin/fckeditor.php

@@ -189,7 +189,7 @@ else
     show_skin(null,1);
     print '<br>'."\n";
     
-    $listofmodes=array('dolibarr_mailings','dolibarr_notes','dolibarr_details','Full');
+    $listofmodes=array('dolibarr_mailings','dolibarr_notes','dolibarr_details','dolibarr_readonly','Full');
     $linkstomode='';
     foreach($listofmodes as $newmode)
     {

+ 103 - 107
htdocs/admin/ihm.php

@@ -157,8 +157,7 @@ if ($action == 'edit')	// Edit
     print '<input type="hidden" name="action" value="update">';
 
     clearstatcache();
-    $var=true;
-
+    
     print '<br>';
     print '<table summary="edit" class="noborder" width="100%">';
     print '<tr class="liste_titre"><td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
@@ -166,16 +165,14 @@ if ($action == 'edit')	// Edit
 	print '</tr>';
 
     // Default language
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultLanguage").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DefaultLanguage").'</td><td>';
     print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'main_lang_default', 1, 0, 0, 0, 0, 'minwidth300');
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
 	// Multilingual GUI
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>';
     print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1);
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
@@ -192,11 +189,9 @@ if ($action == 'edit')	// Edit
     {
         print '<table summary="search" class="noborder" width="100%">';
         print '<tr class="liste_titre"><td width="35%">'.$langs->trans("PermanentLeftSearchForm").'</td><td colspan="2">'.$langs->trans("Activated").'</td></tr>';
-        $var=True;
         foreach ($searchform as $key => $value)
         {
-            $var=!$var;
-            print '<tr '.$bc[$var].'><td width="35%">'.$searchformtitle[$key].'</td><td colspan="2">';
+            print '<tr><td width="35%">'.$searchformtitle[$key].'</td><td colspan="2">';
             print $form->selectyesno($searchform[$key],$searchformconst[$key],1);
             print '</td></tr>';
         }
@@ -210,29 +205,27 @@ if ($action == 'edit')	// Edit
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
-	// Show logo
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableShowLogo").'</td><td>';
-    print $form->selectyesno('MAIN_SHOW_LOGO',$conf->global->MAIN_SHOW_LOGO,1);
-    print '</td>';
-	print '<td width="20">&nbsp;</td>';
-	print '</tr>';
-
 	// Max size of lists
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
+    print '<tr><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
 	// Max size of short lists on customer card
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
+    print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 	
-    // Disable javascript and ajax
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableJavascript").'</td><td>';
+    // show input border
+    /*
+    print '<tr><td>'.$langs->trans("showInputBorder").'</td><td>';
+    print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+    */
+	
+	// Disable javascript and ajax
+    print '<tr><td>'.$langs->trans("DisableJavascript").'</td><td>';
     print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
@@ -241,8 +234,7 @@ if ($action == 'edit')	// Edit
     // Activate preview tab on element card
     if (class_exists("Imagick"))
 	{
-	    $var=!$var;
-	    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("UsePreviewTabs").'</td><td>';
+	    print '<tr><td width="35%">'.$langs->trans("UsePreviewTabs").'</td><td>';
 	    print $form->selectyesno('MAIN_USE_PREVIEW_TABS',isset($conf->global->MAIN_USE_PREVIEW_TABS)?$conf->global->MAIN_USE_PREVIEW_TABS:0,1);
 	    print '</td>';
 		print '<td width="20">&nbsp;</td>';
@@ -250,32 +242,28 @@ if ($action == 'edit')	// Edit
 	}
 
     // First day for weeks
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("WeekStartOnDay").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("WeekStartOnDay").'</td><td>';
     print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0);
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
     // DefaultWorkingDays
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultWorkingDays").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DefaultWorkingDays").'</td><td>';
     print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5').'">';
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
     // DefaultWorkingHours
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultWorkingHours").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DefaultWorkingHours").'</td><td>';
     print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18').'">';
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
 	// Firstname/Name
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FirstnameNamePosition").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("FirstnameNamePosition").'</td><td>';
 	$array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
     print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
     print '</td>';
@@ -283,40 +271,52 @@ if ($action == 'edit')	// Edit
 	print '</tr>';
 
 	// Hide unauthorized button
-	$var=!$var;
-	print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td>';
+	print '<tr><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td>';
 	print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED',isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0,1);
 	print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
-    // Hide helpcenter link on login page
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelpCenter").'</td><td>';
-    print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK',isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0,1);
-    print '</td>';
+	// Show logo
+	print '<tr><td width="35%">'.$langs->trans("EnableShowLogo").'</td><td>';
+	print $form->selectyesno('MAIN_SHOW_LOGO',$conf->global->MAIN_SHOW_LOGO,1);
+	print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+	
+	// Hide version link
+	/*
+	
+	print '<tr><td width="35%">'.$langs->trans("HideVersionLink").'</td><td>';
+	print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1);
+	print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+    */
+	
+	// Show bugtrack link
+	print '<tr><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
+	print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK',$conf->global->MAIN_BUGTRACK_ENABLELINK,1);
+	print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
 	// Hide wiki link on login page
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td>';
     print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0,1);
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
-	// Show bugtrack link
-	$var=!$var;
-	print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
-	print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK',$conf->global->MAIN_BUGTRACK_ENABLELINK,1);
+	// Hide helpcenter link on login page
+	print '<tr><td width="35%">'.$langs->trans("DisableLinkToHelpCenter").'</td><td>';
+	print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK',isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0,1);
 	print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
-
-    // Message on login page
-	$var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
+	
+	// Message on login page
+    print '<tr><td width="35%">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
 
     $doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
 	$doleditor->Create();
@@ -324,8 +324,7 @@ if ($action == 'edit')	// Edit
 	print '</td></tr>'."\n";
 
 	// Message of the day on home page
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
+    print '<tr><td width="35%">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
 
     $doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
 	$doleditor->Create();
@@ -345,14 +344,11 @@ if ($action == 'edit')	// Edit
 }
 else	// Show
 {
-    $var=true;
-
     // Language
     print '<table class="noborder" width="100%">';
     print '<tr class="liste_titre"><td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td><td>&nbsp;</td></tr>';
 
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultLanguage").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DefaultLanguage").'</td><td>';
     $s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
     print ($s?$s.' ':'');
     print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
@@ -361,9 +357,8 @@ else	// Show
     if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
 	print '</td>';
 	print "</tr>";
-
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
+    
+    print '<tr><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print "</tr>";
 
@@ -380,11 +375,10 @@ else	// Show
     {
         print '<table class="noborder" width="100%">';
         print '<tr class="liste_titre"><td width="35%">'.$langs->trans("PermanentLeftSearchForm").'</td><td>'.$langs->trans("Activated").'</td><td>&nbsp;</td></tr>';
-        $var=true;
         foreach ($searchform as $key => $value)
         {
-            $var=!$var;
-            print '<tr '.$bc[$var].'><td width="35%">'.$searchformtitle[$key].'</td><td>'.yn($searchformconst[$key]).'</td>';
+            
+            print '<tr><td width="35%">'.$searchformtitle[$key].'</td><td>'.yn($searchformconst[$key]).'</td>';
     		print '<td align="left">';
     		if (! empty($searchformmodule[$key])) print $langs->trans("IfModuleEnabled",$langs->transnoentitiesnoconv($searchformmodule[$key]));
             print '</td></tr>';
@@ -394,69 +388,63 @@ else	// Show
     }
 
     // Other
-    $var=true;
     print '<table class="noborder" width="100%">';
     print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Parameters").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>';
 
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
-	print '<td width="20">&nbsp;</td>';
-	print "</tr>";
-
-	$var=!$var;
-    print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
+    print '<tr><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print "</tr>";
 	
-	$var=!$var;
-    print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
+    print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print "</tr>";
 
+	/*
+    print '<tr><td>'.$langs->trans("showInputBorder").'</td><td>';
+    print yn($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)."</td>";
+    print '<td width="20">&nbsp;</td>';
+    print "</tr>";
+	*/
+	
     // Disable javascript/ajax
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableJavascript").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DisableJavascript").'</td><td>';
     print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)."</td>";
-	print '<td width="20">&nbsp;</td>';
-	print "</tr>";
+    print '<td width="20">&nbsp;</td>';
+    print "</tr>";
 
     // Activate preview tab on element card
     if (class_exists("Imagick"))
 	{
-		$var=!$var;
-	    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("UsePreviewTabs").'</td><td>';
+		
+	    print '<tr><td width="35%">'.$langs->trans("UsePreviewTabs").'</td><td>';
 	    print yn(isset($conf->global->MAIN_USE_PREVIEW_TABS)?$conf->global->MAIN_USE_PREVIEW_TABS:0)."</td>";
 		print '<td width="20">&nbsp;</td>';
 		print "</tr>";
 	}
 
 	// First day for weeks
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("WeekStartOnDay").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("WeekStartOnDay").'</td><td>';
     print $langs->trans("Day".(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'));
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
     // DefaultWorkingDays
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultWorkingDays").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DefaultWorkingDays").'</td><td>';
     print isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5';
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
     // DefaultWorkingHours
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultWorkingHours").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("DefaultWorkingHours").'</td><td>';
     print isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18';
     print '</td>';
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
 	// Firstname / Name position
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FirstnameNamePosition").'</td><td>';
+    print '<tr><td width="35%">'.$langs->trans("FirstnameNamePosition").'</td><td>';
     if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print $langs->trans("Firstname").' '.$langs->trans("Lastname"); }
     else { print $langs->trans("Lastname").' '.$langs->trans("Firstname"); }
     print '</td>';
@@ -464,40 +452,48 @@ else	// Show
 	print '</tr>';
 
 	// Hide unauthorized button
-	$var=!$var;
-	print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td colspan="2">';
+	print '<tr><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td colspan="2">';
 	print yn((isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0),1);
 	print '</td></tr>';
 
-    // Link to help center
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
-    print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
-    print '</td></tr>';
+    // Show logo
+    print '<tr><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print "</tr>";
+
+	// Hide version link
+	/*
+	 print '<tr><td width="35%">'.$langs->trans("HideVersionLink").'</td><td>';
+	 print yn($conf->global->MAIN_HIDE_VERSION);
+	 print '</td>';
+	 print '<td width="20">&nbsp;</td>';
+	 print '</tr>';
+	 */
+	
+    // Show bugtrack link
+	print '<tr"><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
+	print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
+	print '<td width="20">&nbsp;</td>';
+	print "</tr>";
 
     // Link to wiki help
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td colspan="2">';
+    print '<tr><td width="35%">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td colspan="2">';
     print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
     print '</td></tr>';
 
-	// Show bugtrack link
-	$var=!$var;
-	print '<tr '.$bc[$var].'"><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
-	print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
-	print '<td width="20">&nbsp;</td>';
-	print "</tr>";
+	// Link to help center
+    print '<tr><td width="35%">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
+    print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
+    print '</td></tr>';
 
-    // Message login
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
+	// Message login
+    print '<tr><td width="35%">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
     if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
     else print '&nbsp;';
     print '</td></tr>'."\n";
 
     // Message of the day
-    $var=!$var;
-    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
+    print '<tr><td width="35%">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
     if (isset($conf->global->MAIN_MOTD)) print dol_htmlcleanlastbr($conf->global->MAIN_MOTD);
     else print '&nbsp;';
     print '</td></tr>'."\n";

+ 1 - 1
htdocs/admin/index.php

@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2015       Jean-François Ferry		<jfefe@aternatik.fr>
+ * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by

+ 2 - 4
htdocs/admin/livraison.php

@@ -214,12 +214,10 @@ print load_fiche_titre($langs->trans("SendingsSetup"),$linkback,'title_setup');
 print '<br>';
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'receivings', $langs->trans("Receivings"), 0, 'sending');
+dol_fiche_head($head, 'receivings', $langs->trans("Receivings"), -1, 'sending');
 
 
-/*
- * Livraison numbering model
- */
+// Delivery numbering model
 
 print load_fiche_titre($langs->trans("DeliveryOrderNumberingModules"),'','');
 

+ 1 - 1
htdocs/admin/livraison_extrafields.php

@@ -78,7 +78,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributes_receivings', $langs->trans("Receivings"), 0, 'sending');
+dol_fiche_head($head, 'attributes_receivings', $langs->trans("Receivings"), -1, 'sending');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 1 - 1
htdocs/admin/livraisondet_extrafields.php

@@ -78,7 +78,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributeslines_receivings', $langs->trans("Receivings"), 0, 'sending');
+dol_fiche_head($head, 'attributeslines_receivings', $langs->trans("Receivings"), -1, 'sending');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 2 - 2
htdocs/admin/mails.php

@@ -228,7 +228,7 @@ if ($action == 'edit')
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<input type="hidden" name="action" value="update">';
 
-	dol_fiche_head($head, 'common', '');
+	dol_fiche_head($head, 'common', '', -1);
 	
 	print $langs->trans("EMailsDesc")."<br>\n";
 	print "<br>\n";
@@ -453,7 +453,7 @@ if ($action == 'edit')
 }
 else
 {
-    dol_fiche_head($head, 'common', '');
+    dol_fiche_head($head, 'common', '', -1);
     
     print $langs->trans("EMailsDesc")."<br>\n";
     print "<br>\n";

+ 1 - 1
htdocs/admin/mails_templates.php

@@ -405,7 +405,7 @@ $head[$h][2] = 'templates';
 $h++;
 
 
-dol_fiche_head($head, 'templates', '');
+dol_fiche_head($head, 'templates', '', -1);
 
 // Confirmation de la suppression de la ligne
 if ($action == 'delete')

+ 44 - 24
htdocs/admin/modulehelp.php

@@ -239,7 +239,7 @@ $head[$h][2] = 'desc';
 $h++;
 
 $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature';
-$head[$h][1] = $langs->trans("Features");
+$head[$h][1] = $langs->trans("TechnicalServicesProvided");
 $head[$h][2] = 'feature';
 $h++;
 
@@ -251,45 +251,38 @@ foreach($orders as $tmpkey => $tmpvalue)
     if ($objMod->numero == $id)
     {
         $key = $i;
+        $modName = $filename[$tmpkey];
+        $dirofmodule = $dirmod[$tmpkey];
         break;
     }
     $i++;
 }
 $value = $orders[$key];
+$special = $objMod->special;
+$tab=explode('_',$value);
+$familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
 
-
-print '<div class="centpercent">';
-
-
-print load_fiche_titre($objMod->getDesc(),$moreinfo,'object_'.$objMod->picto);
-print '<br>';
-
-dol_fiche_head($head, $mode, $title);
+// Check filters
+$modulename=$objMod->getName();
+$moduledesc=$objMod->getDesc();
+$moduleauthor=$objMod->getPublisher();
 
 
 
-$tab=explode('_',$value);
-$familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
+print '<div class="centpercent">';
 
-$modName = $filename[$key];
-$objMod  = $modules[$key];
-$dirofmodule = $dirmod[$key];
+print load_fiche_titre(($modulename?$modulename:$moduledesc), $moreinfo, 'object_'.$objMod->picto);
+print '<br>';
 
-$special = $objMod->special;
+dol_fiche_head($head, $mode, $title, -1);
 
-if (! $objMod->getName())
+if (! $modulename)
 {
 	dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
 }
 
 $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
 
-// Check filters
-$modulename=$objMod->getName();
-$moduledesc=$objMod->getDesc();
-$moduledesclong=$objMod->getDescLong();
-$moduleauthor=$objMod->getPublisher();
-
 // Load all lang files of module
 if (isset($objMod->langfiles) && is_array($objMod->langfiles))
 {
@@ -322,6 +315,8 @@ $text='';
    
 if ($mode == 'desc')
 {
+    if ($moduledesc) $text.=$moduledesc.'<br><br>';
+    
     $text.='<strong>'.$langs->trans("Version").':</strong> '.$version;
     
     $textexternal='';
@@ -329,7 +324,7 @@ if ($mode == 'desc')
     {
         $textexternal.='<br><strong>'.$langs->trans("Origin").':</strong> '.$langs->trans("ExternalModule",$dirofmodule);
         if ($objMod->editor_name != 'dolibarr') $textexternal.='<br><strong>'.$langs->trans("Publisher").':</strong> '.(empty($objMod->editor_name)?$langs->trans("Unknown"):$objMod->editor_name);
-        if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='<br><strong>'.$langs->trans("Url").':</strong> '.$objMod->editor_url;
+        if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='<br><strong>'.$langs->trans("Url").':</strong> <a href="'.$objMod->editor_url.'" target="_blank">'.$objMod->editor_url.'</a>';
         $text.=$textexternal;
         $text.='<br>';
     }
@@ -342,7 +337,8 @@ if ($mode == 'desc')
     else $text.=$langs->trans("Disabled");
     $text.='<br>';
 
-    if ($objMod->getDescLong()) $text.=$objMod->getDesc().'<br>';
+    $moduledesclong=$objMod->getDescLong();
+    if ($moduledesclong) $text.='<br><hr><div class="moduledesclong">'.$moduledesclong.'<div>';
 }
 
 if ($mode == 'feature')
@@ -360,6 +356,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddDictionaries").':</strong> ';
     if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib']))
     {
@@ -372,6 +370,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddBoxes").':</strong> ';
     if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes))
     {
@@ -384,6 +384,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddModels").':</strong> ';
     if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models'])
     {
@@ -391,6 +393,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddSubstitutions").':</strong> ';
     if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions'])
     {
@@ -398,6 +402,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddSheduledJobs").':</strong> ';
     if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs))
     {
@@ -410,6 +416,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddTriggers").':</strong> ';
     if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers'])
     {
@@ -417,6 +425,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddHooks").':</strong> ';
     if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks']))
     {
@@ -429,6 +439,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddPermissions").':</strong> ';
     if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights))
     {
@@ -441,6 +453,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddMenus").':</strong> ';
     if (isset($objMod->menu) && ! empty($objMod->menu)) // objMod can be an array or just an int 1
     {
@@ -448,6 +462,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddExportProfiles").':</strong> ';
     if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label))
     {
@@ -460,6 +476,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddImportProfiles").':</strong> ';
     if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label))
     {
@@ -472,6 +490,8 @@ if ($mode == 'feature')
     }
     else $text.=$langs->trans("No");
     
+    $text.='<br>';
+    
     $text.='<br><strong>'.$langs->trans("AddOtherPagesOrServices").':</strong> ';
     $text.=$langs->trans("DetectionNotPossible");
 }

+ 52 - 11
htdocs/admin/modules.php

@@ -235,6 +235,8 @@ $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'
 llxHeader('',$langs->trans("Setup"),$help_url);
 
 $arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers"));
+$arrayofwarnings=array();    // Array of warning each module want to show when activated
+$arrayofwarningsext=array();    // Array of warning each module want to show when we activate an external module
 
 // Search modules dirs
 $modulesdir = dolGetModulesDirs();
@@ -266,7 +268,7 @@ foreach ($modulesdir as $dir)
 
 		        if ($modName)
 		        {
-		        	if (! empty($modNameLoaded[$modName]))
+		        	if (! empty($modNameLoaded[$modName]))   // In cache of already loaded modules ?
 		        	{
 		        		$mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
 		        		setEventMessages($mesg, null, 'warnings');
@@ -297,7 +299,7 @@ foreach ($modulesdir as $dir)
 		    					if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
 								if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
 
-		    					// We discard modules according to property disabled
+		    					// We discard modules according to property ->hidden
 		    					if (! empty($objMod->hidden)) $modulequalified=0;
 
 		    					if ($modulequalified > 0)
@@ -321,8 +323,8 @@ foreach ($modulesdir as $dir)
 		    					// Define array $categ with categ with at least one qualified module
 		    					if ($modulequalified > 0)
 		    					{
-		    						$modules[$i] = $objMod;
 		    			            $filename[$i]= $modName;
+		    					    $modules[$modName] = $objMod;
 
 		    			            $special = $objMod->special;
 
@@ -342,6 +344,16 @@ foreach ($modulesdir as $dir)
 
 		    			            if ($special == 1) $familykey='interface';
 
+		    			            // Add list of warnings to show into arrayofwarnings and arrayofwarningsext
+		    			            if (! empty($objMod->warnings_activation))
+		    			            {
+		    			                $arrayofwarnings[$modName]=$objMod->warnings_activation;
+		    			            }
+		    			            if (! empty($objMod->warnings_activation_ext))
+		    			            {
+		    			                $arrayofwarningsext[$modName]=$objMod->warnings_activation_ext;
+		    			            }
+		    			             
 		    			            $orders[$i]  = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j;   // Sort by family, then by module position then number
 		    						$dirmod[$i]  = $dir;
 		    						//print $i.'-'.$dirmod[$i].'<br>';
@@ -428,7 +440,7 @@ if ($mode == 'common')
     print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
     print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 
-    dol_fiche_head($head, $mode, '');
+    dol_fiche_head($head, $mode, '', -1);
 
     $moreforfilter = '';
     $moreforfilter.='<div class="divsearchfield">';
@@ -484,7 +496,7 @@ if ($mode == 'common')
         $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
 
         $modName = $filename[$key];
-    	$objMod  = $modules[$key];
+    	$objMod  = $modules[$modName];
     	$dirofmodule = $dirmod[$key];
 
     	$special = $objMod->special;
@@ -504,6 +516,7 @@ if ($mode == 'common')
 
         // Check filters
         $modulename=$objMod->getName();
+        $moduletechnicalname=$objMod->name;
         $moduledesc=$objMod->getDesc();
         $moduledesclong=$objMod->getDescLong();
         $moduleauthor=$objMod->getPublisher();
@@ -513,6 +526,7 @@ if ($mode == 'common')
         {
             $qualified=0;
             if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename)
+                || preg_match('/'.preg_quote($search_keyword).'/i', $moduletechnicalname)
                 || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc)
                 || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong)
                 || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor)
@@ -633,7 +647,7 @@ if ($mode == 'common')
         print "</td>\n";
 
         // Activate/Disable and Setup (2 columns)
-        if (! empty($conf->global->$const_name))	// If module is activated
+        if (! empty($conf->global->$const_name))	// If module is already activated
         {
         	$disableSetup = 0;
 
@@ -699,12 +713,12 @@ if ($mode == 'common')
         	}
 
         }
-        else	// Module not activated
+        else	// Module not yet activated
 		{
         	print '<td align="center" valign="middle">';
 		    if (! empty($objMod->always_enabled))
         	{
-        		// Ne devrait pas arriver.
+        		// Should never happened
         	}
         	else if (! empty($objMod->disabled))
         	{
@@ -712,7 +726,34 @@ if ($mode == 'common')
         	}
         	else
         	{
-	        	// Module non actif
+	        	// Module qualified for activation
+        	    $warningmessage='';
+	        	if (! empty($arrayofwarnings[$modName]))
+	        	{
+                    print '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
+	        	    foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage)
+   	        	    {
+	        	        $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
+   	        	    }
+	        	}
+        		if ($objMod->isCoreOrExternalModule() == 'external' && ! empty($arrayofwarningsext))
+	        	{
+	        	    print '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n";
+	        	    foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry)
+	        	    {
+	        	        if (! empty($modules[$keymodule]->const_name))    // If module that request warning is on
+	        	        {
+        	        	    foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage)
+        	        	    {
+        	        	        if ($keycountry == 'always' || $keycountry == $mysoc->country_code)
+        	        	        {
+        	        	            $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName());
+        	        	        }
+        	        	    }
+	        	        }
+	        	    }
+	        	}
+        	    print '<!-- Message to show: '.$warningmessage.' -->'."\n";
 	        	print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '">';
 	        	print img_picto($langs->trans("Disabled"),'switch_off');
 	        	print "</a>\n";
@@ -732,7 +773,7 @@ if ($mode == 'common')
 
 if ($mode == 'marketplace')
 {
-    dol_fiche_head($head, $mode, '');
+    dol_fiche_head($head, $mode, '', -1);
     
     // Marketplace
     print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
@@ -768,7 +809,7 @@ if ($mode == 'marketplace')
    
 if ($mode == 'deploy')
 {
-    dol_fiche_head($head, $mode, '');
+    dol_fiche_head($head, $mode, '', -1);
 
     
     $allowonlineinstall=true;

+ 2 - 2
htdocs/admin/multicurrency.php

@@ -131,7 +131,7 @@ elseif ($action == 'synchronize')
 	}
 	else
 	{
-		setEventMessages($langs->trans('multicurrency_syncronize_error', $reponse->error->info), null, 'errors');
+		setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
 	}
 }
 
@@ -376,4 +376,4 @@ print '
 
 llxFooter();
 
-$db->close();
+$db->close();

+ 1 - 1
htdocs/admin/perms.php

@@ -118,7 +118,7 @@ $db->commit();
 
 $head=security_prepare_head();
 
-dol_fiche_head($head, 'default', $langs->trans("Security"));
+dol_fiche_head($head, 'default', $langs->trans("Security"), -1);
 
 
 // Show warning about external users

+ 1 - 1
htdocs/admin/proxy.php

@@ -96,7 +96,7 @@ print '<input type="hidden" name="action" value="set_proxy">';
 
 $head=security_prepare_head();
 
-dol_fiche_head($head, 'proxy', $langs->trans("Security"));
+dol_fiche_head($head, 'proxy', $langs->trans("Security"), -1);
 
 
 if ($conf->use_javascript_ajax)

+ 1 - 1
htdocs/admin/security.php

@@ -198,7 +198,7 @@ print "<br>\n";
 
 $head=security_prepare_head();
 
-dol_fiche_head($head, 'passwords', $langs->trans("Security"));
+dol_fiche_head($head, 'passwords', $langs->trans("Security"), -1);
 
 
 $var=false;

+ 1 - 1
htdocs/admin/security_file.php

@@ -124,7 +124,7 @@ print '<input type="hidden" name="action" value="updateform">';
 
 $head=security_prepare_head();
 
-dol_fiche_head($head, 'file', $langs->trans("Security"));
+dol_fiche_head($head, 'file', $langs->trans("Security"), -1);
 
 
 // Upload options

+ 1 - 1
htdocs/admin/security_other.php

@@ -103,7 +103,7 @@ print '<input type="hidden" name="action" value="updateform">';
 
 $head=security_prepare_head();
 
-dol_fiche_head($head, 'misc', $langs->trans("Security"));
+dol_fiche_head($head, 'misc', $langs->trans("Security"), -1);
 
 
 // Other Options

+ 247 - 3
htdocs/admin/supplier_payment.php

@@ -40,6 +40,7 @@ $action = GETPOST('action','alpha');
 $value = GETPOST('value','alpha');
 $label = GETPOST('label','alpha');
 $scandir = GETPOST('scandir','alpha');
+$type='supplier_payment';
 
 
 /*
@@ -62,11 +63,112 @@ if ($action == 'updateMask')
     {
         setEventMessages($langs->trans("Error"), null, 'errors');
     }
+}else  if ($action == 'setmod')
+{
+    dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity);
 }
 
-    if ($action == 'setmod')
+// define constants for models generator that need parameters
+else if ($action == 'setModuleOptions')
 {
-    dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity);
+    $post_size=count($_POST);
+    for($i=0;$i < $post_size;$i++)
+    {
+        if (array_key_exists('param'.$i,$_POST))
+        {
+            $param=GETPOST("param".$i,'alpha');
+            $value=GETPOST("value".$i,'alpha');
+            if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
+        }
+    }
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+    }
+    else
+    {
+        setEventMessages($langs->trans("Error"), null, 'errors');
+    }
+}
+
+// Activate a model
+else if ($action == 'set')
+{
+	$ret = addDocumentModel($value, $type, $label, $scandir);
+}
+
+else if ($action == 'del')
+{
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+        if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF',$conf->entity);
+	}
+}
+
+// Set default model
+else if ($action == 'setdoc')
+{
+	if (dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+	{
+		// La constante qui a ete lue en avant du nouveau set
+		// on passe donc par une variable pour avoir un affichage coherent
+		$conf->global->FACTURE_ADDON_PDF = $value;
+	}
+
+	// On active le modele
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+		$ret = addDocumentModel($value, $type, $label, $scandir);
+	}
+}
+
+else if ($action == 'specimen')
+{
+    $modele=GETPOST('module','alpha');
+
+    $paiementFourn = new PaiementFourn($db);
+    $paiementFourn->initAsSpecimen();
+
+	// Search template files
+	$file=''; $classname=''; $filefound=0;
+	$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+	foreach($dirmodels as $reldir)
+	{
+	    $file=dol_buildpath($reldir."core/modules/supplier_payment/pdf/pdf_".$modele.".modules.php",0);
+    	if (file_exists($file))
+    	{
+    		$filefound=1;
+    		$classname = "pdf_".$modele;
+    		break;
+    	}
+    }
+
+    if ($filefound)
+    {
+    	require_once $file;
+
+    	$module = new $classname($db);
+
+    	if ($module->write_file($paiementFourn,$langs) > 0)
+    	{
+    		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf");
+    		return;
+    	}
+    	else
+    	{
+    		setEventMessages($module->error, $module->errors, 'errors');
+    		dol_syslog($module->error, LOG_ERR);
+    	}
+    }
+    else
+    {
+    	setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
+    	dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+    }
 }
 
 /*
@@ -96,6 +198,35 @@ if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMEN
     
 print load_fiche_titre($langs->trans("PaymentsNumberingModule"), '', '');
 
+/*
+ *  Document templates generators
+ */
+print '<br>';
+print load_fiche_titre($langs->trans("BillsPDFModules"),'','');
+
+// Load array def with activated templates
+$def = array();
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = '".$type."'";
+$sql.= " AND entity = ".$conf->entity;
+$resql=$db->query($sql);
+if ($resql)
+{
+    $i = 0;
+    $num_rows=$db->num_rows($resql);
+    while ($i < $num_rows)
+    {
+        $array = $db->fetch_array($resql);
+        array_push($def, $array[0]);
+        $i++;
+    }
+}
+else
+{
+    dol_print_error($db);
+}
+
 print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre">';
 print '<td>'.$langs->trans("Name").'</td>';
@@ -140,7 +271,7 @@ foreach ($dirmodels as $reldir)
                         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;
@@ -217,6 +348,119 @@ foreach ($dirmodels as $reldir)
 
 print '</table>';
 
+
+print '<table class="noborder" width="100%">'."\n";
+print '<tr class="liste_titre">'."\n";
+print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
+print '<td>'.$langs->trans("Description").'</td>'."\n";
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
+print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
+print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
+print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
+print '</tr>'."\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/supplier_payment/pdf/");
+
+    if (is_dir($dir))
+    {
+        $var=true;
+
+        $handle=opendir($dir);
+
+
+        if (is_resource($handle))
+        {
+            while (($file = readdir($handle))!==false)
+            {
+                if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))            	
+                {
+                    $name = substr($file, 4, dol_strlen($file) -16);
+                    $classname = substr($file, 0, dol_strlen($file) -12);
+
+	                require_once $dir.'/'.$file;
+	                $module = new $classname($db, new PaiementFourn($db));
+
+                    $var=!$var;
+                    print "<tr ".$bc[$var].">\n";
+                    print "<td>";
+	                print (empty($module->name)?$name:$module->name);
+	                print "</td>\n";
+                    print "<td>\n";
+                    require_once $dir.$file;
+                    $module = new $classname($db,$specimenthirdparty);
+                    if (method_exists($module,'info')) print $module->info($langs);
+	                else print $module->description;
+
+                    print "</td>\n";
+
+                    // Active
+                    if (in_array($name, $def))
+                    {
+                        print '<td align="center">'."\n";
+                        //if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF != "$name")
+                        //{
+                            // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all
+                            print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=SUPPLIER_PAYMENT">';
+                            print img_picto($langs->trans("Enabled"),'switch_on');
+                            print '</a>';
+                        /*}
+                        else
+                        {
+                            print img_picto($langs->trans("Enabled"),'switch_on');
+                        }*/
+                        print "</td>";
+                    }
+                    else
+                    {
+                        print '<td align="center">'."\n";
+                        print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=SUPPLIER_PAYMENT">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+                        print "</td>";
+                    }
+
+                    // Default
+                    print '<td align="center">';
+                    if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name")
+                    {
+                        //print img_picto($langs->trans("Default"),'on');
+                        // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all
+                        print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
+                    }
+                    else
+                    {
+                        print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
+                    }
+                    print '</td>';
+
+                    // Info
+                    $htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
+                    $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+                    $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+                    $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+                    $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+                    $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
+                    $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
+                    print '<td align="center">';
+                    print $form->textwithpicto('',$htmltooltip,1,0);
+                    print '</td>';
+                    print '<td align="center">';
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
+                    print '</td>';
+
+                    print "</tr>\n";
+                }
+            }
+
+            closedir($handle);
+        }
+    }
+}
+
+print '</table><br>';
+
 dol_fiche_end();
 
 

+ 45 - 64
htdocs/admin/system/about.php

@@ -26,13 +26,26 @@
 
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 $langs->load("admin");
 $langs->load("help");
 $langs->load("members");
+$langs->load("other");
 
-$youuselaststable = 0;
+$action=GETPOST('action','alpha');
+
+if (! $user->admin) accessforbidden();
+
+$sfurl = '';
+$version='0.0';
+
+
+/*
+ *	Actions
+ */
+
+// None
 
 
 /*
@@ -42,7 +55,7 @@ $youuselaststable = 0;
 llxHeader();
 
 
-print load_fiche_titre("Dolibarr",'','title_setup');
+print load_fiche_titre($langs->trans("ExternalResources"),'','title_setup');
 
 print '<div style="padding-left: 30px;">'.img_picto_common('', 'dolibarr_box.png','height="120"').'</div>';
 
@@ -50,51 +63,10 @@ print '<div style="padding-left: 30px;">'.img_picto_common('', 'dolibarr_box.png
 
 print '<div class="fichecenter"><div class="fichehalfleft">';
 
-print $langs->trans("Version").' / '.$langs->trans("DolibarrLicense").':';
-print '<ul>';
-print '<li><strong>'.DOL_VERSION.'</strong>';
-
-$result = getURLContent('http://sourceforge.net/projects/dolibarr/rss');
-//var_dump($result['content']);
-$sfurl = simplexml_load_string($result['content']);
-if ($sfurl)
-{
-    $i=0;
-    $version='0.0';
-    while (! empty($sfurl->channel[0]->item[$i]->title) && $i < 10000)
-    {
-        $title=$sfurl->channel[0]->item[$i]->title;
-        if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg))
-        {
-            $newversion=$reg[1];
-            $newversionarray=explode('.',$newversion);
-            $versionarray=explode('.',$version);
-            //var_dump($newversionarray);var_dump($versionarray);
-            if (versioncompare($newversionarray, $versionarray) > 0) $version=$newversion;
-        }
-        $i++;
-    }
-
-    // Show version
-    if ($version != '0.0') 
-    {
-        print ' ('.$langs->trans("LastStableVersion").': <b>'.$version.'</b>';
-    	if (DOL_VERSION == $version)
-    	{
-    	    $youuselaststable=1;
-            print $langs->trans("YouUseLastStableVersion");  
-    	}
-    	print ')';
-    }
-}
-else
-{
-    print ' ('.$langs->trans("LastStableVersion").' : <b>' .$langs->trans("UpdateServerOffline").'</b>)<br>';
-}
-print ' / <a href="http://www.gnu.org/copyleft/gpl.html">GNU-GPL v3+</a></li>';
-
-
-print '</ul>';
+print $langs->trans("DolibarrLicense").' : ';
+print '<ul><li>';
+print '<a href="http://www.gnu.org/copyleft/gpl.html">GNU-GPL v3+</a></li>';
+print '</li></ul>';
 
 //print "<br>\n";
 
@@ -182,6 +154,11 @@ $url='https://wiki.dolibarr.org/index.php/Subscribe';
 if (preg_match('/^fr_/i',$langs->getDefaultLang())) $url='https://wiki.dolibarr.org/index.php/Adh%C3%A9rer';
 if (preg_match('/^es_/i',$langs->getDefaultLang())) $url='https://wiki.dolibarr.org/index.php/Subscribirse';
 print '<li><a href="'.$url.'" target="_blank" rel="external">'.$langs->trans("SubscribeToFoundation").'</a></li>';
+print '</ul>';
+
+print $langs->trans("SocialNetworks").':';
+
+print '<ul>';
 
 print '<li><a href="https://facebook.com/dolibarr" target="_blank" rel="external">FaceBook</a></li>';
 print '<li><a href="https://twitter.com/dolibarr" target="_blank" rel="external">Twitter</a></li>';
@@ -211,25 +188,29 @@ print '</div>';
 print '<div class="clearboth"></div>';
 
 
-if ($youuselaststable)
+$showpromotemessage=1;
+if ($showpromotemessage)
 {
-    print '<br>';
-    print '<br>';
-    
     $tmp=versiondolibarrarray();
-    if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0))
-    {
-        print $langs->trans("TitleExampleForMajorRelease").':<br>';
-        print '<textarea style="width:80%; min-height: 60px">';
-        print $langs->trans("ExampleOfNewsMessageForMajorRelease", DOL_VERSION, DOL_VERSION);
-        print '</textarea>';
-    }
-    else
+    if (is_numeric($tmp[2]))    // Not alpha, beta or rc
     {
-        print $langs->trans("TitleExampleForMaintenanceRelease").':<br>';
-        print '<textarea style="width:80%; min-height: 60px">';
-        print $langs->trans("ExampleOfNewsMessageForMaintenanceRelease", DOL_VERSION, DOL_VERSION);
-        print '</textarea>';
+        print '<br>';
+        print '<br>';
+        
+        if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0))
+        {
+            print $langs->trans("TitleExampleForMajorRelease").':<br>';
+            print '<textarea style="width:80%; min-height: 60px">';
+            print $langs->trans("ExampleOfNewsMessageForMajorRelease", DOL_VERSION, DOL_VERSION);
+            print '</textarea>';
+        }
+        else
+        {
+            print $langs->trans("TitleExampleForMaintenanceRelease").':<br>';
+            print '<textarea style="width:80%; min-height: 60px">';
+            print $langs->trans("ExampleOfNewsMessageForMaintenanceRelease", DOL_VERSION, DOL_VERSION);
+            print '</textarea>';
+        }
     }
 }
 

+ 73 - 10
htdocs/admin/system/dolibarr.php

@@ -25,15 +25,36 @@
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 $langs->load("admin");
 $langs->load("install");
 $langs->load("other");
 
+$action=GETPOST('action','alpha');
+
 if (! $user->admin)
 	accessforbidden();
 
+$sfurl = '';
+$version='0.0';
+
+
 
+/*
+ *	Actions
+ */
+
+if ($action == 'getlastversion')
+{
+    $result = getURLContent('http://sourceforge.net/projects/dolibarr/rss');
+    //var_dump($result['content']);
+    $sfurl = simplexml_load_string($result['content']);
+}
+
+	
 /*
  * View
  */
@@ -52,23 +73,60 @@ print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Version").'</td><td>'.$langs->trans("Value").'</td></tr>'."\n";
 $var=!$var;
-print '<tr '.$bc[$var].'><td>'.$langs->trans("VersionLastInstall").'</td><td>'.$conf->global->MAIN_VERSION_LAST_INSTALL.'</td></tr>'."\n";
-$var=!$var;
-print '<tr '.$bc[$var].'><td>'.$langs->trans("VersionLastUpgrade").'</td><td>'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</td></tr>'."\n";
-$var=!$var;
-print '<tr '.$bc[$var].'><td>'.$langs->trans("VersionProgram").'</td><td>'.DOL_VERSION;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("CurrentVersion").' ('.$langs->trans("Programs").')</td><td>'.DOL_VERSION;
 // If current version differs from last upgrade
 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE))
 {
-	// Compare version with last install database version (upgrades never occured)
-	if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_INSTALL));
+    // Compare version with last install database version (upgrades never occured)
+    if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_INSTALL));
 }
 else
 {
-	// Compare version with last upgrade database version
-	if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE));
+    // Compare version with last upgrade database version
+    if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE));
 }
+
+if (function_exists('curl_init'))
+{
+    $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10;
+    print ' &nbsp; &nbsp; - &nbsp; &nbsp; ';
+    if ($action == 'getlastversion')
+    {
+        if ($sfurl)
+        {
+            while (! empty($sfurl->channel[0]->item[$i]->title) && $i < 10000)
+            {
+                $title=$sfurl->channel[0]->item[$i]->title;
+                if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg))
+                {
+                    $newversion=$reg[1];
+                    $newversionarray=explode('.',$newversion);
+                    $versionarray=explode('.',$version);
+                    //var_dump($newversionarray);var_dump($versionarray);
+                    if (versioncompare($newversionarray, $versionarray) > 0) $version=$newversion;
+                }
+                $i++;
+            }
+
+            // Show version
+            print $langs->trans("LastStableVersion").' : <b>'. (($version != '0.0')?$version:$langs->trans("Unknown")) .'</b><br>';
+        }
+        else
+        {
+            print $langs->trans("LastStableVersion").' : <b>' .$langs->trans("UpdateServerOffline").'</b><br>';
+        }
+    }
+    else
+    {
+        print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="button">' .$langs->trans("Check").'</a><br>';
+    }
+}
+
 print '</td></tr>'."\n";
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("VersionLastUpgrade").' ('.$langs->trans("Database").')</td><td>'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</td></tr>'."\n";
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("VersionLastInstall").'</td><td>'.$conf->global->MAIN_VERSION_LAST_INSTALL.'</td></tr>'."\n";
 print '</table>';
 print '</div>';
 print '<br>';
@@ -265,6 +323,7 @@ $configfileparameters=array(
 		'?dolibarr_main_db_prefix' => $langs->trans("Prefix"),
 		'separator2' => '',
 		'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"),
+        '?multicompany_transverse_mode'=>  $langs->trans("MultiCompanyMode"),
 		'separator'=> '',
 		'?dolibarr_main_auth_ldap_login_attribute' => 'dolibarr_main_auth_ldap_login_attribute',
 		'?dolibarr_main_auth_ldap_host' => 'dolibarr_main_auth_ldap_host',
@@ -318,7 +377,11 @@ foreach($configfileparameters as $key => $value)
 	{
 		$newkey = preg_replace('/^\?/','',$key);
 
-		if (preg_match('/^\?/',$key) && empty(${$newkey})) continue;    // We discard parametes starting with ?
+		if (preg_match('/^\?/',$key) && empty(${$newkey})) 
+		{
+		    if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled))
+                continue;    // We discard parameters starting with ?
+		}
 		if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue;
 
 		$var=!$var;

+ 3 - 3
htdocs/admin/system/filecheck.php

@@ -95,13 +95,13 @@ print '<!-- for a local check target=local&xmlshortfile=... -->'."\n";
 if (dol_is_file($xmlfile))
 {
     print '<input type="radio" name="target" value="local"'.((! GETPOST('target') || GETPOST('target') == 'local') ? 'checked="checked"':'').'"> '.$langs->trans("LocalSignature").' = ';
-    print '<input name="xmlshortfile" class="flat minwidth200" value="'.dol_escape_htmltag($xmlshortfile).'">';
+    print '<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).'">';
     print '<br>';
 }
 else
 {
     print '<input type="radio" name="target" value="local"> '.$langs->trans("LocalSignature").' = ';
-    print '<input name="xmlshortfile" class="flat minwidth200" value="'.dol_escape_htmltag($xmlshortfile).'">';
+    print '<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).'">';
     print ' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span>';
     print '<br>';
 }
@@ -109,7 +109,7 @@ print '<!-- for a remote target=remote&xmlremote=... -->'."\n";
 if ($enableremotecheck)
 {
     print '<input type="radio" name="target" value="remote"'.(GETPOST('target') == 'remote' ? 'checked="checked"':'').'> '.$langs->trans("RemoteSignature").' = ';
-    print '<input name="xmlremote" class="flat quatrevingtpercent" value="'.dol_escape_htmltag($xmlremote).'"><br>';
+    print '<input name="xmlremote" class="flat minwidth400" value="'.dol_escape_htmltag($xmlremote).'"><br>';
 }
 else
 {

+ 5 - 4
htdocs/admin/tools/dolibarr_export.php

@@ -111,8 +111,9 @@ jQuery(document).ready(function() {
 <?php
 
 print load_fiche_titre($langs->trans("Backup"),'','title_setup');
+//print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup');
 
-print $langs->trans("BackupDesc",DOL_DATA_ROOT).'<br><br>';
+print '<div class="center">'.$langs->trans("BackupDesc",DOL_DATA_ROOT).'</div><br><br>';
 
 ?>
 
@@ -121,7 +122,7 @@ print $langs->trans("BackupDesc",DOL_DATA_ROOT).'<br><br>';
 	name="token" value="<?php echo $_SESSION['newtoken']; ?>" /> <input
 	type="hidden" name="export_type" value="server" />
 
-<fieldset id="fieldsetexport"><legend style="font-size: 3em">1</legend>
+<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>
 
 <?php
 print $langs->trans("BackupDesc3",$dolibarr_main_db_name).'<br>';
@@ -468,7 +469,7 @@ print '</td></tr></table>';
 ?>
 
 </div>
-<div id="backupdatabaseright" class="fichehalfright" style="height:400px; overflow: auto;">
+<div id="backupdatabaseright" class="fichehalfright" style="height:480px; overflow: auto;">
 <div class="ficheaddleft">
 
 <?php
@@ -484,7 +485,7 @@ print '<br>';
 
 <br>
 
-<fieldset><legend style="font-size: 3em">2</legend>
+<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">2</legend>
 <?php
 print $langs->trans("BackupDesc2",DOL_DATA_ROOT).'<br>';
 print $langs->trans("BackupDescX").'<br><br>';

+ 2 - 2
htdocs/admin/tools/index.php

@@ -37,8 +37,8 @@ if (! $user->admin)
 
 $form = new Form($db);
 
-$title=$langs->trans("SystemToolsArea");
-if (GETPOST('leftmenu') == 'admintools') $title=$langs->trans("ModulesSystemTools");
+$title=$langs->trans("AdminTools");
+//if (GETPOST('leftmenu') == 'admintools') $title=$langs->trans("ModulesSystemTools");
 
 llxHeader('', $title);
 

+ 3 - 1
htdocs/admin/tools/update.php

@@ -69,7 +69,9 @@ llxHeader('',$langs->trans("Upgrade"),$wikihelp);
 
 print load_fiche_titre($langs->trans("Upgrade"),'','title_setup');
 
-print $langs->trans("CurrentVersion").' : <b>'.DOL_VERSION.'</b><br>';
+print '<br>';
+
+print $langs->trans("CurrentVersion").' : <strong>'.DOL_VERSION.'</strong><br>';
 
 if (function_exists('curl_init'))
 {

+ 1 - 1
htdocs/admin/translation.php

@@ -181,7 +181,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 
 $head=translation_prepare_head();
 
-dol_fiche_head($head, $mode, '', 0, '');
+dol_fiche_head($head, $mode, '', -1, '');
 
 if ($mode == 'overwrite')
 {

+ 229 - 4
htdocs/admin/user.php

@@ -35,16 +35,83 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
 $langs->load("admin");
 $langs->load("members");
 $langs->load("users");
-
 if (! $user->admin) accessforbidden();
 
 $extrafields = new ExtraFields($db);
 
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+$type='user';
 
 /*
  * Action
  */
-if (preg_match('/set_(.*)/',$action,$reg))
+
+// Activate a model
+
+// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
+if ($action == 'setModuleOptions')
+{
+	$post_size=count($_POST);
+
+	$db->begin();
+
+	for($i=0;$i < $post_size;$i++)
+    {
+    	if (array_key_exists('param'.$i,$_POST))
+    	{
+    		$param=GETPOST("param".$i,'alpha');
+    		$value=GETPOST("value".$i,'alpha');
+    		if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
+	    	if (! $res > 0) $error++;
+    	}
+    }
+	if (! $error)
+    {
+        $db->commit();
+	    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+    }
+    else
+    {
+        $db->rollback();
+	    setEventMessages($langs->trans("Error"), null, 'errors');
+	}
+}
+elseif ($action == 'set_default')
+{
+	$ret = addDocumentModel($value, $type, $label, $scandir);
+	$res = true;
+}
+
+elseif ($action == 'del_default')
+{
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+        if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT',$conf->entity);
+	}
+	$res = true;
+}
+
+// Set default model
+elseif ($action == 'setdoc')
+{
+	if (dolibarr_set_const($db, "USER_ADDON_PDF_ODT",$value,'chaine',0,'',$conf->entity))
+	{
+		// La constante qui a ete lue en avant du nouveau set
+		// on passe donc par une variable pour avoir un affichage coherent
+		$conf->global->USER_ADDON_PDF_ODT = $value;
+	}
+
+	// On active le modele
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+		$ret = addDocumentModel($value, $type, $label, $scandir);
+	}
+	$res = true;
+}
+elseif (preg_match('/set_(.*)/',$action,$reg))
 {
     $code=$reg[1];
     if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
@@ -58,7 +125,7 @@ if (preg_match('/set_(.*)/',$action,$reg))
     }
 }
 
-if (preg_match('/del_(.*)/',$action,$reg))
+elseif (preg_match('/del_(.*)/',$action,$reg))
 {
     $code=$reg[1];
     if (dolibarr_del_const($db, $code, $conf->entity) > 0)
@@ -72,7 +139,7 @@ if (preg_match('/del_(.*)/',$action,$reg))
     }
 }
 //Set hide closed customer into combox or select
-if ($action == 'sethideinactiveuser')
+elseif ($action == 'sethideinactiveuser')
 {
 	$status = GETPOST('status','alpha');
 
@@ -138,6 +205,164 @@ print '</td></tr>';
 
 print '</table>';
 
+
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+$form=new Form($db);
+
+// Defini tableau def des modeles
+$def = array();
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = '".$type."'";
+$sql.= " AND entity = ".$conf->entity;
+$resql=$db->query($sql);
+if ($resql)
+{
+	$i = 0;
+	$num_rows=$db->num_rows($resql);
+	while ($i < $num_rows)
+	{
+		$array = $db->fetch_array($resql);
+		array_push($def, $array[0]);
+		$i++;
+	}
+}
+else
+{
+	dol_print_error($db);
+}
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
+print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
+print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
+print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$var=true;
+foreach ($dirmodels as $reldir)
+{
+    foreach (array('','/doc') as $valdir)
+    {
+    	$dir = dol_buildpath($reldir."core/modules/user".$valdir);
+        if (is_dir($dir))
+        {
+            $handle=opendir($dir);
+            if (is_resource($handle))
+            {
+                while (($file = readdir($handle))!==false)
+                {
+                    $filelist[]=$file;
+                }
+                closedir($handle);
+                arsort($filelist);
+
+                foreach($filelist as $file)
+                {
+                    if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
+                    {
+
+                    	if (file_exists($dir.'/'.$file))
+                    	{
+                    		$name = substr($file, 4, dol_strlen($file) -16);
+	                        $classname = substr($file, 0, dol_strlen($file) -12);
+
+	                        require_once $dir.'/'.$file;
+	                        $module = new $classname($db);
+
+	                        $modulequalified=1;
+	                        if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
+	                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+
+	                        if ($modulequalified)
+	                        {
+	                            $var = !$var;
+	                            print '<tr '.$bc[$var].'><td width="100">';
+	                            print (empty($module->name)?$name:$module->name);
+	                            print "</td><td>\n";
+	                            if (method_exists($module,'info')) print $module->info($langs);
+	                            else print $module->description;
+	                            print '</td>';
+
+	                            // Active
+	                            if (in_array($name, $def))
+	                            {
+	                            	print '<td align="center">'."\n";
+	                            	print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&value='.$name.'">';
+	                            	print img_picto($langs->trans("Enabled"),'switch_on');
+	                            	print '</a>';
+	                            	print '</td>';
+	                            }
+	                            else
+	                            {
+	                                print '<td align="center">'."\n";
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	                                print "</td>";
+	                            }
+
+	                            // Defaut
+	                            print '<td align="center">';
+	                            if ($conf->global->USER_ADDON_PDF == $name)
+	                            {
+	                                print img_picto($langs->trans("Default"),'on');
+	                            }
+	                            else
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
+	                            }
+	                            print '</td>';
+
+	                           // Info
+		    					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
+					    		$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+			                    if ($module->type == 'pdf')
+			                    {
+			                        $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+			                    }
+					    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+					    		$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
+
+
+	                            print '<td align="center">';
+	                            print $form->textwithpicto('',$htmltooltip,1,0);
+	                            print '</td>';
+
+	                            // Preview
+	                            print '<td align="center">';
+	                            if ($module->type == 'pdf')
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
+	                            }
+	                            else
+	                            {
+	                                print img_object($langs->trans("PreviewNotAvailable"),'generic');
+	                            }
+	                            print '</td>';
+
+	                            print "</tr>\n";
+	                        }
+                    	}
+                    }
+                }
+            }
+        }
+    }
+}
+
+print '</table>';
+print "<br>";
+
 dol_fiche_end();
 
 llxFooter();

+ 316 - 0
htdocs/admin/usergroup.php

@@ -0,0 +1,316 @@
+<?php
+/* Copyright (C) 2003		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2003		Jean-Louis Bergamo		<jlb@j1b.org>
+ * Copyright (C) 2004-2009	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2004		Sebastien Di Cintio		<sdicintio@ressource-toi.org>
+ * Copyright (C) 2004		Benoit Mortier			<benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2011	Regis Houssin			<regis.houssin@capnetworks.com>
+ * Copyright (C) 2015		Juanjo Menent			<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/admin/usergroup.php
+ *		\ingroup    core
+ *		\brief      Page to setup usergroup module
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+
+$langs->load("admin");
+$langs->load("members");
+$langs->load("users");
+if (! $user->admin) accessforbidden();
+
+$extrafields = new ExtraFields($db);
+
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+$type='group';
+
+/*
+ * Action
+ */
+
+// Activate a model
+
+// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
+if ($action == 'setModuleOptions')
+{
+	$post_size=count($_POST);
+
+	$db->begin();
+
+	for($i=0;$i < $post_size;$i++)
+    {
+    	if (array_key_exists('param'.$i,$_POST))
+    	{
+    		$param=GETPOST("param".$i,'alpha');
+    		$value=GETPOST("value".$i,'alpha');
+    		if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
+	    	if (! $res > 0) $error++;
+    	}
+    }
+	if (! $error)
+    {
+        $db->commit();
+	    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+    }
+    else
+    {
+        $db->rollback();
+	    setEventMessages($langs->trans("Error"), null, 'errors');
+	}
+}
+elseif ($action == 'set_default')
+{
+	$ret = addDocumentModel($value, $type, $label, $scandir);
+	$res = true;
+}
+
+elseif ($action == 'del_default')
+{
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+        if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT',$conf->entity);
+	}
+	$res = true;
+}
+
+// Set default model
+elseif ($action == 'setdoc')
+{
+	if (dolibarr_set_const($db, "USERGROUP_ADDON_PDF_ODT",$value,'chaine',0,'',$conf->entity))
+	{
+		// La constante qui a ete lue en avant du nouveau set
+		// on passe donc par une variable pour avoir un affichage coherent
+		$conf->global->USERGROUP_ADDON_PDF_ODT = $value;
+	}
+
+	// On active le modele
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+		$ret = addDocumentModel($value, $type, $label, $scandir);
+	}
+	$res = true;
+}
+elseif (preg_match('/set_(.*)/',$action,$reg))
+{
+    $code=$reg[1];
+    if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
+    {
+        header("Location: ".$_SERVER["PHP_SELF"]);
+        exit;
+    }
+    else
+    {
+        dol_print_error($db);
+    }
+}
+
+elseif (preg_match('/del_(.*)/',$action,$reg))
+{
+    $code=$reg[1];
+    if (dolibarr_del_const($db, $code, $conf->entity) > 0)
+    {
+        header("Location: ".$_SERVER["PHP_SELF"]);
+        exit;
+    }
+    else
+    {
+        dol_print_error($db);
+    }
+}
+/*
+ * View
+ */
+
+$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios';
+llxHeader('',$langs->trans("UsersSetup"),$help_url);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print load_fiche_titre($langs->trans("UsersSetup"),$linkback,'title_setup');
+
+
+$head=user_admin_prepare_head();
+
+dol_fiche_head($head,'usergroupcard', $langs->trans("MenuUsersAndGroups"), 0, 'user');
+
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+$form=new Form($db);
+
+// Defini tableau def des modeles
+$def = array();
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = '".$type."'";
+$sql.= " AND entity = ".$conf->entity;
+$resql=$db->query($sql);
+if ($resql)
+{
+	$i = 0;
+	$num_rows=$db->num_rows($resql);
+	while ($i < $num_rows)
+	{
+		$array = $db->fetch_array($resql);
+		array_push($def, $array[0]);
+		$i++;
+	}
+}
+else
+{
+	dol_print_error($db);
+}
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
+print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
+print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
+print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$var=true;
+foreach ($dirmodels as $reldir)
+{
+    foreach (array('','/doc') as $valdir)
+    {
+    	$dir = dol_buildpath($reldir."core/modules/usergroup".$valdir);
+        if (is_dir($dir))
+        {
+            $handle=opendir($dir);
+            if (is_resource($handle))
+            {
+                while (($file = readdir($handle))!==false)
+                {
+                    $filelist[]=$file;
+                }
+                closedir($handle);
+                arsort($filelist);
+
+                foreach($filelist as $file)
+                {
+                    if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
+                    {
+
+                    	if (file_exists($dir.'/'.$file))
+                    	{
+                    		$name = substr($file, 4, dol_strlen($file) -16);
+	                        $classname = substr($file, 0, dol_strlen($file) -12);
+
+	                        require_once $dir.'/'.$file;
+	                        $module = new $classname($db);
+
+	                        $modulequalified=1;
+	                        if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
+	                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+
+	                        if ($modulequalified)
+	                        {
+	                            $var = !$var;
+	                            print '<tr '.$bc[$var].'><td width="100">';
+	                            print (empty($module->name)?$name:$module->name);
+	                            print "</td><td>\n";
+	                            if (method_exists($module,'info')) print $module->info($langs);
+	                            else print $module->description;
+	                            print '</td>';
+
+	                            // Active
+	                            if (in_array($name, $def))
+	                            {
+	                            	print '<td align="center">'."\n";
+	                            	print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&value='.$name.'">';
+	                            	print img_picto($langs->trans("Enabled"),'switch_on');
+	                            	print '</a>';
+	                            	print '</td>';
+	                            }
+	                            else
+	                            {
+	                                print '<td align="center">'."\n";
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	                                print "</td>";
+	                            }
+
+	                            // Defaut
+	                            print '<td align="center">';
+	                            if ($conf->global->USERGROUP_ADDON_PDF == $name)
+	                            {
+	                                print img_picto($langs->trans("Default"),'on');
+	                            }
+	                            else
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
+	                            }
+	                            print '</td>';
+
+	                           // Info
+		    					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
+					    		$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+			                    if ($module->type == 'pdf')
+			                    {
+			                        $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+			                    }
+					    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+					    		$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
+
+
+	                            print '<td align="center">';
+	                            print $form->textwithpicto('',$htmltooltip,1,0);
+	                            print '</td>';
+
+	                            // Preview
+	                            print '<td align="center">';
+	                            if ($module->type == 'pdf')
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
+	                            }
+	                            else
+	                            {
+	                                print img_object($langs->trans("PreviewNotAvailable"),'generic');
+	                            }
+	                            print '</td>';
+
+	                            print "</tr>\n";
+	                        }
+                    	}
+                    }
+                }
+            }
+        }
+    }
+}
+
+print '</table>';
+print "<br>";
+
+dol_fiche_end();
+
+llxFooter();
+$db->close();

+ 7 - 3
htdocs/bookmarks/card.php

@@ -159,7 +159,7 @@ if ($action == 'create')
 
 	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("BookmarkTitle").'</td><td><input class="flat" name="title" size="30" value="'.$title.'"></td><td class="hideonsmartphone">'.$langs->trans("SetHereATitleForLink").'</td></tr>';
 
-	print '<tr><td class="fieldrequired">'.$langs->trans("UrlOrLink").'</td><td><input class="flat" name="url" size="50" value="'.$url.'"></td><td class="hideonsmartphone">'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>';
+	print '<tr><td class="fieldrequired">'.$langs->trans("UrlOrLink").'</td><td><input class="flat" name="url" class="quatrevingtpercent" value="'.$url.'"></td><td class="hideonsmartphone">'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>';
 
 	print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>';
 	$liste=array(0=>$langs->trans("ReplaceWindow"),1=>$langs->trans("OpenANewWindow"));
@@ -219,9 +219,11 @@ if ($id > 0 && ! preg_match('/^add/i',$action))
 
 	$linkback = '<a href="'.DOL_URL_ROOT.'/bookmarks/list.php">'.$langs->trans("BackToList").'</a>';
 	
-  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0);
+    dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0);
 
-  print '<div class="underbanner clearboth"></div>';
+    print '<div class="fichecenter">';
+    
+    print '<div class="underbanner clearboth"></div>';
 	print '<table class="border" width="100%">';
 
 	print '<tr><td class="titlefield">';
@@ -297,6 +299,8 @@ if ($id > 0 && ! preg_match('/^add/i',$action))
 
 	print '</table>';
 
+	print '</div>';
+	
 	dol_fiche_end();
 
 	if ($action == 'edit')

+ 1 - 1
htdocs/cashdesk/tpl/validation2.tpl.php

@@ -41,7 +41,7 @@ $langs->load("bills");
 
 </script>
 
-<p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture.php?action=builddoc&facid=<?php echo $_GET['facid']; ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p>
+<p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture/card.php?action=builddoc&facid=<?php echo $_GET['facid']; ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p>
 <br>
 <p><a class="lien1" href="#" onclick="Javascript: popupTicket(); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p>
 

+ 42 - 3
htdocs/categories/class/api_categories.class.php

@@ -248,6 +248,7 @@ class Categories extends DolibarrApi
         if( ! count($obj_ret)) {
             throw new RestException(404, 'No category found');
         }
+        
 		return $obj_ret;
     }
 
@@ -351,9 +352,47 @@ class Categories extends DolibarrApi
     
         $object = parent::_cleanObjectDatas($object);
     
-        // Remove the subscriptions because they are handled as a subresource.
-        //unset($object->subscriptions);
-    
+        // Remove fields not relevent to categories
+        unset($object->country);
+        unset($object->country_id);
+        unset($object->country_code);
+        unset($object->total_ht);
+        unset($object->total_ht);
+        unset($object->total_localtax1);
+        unset($object->total_localtax2);
+        unset($object->total_ttc);
+        unset($object->total_tva);
+        unset($object->lines);
+        unset($object->fk_incoterms);
+        unset($object->libelle_incoterms);
+        unset($object->location_incoterms);
+        unset($object->civility_id);
+        unset($object->name);
+        unset($object->lastname);
+        unset($object->firstname);
+        unset($object->shipping_method_id);
+        unset($object->fk_delivery_address);
+        unset($object->cond_reglement);
+        unset($object->cond_reglement_id);
+        unset($object->mode_reglement_id);
+        unset($object->barcode_type_coder);
+        unset($object->barcode_type_label);
+        unset($object->barcode_type_code);
+        unset($object->barcode_type);
+        unset($object->canvas);
+        unset($object->cats);
+        unset($object->motherof);
+        unset($object->context);
+        unset($object->socid);
+        unset($object->thirdparty);
+        unset($object->contact);
+        unset($object->contact_id);
+        unset($object->user);
+        unset($object->fk_account);
+        unset($object->fk_project);
+        unset($object->note);
+        unset($object->statut);
+        
         return $object;
     }
     

+ 1 - 1
htdocs/categories/class/api_deprecated_category.class.php

@@ -291,7 +291,7 @@ class CategoryApi extends DolibarrApi
      * @url GET /customer/{cusid}/categories
      */
     function getListCustomerCategories($cusid, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
-        return $this->getListForItem('customer', $sortfield, $sortorder, $limit, $page, $cusid);  
+        return $this->getListForItem($sortfield, $sortorder, $limit, $page, 'customer', $cusid);  
     }
 
     /**

+ 23 - 2
htdocs/categories/class/categorie.class.php

@@ -526,7 +526,17 @@ class Categorie extends CommonObject
 		}
 		if (! $error)
 		{
-			$sql  = "DELETE FROM ".MAIN_DB_PREFIX."categorie_project";
+			$sql  = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact";
+			$sql .= " WHERE fk_categorie = ".$this->id;
+			if (!$this->db->query($sql))
+			{
+				$this->error=$this->db->lasterror();
+				$error++;
+			}
+		}
+		if (! $error)
+		{
+			$sql  = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
 			$sql .= " WHERE fk_categorie = ".$this->id;
 			if (!$this->db->query($sql))
 			{
@@ -535,7 +545,18 @@ class Categorie extends CommonObject
 				$error++;
 			}
 		}
-
+		if (! $error)
+		{
+		    $sql  = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";
+		    $sql .= " WHERE fk_categ = ".$this->id;
+		    if (!$this->db->query($sql))
+		    {
+		        $this->error=$this->db->lasterror();
+		        dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
+		        $error++;
+		    }
+		}
+		
 		if (! $error)
 		{
 			$sql  = "DELETE FROM ".MAIN_DB_PREFIX."categorie_lang";

+ 76 - 31
htdocs/comm/action/card.php

@@ -146,6 +146,14 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
 	$listUserAssignedUpdated = true;
 }
 
+// Link to a project
+if ($action == 'classin' && ($user->rights->agenda->allactions->create ||
+    (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)))
+{
+    $object->fetch($id);
+    $object->setProject(GETPOST('projectid'));
+}
+
 // Action clone object
 if ($action == 'confirm_clone' && $confirm == 'yes')
 {
@@ -577,6 +585,8 @@ if ($action == 'mupdate')
  * View
  */
 
+$formproject=new FormProjets($db);
+
 $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
 llxHeader('',$langs->trans("Agenda"),$help_url);
 
@@ -744,7 +754,7 @@ if ($action == 'create')
 	print '<br><br>';
 	print '<table class="border" width="100%">';
 
-	// Societe, contact
+	// Related company
 	print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ActionOnCompany").'</td><td>';
 	if (GETPOST('socid','int') > 0)
 	{
@@ -755,7 +765,6 @@ if ($action == 'create')
 	}
 	else
 	{
-
 		$events=array();
 		$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
 		//For external user force the company to user company
@@ -768,6 +777,7 @@ if ($action == 'create')
 	}
 	print '</td></tr>';
 
+	// Related contact
 	print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
 	$form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
 	print '</td></tr>';
@@ -852,8 +862,10 @@ if ($id > 0)
 	$result4=$object->fetch_userassigned();
 	$result5=$object->fetch_optionals($id,$extralabels);
 	
-	if ($listUserAssignedUpdated || $donotclearsession) {
-
+	if ($listUserAssignedUpdated || $donotclearsession) 
+	{
+        $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage"));	// If status is -1 or 100, percentage is not defined and we must use status
+	
 		$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
 		$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
 
@@ -1028,7 +1040,7 @@ if ($id > 0)
 
 		// Status
 		print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
-		$percent=GETPOST("percentage")?GETPOST("percentage"):$object->percentage;
+		$percent = GETPOST("percentage") ? GETPOST("percentage"): $object->percentage;
 		$formactions->form_select_status_action('formaction',$percent,1);
 		print '</td></tr>';
 
@@ -1090,10 +1102,10 @@ if ($id > 0)
 		
 		print '<table class="border" width="100%">';
 
-		// Thirdparty - Contact
 		if ($conf->societe->enabled)
 		{
-			print '<tr><td class="titlefieldcreate">'.$langs->trans("ActionOnCompany").'</td>';
+		    // Related company
+		    print '<tr><td class="titlefieldcreate">'.$langs->trans("ActionOnCompany").'</td>';
 			print '<td>';
 			print '<div class="maxwidth200onsmartphone">';
 			$events=array();     // 'method'=parameter action of url, 'url'=url to call that return new list of contacts
@@ -1104,8 +1116,8 @@ if ($id > 0)
 			print '</div>';
 			print '</td></tr>';
 
-			// Contact
-			print '<tr><td>'.$langs->trans("Contact").'</td><td>';
+			// related contact
+			print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td>';
 			print '<div class="maxwidth200onsmartphone">';
 			$form->select_contacts($object->socid, $object->contactid, 'contactid', 1, '', '', 0, 'minwidth200');
 			print '</div>';
@@ -1199,27 +1211,61 @@ if ($id > 0)
 		$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
 		$linkback.=$out;
 		
-		dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
+		
+		$morehtmlref='<div class="refidno">';
+		// Thirdparty
+		//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+		// Project
+		if (! empty($conf->projet->enabled))
+		{
+		    $langs->load("projects");
+		    //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+		    $morehtmlref.=$langs->trans('Project') . ' ';
+    		if ($user->rights->agenda->allactions->create ||
+	       	    (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
+		    {
+		        if ($action != 'classify')
+		            $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
+		            if ($action == 'classify') {
+		                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+		                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+		                $morehtmlref.='<input type="hidden" name="action" value="classin">';
+		                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+		                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+		                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+		                $morehtmlref.='</form>';
+		            } else {
+		                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+		            }
+		    } else {
+		        if (! empty($object->fk_project)) {
+		            $proj = new Project($db);
+		            $proj->fetch($object->fk_project);
+		            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
+		            $morehtmlref.=$proj->ref;
+		            $morehtmlref.='</a>';
+		            if ($proj->title) $morehtmlref.=' - '.$proj->title;
+		        } else {
+		            $morehtmlref.='';
+		        }
+		    }
+		}
+		$morehtmlref.='</div>';
+		
+		
+		dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
 		
 		print '<div class="underbanner clearboth"></div>';
 		
 		// Affichage fiche action en mode visu
 		print '<table class="border" width="100%">';
 
-		// Ref
-		/*print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
-		print $form->showrefnav($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
-		print '</td></tr>';*/
-
 		// Type
 		if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
 		{
 			print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
 		}
 
-		// Title
-		//print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.dol_htmlentities($object->label).'</td></tr>';
-
         // Full day event
         print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
 
@@ -1241,11 +1287,6 @@ if ($id > 0)
 		if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
 		print '</td></tr>';
 
-		// Status
-		/*print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
-		print $object->getLibStatut(4);
-		print '</td></tr>';*/
-
         // Location
 	    if (empty($conf->global->AGENDA_DISABLE_LOCATION))
     	{
@@ -1302,14 +1343,14 @@ if ($id > 0)
 
 		print '</table>';
 
-		print '<br><br>';
+		print '<br>';
 
 		print '<table class="border" width="100%">';
 
-		// Third party - Contact
 		if ($conf->societe->enabled)
 		{
-			print '<tr><td class="titlefield">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
+		    // Related company
+		    print '<tr><td class="titlefield">'.$langs->trans("ActionOnCompany").'</td><td colspan="3">'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):('<span class="opacitymedium">'.$langs->trans("None").'</span>'));
 			if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
 			{
 				if ($object->thirdparty->fetch($object->thirdparty->id))
@@ -1317,9 +1358,11 @@ if ($id > 0)
 					print "<br>".dol_print_phone($object->thirdparty->phone);
 				}
 			}
-			print '</td>';
-			print '<td>'.$langs->trans("Contact").'</td>';
-			print '<td>';
+			print '</td></tr>';
+			
+			// Related contact
+			print '<tr><td>'.$langs->trans("ActionOnContact").'</td>';
+			print '<td colspan="3">';
 			if ($object->contactid > 0)
 			{
 				print $object->contact->getNomUrl(1);
@@ -1333,12 +1376,13 @@ if ($id > 0)
 			}
 			else
 			{
-				print $langs->trans("None");
+				print '<span class="opacitymedium">'.$langs->trans("NoneOrSeveral").'</span>';
 			}
 			print '</td></tr>';
 		}
 
 		// Project
+		/*
 		if (! empty($conf->projet->enabled))
 		{
 			print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
@@ -1350,7 +1394,8 @@ if ($id > 0)
 			}
 			print '</td></tr>';
 		}
-
+        */
+		
 		// Priority
 		print '<tr><td class="nowrap" class="titlefield">'.$langs->trans("Priority").'</td><td colspan="3">';
 		print ($object->priority?$object->priority:'');

+ 24 - 78
htdocs/comm/action/document.php

@@ -140,27 +140,41 @@ if ($object->id > 0)
 	
 	$linkback.=$out;
 
-	dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
+	$morehtmlref='<div class="refidno">';
+	// Thirdparty
+	//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+	// Project
+	if (! empty($conf->projet->enabled))
+	{
+	    $langs->load("projects");
+	    //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+	    $morehtmlref.=$langs->trans('Project') . ': ';
+	    if (! empty($object->fk_project)) {
+	        $proj = new Project($db);
+	        $proj->fetch($object->fk_project);
+	        $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
+	        $morehtmlref.=$proj->ref;
+	        $morehtmlref.='</a>';
+	        if ($proj->title) $morehtmlref.=' - '.$proj->title;
+	    } else {
+	        $morehtmlref.='';
+	    }
+	}
+	$morehtmlref.='</div>';
+	
+	dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
 	
 	print '<div class="underbanner clearboth"></div>';
 	
 	// Affichage fiche action en mode visu
 	print '<table class="border" width="100%">';
 
-	// Ref
-	/*print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
-	print $form->showrefnav($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
-	print '</td></tr>';*/
-
 	// Type
 	if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
 	{
 		print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
 	}
 
-	// Title
-	//print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$object->label.'</td></tr>';
-
 	// Full day event
 	print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
 
@@ -179,11 +193,6 @@ if ($object->id > 0)
 	if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
 	print '</td></tr>';
 
-	// Status
-	/*print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="2">';
-	print $object->getLibStatut(4);
-	print '</td></tr>';*/
-
 	// Location
 	if (empty($conf->global->AGENDA_DISABLE_LOCATION))
 	{
@@ -227,71 +236,8 @@ if ($object->id > 0)
 
 	print '</table>';
 	
-	print '<br><br>';
-	
-	print '<table class="border" width="100%">';
-
-
-	// Third party - Contact
-	print '<tr><td class="titlefield">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
-	if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
-	{
-		if ($object->thirdparty->fetch($object->thirdparty->id))
-		{
-			print "<br>".dol_print_phone($object->thirdparty->phone);
-		}
-	}
-	print '</td>';
-	print '<td>'.$langs->trans("Contact").'</td>';
-	print '<td>';
-	if ($object->contact->id > 0)
-	{
-		print $object->contact->getNomUrl(1);
-		if ($object->contact->id && $object->type_code == 'AC_TEL')
-		{
-			if ($object->contact->fetch($object->contact->id))
-			{
-				print "<br>".dol_print_phone($object->contact->phone_pro);
-			}
-		}
-	}
-	else
-	{
-		print $langs->trans("None");
-	}
-
-	print '</td></tr>';
-
-	// Project
-	if (! empty($conf->projet->enabled))
-	{
-		print '<tr><td class="tdtop">'.$langs->trans("Project").'</td><td colspan="3">';
-		if ($object->fk_project)
-		{
-			$project=new Project($db);
-			$project->fetch($object->fk_project);
-			print $project->getNomUrl(1);
-		}
-		print '</td></tr>';
-	}
-
-	// Priority
-	print '<tr><td class="nowrap">'.$langs->trans("Priority").'</td><td colspan="3">';
-	print ($object->priority?$object->priority:'');
-	print '</td></tr>';
-
-	// Other attributes
-	$parameters=array('colspan'=>' colspan="3"', 'colspanvalue'=>'3', 'id'=>$object->id);
-	$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-	if (empty($reshook) && ! empty($extrafields->attribute_label))
-	{
-		print $object->showOptionals($extrafields,'edit');
-	}
-
-
-	print '</table>';
 
-	print '<br><br>';
+	print '<br>';
 
 	print '<table class="border" width="100%">';
 

+ 27 - 8
htdocs/comm/action/index.php

@@ -1328,7 +1328,16 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                             $cssclass.= " unmovable";
                         }
                     }
-                    else $cssclass.= " movable";
+                    else{
+                        if ($user->rights->agenda->allactions->create ||
+                            (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create))
+                        {
+                            $cssclass.= " movable";
+                        }else{
+                            $cssclass.= " unmovable";
+                        }
+
+                    }
 
                     $h=''; $nowrapontd=1;
                     if ($action == 'show_day')  { $h='height: 100%; '; $nowrapontd=0; }
@@ -1344,7 +1353,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                     print '<ul class="cal_event" style="'.$h.'">';	// always 1 li per ul, 1 ul per event
                     print '<li class="cal_event" style="'.$h.'">';
                     print '<table class="cal_event'.(empty($event->transparency)?'':' cal_event_busy').'" style="'.$h;
-                    print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).'));';
+                    print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($color, -3).'), to(#'.dol_color_minus($color, -3).'));';
                     //if (! empty($event->transparency)) print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).'));';
                     //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;';
                     print ' -moz-border-radius:4px;" width="100%"><tr>';
@@ -1404,7 +1413,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                             {
                                 $savlabel=$event->libelle;
                                 $event->libelle=$daterange;
+                                //print '<strong>';
                                 print $event->getNomUrl(0);
+                                //print '</strong>';
                                 $event->libelle=$savlabel;
                             }
                             else
@@ -1412,7 +1423,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                                 print $daterange;
                             }
                             //print '</strong> ';
-                            print "<br>\n";
+                            print " ";
                         }
                         else
 						{
@@ -1526,14 +1537,22 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
  * Change color with a delta
  *
  * @param	string	$color		Color
- * @param 	int		$minus		Delta
+ * @param 	int		$minus		Delta (1 = 16 unit)
+ * @param   int     $minusunit  Minus unit
  * @return	string				New color
  */
-function dol_color_minus($color, $minus)
+function dol_color_minus($color, $minus, $minusunit = 16)
 {
 	$newcolor=$color;
-	$newcolor[0]=((hexdec($newcolor[0])-$minus)<0)?0:dechex((hexdec($newcolor[0])-$minus));
-	$newcolor[2]=((hexdec($newcolor[2])-$minus)<0)?0:dechex((hexdec($newcolor[2])-$minus));
-	$newcolor[4]=((hexdec($newcolor[4])-$minus)<0)?0:dechex((hexdec($newcolor[4])-$minus));
+	if ($minusunit == 16)
+	{
+    	$newcolor[0]=dechex(max(min(hexdec($newcolor[0])-$minus, 15), 0));
+    	$newcolor[2]=dechex(max(min(hexdec($newcolor[2])-$minus, 15), 0));
+    	$newcolor[4]=dechex(max(min(hexdec($newcolor[4])-$minus, 15), 0));
+	}
+	else
+	{
+	    // Not yet implemented
+	}
 	return $newcolor;
 }

+ 27 - 1
htdocs/comm/action/info.php

@@ -28,6 +28,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
+if (! empty($conf->projet->enabled)) {
+    require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+    require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
+}
 
 $langs->load("commercial");
 
@@ -74,7 +78,29 @@ $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.do
 
 $linkback.=$out;
 
-dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
+$morehtmlref='<div class="refidno">';
+// Thirdparty
+//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+// Project
+if (! empty($conf->projet->enabled))
+{
+    $langs->load("projects");
+    //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+    $morehtmlref.=$langs->trans('Project') . ': ';
+    if (! empty($object->fk_project)) {
+        $proj = new Project($db);
+        $proj->fetch($object->fk_project);
+        $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
+        $morehtmlref.=$proj->ref;
+        $morehtmlref.='</a>';
+        if ($proj->title) $morehtmlref.=' - '.$proj->title;
+    } else {
+        $morehtmlref.='';
+    }
+}
+$morehtmlref.='</div>';
+
+dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
 
 print '<div class="underbanner clearboth"></div>';
 

+ 9 - 8
htdocs/comm/card.php

@@ -519,7 +519,7 @@ if ($id > 0)
 
 	// Lien recap
 	$boxstat.='<div class="box">';
-	$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">';
+	$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable boxtablenobottom" width="100%">';
 	$boxstat.='<tr class="impair"><td colspan="2" class="tdboxstats nohover">';
 	
 	if ($conf->propal->enabled)
@@ -1039,6 +1039,11 @@ if ($id > 0)
 
     if (empty($reshook))
     {
+        if ($object->status != 1)
+        {
+            print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
+        }
+        
     	if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1)
     	{
     		$langs->load("propal");
@@ -1072,16 +1077,12 @@ if ($id > 0)
     			print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
     		}
     
-    		if (! empty($conf->facture->enabled))
+    		if (! empty($conf->facture->enabled) && $object->status==1)
     		{
     			if (empty($user->rights->facture->creer))
     			{
     			    print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
     			}
-    			else if ($object->status != 1)
-    			{
-    			    print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
-    			}
     			else
     			{
     				$langs->load("bills");
@@ -1093,7 +1094,7 @@ if ($id > 0)
     					else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
     				}
     
-    				if ($object->client != 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
+    				if ($object->client != 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
     				else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
     
     			}
@@ -1101,7 +1102,7 @@ if ($id > 0)
     	}
     
     	// Add action
-    	if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
+    	if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status==1)
     	{
     		if ($user->rights->agenda->myactions->create)
     		{

+ 63 - 61
htdocs/comm/index.php

@@ -77,59 +77,61 @@ print load_fiche_titre($langs->trans("CommercialArea"),'','title_commercial.png'
 
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
-// Search proposal
-if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
-{
-	$listofsearchfields['search_proposal']=array('text'=>'Proposal');
-}
-// Search customer order
-if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
-{
-	$listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder');
-}
-// Search supplier proposal
-if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
-{
-    $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort');
-}
-// Search supplier order
-if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
-{
-	$listofsearchfields['search_supplier_order']=array('text'=>'SupplierOrder');
-}
-// Search intervention
-if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
-{
-	$listofsearchfields['search_intervention']=array('text'=>'Intervention');
-}
-// Search contract
-if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
+if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
 {
-    $listofsearchfields['search_contract']=array('text'=>'Contract');
-}
-
-if (count($listofsearchfields))
-{
-	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-	print '<table class="noborder nohover centpercent">';
-	$i=0;
-	foreach($listofsearchfields as $key => $value)
-	{
-		if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
-		print '<tr '.$bc[false].'>';
-		print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
-		if ($i == 0) print '<td class="noborderbottom" rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button "></td>';
-		print '</tr>';
-		$i++;
-	}
-	print '</table>';	
-	print '</form>';
-	print '<br>';
+    // Search proposal
+    if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
+    {
+    	$listofsearchfields['search_proposal']=array('text'=>'Proposal');
+    }
+    // Search customer order
+    if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
+    {
+    	$listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder');
+    }
+    // Search supplier proposal
+    if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
+    {
+        $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort');
+    }
+    // Search supplier order
+    if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
+    {
+    	$listofsearchfields['search_supplier_order']=array('text'=>'SupplierOrder');
+    }
+    // Search intervention
+    if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
+    {
+    	$listofsearchfields['search_intervention']=array('text'=>'Intervention');
+    }
+    // Search contract
+    if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
+    {
+        $listofsearchfields['search_contract']=array('text'=>'Contract');
+    }
+    
+    if (count($listofsearchfields))
+    {
+    	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
+    	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    	print '<table class="noborder nohover centpercent">';
+    	$i=0;
+    	foreach($listofsearchfields as $key => $value)
+    	{
+    		if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
+    		print '<tr '.$bc[false].'>';
+    		print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
+    		if ($i == 0) print '<td class="noborderbottom" rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button "></td>';
+    		print '</tr>';
+    		$i++;
+    	}
+    	print '</table>';	
+    	print '</form>';
+    	print '<br>';
+    }
 }
 
 
-
 /*
  * Draft proposals
  */
@@ -156,7 +158,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 	    
 		print '<table class="noborder" width="100%">';
 		print '<tr class="liste_titre">';
-		print '<td colspan="3">'.$langs->trans("ProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</td></tr>';
+		print '<th colspan="3">'.$langs->trans("ProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
 
 		if ($num > 0)
 		{
@@ -237,7 +239,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos
          
         print '<table class="noborder" width="100%">';
         print '<tr class="liste_titre">';
-        print '<td colspan="3">'.$langs->trans("SupplierProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</td></tr>';
+        print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
 
         if ($num > 0)
         {
@@ -316,7 +318,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 	    
 		print '<table class="noborder" width="100%">';
 		print '<tr class="liste_titre">';
-		print '<td colspan="3">'.$langs->trans("DraftOrders").($num?' <span class="badge">'.$num.'</span>':'').'</td></tr>';
+		print '<th colspan="3">'.$langs->trans("DraftOrders").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
 
 		if ($num)
 		{
@@ -397,7 +399,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande
 
         print '<table class="noborder" width="100%">';
         print '<tr class="liste_titre">';
-        print '<td colspan="3">'.$langs->trans("DraftSuppliersOrders").($num?' <span class="badge">'.$num.'</span>':'').'</td></tr>';
+        print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
 
         if ($num)
         {
@@ -483,12 +485,12 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
 
 		print '<table class="noborder" width="100%">';
 		print '<tr class="liste_titre">';
-		print '<td colspan="2">';
+		print '<th colspan="2">';
 		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max);
         else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max);
 		else print $langs->trans("BoxTitleLastModifiedCustomers",$max);
-		print '</td>';
-		print '<td align="right">'.$langs->trans("DateModificationShort").'</td>';
+		print '</th>';
+		print '<th align="right">'.$langs->trans("DateModificationShort").'</th>';
 		print '</tr>';
 		if ($num)
 		{
@@ -547,8 +549,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire)
 		$i = 0;
 
 		print '<table class="noborder" width="100%">';
-		print '<tr class="liste_titre"><td>'.$langs->trans("BoxTitleLastModifiedSuppliers",min($max,$num)).'</td>';
-		print '<td align="right">'.$langs->trans("DateModificationShort").'</td>';
+		print '<tr class="liste_titre"><th>'.$langs->trans("BoxTitleLastModifiedSuppliers",min($max,$num)).'</th>';
+		print '<th align="right">'.$langs->trans("DateModificationShort").'</th>';
 		print '</tr>';
 		if ($num)
 		{
@@ -626,7 +628,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO
 		if ($num > 0)
 		{
 			print '<table class="noborder" width="100%">';
-			print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("LastContracts",5).'</td></tr>';
+			print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("LastContracts",5).'</th></tr>';
 			$i = 0;
 
 			$staticcontrat=new Contrat($db);
@@ -687,7 +689,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 			$var=true;
 
 			print '<table class="noborder" width="100%">';
-			print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></td></tr>';
+			print '<tr class="liste_titre"><th colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></th></tr>';
 
 			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
@@ -786,7 +788,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 			$var=true;
 
 			print '<table class="noborder" width="100%">';
-			print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("OrdersOpened").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1"><span class="badge">'.$num.'</span></td></tr>';
+			print '<tr class="liste_titre"><th class="liste_titre" colspan="5">'.$langs->trans("OrdersOpened").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1"><span class="badge">'.$num.'</span></th></tr>';
 
 			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)

+ 12 - 19
htdocs/comm/mailing/card.php

@@ -697,14 +697,19 @@ if ($action == 'create')
 		$htmltext.=$key.' = '.$langs->trans($val).'<br>';
 	}
 	$htmltext.='</i>';
-			
+
+	
+	$availablelink=$form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar');
+	//print '<a href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.$objMod->numero.'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto($langs->trans("ClickToShowDescription"), $imginfo).'</a>';
+	
+	
 	// Print mail form
-	print load_fiche_titre($langs->trans("NewMailing"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext), 'title_generic');
+	print load_fiche_titre($langs->trans("NewMailing"), $availablelink, 'title_generic');
 
 	dol_fiche_head();
 
 	print '<table class="border" width="100%">';
-	print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTitle").'</td><td><input class="flat minwidth200" name="titre" value="'.dol_escape_htmltag(GETPOST('titre')).'"></td></tr>';
+	print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTitle").'</td><td><input class="flat minwidth300" name="titre" value="'.dol_escape_htmltag(GETPOST('titre')).'"></td></tr>';
 	print '<tr><td class="fieldrequired">'.$langs->trans("MailFrom").'</td><td><input class="flat minwidth200" name="from" value="'.$conf->global->MAILING_EMAIL_FROM.'"></td></tr>';
 	print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td><input class="flat minwidth200" name="errorsto" value="'.(!empty($conf->global->MAILING_EMAIL_ERRORSTO)?$conf->global->MAILING_EMAIL_ERRORSTO:$conf->global->MAIN_MAIL_ERRORS_TO).'"></td></tr>';
 
@@ -720,7 +725,7 @@ if ($action == 'create')
 	print '</br><br>';
 
 	print '<table class="border" width="100%">';
-	print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td><td><input class="flat minwidth200" name="sujet" value="'.dol_escape_htmltag(GETPOST('sujet')).'"></td></tr>';
+	print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td><td><input class="flat minwidth200 quatrevingtpercent" name="sujet" value="'.dol_escape_htmltag(GETPOST('sujet')).'"></td></tr>';
 	print '<tr><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
 	print $htmlother->selectColor($_POST['bgcolor'],'bgcolor','new_mailing',0);
 	print '</td></tr>';
@@ -841,11 +846,6 @@ else
 			
 			print '<table class="border" width="100%">';
 
-/*			print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>';
-			print '<td colspan="3">';
-			print $form->showrefnav($object,'id', $linkback);
-			print '</td></tr>';
-*/
 			// Description
 			print '<tr><td class="titlefield">'.$form->editfieldkey("MailTitle",'titre',$object->titre,$object,$user->rights->mailing->creer && $object->statut < 3,'string').'</td><td colspan="3">';
 			print $form->editfieldval("MailTitle",'titre',$object->titre,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
@@ -860,13 +860,6 @@ else
 			print '<tr><td>'.$form->editfieldkey("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string').'</td><td colspan="3">';
 			print $form->editfieldval("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
 			print '</td></tr>';
-
-			// Status
-			/*
-			print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4);
-			if ($object->statut == 2) print ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.')';
-			print'</td></tr>';
-			*/
 			
 			// Nb of distinct emails
 			print '<tr><td>';
@@ -1057,7 +1050,7 @@ else
 			$htmltext.='</i>';
 			
 			// Print mail content
-			print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext), 'title_generic');
+			print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic');
 			
 			dol_fiche_head('');
 			
@@ -1080,7 +1073,7 @@ else
 			}
 			else
 			{
-				print $langs->trans("NoAttachedFiles").'<br>';
+				print '<span class="opacitymedium">'.$langs->trans("NoAttachedFiles").'</span><br>';
 			}
 			print '</td></tr>';
 
@@ -1186,7 +1179,7 @@ else
 			$htmltext.='</i>';
 			
 			// Print mail content
-			print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext), 'title_generic');
+			print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic');
 
 			dol_fiche_head();
 			

+ 16 - 13
htdocs/comm/mailing/index.php

@@ -49,19 +49,22 @@ print load_fiche_titre($langs->trans("MailingArea"));
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
 
-// Recherche emails
-$var=false;
-print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
-print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-print '<table class="noborder nohover" width="100%">';
-print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
-print '<tr '.$bc[$var].'><td class="nowrap">';
-print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
-print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
-print '<tr '.$bc[$var].'><td class="nowrap">';
-print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
-
-print "</table></form><br>\n";
+//if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
+//{
+    // Recherche emails
+    $var=false;
+    print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<table class="noborder nohover" width="100%">';
+    print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
+    print '<tr '.$bc[$var].'><td class="nowrap">';
+    print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
+    print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
+    print '<tr '.$bc[$var].'><td class="nowrap">';
+    print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
+    
+    print "</table></form><br>\n";
+//}
 
 
 // Affiche stats de tous les modules de destinataires mailings

+ 0 - 224
htdocs/comm/propal/apercu.php

@@ -1,224 +0,0 @@
-<?php
-/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
- * Copyright (C) 2004-2007 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2011      Juanjo Menent        <jmenent@2byte.es>
- * Copyright (C) 2014      Frederic France      <frederic.france@free.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- *  \file		htdocs/comm/propal/apercu.php
- *  \ingroup	propal
- *  \brief		Preview tab of propal
- */
-
-require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
-$langs->load('propal');
-$langs->load("bills");
-$langs->load('compta');
-
-// Security check
-$socid=0;
-$id = GETPOST('id','int');
-$ref = GETPOST("ref");
-if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'propal', $id);
-
-
-/*
- * View Mode
- */
-
-$form = new Form($db);
-
-llxHeader();
-
-if ($id > 0 || ! empty($ref))
-{
-	$object = new Propal($db);
-
-	if ($object->fetch($id,$ref) > 0)
-	{
-		$soc = new Societe($db);
-		$soc->fetch($object->socid);
-
-		$head = propal_prepare_head($object);
-		dol_fiche_head($head, 'preview', $langs->trans('Proposal'), 0, 'propal');
-
-
-		/*
-		 *   Propal
-		 */
-        print '<table class="border" width="100%">';
-
-    	$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
-    
-    	// Ref
-    	print '<tr><td>' . $langs->trans('Ref') . '</td><td colspan="5">';
-    	print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
-    	print '</td></tr>';
-
-        // Ref client
-        print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
-        print '<td colspan="5">'.$object->ref_client.'</td>';
-        print '</tr>';
-
-
-        // Thirdparty
-        print '<tr><td>'.$langs->trans('Company').'</td>';
-        print '<td colspan="5">'.$soc->getNomUrl(1).'</td>';
-        print '</tr>';
-
-        // Status
-        print '<tr><td>'.$langs->trans("Status").'</td>';
-        print '<td colspan="5">'.$object->getLibStatut(4).'</td>';
-        print '</tr>';
-
-        // Discount
-		print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
-		if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
-		else print $langs->trans("CompanyHasNoRelativeDiscount");
-		$absolute_discount=$soc->getAvailableDiscounts();
-		print '. ';
-		if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->currency));
-		else print $langs->trans("CompanyHasNoAbsoluteDiscount");
-        print '.</td>';
-        print '</tr>';
-
-        // Date
-        print '<tr><td>'.$langs->trans('Date').'</td>';
-        print '<td>'.dol_print_date($object->date,'daytext').'</td>';
-
-        // Right part with $rowspan lines
-        $rowspan=4;
-        print '<td rowspan="'.$rowspan.'" valign="top" width="50%">';
-
-        /*
-         * Documents
-         */
-        $objectref = dol_sanitizeFileName($object->ref);
-        $dir_output = $conf->propal->dir_output . "/";
-        $filepath = $dir_output . $objectref . "/";
-        $file = $filepath . $objectref . ".pdf";
-        $filedetail = $filepath . $objectref . "-detail.pdf";
-        $relativepath = $objectref.'/'.$objectref.'.pdf';
-        $relativepathdetail = $objectref.'/'.$objectref.'-detail.pdf';
-
-        // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png")
-        $fileimage = $file.'_preview.png';              // If PDF has 1 page
-        $fileimagebis = $file.'_preview-0.pdf.png';     // If PDF has more than one page
-        $relativepathimage = $relativepath.'_preview.png';
-
-        $var=true;
-
-		// Si fichier PDF existe
-		if (file_exists($file))
-		{
-			$encfile = urlencode($file);
-            print '<table class="nobordernopadding" width="100%">';
-            print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Documents").'</td></tr>';
-
-            print '<tr '.$bc[$var].'><td>'.$langs->trans("Proposal").' PDF</td>';
-
-			print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
-
-			print '<td align="right">'.dol_print_size(dol_filesize($file)).'</td>';
-			print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
-			print '</tr>';
-
-			print "</table>\n";
-
-			// Conversion du PDF en image png si fichier png non existant
-			if ((! file_exists($fileimage) && ! file_exists($fileimagebis)) || (filemtime($fileimage) < filemtime($file)))
-			{
-				if (class_exists("Imagick"))
-				{
-					$ret = dol_convert_file($file,'png',$fileimage);
-					if ($ret < 0) $error++;
-				}
-				else
-				{
-					$langs->load("errors");
-					print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
-				}
-			}
-		}
-
-        print '</td>';
-        print '</tr>';
-
-        // Total HT - left part
-        print '<tr><td>'.$langs->trans('AmountHT').'</td>';
-        print '<td align="right" class="nowrap"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
-        print '</tr>';
-
-        // Total VAT - left part
-        print '<tr><td>'.$langs->trans('AmountVAT').'</td>';
-        print '<td align="right" class="nowrap"><b>' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
-        print '</tr>';
-
-        // Total TTC - left part
-        print '<tr><td>'.$langs->trans('AmountTTC').'</td>';
-        print '<td align="right" class="nowrap"><b>' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
-        print '</tr>';
-
-        print '</table>';
-
-		dol_fiche_end();
-	}
-	else
-	{
-		// Propal non trouvee
-		print $langs->trans("ErrorPropalNotFound",$_GET["id"]);
-	}
-}
-
-print '<table class="border" width="100%">';
-print '<tr><td>';
-print '<div class="photolist">';
-// Si fichier png PDF d'1 page trouve
-if (file_exists($fileimage))
-{
-	print '<img class="photo photowithmargin" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&amp;file='.urlencode($relativepathimage).'">';
-}
-// Si fichier png PDF de plus d'1 page trouve
-elseif (file_exists($fileimagebis))
-{
-	$multiple = preg_replace('/\.png/','',$relativepath) . "-";
-
-	for ($i = 0; $i < 20; $i++)
-	{
-		$preview = $multiple.$i.'.png';
-
-		if (file_exists($dir_output.$preview))
-		{
-			print '<img class="photo photowithmargin" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&amp;file='.urlencode($preview).'"><p>';
-		}
-	}
-}
-print '</div>';
-print '</td></tr>';
-print '</table>';
-
-
-llxFooter();
-
-$db->close();

+ 107 - 130
htdocs/comm/propal/card.php

@@ -751,9 +751,11 @@ if (empty($reshook))
 
 			$db->begin();
 
+            // $tva_tx can be 'x.x (XXX)'
+            
 			// Ecrase $pu par celui du produit
 			// Ecrase $desc par celui du produit
-			// Ecrase $txtva par celui du produit
+			// Ecrase $tva_tx par celui du produit
 			// Replaces $fk_unit with the product unit
 			if (! empty($idprod)) {
 				$prod = new Product($db);
@@ -761,111 +763,113 @@ if (empty($reshook))
 
 				$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
 
-				// If prices fields are update
-					$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
-					$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
-					if (empty($tva_tx)) $tva_npr=0;
+				// Update if prices fields are defined
+				$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
+				$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
+				if (empty($tva_tx)) $tva_npr=0;
 
-					$pu_ht = $prod->price;
-					$pu_ttc = $prod->price_ttc;
-					$price_min = $prod->price_min;
-					$price_base_type = $prod->price_base_type;
+				$pu_ht = $prod->price;
+				$pu_ttc = $prod->price_ttc;
+				$price_min = $prod->price_min;
+				$price_base_type = $prod->price_base_type;
 
-					// On defini prix unitaire
-					if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level)
+				// On defini prix unitaire
+				if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level)
+				{
+				    $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
+					$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
+					$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
+					$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
+					if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))  // using this option is a bug. kept for backward compatibility
 					{
-						$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
-						$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
-						$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
-						$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
-						if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))  // using this option is a bug. kept for backward compatibility
-						{
-						  if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
-						  if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
-						}
+					  if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
+					  if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
 					}
-					elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
-					{
-						require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
+				}
+				elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+				{
+					require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
 
-						$prodcustprice = new Productcustomerprice($db);
+					$prodcustprice = new Productcustomerprice($db);
 
-						$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
+					$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
 
-						$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
-						if ($result) {
-							if (count($prodcustprice->lines) > 0) {
-								$pu_ht = price($prodcustprice->lines [0]->price);
-								$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
-								$price_base_type = $prodcustprice->lines [0]->price_base_type;
-								$tva_tx = $prodcustprice->lines [0]->tva_tx;
-							}
+					$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
+					if ($result) {
+						if (count($prodcustprice->lines) > 0) {
+							$pu_ht = price($prodcustprice->lines[0]->price);
+							$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
+							$price_base_type = $prodcustprice->lines[0]->price_base_type;
+							$tva_tx = $prodcustprice->lines[0]->tva_tx;
 						}
 					}
+				}
 
-					// if price ht is forced (ie: calculated by margin rate and cost price)
-					if (! empty($price_ht)) {
-						$pu_ht = price2num($price_ht, 'MU');
-						$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
-					}
-
-					// On reevalue prix selon taux tva car taux tva transaction peut etre different
-					// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
-					elseif ($tva_tx != $prod->tva_tx) {
-						if ($price_base_type != 'HT') {
-							$pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU');
-						} else {
-							$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
-						}
+				$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
+				$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
+				
+				// if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ?
+				if (! empty($price_ht)) {
+					$pu_ht = price2num($price_ht, 'MU');
+					$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
+				}
+				// On reevalue prix selon taux tva car taux tva transaction peut etre different
+				// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
+				elseif ($tmpvat != $tmpprodvat) {
+					if ($price_base_type != 'HT') {
+						$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
+					} else {
+						$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
 					}
+				}
 
-					$desc = '';
-
-					// Define output language
-					if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
-						$outputlangs = $langs;
-						$newlang = '';
-						if (empty($newlang) && GETPOST('lang_id'))
-							$newlang = GETPOST('lang_id');
-						if (empty($newlang))
-							$newlang = $object->thirdparty->default_lang;
-						if (! empty($newlang)) {
-							$outputlangs = new Translate("", $conf);
-							$outputlangs->setDefaultLang($newlang);
-						}
+				$desc = '';
 
-						$desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
-					} else {
-						$desc = $prod->description;
+				// Define output language
+				if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
+					$outputlangs = $langs;
+					$newlang = '';
+					if (empty($newlang) && GETPOST('lang_id'))
+						$newlang = GETPOST('lang_id');
+					if (empty($newlang))
+						$newlang = $object->thirdparty->default_lang;
+					if (! empty($newlang)) {
+						$outputlangs = new Translate("", $conf);
+						$outputlangs->setDefaultLang($newlang);
 					}
 
-					$desc = dol_concatdesc($desc, $product_desc);
+					$desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
+				} else {
+					$desc = $prod->description;
+				}
+
+				$desc = dol_concatdesc($desc, $product_desc);
 
-					// Add dimensions into product description
-					/*if (empty($conf->global->MAIN_PRODUCT_DISABLE_AUTOADD_DIM))
-					{
-						$text='';
-						if ($prod->weight) $text.=($text?"\n":"").$outputlangs->trans("Weight").': '.$prod->weight.' '.$prod->weight_units;
-						if ($prod->length) $text.=($text?"\n":"").$outputlangs->trans("Length").': '.$prod->length.' '.$prod->length_units;
-						if ($prod->surface) $text.=($text?"\n":"").$outputlangs->trans("Surface").': '.$prod->surface.' '.$prod->surface_units;
-						if ($prod->volume) $text.=($text?"\n":"").$outputlangs->trans("Volume").': '.$prod->volume.' '.$prod->volume_units;
+				// Add dimensions into product description
+				/*if (empty($conf->global->MAIN_PRODUCT_DISABLE_AUTOADD_DIM))
+				{
+					$text='';
+					if ($prod->weight) $text.=($text?"\n":"").$outputlangs->trans("Weight").': '.$prod->weight.' '.$prod->weight_units;
+					if ($prod->length) $text.=($text?"\n":"").$outputlangs->trans("Length").': '.$prod->length.' '.$prod->length_units;
+					if ($prod->surface) $text.=($text?"\n":"").$outputlangs->trans("Surface").': '.$prod->surface.' '.$prod->surface_units;
+					if ($prod->volume) $text.=($text?"\n":"").$outputlangs->trans("Volume").': '.$prod->volume.' '.$prod->volume_units;
 
-						$desc = dol_concatdesc($desc, $text);
-					}*/
+					$desc = dol_concatdesc($desc, $text);
+				}*/
 
-					// Add custom code and origin country into description
-					if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
-					{
-						$tmptxt = '(';
-						if (! empty($prod->customcode))
-							$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
-						if (! empty($prod->customcode) && ! empty($prod->country_code))
-							$tmptxt .= ' - ';
-						if (! empty($prod->country_code))
-							$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
-						$tmptxt .= ')';
-						$desc = dol_concatdesc($desc, $tmptxt);
-					}
+				// Add custom code and origin country into description
+				if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
+				{
+					$tmptxt = '(';
+					if (! empty($prod->customcode))
+						$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
+					if (! empty($prod->customcode) && ! empty($prod->country_code))
+						$tmptxt .= ' - ';
+					if (! empty($prod->country_code))
+						$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
+					$tmptxt .= ')';
+					$desc = dol_concatdesc($desc, $tmptxt);
+				}
 
 				$type = $prod->type;
 				$fk_unit = $prod->fk_unit;
@@ -1317,8 +1321,18 @@ if ($action == 'create')
 			// Replicate extrafields
 			$objectsrc->fetch_optionals($originid);
 			$object->array_options = $objectsrc->array_options;
+			
+			if (!empty($conf->multicurrency->enabled))
+			{
+			    if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
+			    if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx))	$currency_tx = $objectsrc->multicurrency_tx;
+			}
 		}
 	}
+	else
+	{
+	    if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
+	}
 
 	$object = new Propal($db);
 
@@ -1496,7 +1510,6 @@ if ($action == 'create')
 		print '<tr>';
 		print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
         print '<td colspan="3" class="maxwidthonsmartphone">';
-		$currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency));
 	    print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
 		print '</td></tr>';
 	}
@@ -1662,7 +1675,7 @@ if ($action == 'create')
 	$soc->fetch($object->socid);
 
 	$head = propal_prepare_head($object);
-	dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal');
+	dol_fiche_head($head, 'comm', $langs->trans('Proposal'), -1, 'propal');
 
 	$formconfirm = '';
 
@@ -1791,42 +1804,7 @@ if ($action == 'create')
 
 	print '<table class="border" width="100%">';
 
-    // Ref
-    /*
-	print '<tr><td>' . $langs->trans('Ref') . '</td><td colspan="5">';
-	print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
-	print '</td></tr>';
-	*/
-
-	// Ref customer
-	/*
-	print '<tr><td>';
-	print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
-	print $langs->trans('RefCustomer') . '</td>';
-	if ($action != 'refclient' && ! empty($object->brouillon))
-		print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=refclient&amp;id=' . $object->id . '">' . img_edit($langs->trans('Modify')) . '</a></td>';
-	print '</td></tr></table>';
-	print '</td><td colspan="5">';
-	if ($user->rights->propal->creer && $action == 'refclient') {
-		print '<form action="'.$_SERVER["PHP_SELF"].'?id=' . $object->id . '" method="post">';
-		print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
-		print '<input type="hidden" name="action" value="set_ref_client">';
-		print '<input type="text" class="flat" size="20" name="ref_client" value="' . $object->ref_client . '">';
-		print ' <input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
-		print '</form>';
-	} else {
-		print $object->ref_client;
-	}
-	print '</td>';
-	print '</tr>';
-    */
-
-	// Company
-	/*
-	print '<tr><td>' . $langs->trans('Company') . '</td><td colspan="5">' . $soc->getNomUrl(1) . '</td>';
-	print '</tr>';*/
-
-	// Lin for thirdparty discounts
+	// Link for thirdparty discounts
 	print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
 	if ($soc->remise_percent)
 		print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
@@ -2034,7 +2012,7 @@ if ($action == 'create')
 		print '<table class="nobordernopadding" width="100%"><tr><td>';
 		print fieldLabel('CurrencyRate','multicurrency_tx');
 		print '</td>';
-		if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
+		if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency)
 			print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
 		print '</tr></table>';
 		print '</td><td>';
@@ -2045,7 +2023,7 @@ if ($action == 'create')
 			$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
 		} else {
 			$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
-			if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code != $conf->currency) {
+			if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
 				print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
 				print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
 				print '</div>';
@@ -2379,7 +2357,7 @@ if ($action == 'create')
 				{
 					if (! empty($conf->facture->enabled) && $user->rights->facture->creer)
 					{
-						print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddBill") . '</a></div>';
+						print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddBill") . '</a></div>';
 					}
 
 					$arrayofinvoiceforpropal = $object->getInvoiceArrayList();
@@ -2410,7 +2388,6 @@ if ($action == 'create')
 
 		print '</div>';
 	}
-	print "<br>\n";
 
 	//Select mail models is same action as presend
 	if (GETPOST('modelselected')) $action = 'presend';

+ 3 - 14
htdocs/comm/propal/class/propal.class.php

@@ -413,7 +413,7 @@ class Propal extends CommonObject
         $qty=price2num($qty);
         $pu_ht=price2num($pu_ht);
         $pu_ttc=price2num($pu_ttc);
-        $txtva=price2num($txtva);
+        $txtva=price2num($txtva);               // $txtva can have format '5.0(XXX)' or '5'
         $txlocaltax1=price2num($txlocaltax1);
         $txlocaltax2=price2num($txlocaltax2);
     	$pa_ht=price2num($pa_ht);
@@ -428,7 +428,7 @@ class Propal extends CommonObject
 
         // Check parameters
         if ($type < 0) return -1;
-
+      
         if ($this->statut == self::STATUS_DRAFT)
         {
             $this->db->begin();
@@ -1166,14 +1166,9 @@ class Propal extends CommonObject
         }
 
         $clonedObj->id=0;
+        $clonedObj->ref='';
         $clonedObj->statut=self::STATUS_DRAFT;
 
-        if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
-        {
-            $this->error='ErrorSetupNotComplete';
-            return -1;
-        }
-
         // Clear fields
         $clonedObj->user_author	= $user->id;
         $clonedObj->user_valid	= '';
@@ -1182,12 +1177,6 @@ class Propal extends CommonObject
         $clonedObj->fin_validite	= $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600);
         if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client	= '';
 
-        // Set ref
-        require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php';
-        $obj = $conf->global->PROPALE_ADDON;
-        $modPropale = new $obj;
-        $clonedObj->ref = $modPropale->getNextValue($objsoc,$clonedObj);
-
         // Create clone
 
         $result=$clonedObj->create($user);

+ 1 - 1
htdocs/comm/propal/contact.php

@@ -151,7 +151,7 @@ $formother = new FormOther($db);
 if ($object->id > 0)
 {
     $head = propal_prepare_head($object);
-	dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
+	dol_fiche_head($head, 'contact', $langs->trans("Proposal"), -1, 'propal');
 
 
 	// Proposal card

+ 1 - 1
htdocs/comm/propal/document.php

@@ -89,7 +89,7 @@ if ($object->id > 0)
 	$upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
 
 	$head = propal_prepare_head($object);
-	dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
+	dol_fiche_head($head, 'document', $langs->trans('Proposal'), -1, 'propal');
 
 	// Construit liste des fichiers
 	$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);

+ 11 - 11
htdocs/comm/propal/index.php

@@ -59,17 +59,17 @@ print load_fiche_titre($langs->trans("ProspectionArea"));
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
 
-/*
- * Search form
- */
-$var=false;
-print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
-print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-print '<table class="noborder nohover" width="100%">';
-print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
-print '<tr '.$bc[$var].'><td>';
-print $langs->trans("Proposal").':</td><td><input type="text" class="flat" name="sall" size=18></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
-print "</table></form><br>\n";
+if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
+{
+    $var=false;
+    print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<table class="noborder nohover" width="100%">';
+    print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
+    print '<tr '.$bc[$var].'><td>';
+    print $langs->trans("Proposal").':</td><td><input type="text" class="flat" name="sall" size=18></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
+    print "</table></form><br>\n";
+}
 
 
 /*

+ 1 - 1
htdocs/comm/propal/info.php

@@ -59,7 +59,7 @@ llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_c
 $object->fetch_thirdparty();
 
 $head = propal_prepare_head($object);
-dol_fiche_head($head, 'info', $langs->trans('Proposal'), 0, 'propal');
+dol_fiche_head($head, 'info', $langs->trans('Proposal'), -1, 'propal');
 
 $object->info($object->id);
 

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