Преглед изворни кода

Merge branch 'develop' into dev_updatedocker

Florian HENRY пре 4 година
родитељ
комит
07242a1c5d
100 измењених фајлова са 11337 додато и 10396 уклоњено
  1. 1 1
      .travis.yml
  2. 9 8
      ChangeLog
  3. 8 6
      SECURITY.md
  4. 229 163
      htdocs/accountancy/admin/index.php
  5. 19 12
      htdocs/accountancy/bookkeeping/balance.php
  6. 9 2
      htdocs/accountancy/class/accountingaccount.class.php
  7. 33 33
      htdocs/accountancy/customer/lines.php
  8. 3 3
      htdocs/accountancy/customer/list.php
  9. 65 65
      htdocs/accountancy/expensereport/index.php
  10. 43 43
      htdocs/accountancy/expensereport/lines.php
  11. 89 89
      htdocs/accountancy/expensereport/list.php
  12. 57 57
      htdocs/accountancy/supplier/index.php
  13. 32 32
      htdocs/accountancy/supplier/lines.php
  14. 4 4
      htdocs/accountancy/supplier/list.php
  15. 19 19
      htdocs/adherents/admin/adherent_emails.php
  16. 42 42
      htdocs/adherents/card.php
  17. 218 218
      htdocs/adherents/class/adherent_type.class.php
  18. 1 1
      htdocs/adherents/subscription.php
  19. 158 158
      htdocs/adherents/type.php
  20. 161 161
      htdocs/admin/bank.php
  21. 141 141
      htdocs/admin/bom.php
  22. 144 144
      htdocs/admin/boxes.php
  23. 169 169
      htdocs/admin/commande.php
  24. 1 1
      htdocs/admin/company.php
  25. 138 138
      htdocs/admin/contract.php
  26. 46 46
      htdocs/admin/emailcollector_card.php
  27. 124 124
      htdocs/admin/expedition.php
  28. 427 427
      htdocs/admin/facture.php
  29. 143 143
      htdocs/admin/holiday.php
  30. 471 471
      htdocs/admin/mails_templates.php
  31. 574 0
      htdocs/admin/mails_ticket.php
  32. 1 3
      htdocs/admin/menus/edit.php
  33. 141 141
      htdocs/admin/mrp.php
  34. 125 125
      htdocs/admin/reception_setup.php
  35. 143 143
      htdocs/admin/stock.php
  36. 174 174
      htdocs/bom/bom_card.php
  37. 15 15
      htdocs/bom/tpl/objectline_create.tpl.php
  38. 712 712
      htdocs/categories/class/api_categories.class.php
  39. 278 278
      htdocs/categories/class/categorie.class.php
  40. 66 51
      htdocs/comm/action/card.php
  41. 454 448
      htdocs/comm/action/class/actioncomm.class.php
  42. 4 4
      htdocs/comm/action/class/actioncommreminder.class.php
  43. 297 278
      htdocs/comm/action/index.php
  44. 2 2
      htdocs/comm/action/list.php
  45. 5 5
      htdocs/comm/index.php
  46. 0 1
      htdocs/comm/mailing/card.php
  47. 9 9
      htdocs/comm/propal/card.php
  48. 6 6
      htdocs/comm/propal/class/propal.class.php
  49. 78 4
      htdocs/comm/propal/list.php
  50. 61 10
      htdocs/commande/class/api_orders.class.php
  51. 37 8
      htdocs/commande/class/commande.class.php
  52. 26 20
      htdocs/compta/facture/card.php
  53. 32 7
      htdocs/compta/facture/class/facture.class.php
  54. 59 20
      htdocs/compta/index.php
  55. 39 39
      htdocs/compta/prelevement/card.php
  56. 9 9
      htdocs/compta/prelevement/class/bonprelevement.class.php
  57. 35 35
      htdocs/compta/prelevement/create.php
  58. 56 56
      htdocs/compta/prelevement/factures.php
  59. 33 33
      htdocs/compta/prelevement/fiche-rejet.php
  60. 544 544
      htdocs/contact/card.php
  61. 23 23
      htdocs/contact/list.php
  62. 14 14
      htdocs/core/actions_addupdatedelete.inc.php
  63. 7 7
      htdocs/core/actions_sendmails.inc.php
  64. 194 194
      htdocs/core/ajax/ajaxdirpreview.php
  65. 176 168
      htdocs/core/class/CMailFile.class.php
  66. 209 207
      htdocs/core/class/commonobject.class.php
  67. 1 1
      htdocs/core/class/extrafields.class.php
  68. 248 248
      htdocs/core/class/html.form.class.php
  69. 251 251
      htdocs/core/class/html.formactions.class.php
  70. 200 200
      htdocs/core/class/html.formcompany.class.php
  71. 76 76
      htdocs/core/class/html.formfile.class.php
  72. 86 84
      htdocs/core/class/html.formmail.class.php
  73. 3 3
      htdocs/core/class/html.formticket.class.php
  74. 6 8
      htdocs/core/class/menubase.class.php
  75. 8 0
      htdocs/core/lib/admin.lib.php
  76. 21 21
      htdocs/core/lib/ajax.lib.php
  77. 512 512
      htdocs/core/lib/company.lib.php
  78. 10 10
      htdocs/core/lib/expedition.lib.php
  79. 4 4
      htdocs/core/lib/files.lib.php
  80. 341 341
      htdocs/core/lib/functions.lib.php
  81. 463 463
      htdocs/core/lib/functions2.lib.php
  82. 1 1
      htdocs/core/lib/functionsnumtoword.lib.php
  83. 19 19
      htdocs/core/lib/hrm.lib.php
  84. 84 84
      htdocs/core/lib/images.lib.php
  85. 111 111
      htdocs/core/lib/member.lib.php
  86. 9 9
      htdocs/core/lib/multicurrency.lib.php
  87. 24 24
      htdocs/core/lib/reception.lib.php
  88. 3 3
      htdocs/core/lib/resource.lib.php
  89. 46 46
      htdocs/core/lib/salaries.lib.php
  90. 2 2
      htdocs/core/lib/security.lib.php
  91. 1 1
      htdocs/core/lib/takepos.lib.php
  92. 526 526
      htdocs/core/lib/ticket.lib.php
  93. 9 9
      htdocs/core/menus/init_menu_auguria.sql
  94. 6 3
      htdocs/core/menus/standard/auguria.lib.php
  95. 299 296
      htdocs/core/menus/standard/eldy.lib.php
  96. 0 1
      htdocs/core/modules/DolibarrModules.class.php
  97. 40 40
      htdocs/core/modules/bank/doc/pdf_ban.modules.php
  98. 92 92
      htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
  99. 89 89
      htdocs/core/modules/cheque/doc/pdf_blochet.class.php
  100. 104 104
      htdocs/core/modules/contract/doc/pdf_strato.modules.php

+ 1 - 1
.travis.yml

@@ -135,7 +135,7 @@ install:
   fi
   if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
       composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \
-                                                 jakub-onderka/php-parallel-lint ^0 \
+                                                 jakub-onderka/php-parallel-lint ^1 \
                                                  jakub-onderka/php-console-highlighter ^0 \
                                                  squizlabs/php_codesniffer ^3
     fi

+ 9 - 8
ChangeLog

@@ -13,7 +13,8 @@ WARNING:
 Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
 * Properties ->contactid has been renamed into ->contact_id
 * Rename property $paiementid in API api_supplier_invoices into $payment_mode_id
-
+* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in
+  your email templates. 
 
 ***** ChangeLog for 12.0.2 compared to 12.0.1 *****
 FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet
@@ -341,14 +342,14 @@ Following changes may create regressions for some external modules, but were nec
 
 WARNING FOR DOLIWAMP USERS ONLY:
 
-Only people that installed Dolibarr using the all-in-one autoinstaller for Windows called "DoliWAMP" are concerned by the following warnings:
+Only people that installed Dolibarr using the all-in-one auto-installer for Windows called "DoliWAMP" are concerned by the following warnings:
  
-* DoliWAMP autoinstaller for Windows is not more available on 32bits systems. Use standard package if you need to use such architecture.
-* It is not possible to migrate from an installation done with the old DoliWAMP autoinstaller for Windows by using this new one. You must make a backup 
-  of your database, make a fresh installation using the new installer and reload your backup. Don't forget that DoliWAMP is a good solution to make a 
-  quick test of Dolibarr on your local computer but was never recommanded as a production solution on a local desktop since a desktop computer has not
-  a backup and security policy as good as on a server (when there is one). 
-  DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard package for production.
+* DoliWAMP auto-installer for Windows is no more available on 32 bits systems. Use standard package if you need to use such architecture.
+* It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one. 
+  You must make a backup of your database, make a fresh installation using the new installer and reload your backup. 
+  Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production 
+  solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one). 
+  DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard packages for production.
 
 
 ***** ChangeLog for 11.0.5 compared to 11.0.4 *****

+ 8 - 6
SECURITY.md

@@ -62,12 +62,12 @@ No vulnerability disclosure, including partial is allowed for the moment.
 
 ## Scope for qualified vulnerabilities
 
-ONLY vulnerabilities discovered when the following setup is used are accepted:
+ONLY vulnerabilities discovered, when the following setup on tested platform is used, are accepted:
 
 * $dolibarr_main_prod must be 1 into conf.php
 * $dolibarr_nocsrfcheck must not be set to 0 (should be 1 by default) into conf.php
-* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be switched soon to 1 by default)
-* ONLY security reports on "stable" modules are allowed (troubles into experimental and developement modules are not accepted).
+* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be hard switched soon to 1 by default)
+* ONLY security reports on "stable" modules are allowed (troubles into "experimental" and "developement" modules are not accepted).
 
 Scope is the web application (back office) and the APIs.
 
@@ -84,6 +84,8 @@ Scope is the web application (back office) and the APIs.
 * CORS with real security impact
 * Horizontal and vertical privilege escalation
 * "HTTP Host Header" XSS
+* Software version disclosure (for non admin users only)
+* Stack traces or path disclosure (for non admin users only)
 
 
 ## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting
@@ -93,8 +95,6 @@ Scope is the web application (back office) and the APIs.
 * Mixed content warnings
 * Denial of Service attacks
 * Clickjacking/UI redressing
-* Software version disclosure
-* Stack traces or path disclosure
 * Physical or social engineering attempts
 * Recently disclosed 0-day vulnerabilities
 * Presence of autocomplete attribute on web forms
@@ -104,5 +104,7 @@ Scope is the web application (back office) and the APIs.
 * Missing security-related HTTP headers which do not lead directly to a vulnerability
 * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated
 * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC)
-* Reports on features flagged as experimental
+* Reports on features flagged as "experimental" or "development"
+* Software version disclosure when logged user is admin
+* Stack traces or path disclosure when logged user is admin
 

+ 229 - 163
htdocs/accountancy/admin/index.php

@@ -46,8 +46,8 @@ $action = GETPOST('action', 'aZ09');
 
 // Parameters ACCOUNTING_* and others
 $list = array(
-    'ACCOUNTING_LENGTH_GACCOUNT',
-    'ACCOUNTING_LENGTH_AACCOUNT',
+	'ACCOUNTING_LENGTH_GACCOUNT',
+	'ACCOUNTING_LENGTH_AACCOUNT',
 //    'ACCOUNTING_LENGTH_DESCRIPTION',         // adjust size displayed for lines description for dol_trunc
 //    'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
 );
@@ -67,17 +67,17 @@ if ($action == 'update') {
 
 	if (!$error)
 	{
-	    foreach ($list as $constname)
-	    {
-	        $constvalue = GETPOST($constname, 'alpha');
-
-	        if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
-	            $error++;
-	        }
-	    }
-	    if ($error) {
-	    	setEventMessages($langs->trans("Error"), null, 'errors');
-	    }
+		foreach ($list as $constname)
+		{
+			$constvalue = GETPOST($constname, 'alpha');
+
+			if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
+				$error++;
+			}
+		}
+		if ($error) {
+			setEventMessages($langs->trans("Error"), null, 'errors');
+		}
 
 		foreach ($list_binding as $constname)
 		{
@@ -96,46 +96,46 @@ if ($action == 'update') {
 		}
 	}
 
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    }
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setlistsorttodo') {
-    $setlistsorttodo = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setlistsorttodo = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setlistsortdone') {
-    $setlistsortdone = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setlistsortdone = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setmanagezero') {
-    $setmanagezero = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setmanagezero = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setdisabledirectinput') {
@@ -163,15 +163,51 @@ if ($action == 'setenabledraftexport') {
 }
 
 if ($action == 'setenablesubsidiarylist') {
-    $setenablesubsidiarylist = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setenablesubsidiarylist = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
+}
+
+if ($action == 'setdisablebindingonsales') {
+	$setdisablebindingonsales = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
+}
+
+if ($action == 'setdisablebindingonpurchases') {
+	$setdisablebindingonpurchases = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
+}
+
+if ($action == 'setdisablebindingonexpensereports') {
+	$setdisablebindingonexpensereports = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 /*
@@ -226,82 +262,78 @@ print '<tr class="liste_titre">';
 print '<td colspan="2">'.$langs->trans('Options').'</td>';
 print "</tr>\n";
 
-if (!empty($user->admin))
-{
-    // TO DO Mutualize code for yes/no constants
-
-    /* Set this option as a hidden option but keep it for some needs.
-	print '<tr>';
-	print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
-	if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=0">';
-		print img_picto($langs->trans("Activated"), 'switch_on');
-		print '</a></td>';
-	} else {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=1">';
-		print img_picto($langs->trans("Disabled"), 'switch_off');
-		print '</a></td>';
-	}
-	print '</tr>';
-	*/
-
-	print '<tr class="oddeven">';
-	print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
-	if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=0">';
-		print img_picto($langs->trans("Activated"), 'switch_on');
-		print '</a></td>';
-	} else {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=1">';
-		print img_picto($langs->trans("Disabled"), 'switch_off');
-		print '</a></td>';
-	}
-	print '</tr>';
+// TO DO Mutualize code for yes/no constants
+
+/* Set this option as a hidden option but keep it for some needs.
+print '<tr>';
+print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
+if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=0">';
+	print img_picto($langs->trans("Activated"), 'switch_on');
+	print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=1">';
+	print img_picto($langs->trans("Disabled"), 'switch_off');
+	print '</a></td>';
+}
+print '</tr>';
+*/
 
-    print '<tr>';
-    print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
-    if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
-        print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">';
-        print img_picto($langs->trans("Activated"), 'switch_on');
-        print '</a></td>';
-    } else {
-        print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">';
-        print img_picto($langs->trans("Disabled"), 'switch_off');
-        print '</a></td>';
-    }
-    print '</tr>';
-
-    print '<tr>';
-    print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
-    if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
-        print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">';
-        print img_picto($langs->trans("Activated"), 'switch_on');
-        print '</a></td>';
-    } else {
-        print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">';
-        print img_picto($langs->trans("Disabled"), 'switch_off');
-        print '</a></td>';
-    }
-    print '</tr>';
-
-	// Param a user $user->rights->accounting->chartofaccount can access
-	foreach ($list as $key)
-	{
-		print '<tr class="oddeven value">';
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
+if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=0">';
+	print img_picto($langs->trans("Activated"), 'switch_on');
+	print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=1">';
+	print img_picto($langs->trans("Disabled"), 'switch_off');
+	print '</a></td>';
+}
+print '</tr>';
+
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
+if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">';
+    print img_picto($langs->trans("Activated"), 'switch_on');
+    print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">';
+    print img_picto($langs->trans("Disabled"), 'switch_off');
+    print '</a></td>';
+}
+print '</tr>';
+
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
+if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">';
+    print img_picto($langs->trans("Activated"), 'switch_on');
+    print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">';
+    print img_picto($langs->trans("Disabled"), 'switch_off');
+    print '</a></td>';
+}
+print '</tr>';
 
-		if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
+// Param a user $user->rights->accounting->chartofaccount can access
+foreach ($list as $key)
+{
+	print '<tr class="oddeven value">';
 
-		// Param
-		$label = $langs->trans($key);
-		print '<td>'.$label.'</td>';
-		// Value
-		print '<td class="right">';
-		print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
+	if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
 
-		print '</td>';
+	// Param
+	$label = $langs->trans($key);
+	print '<td>'.$label.'</td>';
+	// Value
+	print '<td class="right">';
+	print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
 
-		print '</tr>';
-	}
+	print '</td>';
+	print '</tr>';
 }
 print '</table>';
 print '<br>';
@@ -312,57 +344,91 @@ print '<tr class="liste_titre">';
 print '<td colspan="2">'.$langs->trans('BindingOptions').'</td>';
 print "</tr>\n";
 
-if (!empty($user->admin))
-{
-	// TO DO Mutualize code for yes/no constants
-	print '<tr class="oddeven">';
-	print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
-	if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=0">';
-		print img_picto($langs->trans("Activated"), 'switch_on');
-		print '</a></td>';
-	} else {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=1">';
-		print img_picto($langs->trans("Disabled"), 'switch_off');
-		print '</a></td>';
-	}
-	print '</tr>';
-
-	print '<tr>';
-	print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
-	if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=0">';
-		print img_picto($langs->trans("Activated"), 'switch_on');
-		print '</a></td>';
-	} else {
-		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=1">';
-		print img_picto($langs->trans("Disabled"), 'switch_off');
-		print '</a></td>';
-	}
-	print '</tr>';
+// TO DO Mutualize code for yes/no constants
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
+if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=0">';
+	print img_picto($langs->trans("Activated"), 'switch_on');
+	print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=1">';
+	print img_picto($langs->trans("Disabled"), 'switch_off');
+	print '</a></td>';
 }
+print '</tr>';
+
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
+if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=0">';
+	print img_picto($langs->trans("Activated"), 'switch_on');
+	print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=1">';
+	print img_picto($langs->trans("Disabled"), 'switch_off');
+	print '</a></td>';
+}
+print '</tr>';
 
 // Param a user $user->rights->accounting->chartofaccount can access
 foreach ($list_binding as $key)
 {
-    print '<tr class="oddeven value">';
-
-    // Param
-    $label = $langs->trans($key);
-    print '<td>'.$label.'</td>';
-    // Value
-    print '<td class="right">';
-    if ($key == 'ACCOUNTING_DATE_START_BINDING') {
+	print '<tr class="oddeven value">';
+
+	// Param
+	$label = $langs->trans($key);
+	print '<td>'.$label.'</td>';
+	// Value
+	print '<td class="right">';
+	if ($key == 'ACCOUNTING_DATE_START_BINDING') {
 		print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1);
 	} else {
 		print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
 	}
 
-    print '</td>';
-
-    print '</tr>';
+	print '</td>';
+	print '</tr>';
 }
 
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").'</td>';
+if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisablebindingonsales&value=0">';
+	print img_picto($langs->trans("Activated"), 'switch_on');
+	print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisablebindingonsales&value=1">';
+	print img_picto($langs->trans("Disabled"), 'switch_off');
+	print '</a></td>';
+}
+print '</tr>';
+
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").'</td>';
+if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisablebindingonpurchases&value=0">';
+	print img_picto($langs->trans("Activated"), 'switch_on');
+	print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisablebindingonpurchases&value=1">';
+	print img_picto($langs->trans("Disabled"), 'switch_off');
+	print '</a></td>';
+}
+print '</tr>';
+
+print '<tr class="oddeven">';
+print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").'</td>';
+if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisablebindingonexpensereports&value=0">';
+	print img_picto($langs->trans("Activated"), 'switch_on');
+	print '</a></td>';
+} else {
+	print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisablebindingonexpensereports&value=1">';
+	print img_picto($langs->trans("Disabled"), 'switch_off');
+	print '</a></td>';
+}
+print '</tr>';
 
 print '</table>';
 

+ 19 - 12
htdocs/accountancy/bookkeeping/balance.php

@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2016       Olivier Geffroy         <jeff@jeffinfo.com>
  * Copyright (C) 2016       Florian Henry           <florian.henry@open-concept.pro>
- * Copyright (C) 2016-2019  Alexandre Spangaro      <aspangaro@open-dsi.fr>
+ * Copyright (C) 2016-2020  Alexandre Spangaro      <aspangaro@open-dsi.fr>
  * Copyright (C) 2018       Frédéric France         <frederic.france@netlogic.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -31,6 +31,7 @@ require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -244,7 +245,7 @@ if ($action != 'export_csv')
 	print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
 
 	print '<tr class="liste_titre_filter">';
-	print '<td class="liste_titre" colspan="6">';
+	print '<td class="liste_titre" colspan="5">';
 	print $langs->trans('From');
 	print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
 	print ' ';
@@ -260,7 +261,6 @@ if ($action != 'export_csv')
 
 	print '<tr class="liste_titre">';
 	print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
-	print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
 	print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
 	print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
 	print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
@@ -274,6 +274,8 @@ if ($action != 'export_csv')
 	$sous_total_credit = 0;
 	$displayed_account = "";
 
+    $accountingaccountstatic = new AccountingAccount($db);
+
 	$sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity;
 	$sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte";
 	$resql = $db->query($sql);
@@ -286,12 +288,18 @@ if ($action != 'export_csv')
 
 	foreach ($object->lines as $line)
 	{
+        $accountingaccountstatic->fetch(null, $line->numero_compte, true);
+        if (!empty($accountingaccountstatic->account_number)) {
+            $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
+        } else {
+            $accounting_account = length_accountg($line->numero_compte);
+        }
+
 		$link = '';
 		$total_debit += $line->debit;
 		$total_credit += $line->credit;
-		$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
 		$root_account_description = $object->get_compte_racine($line->numero_compte);
-		if (empty($description)) {
+		if (empty($accountingaccountstatic->account_number)) {
 			$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
 		}
 		print '<tr class="oddeven">';
@@ -303,7 +311,7 @@ if ($action != 'export_csv')
 				// Show subtotal per accounting account
 				if ($displayed_account != "") {
 					print '<tr class="liste_total">';
-					print '<td class="right" colspan="3">'.$langs->trans("SubTotal").':</td>';
+					print '<td class="right" colspan="2">'.$langs->trans("SubTotal").':</td>';
 					print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
 					print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
 					print '<td class="nowrap right">'.price(price2num($sous_total_credit - $sous_total_debit)).'</td>';
@@ -313,7 +321,7 @@ if ($action != 'export_csv')
 
 				// Show first line of a break
 				print '<tr class="trforbreak">';
-				print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
+				print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
 				print '</tr>';
 
 				$displayed_account = $root_account_description;
@@ -321,10 +329,9 @@ if ($action != 'export_csv')
 				$sous_total_credit = 0;
 			}
 		}
-		// $object->get_compte_racine($line->numero_compte);
 
-		print '<td>'.length_accountg($line->numero_compte).'</td>';
-		print '<td>'.$description.'</td>';
+		// $object->get_compte_racine($line->numero_compte);
+		print '<td>'.$accounting_account.'</td>';
 		print '<td class="nowraponall right">'.price($opening_balances["'".$line->numero_compte."'"]).'</td>';
 		print '<td class="nowraponall right">'.price($line->debit).'</td>';
 		print '<td class="nowraponall right">'.price($line->credit).'</td>';
@@ -340,12 +347,12 @@ if ($action != 'export_csv')
 
 	if (!empty($show_subgroup))
 	{
-		print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
+		print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
 		print "<td></td>\n";
 		print '</tr>';
 	}
 
-	print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
+	print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
 	print "<td></td>\n";
 	print '</tr>';
 

+ 9 - 2
htdocs/accountancy/class/accountingaccount.class.php

@@ -448,9 +448,10 @@ class AccountingAccount extends CommonObject
 	 * @param	int  	$notooltip					1=Disable tooltip
      * @param	int     $save_lastsearch_value		-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
 	 * @param	int     $withcompletelabel		    0=Short label (field short label), 1=Complete label (field label)
+	 * @param	int		$option						'bookkeeping', 'bookkeepinglistbyaccount', 'accountcard'
 	 * @return  string	String with URL
 	 */
-    public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0)
+    public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '')
 	{
 		global $langs, $conf, $user;
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@@ -459,7 +460,13 @@ class AccountingAccount extends CommonObject
 
 		$result = '';
 
-		$url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$this->id;
+		if (empty($option)) {
+			$url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
+		} elseif ($option == 'bookkeepinglistbyaccount') {
+			$url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
+		} elseif ($option == 'accountcard') {
+			$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
+		}
 
 		// Add param to save lastsearch_values or not
 		$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);

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

@@ -93,7 +93,7 @@ $formaccounting = new FormAccounting($db);
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
 {
 	$search_societe = '';
-    $search_lineid = '';
+	$search_lineid = '';
 	$search_ref = '';
 	$search_invoice = '';
 	$search_label = '';
@@ -203,7 +203,7 @@ if ($search_societe) {
 	$sql .= natural_search('s.nom', $search_societe);
 }
 if ($search_lineid) {
-    $sql .= natural_search("fd.rowid", $search_lineid, 1);
+	$sql .= natural_search("fd.rowid", $search_lineid, 1);
 }
 if (strlen(trim($search_invoice))) {
 	$sql .= natural_search("f.ref", $search_invoice);
@@ -251,13 +251,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -309,9 +309,9 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></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 center nowraponall">';
-    if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
-        print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
-    }
+	if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
+		print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
+	}
    	print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
    	$formother->select_year($search_year, 'search_year', 1, 20, 5);
 	print '</td>';
@@ -349,10 +349,10 @@ if ($result) {
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
-    $thirdpartystatic = new Societe($db);
-    $facturestatic = new Facture($db);
+	$thirdpartystatic = new Societe($db);
+	$facturestatic = new Facture($db);
 	$productstatic = new Product($db);
-    $accountingaccountstatic = new AccountingAccount($db);
+	$accountingaccountstatic = new AccountingAccount($db);
 
 	$i = 0;
 	while ($i < min($num_lines, $limit)) {
@@ -362,16 +362,16 @@ if ($result) {
 		$facturestatic->id = $objp->facid;
 		$facturestatic->type = $objp->ftype;
 
-        $thirdpartystatic->id = $objp->socid;
-        $thirdpartystatic->name = $objp->name;
-        $thirdpartystatic->client = $objp->client;
-        $thirdpartystatic->fournisseur = $objp->fournisseur;
-        $thirdpartystatic->code_client = $objp->code_client;
-        $thirdpartystatic->code_compta_client = $objp->code_compta_client;
-        $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
-        $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
-        $thirdpartystatic->email = $objp->email;
-        $thirdpartystatic->country_code = $objp->country_code;
+		$thirdpartystatic->id = $objp->socid;
+		$thirdpartystatic->name = $objp->name;
+		$thirdpartystatic->client = $objp->client;
+		$thirdpartystatic->fournisseur = $objp->fournisseur;
+		$thirdpartystatic->code_client = $objp->code_client;
+		$thirdpartystatic->code_compta_client = $objp->code_compta_client;
+		$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
+		$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
+		$thirdpartystatic->email = $objp->email;
+		$thirdpartystatic->country_code = $objp->country_code;
 
 		$productstatic->ref = $objp->product_ref;
 		$productstatic->id = $objp->product_id;
@@ -412,7 +412,7 @@ if ($result) {
 		print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
 
 		// Country
 		print '<td>';
@@ -425,7 +425,7 @@ if ($result) {
 		print '<td>'.$objp->tva_intra.'</td>';
 
 		print '<td class="center">';
-        print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
+		print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
 		print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
 		print img_edit();
 		print '</a></td>';
@@ -434,14 +434,14 @@ if ($result) {
 		print '</tr>';
 		$i++;
 	}
-    print '</table>';
-    print "</div>";
+	print '</table>';
+	print "</div>";
 
-    if ($nbtotalofrecords > $limit) {
-        print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
-    }
+	if ($nbtotalofrecords > $limit) {
+		print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
+	}
 
-    print '</form>';
+	print '</form>';
 } else {
 	print $db->lasterror();
 }

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

@@ -114,7 +114,7 @@ if (empty($reshook))
 	// Purge search criteria
 	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
 	{
-		$search_societe='';
+		$search_societe = '';
 		$search_lineid = '';
 		$search_ref = '';
 		$search_invoice = '';
@@ -386,7 +386,7 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
 	print '<td class="liste_titre 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"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
 	print '<td class="liste_titre">';
 	print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
 	//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@@ -582,7 +582,7 @@ if ($result) {
 		print '</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
 
 		// Country
         print '<td>';

+ 65 - 65
htdocs/accountancy/expensereport/index.php

@@ -201,16 +201,16 @@ if ($resql) {
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
 		} else print $row[1];
 		print '</td>';
-    	for ($i = 2; $i <= 12; $i++) {
-            print '<td class="nowrap right">'.price($row[$i]).'</td>';
-        }
-        print '<td class="nowrap right">'.price($row[13]).'</td>';
-        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
-        print '</tr>';
-    }
-    $db->free($resql);
+		for ($i = 2; $i <= 12; $i++) {
+			print '<td class="nowrap right">'.price($row[$i]).'</td>';
+		}
+		print '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
+		print '</tr>';
+	}
+	$db->free($resql);
 } else {
-    print $db->lasterror(); // Show last sql error
+	print $db->lasterror(); // Show last sql error
 }
 print "</table>\n";
 print '</div>';
@@ -275,16 +275,16 @@ if ($resql) {
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
 		} else print $row[1];
 		print '</td>';
-    	for ($i = 2; $i <= 12; $i++) {
-            print '<td class="nowrap right">'.price($row[$i]).'</td>';
-        }
-        print '<td class="nowrap right">'.price($row[13]).'</td>';
-        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
-        print '</tr>';
-    }
-    $db->free($resql);
+		for ($i = 2; $i <= 12; $i++) {
+			print '<td class="nowrap right">'.price($row[$i]).'</td>';
+		}
+		print '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
+		print '</tr>';
+	}
+	$db->free($resql);
 } else {
-    print $db->lasterror(); // Show last sql error
+	print $db->lasterror(); // Show last sql error
 }
 print "</table>\n";
 print '</div>';
@@ -293,60 +293,60 @@ print '</div>';
 
 if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
 {
-    print '<br>';
-    print '<br>';
+	print '<br>';
+	print '<br>';
 
-    print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
-    //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
+	print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
+	//print load_fiche_titre($langs->trans("OtherInfo"), '', '');
 
 	print '<div class="div-table-responsive-no-min">';
-    print '<table class="noborder centpercent">';
-    print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
-    }
-    print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
-
-    $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,";
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
-    }
-    $sql .= " SUM(erd.total_ht) as total";
-    $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
-    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
-    $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
-    $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
+	}
+	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+	$sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,";
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
+	}
+	$sql .= " SUM(erd.total_ht) as total";
+	$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
+	$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
+	$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
 	// Define begin binding date
 	if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
 		$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
 	}
-    $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
-    $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
-
-    dol_syslog('htdocs/accountancy/expensereport/index.php');
-    $resql = $db->query($sql);
-    if ($resql) {
-        $num = $db->num_rows($resql);
-
-    	while ($row = $db->fetch_row($resql)) {
-    		print '<tr><td>'.$row[0].'</td>';
-            for ($i = 1; $i <= 12; $i++) {
-    			print '<td class="nowrap right">'.price($row[$i]).'</td>';
-    		}
-    		print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
-    		print '</tr>';
-    	}
-
-    	$db->free($resql);
-    } else {
-    	print $db->lasterror(); // Show last sql error
-    }
-    print "</table>\n";
-    print '</div>';
+	$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
+	$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
+
+	dol_syslog('htdocs/accountancy/expensereport/index.php');
+	$resql = $db->query($sql);
+	if ($resql) {
+		$num = $db->num_rows($resql);
+
+		while ($row = $db->fetch_row($resql)) {
+			print '<tr><td>'.$row[0].'</td>';
+			for ($i = 1; $i <= 12; $i++) {
+				print '<td class="nowrap right">'.price($row[$i]).'</td>';
+			}
+			print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
+			print '</tr>';
+		}
+
+		$db->free($resql);
+	} else {
+		print $db->lasterror(); // Show last sql error
+	}
+	print "</table>\n";
+	print '</div>';
 }
 
 // End of page

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

@@ -86,8 +86,8 @@ $formaccounting = new FormAccounting($db);
 // Purge search criteria
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
 {
-    $search_login = '';
-    $search_expensereport = '';
+	$search_login = '';
+	$search_expensereport = '';
 	$search_label = '';
 	$search_desc = '';
 	$search_amount = '';
@@ -178,7 +178,7 @@ $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't sha
 $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
 // Add search filter like
 if (strlen(trim($search_login))) {
-    $sql .= natural_search("u.login", $search_login);
+	$sql .= natural_search("u.login", $search_login);
 }
 if (strlen(trim($search_expensereport))) {
 	$sql .= natural_search("er.ref", $search_expensereport);
@@ -207,13 +207,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -228,7 +228,7 @@ if ($result) {
 	$param = '';
 	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
 	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
-    if ($search_login)       $param .= '&search_login='.urlencode($search_login);
+	if ($search_login)       $param .= '&search_login='.urlencode($search_login);
 	if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport);
 	if ($search_label)		$param .= "&search_label=".urlencode($search_label);
 	if ($search_desc)		$param .= "&search_desc=".urlencode($search_desc);
@@ -257,12 +257,12 @@ if ($result) {
 
 	$moreforfilter = '';
 
-    print '<div class="div-table-responsive">';
+	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 	print '<tr class="liste_titre_filter">';
-    print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
-    print '<td class="liste_titre"></td>';
+	print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
+	print '<td class="liste_titre"></td>';
 	print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
 		print '<td class="liste_titre"></td>';
@@ -278,14 +278,14 @@ if ($result) {
 	print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" 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 center">';
-    $searchpicto = $form->showFilterButtons();
-    print $searchpicto;
-    print '</td>';
+	$searchpicto = $form->showFilterButtons();
+	print $searchpicto;
+	print '</td>';
 	print "</tr>\n";
 
 	print '<tr class="liste_titre">';
-    print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
-    print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
+	print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
+	print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
 		print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
@@ -296,31 +296,31 @@ if ($result) {
 	print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
 	print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center ');
 	print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
-    $checkpicto = $form->showCheckAddButtons();
+	$checkpicto = $form->showCheckAddButtons();
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
 	$expensereportstatic = new ExpenseReport($db);
 	$accountingaccountstatic = new AccountingAccount($db);
-    $userstatic = new User($db);
+	$userstatic = new User($db);
 
-    $i = 0;
+	$i = 0;
 	while ($i < min($num_lines, $limit)) {
 		$objp = $db->fetch_object($result);
 
 		$expensereportstatic->ref = $objp->ref;
 		$expensereportstatic->id = $objp->erid;
 
-        $userstatic->id = $objp->rowid;
-        $userstatic->ref = $objp->label;
-        $userstatic->login = $objp->login;
-        $userstatic->statut = $objp->statut;
-        $userstatic->email = $objp->email;
-        $userstatic->gender = $objp->gender;
-        $userstatic->firstname = $objp->firstname;
-        $userstatic->lastname = $objp->lastname;
-        $userstatic->employee = $objp->employee;
-        $userstatic->photo = $objp->photo;
+		$userstatic->id = $objp->rowid;
+		$userstatic->ref = $objp->label;
+		$userstatic->login = $objp->login;
+		$userstatic->statut = $objp->statut;
+		$userstatic->email = $objp->email;
+		$userstatic->gender = $objp->gender;
+		$userstatic->firstname = $objp->firstname;
+		$userstatic->lastname = $objp->lastname;
+		$userstatic->employee = $objp->employee;
+		$userstatic->photo = $objp->photo;
 
 		$accountingaccountstatic->rowid = $objp->fk_compte;
 		$accountingaccountstatic->label = $objp->label;
@@ -329,15 +329,15 @@ if ($result) {
 
 		print '<tr class="oddeven">';
 
-        // Login
-        print '<td class="nowraponall">';
-        print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
-        print '</td>';
+		// Login
+		print '<td class="nowraponall">';
+		print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
+		print '</td>';
 
-        // Line id
+		// Line id
 		print '<td>'.$objp->rowid.'</td>';
 
-        // Ref Expense report
+		// Ref Expense report
 		print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
 
 		// Date validation
@@ -347,10 +347,10 @@ if ($result) {
 
 		print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
 
-        // Fees label
+		// Fees label
 		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>';
 
-        // Fees description -- Can be null
+		// Fees description -- Can be null
 		print '<td>';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
 		$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
@@ -360,13 +360,13 @@ if ($result) {
 		// Amount without taxes
 		print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
 
-        // Vat rate
+		// Vat rate
 		print '<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
 
 		// Accounting account affected
 		print '<td class="center">';
 		print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
-        print ' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
+		print ' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
 		print img_edit();
 		print '</a></td>';
 		print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
@@ -379,7 +379,7 @@ if ($result) {
 	print "</div>";
 
 	if ($nbtotalofrecords > $limit) {
-	    print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
+		print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
 	}
 
 	print '</form>';

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

@@ -102,16 +102,16 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
 // Purge search criteria
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
 {
-    $search_login = '';
-    $search_expensereport = '';
-    $search_label = '';
-    $search_desc = '';
-    $search_amount = '';
-    $search_account = '';
-    $search_vat = '';
-    $search_day = '';
-    $search_month = '';
-    $search_year = '';
+	$search_login = '';
+	$search_expensereport = '';
+	$search_label = '';
+	$search_desc = '';
+	$search_amount = '';
+	$search_account = '';
+	$search_vat = '';
+	$search_day = '';
+	$search_month = '';
+	$search_year = '';
 }
 
 // Mass actions
@@ -124,46 +124,46 @@ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
 
 if ($massaction == 'ventil') {
 	$msg = '';
-    //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
-    if (!empty($mesCasesCochees)) {
-        $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
-        $msg .= '<div class="detail">';
-        $cpt = 0;
-        $ok = 0;
-        $ko = 0;
-
-        foreach ($mesCasesCochees as $maLigneCochee) {
-            $maLigneCourante = explode("_", $maLigneCochee);
-            $monId = $maLigneCourante[0];
-            $monCompte = GETPOST('codeventil'.$monId);
-
-            if ($monCompte <= 0)
-            {
-                $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
-                $ko++;
-            } else {
-                $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
-                $sql .= " SET fk_code_ventilation = ".$monCompte;
-                $sql .= " WHERE rowid = ".$monId;
-
-                $accountventilated = new AccountingAccount($db);
-                $accountventilated->fetch($monCompte, '');
-
-                dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
-                if ($db->query($sql)) {
-                    $msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
-                    $ok++;
-                } else {
-                    $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
-                    $ko++;
-                }
-            }
-
-            $cpt++;
-        }
-        $msg .= '</div>';
-        $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
-    }
+	//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
+	if (!empty($mesCasesCochees)) {
+		$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
+		$msg .= '<div class="detail">';
+		$cpt = 0;
+		$ok = 0;
+		$ko = 0;
+
+		foreach ($mesCasesCochees as $maLigneCochee) {
+			$maLigneCourante = explode("_", $maLigneCochee);
+			$monId = $maLigneCourante[0];
+			$monCompte = GETPOST('codeventil'.$monId);
+
+			if ($monCompte <= 0)
+			{
+				$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
+				$ko++;
+			} else {
+				$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
+				$sql .= " SET fk_code_ventilation = ".$monCompte;
+				$sql .= " WHERE rowid = ".$monId;
+
+				$accountventilated = new AccountingAccount($db);
+				$accountventilated->fetch($monCompte, '');
+
+				dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
+				if ($db->query($sql)) {
+					$msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
+					$ok++;
+				} else {
+					$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
+					$ko++;
+				}
+			}
+
+			$cpt++;
+		}
+		$msg .= '</div>';
+		$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
+	}
 }
 
 
@@ -181,8 +181,8 @@ if (empty($chartaccountcode))
 {
 	print $langs->trans("ErrorChartOfAccountSystemNotSelected");
 	// End of page
-    llxFooter();
-    $db->close();
+	llxFooter();
+	$db->close();
 	exit;
 }
 
@@ -204,25 +204,25 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
 }
 // Add search filter like
 if (strlen(trim($search_login))) {
-    $sql .= natural_search("u.login", $search_login);
+	$sql .= natural_search("u.login", $search_login);
 }
 if (strlen(trim($search_expensereport))) {
-    $sql .= natural_search("er.ref", $search_expensereport);
+	$sql .= natural_search("er.ref", $search_expensereport);
 }
 if (strlen(trim($search_label))) {
-    $sql .= natural_search("f.label", $search_label);
+	$sql .= natural_search("f.label", $search_label);
 }
 if (strlen(trim($search_desc))) {
-    $sql .= natural_search("erd.comments", $search_desc);
+	$sql .= natural_search("erd.comments", $search_desc);
 }
 if (strlen(trim($search_amount))) {
-    $sql .= natural_search("erd.total_ht", $search_amount, 1);
+	$sql .= natural_search("erd.total_ht", $search_amount, 1);
 }
 if (strlen(trim($search_account))) {
-    $sql .= natural_search("aa.account_number", $search_account);
+	$sql .= natural_search("aa.account_number", $search_account);
 }
 if (strlen(trim($search_vat))) {
-    $sql .= natural_search("erd.tva_tx", $search_vat, 1);
+	$sql .= natural_search("erd.tva_tx", $search_vat, 1);
 }
 $sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year);
 $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
@@ -233,13 +233,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -255,7 +255,7 @@ if ($result) {
 	$param = '';
 	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
 	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
-    if ($search_login)       $param .= '&search_login='.urlencode($search_login);
+	if ($search_login)       $param .= '&search_login='.urlencode($search_login);
 	if ($search_lineid)      $param .= '&search_lineid='.urlencode($search_lineid);
 	if ($search_day)         $param .= '&search_day='.urlencode($search_day);
 	if ($search_month)       $param .= '&search_month='.urlencode($search_month);
@@ -267,7 +267,7 @@ if ($result) {
 	if ($search_vat)         $param .= '&search_vat='.urlencode($search_vat);
 
 	$arrayofmassactions = array(
-	    'ventil' => $langs->trans("Ventilate")
+		'ventil' => $langs->trans("Ventilate")
 	);
 	$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
 
@@ -295,12 +295,12 @@ if ($result) {
 
 	$moreforfilter = '';
 
-    print '<div class="div-table-responsive">';
+	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 	// We add search filter
 	print '<tr class="liste_titre_filter">';
-    print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
+	print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
@@ -324,7 +324,7 @@ if ($result) {
 	print '</tr>';
 
 	print '<tr class="liste_titre">';
-    print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
+	print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
 	print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
@@ -356,23 +356,23 @@ if ($result) {
 		$expensereport_static->ref = $objp->ref;
 		$expensereport_static->id = $objp->erid;
 
-        $userstatic->id = $objp->rowid;
-        $userstatic->ref = $objp->label;
-        $userstatic->login = $objp->login;
-        $userstatic->statut = $objp->statut;
-        $userstatic->email = $objp->email;
-        $userstatic->gender = $objp->gender;
-        $userstatic->firstname = $objp->firstname;
-        $userstatic->lastname = $objp->lastname;
-        $userstatic->employee = $objp->employee;
-        $userstatic->photo = $objp->photo;
-
-        print '<tr class="oddeven">';
-
-        // Login
-        print '<td class="nowraponall">';
-        print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
-        print '</td>';
+		$userstatic->id = $objp->rowid;
+		$userstatic->ref = $objp->label;
+		$userstatic->login = $objp->login;
+		$userstatic->statut = $objp->statut;
+		$userstatic->email = $objp->email;
+		$userstatic->gender = $objp->gender;
+		$userstatic->firstname = $objp->firstname;
+		$userstatic->lastname = $objp->lastname;
+		$userstatic->employee = $objp->employee;
+		$userstatic->photo = $objp->photo;
+
+		print '<tr class="oddeven">';
+
+		// Login
+		print '<td class="nowraponall">';
+		print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
+		print '</td>';
 
 		// Line id
 		print '<td>'.$objp->rowid.'</td>';
@@ -400,7 +400,7 @@ if ($result) {
 		print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
 		print '</td>';
 
-        // Amount without taxes
+		// Amount without taxes
 		print '<td class="nowrap right">';
 		print price($objp->price);
 		print '</td>';

+ 57 - 57
htdocs/accountancy/supplier/index.php

@@ -331,9 +331,9 @@ $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
 dol_syslog('htdocs/accountancy/supplier/index.php');
 $resql = $db->query($sql);
 if ($resql) {
-    $num = $db->num_rows($resql);
+	$num = $db->num_rows($resql);
 
-    while ($row = $db->fetch_row($resql)) {
+	while ($row = $db->fetch_row($resql)) {
 		print '<tr class="oddeven"><td>';
 		if ($row[0] == 'tobind')
 		{
@@ -346,16 +346,16 @@ if ($resql) {
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
 		} else print $row[1];
 		print '</td>';
-    	for ($i = 2; $i <= 12; $i++) {
-            print '<td class="nowrap right">'.price($row[$i]).'</td>';
-        }
-        print '<td class="nowrap right">'.price($row[13]).'</td>';
-        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
-        print '</tr>';
-    }
-    $db->free($resql);
+		for ($i = 2; $i <= 12; $i++) {
+			print '<td class="nowrap right">'.price($row[$i]).'</td>';
+		}
+		print '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
+		print '</tr>';
+	}
+	$db->free($resql);
 } else {
-    print $db->lasterror(); // Show last sql error
+	print $db->lasterror(); // Show last sql error
 }
 print "</table>\n";
 print '</div>';
@@ -364,60 +364,60 @@ print '</div>';
 
 if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
 {
-    print '<br>';
-    print '<br>';
+	print '<br>';
+	print '<br>';
 
-    print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
-    //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
+	print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
+	//print load_fiche_titre($langs->trans("OtherInfo"), '', '');
 
 	print '<div class="div-table-responsive-no-min">';
-    print '<table class="noborder centpercent">';
-    print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
-    }
-    print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
-
-    $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,";
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	$sql .= "  SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
-    }
-    $sql .= "  SUM(ffd.total_ht) as total";
-    $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
-    $sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
-    $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
-    $sql .= "  AND ff.datef <= '".$db->idate($search_date_end)."'";
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
+	}
+	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+	$sql = "SELECT '".$langs->trans("CAHTF")."' AS label,";
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		$sql .= "  SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
+	}
+	$sql .= "  SUM(ffd.total_ht) as total";
+	$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
+	$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
+	$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
+	$sql .= "  AND ff.datef <= '".$db->idate($search_date_end)."'";
 	// Define begin binding date
 	if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
 		$sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
 	}
-    $sql .= "  AND ff.fk_statut > 0";
+	$sql .= "  AND ff.fk_statut > 0";
 	$sql .= "  AND ffd.product_type <= 2";
-    $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
-
-    dol_syslog('htdocs/accountancy/supplier/index.php');
-    $resql = $db->query($sql);
-    if ($resql) {
-    	$num = $db->num_rows($resql);
-
-    	while ($row = $db->fetch_row($resql)) {
-    		print '<tr><td>'.$row[0].'</td>';
-            for ($i = 1; $i <= 12; $i++) {
-    			print '<td class="nowrap right">'.price($row[$i]).'</td>';
-    		}
-    		print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
-    		print '</tr>';
-    	}
-        $db->free($resql);
-    } else {
-        print $db->lasterror(); // Show last sql error
-    }
-    print "</table>\n";
-    print '</div>';
+	$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
+
+	dol_syslog('htdocs/accountancy/supplier/index.php');
+	$resql = $db->query($sql);
+	if ($resql) {
+		$num = $db->num_rows($resql);
+
+		while ($row = $db->fetch_row($resql)) {
+			print '<tr><td>'.$row[0].'</td>';
+			for ($i = 1; $i <= 12; $i++) {
+				print '<td class="nowrap right">'.price($row[$i]).'</td>';
+			}
+			print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
+			print '</tr>';
+		}
+		$db->free($resql);
+	} else {
+		print $db->lasterror(); // Show last sql error
+	}
+	print "</table>\n";
+	print '</div>';
 }
 
 // End of page

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

@@ -94,7 +94,7 @@ $formaccounting = new FormAccounting($db);
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
 {
 	$search_societe = '';
-    $search_lineid = '';
+	$search_lineid = '';
 	$search_ref = '';
 	$search_invoice = '';
 	$search_label = '';
@@ -196,7 +196,7 @@ if ($search_societe) {
 	$sql .= natural_search('s.nom', $search_societe);
 }
 if ($search_lineid) {
-    $sql .= natural_search("l.rowid", $search_lineid, 1);
+	$sql .= natural_search("l.rowid", $search_lineid, 1);
 }
 if (strlen(trim($search_invoice))) {
 	$sql .= natural_search("f.ref", $search_invoice);
@@ -250,13 +250,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -318,7 +318,7 @@ if ($result) {
 	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 right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
 	print '<td class="liste_titre 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"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
 	print '<td class="liste_titre">';
 	print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
 	//	print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@@ -348,29 +348,29 @@ if ($result) {
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
-    $thirdpartystatic = new Societe($db);
+	$thirdpartystatic = new Societe($db);
 	$facturefournisseur_static = new FactureFournisseur($db);
 	$productstatic = new ProductFournisseur($db);
-    $accountingaccountstatic = new AccountingAccount($db);
+	$accountingaccountstatic = new AccountingAccount($db);
 
-    $i = 0;
+	$i = 0;
 	while ($i < min($num_lines, $limit))
-    {
+	{
 		$objp = $db->fetch_object($result);
 
 		$facturefournisseur_static->ref = $objp->ref;
 		$facturefournisseur_static->id = $objp->facid;
 
-        $thirdpartystatic->id = $objp->socid;
-        $thirdpartystatic->name = $objp->name;
-        $thirdpartystatic->client = $objp->client;
-        $thirdpartystatic->fournisseur = $objp->fournisseur;
-        $thirdpartystatic->code_client = $objp->code_client;
-        $thirdpartystatic->code_compta_client = $objp->code_compta_client;
-        $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
-        $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
-        $thirdpartystatic->email = $objp->email;
-        $thirdpartystatic->country_code = $objp->country_code;
+		$thirdpartystatic->id = $objp->socid;
+		$thirdpartystatic->name = $objp->name;
+		$thirdpartystatic->client = $objp->client;
+		$thirdpartystatic->fournisseur = $objp->fournisseur;
+		$thirdpartystatic->code_client = $objp->code_client;
+		$thirdpartystatic->code_compta_client = $objp->code_compta_client;
+		$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
+		$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
+		$thirdpartystatic->email = $objp->email;
+		$thirdpartystatic->country_code = $objp->country_code;
 
 		$productstatic->ref = $objp->product_ref;
 		$productstatic->id = $objp->product_id;
@@ -415,7 +415,7 @@ if ($result) {
 		print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
 
 		// Country
 		print '<td>';
@@ -428,7 +428,7 @@ if ($result) {
 		print '<td>'.$objp->tva_intra.'</td>';
 
 		print '<td class="center">';
-        print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
+		print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
 		print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
 		print img_edit();
 		print '</a></td>';
@@ -437,14 +437,14 @@ if ($result) {
 		print '</tr>';
 		$i++;
 	}
-    print '</table>';
-    print "</div>";
+	print '</table>';
+	print "</div>";
 
-    if ($nbtotalofrecords > $limit) {
-        print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
-    }
+	if ($nbtotalofrecords > $limit) {
+		print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
+	}
 
-    print '</form>';
+	print '</form>';
 } else {
 	print $db->lasterror();
 }

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

@@ -118,7 +118,7 @@ if (empty($reshook))
 	// Purge search criteria
 	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
 	{
-		$search_societe='';
+		$search_societe = '';
 		$search_lineid = '';
 		$search_ref = '';
 		$search_invoice = '';
@@ -385,7 +385,7 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
 	print '<td class="liste_titre 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"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
 	print '<td class="liste_titre">';
 	print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
 	//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@@ -419,7 +419,7 @@ if ($result) {
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
-	$thirdpartystatic=new Societe($db);
+	$thirdpartystatic = new Societe($db);
 	$facturefourn_static = new FactureFournisseur($db);
 	$product_static = new Product($db);
 
@@ -569,7 +569,7 @@ if ($result) {
 		print '</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
 
 		// Country
         print '<td>';

+ 19 - 19
htdocs/adherents/admin/adherent_emails.php

@@ -47,15 +47,15 @@ $error = 0;
 
 // Editing global variables not related to a specific theme
 $constantes = array(
-    'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
-    'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
-    'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER'		=>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
-    'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'	=>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
-    'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
-    'ADHERENT_EMAIL_TEMPLATE_CANCELATION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
-    'ADHERENT_MAIL_FROM'=>'string',
-    'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
-    'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
+	'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
+	'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
+	'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER'		=>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
+	'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'	=>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
+	'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
+	'ADHERENT_EMAIL_TEMPLATE_CANCELATION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
+	'ADHERENT_MAIL_FROM'=>'string',
+	'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
+	'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
 );
 
 
@@ -66,16 +66,16 @@ $constantes = array(
 
 //
 if ($action == 'updateall') {
-    $db->begin();
-    $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
-    $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
-    if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
-        setEventMessages('ErrorFailedToSaveDate', null, 'errors');
-        $db->rollback();
-    } else {
-        setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
-        $db->commit();
-    }
+	$db->begin();
+	$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
+	$res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
+	if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
+		setEventMessages('ErrorFailedToSaveDate', null, 'errors');
+		$db->rollback();
+	} else {
+		setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
+		$db->commit();
+	}
 }
 
 // Action to update or add a constant

+ 42 - 42
htdocs/adherents/card.php

@@ -335,8 +335,8 @@ if (empty($reshook)) {
 							if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) {
 								setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
 							} else {
-							    // Create thumbs
-							    $object->addThumbs($newfile);
+								// Create thumbs
+								$object->addThumbs($newfile);
 							}
 						}
 					} else {
@@ -354,8 +354,8 @@ if (empty($reshook)) {
 					}
 				}
 
-	            $rowid = $object->id;
-	            $id = $object->id;
+				$rowid = $object->id;
+				$id = $object->id;
 				$action = '';
 
 				if (!empty($backtopage)) {
@@ -402,7 +402,7 @@ if (empty($reshook)) {
 		// $skype=GETPOST("member_skype", 'alpha');
 		// $twitter=GETPOST("member_twitter", 'alpha');
 		// $facebook=GETPOST("member_facebook", 'alpha');
-        // $linkedin=GETPOST("member_linkedin", 'alpha');
+		// $linkedin=GETPOST("member_linkedin", 'alpha');
 		$email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
 		$login = GETPOST("member_login", 'alpha');
 		$pass = GETPOST("password", 'alpha');
@@ -755,7 +755,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		if ($result <= 0) dol_print_error('', $object->error);
 	}
    	$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
-    $objcanvas->display_canvas($action); // Show template
+	$objcanvas->display_canvas($action); // Show template
 } else {
 	// -----------------------------------------
 	// When used in standard mode
@@ -778,16 +778,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			$object->country = $tmparray['label'];
 		}
 
-        if (!empty($socid)) {
-            $object = new Societe($db);
-            if ($socid > 0) $object->fetch($socid);
+		if (!empty($socid)) {
+			$object = new Societe($db);
+			if ($socid > 0) $object->fetch($socid);
 
-            if (!($object->id > 0)) {
-                $langs->load("errors");
-                print($langs->trans('ErrorRecordNotFound'));
-                exit;
-            }
-        }
+			if (!($object->id > 0)) {
+				$langs->load("errors");
+				print($langs->trans('ErrorRecordNotFound'));
+				exit;
+			}
+		}
 
 		$adht = new AdherentType($db);
 
@@ -829,7 +829,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print '<input type="hidden" name="socid" value="'.$socid.'">';
 		if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
 
-        dol_fiche_head('');
+		dol_fiche_head('');
 
 		print '<table class="border centpercent">';
 		print '<tbody>';
@@ -934,14 +934,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
 		print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" size="20" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
 
-	    if (!empty($conf->socialnetworks->enabled)) {
+		if (!empty($conf->socialnetworks->enabled)) {
 			foreach ($socialnetworks as $key => $value) {
-                if (!$value['active']) break;
+				if (!$value['active']) break;
 				print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>';
 			}
 		}
 
-	    // Birth Date
+		// Birth Date
 		print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n";
 		print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
 		print "</td></tr>\n";
@@ -1167,14 +1167,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
 		print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" value="'.(GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>';
 
-        if (!empty($conf->socialnetworks->enabled)) {
+		if (!empty($conf->socialnetworks->enabled)) {
 			foreach ($socialnetworks as $key => $value) {
-                if (!$value['active']) break;
+				if (!$value['active']) break;
 				print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'"></td></tr>';
 			}
 		}
 
-	    // Birth Date
+		// Birth Date
 		print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n";
 		print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
 		print "</td></tr>\n";
@@ -1447,10 +1447,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 
 		dol_banner_tab($object, 'rowid', $linkback);
 
-        print '<div class="fichecenter">';
-        print '<div class="fichehalfleft">';
+		print '<div class="fichecenter">';
+		print '<div class="fichehalfleft">';
 
-        print '<div class="underbanner clearboth"></div>';
+		print '<div class="underbanner clearboth"></div>';
 		print '<table class="border tableforfield centpercent">';
 
 		// Login
@@ -1483,13 +1483,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
 			if ($object->pass) print preg_replace('/./i', '*', $object->pass);
 			else {
-			    if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
-			    else print $langs->trans("Hidden");
+				if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
+				else print $langs->trans("Hidden");
 			}
 			if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
-			    $langs->load("errors");
-			    $htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
-			    print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
+				$langs->load("errors");
+				$htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
+				print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
 			}
 			print '</td></tr>';
 		}
@@ -1503,8 +1503,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			}
 		} else {
 			if ($object->need_subscription == 0) {
-                print $langs->trans("SubscriptionNotNeeded");
-            } elseif (!$adht->subscription) {
+				print $langs->trans("SubscriptionNotNeeded");
+			} elseif (!$adht->subscription) {
 				print $langs->trans("SubscriptionNotRecorded");
 				if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
 			} else {
@@ -1560,14 +1560,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		}
 		print '</td></tr>';
 
-        print '</table>';
+		print '</table>';
 
-        print '</div>';
+		print '</div>';
 
-        print '<div class="fichehalfright"><div class="ficheaddleft">';
-        print '<div class="underbanner clearboth"></div>';
+		print '<div class="fichehalfright"><div class="ficheaddleft">';
+		print '<div class="underbanner clearboth"></div>';
 
-        print '<table class="border tableforfield tableforfield" width="100%">';
+		print '<table class="border tableforfield tableforfield" width="100%">';
 
 		// Birth Date
 		print '<tr><td class="titlefield">'.$langs->trans("DateToBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
@@ -1585,12 +1585,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 
 		//VCard
 		print '<tr><td>';
-        print $langs->trans("VCard").'</td><td colspan="3">';
+		print $langs->trans("VCard").'</td><td colspan="3">';
 		print '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'">';
 		print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"');
 		print $langs->trans("Download");
 		print '</a>';
-        print '</td></tr>';
+		print '</td></tr>';
 
 		// Other attributes
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
@@ -1598,9 +1598,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print "</table>\n";
 
 		print "</div></div></div>\n";
-        print '<div style="clear:both"></div>';
+		print '<div style="clear:both"></div>';
 
-        dol_fiche_end();
+		dol_fiche_end();
 
 
 		/*
@@ -1769,7 +1769,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			$morehtmlright .= '</a>';
 
 			// List of actions on element
-	        include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+			include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
 			$formactions = new FormActions($db);
 			$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright);
 

+ 218 - 218
htdocs/adherents/class/adherent_type.class.php

@@ -62,26 +62,26 @@ class AdherentType extends CommonObject
 	public $libelle;
 
 	/**
-     * @var string Adherent type label
-     */
-    public $label;
+	 * @var string Adherent type label
+	 */
+	public $label;
 
-    /**
-     * @var string Adherent type nature
-     */
-    public $morphy;
+	/**
+	 * @var string Adherent type nature
+	 */
+	public $morphy;
 
-    public $duration;
+	public $duration;
 
-    /*
+	/*
     * type expiration
     */
-    public $duration_value;
+	public $duration_value;
 
-    /**
-     * Expiration unit
-     */
-    public $duration_unit;
+	/**
+	 * Expiration unit
+	 */
+	public $duration_unit;
 
 	/**
 	 * @var int Subsription required (0 or 1)
@@ -101,7 +101,7 @@ class AdherentType extends CommonObject
 	/** @var array Array of members */
 	public $members = array();
 
-    public $multilangs = array();
+	public $multilangs = array();
 
 
 	/**
@@ -115,157 +115,157 @@ class AdherentType extends CommonObject
 		$this->status = 1;
 	}
 
-    /**
-     *    Load array this->multilangs
-     *
-     * @return int        <0 if KO, >0 if OK
-     */
-    public function getMultiLangs()
-    {
-        global $langs;
-
-        $current_lang = $langs->getDefaultLang();
-
-        $sql = "SELECT lang, label, description, email";
-        $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-        $sql .= " WHERE fk_type=".$this->id;
-
-        $result = $this->db->query($sql);
-        if ($result) {
-            while ($obj = $this->db->fetch_object($result)) {
-                //print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
-                if ($obj->lang == $current_lang) {  // si on a les traduct. dans la langue courante on les charge en infos principales.
+	/**
+	 *    Load array this->multilangs
+	 *
+	 * @return int        <0 if KO, >0 if OK
+	 */
+	public function getMultiLangs()
+	{
+		global $langs;
+
+		$current_lang = $langs->getDefaultLang();
+
+		$sql = "SELECT lang, label, description, email";
+		$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+		$sql .= " WHERE fk_type=".$this->id;
+
+		$result = $this->db->query($sql);
+		if ($result) {
+			while ($obj = $this->db->fetch_object($result)) {
+				//print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
+				if ($obj->lang == $current_lang) {  // si on a les traduct. dans la langue courante on les charge en infos principales.
 					$this->label        = $obj->label;
-                    $this->description = $obj->description;
-                    $this->email        = $obj->email;
-                }
-                $this->multilangs["$obj->lang"]["label"] = $obj->label;
-                $this->multilangs["$obj->lang"]["description"] = $obj->description;
-                $this->multilangs["$obj->lang"]["email"] = $obj->email;
-            }
-            return 1;
-        } else {
-            $this->error = "Error: ".$this->db->lasterror()." - ".$sql;
-            return -1;
-        }
-    }
-
-    /**
-     *    Update or add a translation for a product
-     *
-     * @param  User $user Object user making update
-     * @return int        <0 if KO, >0 if OK
-     */
-    public function setMultiLangs($user)
-    {
-        global $conf, $langs;
-
-        $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
-        $current_lang = $langs->getDefaultLang();
-
-        foreach ($langs_available as $key => $value) {
-            if ($key == $current_lang) {
-                $sql = "SELECT rowid";
-                $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-                $sql .= " WHERE fk_type=".$this->id;
-                $sql .= " AND lang='".$key."'";
-
-                $result = $this->db->query($sql);
-
-                if ($this->db->num_rows($result)) { // if there is already a description line for this language
+					$this->description = $obj->description;
+					$this->email        = $obj->email;
+				}
+				$this->multilangs["$obj->lang"]["label"] = $obj->label;
+				$this->multilangs["$obj->lang"]["description"] = $obj->description;
+				$this->multilangs["$obj->lang"]["email"] = $obj->email;
+			}
+			return 1;
+		} else {
+			$this->error = "Error: ".$this->db->lasterror()." - ".$sql;
+			return -1;
+		}
+	}
+
+	/**
+	 *    Update or add a translation for a product
+	 *
+	 * @param  User $user Object user making update
+	 * @return int        <0 if KO, >0 if OK
+	 */
+	public function setMultiLangs($user)
+	{
+		global $conf, $langs;
+
+		$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
+		$current_lang = $langs->getDefaultLang();
+
+		foreach ($langs_available as $key => $value) {
+			if ($key == $current_lang) {
+				$sql = "SELECT rowid";
+				$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+				$sql .= " WHERE fk_type=".$this->id;
+				$sql .= " AND lang='".$key."'";
+
+				$result = $this->db->query($sql);
+
+				if ($this->db->num_rows($result)) { // if there is already a description line for this language
 					$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
-                    $sql2 .= " SET ";
-                    $sql2 .= " label='".$this->db->escape($this->label)."',";
-                    $sql2 .= " description='".$this->db->escape($this->description)."'";
-                    $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
-                } else {
-                    $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
-                    $sql2 .= ")";
-                    $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
-                    $sql2 .= " '".$this->db->escape($this->description)."'";
-                    $sql2 .= ")";
-                }
-                dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
-                if (!$this->db->query($sql2)) {
-                    $this->error = $this->db->lasterror();
-                    return -1;
-                }
-            } elseif (isset($this->multilangs[$key])) {
-                $sql = "SELECT rowid";
-                $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-                $sql .= " WHERE fk_type=".$this->id;
-                $sql .= " AND lang='".$key."'";
-
-                $result = $this->db->query($sql);
-
-                if ($this->db->num_rows($result)) { // if there is already a description line for this language
+					$sql2 .= " SET ";
+					$sql2 .= " label='".$this->db->escape($this->label)."',";
+					$sql2 .= " description='".$this->db->escape($this->description)."'";
+					$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
+				} else {
+					$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
+					$sql2 .= ")";
+					$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
+					$sql2 .= " '".$this->db->escape($this->description)."'";
+					$sql2 .= ")";
+				}
+				dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
+				if (!$this->db->query($sql2)) {
+					$this->error = $this->db->lasterror();
+					return -1;
+				}
+			} elseif (isset($this->multilangs[$key])) {
+				$sql = "SELECT rowid";
+				$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+				$sql .= " WHERE fk_type=".$this->id;
+				$sql .= " AND lang='".$key."'";
+
+				$result = $this->db->query($sql);
+
+				if ($this->db->num_rows($result)) { // if there is already a description line for this language
 					$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
-                    $sql2 .= " SET ";
-                    $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
-                    $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
-                    $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
-                } else {
-                    $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
-                    $sql2 .= ")";
-                    $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
-                    $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
-                    $sql2 .= ")";
-                }
-
-                // We do not save if main fields are empty
-                if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
-                    if (!$this->db->query($sql2)) {
-                        $this->error = $this->db->lasterror();
-                        return -1;
-                    }
-                }
-            } else {
-                // language is not current language and we didn't provide a multilang description for this language
-            }
-        }
-
-        // Call trigger
-        $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
-        if ($result < 0) {
-            $this->error = $this->db->lasterror();
-            return -1;
-        }
-        // End call triggers
-
-        return 1;
-    }
-
-       /**
-     *    Delete a language for this product
-     *
-     * @param string $langtodelete Language code to delete
-     * @param User   $user         Object user making delete
-     *
-     * @return int                            <0 if KO, >0 if OK
-     */
-    public function delMultiLangs($langtodelete, $user)
-    {
-        $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-        $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
-
-        dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
-        $result = $this->db->query($sql);
-        if ($result) {
-            // Call trigger
-            $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user);
-            if ($result < 0) {
-                $this->error = $this->db->lasterror();
-                dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
-                return -1;
-            }
-            // End call triggers
-            return 1;
-        } else {
-            $this->error = $this->db->lasterror();
-            dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
-            return -1;
-        }
-    }
+					$sql2 .= " SET ";
+					$sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
+					$sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
+					$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
+				} else {
+					$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
+					$sql2 .= ")";
+					$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
+					$sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
+					$sql2 .= ")";
+				}
+
+				// We do not save if main fields are empty
+				if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
+					if (!$this->db->query($sql2)) {
+						$this->error = $this->db->lasterror();
+						return -1;
+					}
+				}
+			} else {
+				// language is not current language and we didn't provide a multilang description for this language
+			}
+		}
+
+		// Call trigger
+		$result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
+		if ($result < 0) {
+			$this->error = $this->db->lasterror();
+			return -1;
+		}
+		// End call triggers
+
+		return 1;
+	}
+
+	   /**
+	    *    Delete a language for this product
+	    *
+	    * @param string $langtodelete Language code to delete
+	    * @param User   $user         Object user making delete
+	    *
+	    * @return int                            <0 if KO, >0 if OK
+	    */
+	public function delMultiLangs($langtodelete, $user)
+	{
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+		$sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
+
+		dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
+		$result = $this->db->query($sql);
+		if ($result) {
+			// Call trigger
+			$result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user);
+			if ($result < 0) {
+				$this->error = $this->db->lasterror();
+				dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
+				return -1;
+			}
+			// End call triggers
+			return 1;
+		} else {
+			$this->error = $this->db->lasterror();
+			dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
+			return -1;
+		}
+	}
 
 	/**
 	 *  Fonction qui permet de creer le status de l'adherent
@@ -337,7 +337,7 @@ class AdherentType extends CommonObject
 	 */
 	public function update($user, $notrigger = 0)
 	{
-        global $langs, $conf, $hookmanager;
+		global $langs, $conf, $hookmanager;
 
 		$error = 0;
 
@@ -359,15 +359,15 @@ class AdherentType extends CommonObject
 
 		$result = $this->db->query($sql);
 		if ($result) {
-            $this->description = $this->db->escape($this->note);
+			$this->description = $this->db->escape($this->note);
 
-            // Multilangs
-            if (!empty($conf->global->MAIN_MULTILANGS)) {
-                if ($this->setMultiLangs($user) < 0) {
-                    $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
-                    return -2;
-                }
-            }
+			// Multilangs
+			if (!empty($conf->global->MAIN_MULTILANGS)) {
+				if ($this->setMultiLangs($user) < 0) {
+					$this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
+					return -2;
+				}
+			}
 
 			$action = 'update';
 
@@ -439,7 +439,7 @@ class AdherentType extends CommonObject
 	 */
 	public function fetch($rowid)
 	{
-        global $langs, $conf;
+		global $langs, $conf;
 
 		$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote";
 		$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
@@ -465,10 +465,10 @@ class AdherentType extends CommonObject
 				$this->note           = $obj->note;
 				$this->vote           = $obj->vote;
 
-                // multilangs
-                if (!empty($conf->global->MAIN_MULTILANGS)) {
-                    $this->getMultiLangs();
-                }
+				// multilangs
+				if (!empty($conf->global->MAIN_MULTILANGS)) {
+					$this->getMultiLangs();
+				}
 			}
 
 			return 1;
@@ -478,7 +478,7 @@ class AdherentType extends CommonObject
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Return list of members' type
 	 *
@@ -487,7 +487,7 @@ class AdherentType extends CommonObject
 	 */
 	public function liste_array($status = -1)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs;
 
 		$adherenttypes = array();
@@ -578,31 +578,31 @@ class AdherentType extends CommonObject
 		//return $morphy;
 	}
 
-    /**
-     *  Return clicable name (with picto eventually)
-     *
-     *  @param		int		$withpicto		0=No picto, 1=Include picto into link, 2=Only picto
-     *  @param		int		$maxlen			length max label
-     *  @param		int  	$notooltip		1=Disable tooltip
-     *  @return		string					String with URL
-     */
-    public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0)
-    {
-        global $langs;
+	/**
+	 *  Return clicable name (with picto eventually)
+	 *
+	 *  @param		int		$withpicto		0=No picto, 1=Include picto into link, 2=Only picto
+	 *  @param		int		$maxlen			length max label
+	 *  @param		int  	$notooltip		1=Disable tooltip
+	 *  @return		string					String with URL
+	 */
+	public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0)
+	{
+		global $langs;
 
-        $result = '';
-        $label = $langs->trans("ShowTypeCard", $this->label);
+		$result = '';
+		$label = $langs->trans("ShowTypeCard", $this->label);
 
-        $linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
-        $linkend = '</a>';
+		$linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
+		$linkend = '</a>';
 
-        $result .= $linkstart;
-        if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
-        if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
-        $result .= $linkend;
+		$result .= $linkstart;
+		if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+		if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
+		$result .= $linkend;
 
-        return $result;
-    }
+		return $result;
+	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
@@ -611,7 +611,7 @@ class AdherentType extends CommonObject
 	 *    @param  	int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
 	 *    @return   string     	   		Label of status
 	 */
-    public function getLibStatut($mode = 0)
+	public function getLibStatut($mode = 0)
 	{
 		return $this->LibStatut($this->status, $mode);
 	}
@@ -623,9 +623,9 @@ class AdherentType extends CommonObject
 	 *  @param	int		$mode           0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
 	 *  @return	string          		Status label
 	 */
-    public function LibStatut($status, $mode = 0)
+	public function LibStatut($status, $mode = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $langs;
 		$langs->load('companies');
 
@@ -640,10 +640,10 @@ class AdherentType extends CommonObject
 		}
 
 		return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
-    }
+	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *	Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
 	 *
@@ -655,7 +655,7 @@ class AdherentType extends CommonObject
 	 */
 	public function _load_ldap_dn($info, $mode = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 		$dn = '';
 		if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
@@ -665,8 +665,8 @@ class AdherentType extends CommonObject
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *	Initialize the info array (array of LDAP values) that will be used to call LDAP functions
 	 *
@@ -674,7 +674,7 @@ class AdherentType extends CommonObject
 	 */
 	public function _load_ldap_info()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs;
 
 		$info = array();
@@ -766,15 +766,15 @@ class AdherentType extends CommonObject
 	 *
 	 *     @return string     Return mail model content of type or empty
 	 */
-    public function getMailOnResiliate()
-    {
-        global $conf;
+	public function getMailOnResiliate()
+	{
+		global $conf;
 
-        // NOTE mail_resiliate not defined so never used
-        if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) {  // Property not yet defined
+		// NOTE mail_resiliate not defined so never used
+		if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) {  // Property not yet defined
 			return $this->mail_resiliate;
-        }
+		}
 
-        return '';
-    }
+		return '';
+	}
 }

+ 1 - 1
htdocs/adherents/subscription.php

@@ -854,7 +854,7 @@ if ($rowid > 0) {
             print '"></td></tr>';
 
             // Complementary action
-            if (!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) {
+            if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
                 $company = new Societe($db);
                 if ($object->fk_soc) {
                     $result = $company->fetch($object->fk_soc);

+ 158 - 158
htdocs/adherents/type.php

@@ -81,10 +81,10 @@ $extrafields->fetch_name_optionals_label($object->table_element);
 
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
 	$search_lastname = "";
-    $search_login = "";
-    $search_email = "";
-    $type = "";
-    $sall = "";
+	$search_login = "";
+	$search_email = "";
+	$type = "";
+	$sall = "";
 }
 
 
@@ -226,8 +226,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
 
 		$newcardbutton = '';
 		if ($user->rights->adherent->configurer) {
-            $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
-        }
+			$newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
+		}
 
 		print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
 		if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
 		print '<tr class="liste_titre">';
 		print '<th>'.$langs->trans("Ref").'</th>';
 		print '<th>'.$langs->trans("Label").'</th>';
-        print '<th class="center">'.$langs->trans("MemberNature").'</th>';
+		print '<th class="center">'.$langs->trans("MemberNature").'</th>';
 		print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
 		print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
 		print '<th class="center">'.$langs->trans("Status").'</th>';
@@ -270,9 +270,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
 			//<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
 			print '</td>';
 			print '<td>'.dol_escape_htmltag($objp->label).'</td>';
-            print '<td class="center">';
+			print '<td class="center">';
 			if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy");
-            print '</td>';
+			print '</td>';
 			print '<td class="center">'.yn($objp->subscription).'</td>';
 			print '<td class="center">'.yn($objp->vote).'</td>';
 			print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
@@ -308,7 +308,7 @@ if ($action == 'create') {
 	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="action" value="add">';
 
-    dol_fiche_head('');
+	dol_fiche_head('');
 
 	print '<table class="border centpercent">';
 	print '<tbody>';
@@ -319,10 +319,10 @@ if ($action == 'create') {
   	print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
   	print '</td></tr>';
 
-    // Morphy
+	// Morphy
   	$morphys = array();
-    $morphys[""] = $langs->trans("MorPhy");
-    $morphys["phy"] = $langs->trans("Physical");
+	$morphys[""] = $langs->trans("MorPhy");
+	$morphys["phy"] = $langs->trans("Physical");
 	$morphys["mor"] = $langs->trans("Moral");
 	print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
 	print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
@@ -447,11 +447,11 @@ if ($rowid > 0) {
 		}
 
 		// Add
-        if ($user->rights->adherent->configurer && !empty($object->status)) {
-            print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
-        } else {
-		    print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
-        }
+		if ($user->rights->adherent->configurer && !empty($object->status)) {
+			print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
+		} else {
+			print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
+		}
 
 		// Delete
 		if ($user->rights->adherent->configurer) {
@@ -479,7 +479,7 @@ if ($rowid > 0) {
 			$sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
 		}
 		if ($status != '') {
-		    $sql .= natural_search('d.statut', $status, 2);
+			$sql .= natural_search('d.statut', $status, 2);
 		}
 		if ($action == 'search') {
 			if (GETPOST('search', 'alpha')) {
@@ -495,12 +495,12 @@ if ($rowid > 0) {
 		if (!empty($search_email)) {
 			$sql .= natural_search("d.email", $search_email);
 		}
-        if ($filter == 'uptodate') {
-            $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
-        }
-        if ($filter == 'outofdate') {
-            $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
-        }
+		if ($filter == 'uptodate') {
+			$sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
+		}
+		if ($filter == 'outofdate') {
+			$sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
+		}
 
 		$sql .= " ".$db->order($sortfield, $sortorder);
 
@@ -508,71 +508,71 @@ if ($rowid > 0) {
 		$nbtotalofrecords = '';
 		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
 			$resql = $db->query($sql);
-		    if ($resql) $nbtotalofrecords = $db->num_rows($result);
-		    else dol_print_error($db);
-		    if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller then paging size (filtering), goto and load page 0
+			if ($resql) $nbtotalofrecords = $db->num_rows($result);
+			else dol_print_error($db);
+			if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller then paging size (filtering), goto and load page 0
 				$page = 0;
-		    	$offset = 0;
-		    }
+				$offset = 0;
+			}
 		}
 
 		$sql .= " ".$db->plimit($conf->liste_limit + 1, $offset);
 
 		$resql = $db->query($sql);
 		if ($resql) {
-		    $num = $db->num_rows($resql);
-		    $i = 0;
-
-		    $titre = $langs->trans("MembersList");
-            if ($status != '') {
-                if ($status == '-1,1') {
-                    $titre = $langs->trans("MembersListQualified");
-                } elseif ($status == '-1') {
-                    $titre = $langs->trans("MembersListToValid");
-                } elseif ($status == '1' && !$filter) {
-                    $titre = $langs->trans("MembersListValid");
-                } elseif ($status == '1' && $filter == 'uptodate') {
-                    $titre = $langs->trans("MembersListUpToDate");
-                } elseif ($status == '1' && $filter == 'outofdate') {
-                    $titre = $langs->trans("MembersListNotUpToDate");
-                } elseif ($status == '0') {
-                    $titre = $langs->trans("MembersListResiliated");
-                }
-		    } elseif ($action == 'search') {
-		        $titre = $langs->trans("MembersListQualified");
-		    }
-
-		    if ($type > 0) {
+			$num = $db->num_rows($resql);
+			$i = 0;
+
+			$titre = $langs->trans("MembersList");
+			if ($status != '') {
+				if ($status == '-1,1') {
+					$titre = $langs->trans("MembersListQualified");
+				} elseif ($status == '-1') {
+					$titre = $langs->trans("MembersListToValid");
+				} elseif ($status == '1' && !$filter) {
+					$titre = $langs->trans("MembersListValid");
+				} elseif ($status == '1' && $filter == 'uptodate') {
+					$titre = $langs->trans("MembersListUpToDate");
+				} elseif ($status == '1' && $filter == 'outofdate') {
+					$titre = $langs->trans("MembersListNotUpToDate");
+				} elseif ($status == '0') {
+					$titre = $langs->trans("MembersListResiliated");
+				}
+			} elseif ($action == 'search') {
+				$titre = $langs->trans("MembersListQualified");
+			}
+
+			if ($type > 0) {
 				$membertype = new AdherentType($db);
-		        $result = $membertype->fetch($type);
+				$result = $membertype->fetch($type);
 				$titre .= " (".$membertype->label.")";
-		    }
+			}
 
-		    $param = "&rowid=".$object->id;
-		    if (!empty($status))			$param .= "&status=".$status;
-		    if (!empty($search_lastname))	$param .= "&search_lastname=".$search_lastname;
-		    if (!empty($search_firstname))	$param .= "&search_firstname=".$search_firstname;
-		    if (!empty($search_login))		$param .= "&search_login=".$search_login;
-		    if (!empty($search_email))		$param .= "&search_email=".$search_email;
-		    if (!empty($filter))			$param .= "&filter=".$filter;
+			$param = "&rowid=".$object->id;
+			if (!empty($status))			$param .= "&status=".$status;
+			if (!empty($search_lastname))	$param .= "&search_lastname=".$search_lastname;
+			if (!empty($search_firstname))	$param .= "&search_firstname=".$search_firstname;
+			if (!empty($search_login))		$param .= "&search_login=".$search_login;
+			if (!empty($search_email))		$param .= "&search_email=".$search_email;
+			if (!empty($filter))			$param .= "&filter=".$filter;
 
-		    if ($sall) {
-		        print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
-		    }
+			if ($sall) {
+				print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
+			}
 
 			print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
-            print '<input type="hidden" name="token" value="'.newToken().'">';
+			print '<input type="hidden" name="token" value="'.newToken().'">';
 			print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
 
 			print '<br>';
-            print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
+			print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
 
-            $moreforfilter = '';
+			$moreforfilter = '';
 
-            print '<div class="div-table-responsive">';
-            print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
+			print '<div class="div-table-responsive">';
+			print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
-            // Fields title search
+			// Fields title search
 			print '<tr class="liste_titre_filter">';
 
 			print '<td class="liste_titre left">';
@@ -590,105 +590,105 @@ if ($rowid > 0) {
 
 			print '<td class="liste_titre right" colspan="2">';
 			print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
-		    print '&nbsp; ';
-		    print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
+			print '&nbsp; ';
+			print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
 			print '</td>';
 
 			print "</tr>\n";
 
 			print '<tr class="liste_titre">';
-            print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
-		    print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
-		    print "</tr>\n";
-
-		    while ($i < $num && $i < $conf->liste_limit) {
-		        $objp = $db->fetch_object($resql);
-
-		        $datefin = $db->jdate($objp->datefin);
-
-		        $adh = new Adherent($db);
-		        $adh->lastname = $objp->lastname;
-		        $adh->firstname = $objp->firstname;
-
-		        // Lastname
-		        print '<tr class="oddeven">';
-		        if ($objp->company != '') {
-		            print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n";
-		        } else {
-		            print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
-		        }
-
-		        // Login
-		        print "<td>".$objp->login."</td>\n";
-
-		        // Type
-		        /*print '<td class="nowrap">';
+			print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
+			print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
+			print "</tr>\n";
+
+			while ($i < $num && $i < $conf->liste_limit) {
+				$objp = $db->fetch_object($resql);
+
+				$datefin = $db->jdate($objp->datefin);
+
+				$adh = new Adherent($db);
+				$adh->lastname = $objp->lastname;
+				$adh->firstname = $objp->firstname;
+
+				// Lastname
+				print '<tr class="oddeven">';
+				if ($objp->company != '') {
+					print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n";
+				} else {
+					print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
+				}
+
+				// Login
+				print "<td>".$objp->login."</td>\n";
+
+				// Type
+				/*print '<td class="nowrap">';
 		        $membertypestatic->id=$objp->type_id;
 		        $membertypestatic->label=$objp->type;
 		        print $membertypestatic->getNomUrl(1,12);
 		        print '</td>';
 				*/
 
-		        // Moral/Physique
-		        print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
-
-		        // EMail
-		        print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
-
-		        // Statut
-		        print '<td class="nowrap">';
-		        print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2);
-		        print "</td>";
-
-		        // Date end subscription
-		        if ($datefin) {
-			        print '<td class="nowrap center">';
-		            if ($datefin < dol_now() && $objp->status > 0) {
-		                print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
-		            } else {
-		                print dol_print_date($datefin, 'day');
-		            }
-		            print '</td>';
-		        } else {
-			        print '<td class="nowrap left">';
-			        if ($objp->subscription == 'yes') {
-		                print $langs->trans("SubscriptionNotReceived");
-		                if ($objp->status > 0) print " ".img_warning();
-			        } else {
-			            print '&nbsp;';
-			        }
-		            print '</td>';
-		        }
-
-		        // Actions
-		        print '<td class="center">';
+				// Moral/Physique
+				print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
+
+				// EMail
+				print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
+
+				// Statut
+				print '<td class="nowrap">';
+				print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2);
+				print "</td>";
+
+				// Date end subscription
+				if ($datefin) {
+					print '<td class="nowrap center">';
+					if ($datefin < dol_now() && $objp->status > 0) {
+						print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
+					} else {
+						print dol_print_date($datefin, 'day');
+					}
+					print '</td>';
+				} else {
+					print '<td class="nowrap left">';
+					if ($objp->subscription == 'yes') {
+						print $langs->trans("SubscriptionNotReceived");
+						if ($objp->status > 0) print " ".img_warning();
+					} else {
+						print '&nbsp;';
+					}
+					print '</td>';
+				}
+
+				// Actions
+				print '<td class="center">';
 				if ($user->rights->adherent->creer) {
 					print '<a class="editfielda" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
 				}
 				print '&nbsp;';
 				if ($user->rights->adherent->supprimer) {
 					print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
-		        }
+				}
 				print "</td>";
 
-		        print "</tr>\n";
-		        $i++;
-		    }
+				print "</tr>\n";
+				$i++;
+			}
 
-		    print "</table>\n";
-            print '</div>';
-            print '</form>';
+			print "</table>\n";
+			print '</div>';
+			print '</form>';
 
 			if ($num > $conf->liste_limit) {
-			    print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
+				print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
 			}
 		} else {
-		    dol_print_error($db);
+			dol_print_error($db);
 		}
 	}
 
@@ -719,18 +719,18 @@ if ($rowid > 0) {
 		print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
 
 		print '<tr><td>'.$langs->trans("Status").'</td><td>';
-    	print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status);
-    	print '</td></tr>';
-
-        // Morphy
-        $morphys[""] = $langs->trans("MorPhy");
-        $morphys["phy"] = $langs->trans("Physical");
-        $morphys["mor"] = $langs->trans("Moral");
-        print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
-        print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy);
-        print "</td></tr>";
-
-    	print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
+		print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status);
+		print '</td></tr>';
+
+		// Morphy
+		$morphys[""] = $langs->trans("MorPhy");
+		$morphys["phy"] = $langs->trans("Physical");
+		$morphys["mor"] = $langs->trans("Moral");
+		print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
+		print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy);
+		print "</td></tr>";
+
+		print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
 		print $form->selectyesno("subscription", $object->subscription, 1);
 		print '</td></tr>';
 

+ 161 - 161
htdocs/admin/bank.php

@@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
 $langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
 
 if (!$user->admin)
-    accessforbidden();
+	accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $actionsave = GETPOST('save', 'alpha');
@@ -240,31 +240,31 @@ $i = 0;
 
 $nbofbank = count($bankorder);
 while ($i < $nbofbank) {
-    print '<tr class="oddeven">';
-    print '<td>'.$bankorder[$i][0]."</td><td>\n";
-    print $bankorder[$i][1];
-    print '</td>';
-    print '<td class="nowrap">';
-    $tmparray = explode(' ', $bankorder[$i][2]);
-    foreach ($tmparray as $key => $val) {
-        if ($key > 0)
-            print ', ';
-        print $langs->trans($val);
-    }
-    print "</td>\n";
-
-    if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) {
-        print '<td class="center">';
-        print img_picto($langs->trans("Activated"), 'on');
-        print '</td>';
-    } else {
-        print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbankorder&amp;value='.$i.'">';
-        print img_picto($langs->trans("Disabled"), 'off');
-        print '</a></td>';
-    }
-    print '<td>&nbsp;</td>';
-    print '</tr>'."\n";
-    $i++;
+	print '<tr class="oddeven">';
+	print '<td>'.$bankorder[$i][0]."</td><td>\n";
+	print $bankorder[$i][1];
+	print '</td>';
+	print '<td class="nowrap">';
+	$tmparray = explode(' ', $bankorder[$i][2]);
+	foreach ($tmparray as $key => $val) {
+		if ($key > 0)
+			print ', ';
+		print $langs->trans($val);
+	}
+	print "</td>\n";
+
+	if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) {
+		print '<td class="center">';
+		print img_picto($langs->trans("Activated"), 'on');
+		print '</td>';
+	} else {
+		print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbankorder&amp;value='.$i.'">';
+		print img_picto($langs->trans("Disabled"), 'off');
+		print '</a></td>';
+	}
+	print '<td>&nbsp;</td>';
+	print '</tr>'."\n";
+	$i++;
 }
 
 print '</table>'."\n";
@@ -287,15 +287,15 @@ $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++;
-    }
+	$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);
+	dol_print_error($db);
 }
 
 print "<table class=\"noborder\" width=\"100%\">\n";
@@ -311,100 +311,100 @@ print "</tr>\n";
 clearstatcache();
 
 foreach ($dirmodels as $reldir) {
-    foreach (array('', '/doc') as $valdir) {
-        $dir = dol_buildpath($reldir."core/modules/bank".$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) {
-                                print '<tr class="oddeven"><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 class="center">'."\n";
-                                    print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-                                    print img_picto($langs->trans("Enabled"), 'switch_on');
-                                    print '</a>';
-                                    print '</td>';
-                                } else {
-                                    print '<td class="center">'."\n";
-                                    print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-                                    print "</td>";
-                                }
-
-                                // Default
-                                print '<td class="center">';
-                                if ($conf->global->BANKADDON_PDF == $name) {
-                                    print img_picto($langs->trans("Default"), 'on');
-                                } else {
-                                    print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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("Discounts").': '.yn($module->option_escompte,1,1);
-                                // $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
-                                //$htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
-
-                                print '<td class="center">';
-                                print $form->textwithpicto('', $htmltooltip, 1, 0);
-                                print '</td>';
-
-                                // Preview
-                                print '<td class="center">';
-                                if ($module->type == 'pdf') {
-                                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-                                } else {
-                                    print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-                                }
-                                print '</td>';
-
-                                print "</tr>\n";
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir) {
+		$dir = dol_buildpath($reldir."core/modules/bank".$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) {
+								print '<tr class="oddeven"><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 class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Default
+								print '<td class="center">';
+								if ($conf->global->BANKADDON_PDF == $name) {
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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("Discounts").': '.yn($module->option_escompte,1,1);
+								// $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
+								//$htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf') {
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 print '</table>';
 //}
@@ -423,38 +423,38 @@ print $langs->trans('BankColorizeMovementDesc');
 print "</td>";
 // Active
 if ($conf->global->BANK_COLORIZE_MOVEMENT) {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetbankcolorizemovement">';
-    print img_picto($langs->trans("Enabled"), 'switch_on');
-    print '</a>';
-    print '</td>';
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetbankcolorizemovement">';
+	print img_picto($langs->trans("Enabled"), 'switch_on');
+	print '</a>';
+	print '</td>';
 } else {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setbankcolorizemovement">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-    print "</td>";
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=setbankcolorizemovement">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+	print "</td>";
 }
 
 print "</tr>\n";
 
 if (!empty($conf->global->BANK_COLORIZE_MOVEMENT))
 {
-    $i = 1;
-    while ($i <= 2)
-    {
-        $key = $i;
-        $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
-
-        print '<tr class="oddeven">';
-
-        // Label
-        print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
-        // Color
-        print '<td class="nowrap right">';
-        print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset');
-        print '</td>';
-        print "</tr>";
-        $i++;
-    }
+	$i = 1;
+	while ($i <= 2)
+	{
+		$key = $i;
+		$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
+
+		print '<tr class="oddeven">';
+
+		// Label
+		print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
+		// Color
+		print '<td class="nowrap right">';
+		print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset');
+		print '</td>';
+		print "</tr>";
+		$i++;
+	}
 }
 print '</table>';
 
@@ -482,15 +482,15 @@ print $langs->trans('AutoReportLastAccountStatement');
 print '</td>';
 // Active
 if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetreportlastnumreleve">';
-    print img_picto($langs->trans("Enabled"), 'switch_on');
-    print '</a>';
-    print '</td>';
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetreportlastnumreleve">';
+	print img_picto($langs->trans("Enabled"), 'switch_on');
+	print '</a>';
+	print '</td>';
 } else {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-    print "</td>";
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+	print "</td>";
 }
 
 print "</tr>\n";

+ 141 - 141
htdocs/admin/bom.php

@@ -55,11 +55,11 @@ if ($action == 'updateMask')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
 	$modele = GETPOST('module', 'alpha');
@@ -72,7 +72,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -110,7 +110,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
+		if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -144,11 +144,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_BOM_FREE_TEXT')
 {
 	$freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string
@@ -158,11 +158,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir)
 		{
 			while (($file = readdir($handle)) !== false)
 			{
-			    if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
+				if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
 				{
 					$file = substr($file, 0, dol_strlen($file) - 4);
 
@@ -229,13 +229,13 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering model
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                        elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						// Show example of numbering model
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+						elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->BOM_ADDON == $file)
@@ -256,16 +256,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$bom->type = 0;
 						$nextval = $module->getNextValue($mysoc, $bom);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -324,108 +324,108 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/bom".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        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)
-	                        {
-	                            print '<tr class="oddeven"><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 class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Default
-	                            print '<td class="center">';
-	                            if ($conf->global->BOM_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-			                    $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/bom".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		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)
+							{
+								print '<tr class="oddeven"><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 class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Default
+								print '<td class="center">';
+								if ($conf->global->BOM_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+								$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -457,11 +457,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("
 $variablename = 'BOM_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

+ 144 - 144
htdocs/admin/boxes.php

@@ -48,99 +48,99 @@ $boxes = array();
 
 if ($action == 'addconst')
 {
-    dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity);
-    dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity);
 }
 
 if ($action == 'add') {
-    $error = 0;
-    $db->begin();
-    if (isset($_POST['boxid']) && is_array($_POST['boxid']))
-    {
-        foreach ($_POST['boxid'] as $boxid)
-        {
-            if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0)	// 0=Home, 1=...
-            {
-                $pos = $boxid['pos'];
-
-                // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
-                $distinctfkuser = array();
-                if (!$error)
-                {
-                    $sql = "SELECT fk_user";
-                    $sql .= " FROM ".MAIN_DB_PREFIX."user_param";
-                    $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
-                    $sql .= " AND entity = ".$conf->entity;
-                    dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
-                    $resql = $db->query($sql);
-                    if ($resql)
-                    {
-                        $num = $db->num_rows($resql);
-                        $i = 0;
-                        while ($i < $num)
-                        {
-                            $obj = $db->fetch_object($resql);
-                            $distinctfkuser[$obj->fk_user] = $obj->fk_user;
-                            $i++;
-                        }
-                    } else {
-                        setEventMessages($db->lasterror(), null, 'errors');
-                        $error++;
-                    }
-                }
-
-                $distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val
-
-                foreach ($distinctfkuser as $fk_user)
-                {
-                    if (!$error && $fk_user != '')
-                    {
-                    	$arrayofexistingboxid = array();
-                        $nbboxonleft = $nbboxonright = 0;
-                        $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes";
-                        $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
-                        dol_syslog("boxes.php activate box", LOG_DEBUG);
-                        $resql = $db->query($sql);
-                        if ($resql)
-                        {
-                            while ($obj = $db->fetch_object($resql))
-                            {
-                                $boxorder = $obj->box_order;
-                                if (preg_match('/A/', $boxorder)) $nbboxonleft++;
-                                if (preg_match('/B/', $boxorder)) $nbboxonright++;
-                                $arrayofexistingboxid[$obj->box_id] = 1;
-                            }
-                        } else dol_print_error($db);
-
-                        if (empty($arrayofexistingboxid[$boxid['value']])) {
-	                        $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
-	                        $sql .= "box_id, position, box_order, fk_user, entity";
-	                        $sql .= ") values (";
-	                        $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
-	                        $sql .= ")";
-
-	                        dol_syslog("boxes.php activate box", LOG_DEBUG);
-	                        $resql = $db->query($sql);
-	                        if (!$resql)
-	                        {
-	                            setEventMessages($db->lasterror(), null, 'errors');
-	                            $error++;
-	                        }
-                        } else {
-                        	dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG);
-                        }
-                    }
-                }
-            }
-        }
-    }
-    if (!$error)
-    {
-        $db->commit();
-        $action = '';
-    } else {
-        $db->rollback();
-    }
+	$error = 0;
+	$db->begin();
+	if (isset($_POST['boxid']) && is_array($_POST['boxid']))
+	{
+		foreach ($_POST['boxid'] as $boxid)
+		{
+			if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0)	// 0=Home, 1=...
+			{
+				$pos = $boxid['pos'];
+
+				// Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
+				$distinctfkuser = array();
+				if (!$error)
+				{
+					$sql = "SELECT fk_user";
+					$sql .= " FROM ".MAIN_DB_PREFIX."user_param";
+					$sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
+					$sql .= " AND entity = ".$conf->entity;
+					dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
+					$resql = $db->query($sql);
+					if ($resql)
+					{
+						$num = $db->num_rows($resql);
+						$i = 0;
+						while ($i < $num)
+						{
+							$obj = $db->fetch_object($resql);
+							$distinctfkuser[$obj->fk_user] = $obj->fk_user;
+							$i++;
+						}
+					} else {
+						setEventMessages($db->lasterror(), null, 'errors');
+						$error++;
+					}
+				}
+
+				$distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val
+
+				foreach ($distinctfkuser as $fk_user)
+				{
+					if (!$error && $fk_user != '')
+					{
+						$arrayofexistingboxid = array();
+						$nbboxonleft = $nbboxonright = 0;
+						$sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes";
+						$sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
+						dol_syslog("boxes.php activate box", LOG_DEBUG);
+						$resql = $db->query($sql);
+						if ($resql)
+						{
+							while ($obj = $db->fetch_object($resql))
+							{
+								$boxorder = $obj->box_order;
+								if (preg_match('/A/', $boxorder)) $nbboxonleft++;
+								if (preg_match('/B/', $boxorder)) $nbboxonright++;
+								$arrayofexistingboxid[$obj->box_id] = 1;
+							}
+						} else dol_print_error($db);
+
+						if (empty($arrayofexistingboxid[$boxid['value']])) {
+							$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
+							$sql .= "box_id, position, box_order, fk_user, entity";
+							$sql .= ") values (";
+							$sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
+							$sql .= ")";
+
+							dol_syslog("boxes.php activate box", LOG_DEBUG);
+							$resql = $db->query($sql);
+							if (!$resql)
+							{
+								setEventMessages($db->lasterror(), null, 'errors');
+								$error++;
+							}
+						} else {
+							dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG);
+						}
+					}
+				}
+			}
+		}
+	}
+	if (!$error)
+	{
+		$db->commit();
+		$action = '';
+	} else {
+		$db->rollback();
+	}
 }
 
 if ($action == 'delete')
@@ -150,23 +150,23 @@ if ($action == 'delete')
 
 	$resql = $db->query($sql);
 	$obj = $db->fetch_object($resql);
-    if (!empty($obj->box_id))
-    {
-	    $db->begin();
+	if (!empty($obj->box_id))
+	{
+		$db->begin();
 
-    	// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
-        //	$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
-        //	$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
-        //	$resql = $db->query($sql);
+		// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
+		//	$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
+		//	$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
+		//	$resql = $db->query($sql);
 
-	    $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
-	    $sql .= " WHERE entity = ".$conf->entity;
-    	$sql .= " AND box_id=".$obj->box_id;
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
+		$sql .= " WHERE entity = ".$conf->entity;
+		$sql .= " AND box_id=".$obj->box_id;
 
-    	$resql = $db->query($sql);
+		$resql = $db->query($sql);
 
-    	$db->commit();
-    }
+		$db->commit();
+	}
 }
 
 if ($action == 'switch')
@@ -184,14 +184,14 @@ if ($action == 'switch')
 	$resultupdateto = 0;
 	if (is_object($objfrom) && is_object($objto))
 	{
-	    $newfirst = $objto->box_order;
+		$newfirst = $objto->box_order;
 		$newsecond = $objfrom->box_order;
-	    if ($newfirst == $newsecond)
-	    {
-	         $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond);
-	         $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond);
-	         $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1);
-	    }
+		if ($newfirst == $newsecond)
+		{
+			 $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond);
+			 $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond);
+			 $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1);
+		}
 		$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid;
 		dol_syslog($sql);
 		$resultupdatefrom = $db->query($sql);
@@ -268,7 +268,7 @@ if ($resql)
 
 	if ($decalage)
 	{
-	    // If we have renumbered, we correct the field box_order
+		// If we have renumbered, we correct the field box_order
 		// This occurs just after an insert.
 		$sql = "SELECT box_order";
 		$sql .= " FROM ".MAIN_DB_PREFIX."boxes";
@@ -339,34 +339,34 @@ print "</tr>\n";
 
 foreach ($boxtoadd as $box)
 {
-    if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg))
-    {
-        $logo = $box->boximg;
-    } else {
-        $logo = preg_replace("/^object_/i", "", $box->boximg);
-    }
-
-    print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
-    print '<tr class="oddeven">'."\n";
-    print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
-    if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
-    print '</td>'."\n";
-    print '<td>';
-    if ($box->note == '(WarningUsingThisBoxSlowDown)')
-    {
-    	$langs->load("errors");
-    	print $langs->trans("WarningUsingThisBoxSlowDown");
-    } else print ($box->note ? $box->note : '&nbsp;');
-    print '</td>'."\n";
-    print '<td>'.$box->sourcefile.'</td>'."\n";
-
-    // For each possible position, an activation link is displayed if the box is not already active for that position
-    print '<td class="center">';
-    print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n";
-    print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n";
-    print '</td>';
-
-    print '</tr>'."\n";
+	if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg))
+	{
+		$logo = $box->boximg;
+	} else {
+		$logo = preg_replace("/^object_/i", "", $box->boximg);
+	}
+
+	print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
+	print '<tr class="oddeven">'."\n";
+	print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
+	if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
+	print '</td>'."\n";
+	print '<td>';
+	if ($box->note == '(WarningUsingThisBoxSlowDown)')
+	{
+		$langs->load("errors");
+		print $langs->trans("WarningUsingThisBoxSlowDown");
+	} else print ($box->note ? $box->note : '&nbsp;');
+	print '</td>'."\n";
+	print '<td>'.$box->sourcefile.'</td>'."\n";
+
+	// For each possible position, an activation link is displayed if the box is not already active for that position
+	print '<td class="center">';
+	print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n";
+	print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n";
+	print '</td>';
+
+	print '</tr>'."\n";
 }
 if (!count($boxtoadd) && count($boxactivated))
 {
@@ -408,7 +408,7 @@ foreach ($boxactivated as $key => $box)
 		$logo = preg_replace("/^object_/i", "", $box->boximg);
 	}
 
-    print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
+	print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
 	print '<tr class="oddeven">';
 	print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
 	if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
@@ -465,10 +465,10 @@ print '</tr>';
 
 // Activate FileCache - Developement
 if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
-    print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
-    print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1);
-    print '</td>';
-    print '</tr>';
+	print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
+	print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1);
+	print '</td>';
+	print '</tr>';
 }
 
 print '</table>';

+ 169 - 169
htdocs/admin/commande.php

@@ -64,11 +64,11 @@ if ($action == 'updateMask')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
 	$modele = GETPOST('module', 'alpha');
@@ -81,7 +81,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -119,7 +119,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
+		if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -153,11 +153,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_ORDER_FREE_TEXT')
 {
 	$freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string
@@ -167,21 +167,21 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == "setshippableiconinlist") {
-    // Activate Set Shippable Icon In List
-    $setshippableiconinlist = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0) $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	// Activate Set Shippable Icon In List
+	$setshippableiconinlist = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0) $error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'setribchq')
 {
 	$rib = GETPOST('rib', 'alpha');
@@ -203,31 +203,31 @@ elseif ($action == 'setdoc')
 // Activate ask for payment bank
 elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
 {
-    $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
-    if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	if (!$error)
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 // Activate ask for warehouse
 elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
 {
-    $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
-    if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	if (!$error)
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -294,13 +294,13 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering model
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                        elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						// Show example of numbering model
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+						elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->COMMANDE_ADDON == $file)
@@ -321,16 +321,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$commande->type = 0;
 						$nextval = $module->getNextValue($mysoc, $commande);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -389,113 +389,113 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/commande".$valdir;
-    	$dir = dol_buildpath($realpath);
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/commande".$valdir;
+		$dir = dol_buildpath($realpath);
 
-        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)
-	                        {
-	                            print '<tr class="oddeven"><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 class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Default
-	                            print '<td class="center">';
-	                            if ($conf->global->COMMANDE_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-			                    $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("Discounts").': '.yn($module->option_escompte,1,1);
-					    		//$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+		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)
+							{
+								print '<tr class="oddeven"><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 class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Default
+								print '<td class="center">';
+								if ($conf->global->COMMANDE_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+								$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("Discounts").': '.yn($module->option_escompte,1,1);
+								//$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -636,11 +636,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans
 $variablename = 'ORDER_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

+ 1 - 1
htdocs/admin/company.php

@@ -109,7 +109,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
 
 	foreach ($arrayofimages as $varforimage)
 	{
-		if ($_FILES[$varforimage]["name"] && ! preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) {	// Logo can be used on a lot of different places. Only jpg and png can be supported.
+		if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) {	// Logo can be used on a lot of different places. Only jpg and png can be supported.
 			$langs->load("errors");
 			setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
 			break;

+ 138 - 138
htdocs/admin/contract.php

@@ -41,7 +41,7 @@ $type = 'contract';
 
 if (empty($conf->global->CONTRACT_ADDON))
 {
-    $conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
+	$conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
 }
 
 
@@ -53,18 +53,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-    $maskconst = GETPOST('maskconstcontract', 'alpha');
-    $maskvalue = GETPOST('maskcontract', 'alpha');
-    if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
+	$maskconst = GETPOST('maskconstcontract', 'alpha');
+	$maskvalue = GETPOST('maskcontract', 'alpha');
+	if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen') // For contract
 {
 	$modele = GETPOST('module', 'alpha');
@@ -77,7 +77,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -115,7 +115,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
+		if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -149,17 +149,17 @@ elseif ($action == 'setdoc')
 	$draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha');
 	$res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
 
-    $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
-    $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
+	$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
+	$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
 
 	if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $contract);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -319,111 +319,111 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/contract".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        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)
-	                        {
-	                            print '<tr class="oddeven"><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 class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->CONTRACT_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-			                    $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 class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="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";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/contract".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		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)
+							{
+								print '<tr class="oddeven"><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 class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->CONTRACT_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+								$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 class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="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>';
@@ -457,11 +457,11 @@ print '<br>';
 $variablename = 'CONTRACT_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td></tr>'."\n";
 

+ 46 - 46
htdocs/admin/emailcollector_card.php

@@ -165,19 +165,19 @@ if (GETPOST('addoperation', 'alpha'))
 
 if ($action == 'updateoperation')
 {
-    $emailcollectoroperation = new EmailCollectorAction($db);
-    $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
+	$emailcollectoroperation = new EmailCollectorAction($db);
+	$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
 
-    $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none');
+	$emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none');
 
-    $result = $emailcollectoroperation->update($user);
+	$result = $emailcollectoroperation->update($user);
 
-    if ($result > 0)
-    {
-        $object->fetchActions();
-    } else {
-        setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
-    }
+	if ($result > 0)
+	{
+		$object->fetchActions();
+	} else {
+		setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
+	}
 }
 if ($action == 'deleteoperation')
 {
@@ -199,11 +199,11 @@ if ($action == 'confirm_collect')
 	$res = $object->doCollectOneCollector();
 	if ($res > 0)
 	{
-	    $debuginfo = $object->debuginfo;
-	    setEventMessages($object->lastresult, null, 'mesgs');
+		$debuginfo = $object->debuginfo;
+		setEventMessages($object->lastresult, null, 'mesgs');
 	} else {
-	    $debuginfo = $object->debuginfo;
-	    setEventMessages($object->error, null, 'errors');
+		$debuginfo = $object->debuginfo;
+		setEventMessages($object->error, null, 'errors');
 	}
 
 	$action = '';
@@ -475,27 +475,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '<tr class="oddeven">';
 	print '<td>';
 	$arrayoftypes = array(
-	    'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')),
-	    // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2
-	    //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'),                // HEADER key value
-	    //'X1'=>'---',
-	    //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'),
-	    //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'),
-	    'X2'=>'---',
-	    'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1),
-	    'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1),
-	    'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1),
-	    'answered'=>array('label'=>'Answered', 'data-noparam'=>1),
-	    'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
-	    'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
-	    'X3'=>'---',
-	    'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1),
-	    'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1),
+		'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')),
+		'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')),
+		'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')),
+		'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')),
+		'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')),
+		'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')),
+		// disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2
+		//'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'),                // HEADER key value
+		//'X1'=>'---',
+		//'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'),
+		//'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'),
+		'X2'=>'---',
+		'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1),
+		'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1),
+		'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1),
+		'answered'=>array('label'=>'Answered', 'data-noparam'=>1),
+		'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
+		'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
+		'X3'=>'---',
+		'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1),
+		'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1),
 		'X4'=>'---',
 		'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1),
 		'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1)
@@ -559,9 +559,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '<tr class="oddeven">';
 	print '<td>';
 	$arrayoftypes = array(
-	    'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
-	    'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
-	    'recordevent'=>'RecordEvent');
+		'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
+		'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
+		'recordevent'=>'RecordEvent');
 	if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
 	if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
 	if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature';
@@ -602,7 +602,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 		print $langs->trans($arrayoftypes[$ruleaction['type']]);
 		if (in_array($ruleaction['type'], array('recordevent')))
 		{
-            print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
+			print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
 		} elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
 			print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
 		}
@@ -610,11 +610,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 		print '<td class="wordbreak">';
 		if ($action == 'editoperation' && $ruleaction['id'] == $operationid)
 		{
-		    print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
-		    print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
-		    print '<input type="submit" class="button" name="saveoperation2" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+			print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
+			print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
+			print '<input type="submit" class="button" name="saveoperation2" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
 		} else {
-		    print $ruleaction['actionparam'];
+			print $ruleaction['actionparam'];
 		}
 		print '</td>';
 		// Move up/down
@@ -641,7 +641,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '</div>';
 
 	if (!empty($conf->use_javascript_ajax)) {
-	    $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
+		$urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
 		include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
 	}
 
@@ -668,7 +668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 			print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a></div>';
 
 			// Clone
-		    print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
+			print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
 
 		    // Collect now
 		    if (count($object->actions) > 0) {
@@ -684,7 +684,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	if (!empty($debuginfo))
 	{
-	    print info_admin($debuginfo);
+		print info_admin($debuginfo);
 	}
 
 

+ 124 - 124
htdocs/admin/expedition.php

@@ -48,7 +48,7 @@ $type = 'shipping';
 
 if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
 {
-    $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor';
+	$conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor';
 }
 
 
@@ -105,7 +105,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -143,7 +143,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity);
+		if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -231,14 +231,14 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering module
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) {
+						// Show example of numbering module
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) {
 							$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
 						} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file")
@@ -258,16 +258,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $expedition);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -328,107 +328,107 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$dir = dol_buildpath($reldir."core/modules/expedition".$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)
-	                        {
-	                            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);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->EXPEDITION_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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 class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$dir = dol_buildpath($reldir."core/modules/expedition".$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)
+							{
+								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);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->EXPEDITION_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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 class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -461,11 +461,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->tr
 $variablename = 'SHIPPING_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print "</td></tr>\n";
 

+ 427 - 427
htdocs/admin/facture.php

@@ -53,66 +53,66 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-    $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
-    $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha');
-    $maskconstcredit = GETPOST('maskconstcredit', 'alpha');
+	$maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
+	$maskconstreplacement = GETPOST('maskconstreplacement', 'alpha');
+	$maskconstcredit = GETPOST('maskconstcredit', 'alpha');
 	$maskconstdeposit = GETPOST('maskconstdeposit', 'alpha');
-    $maskinvoice = GETPOST('maskinvoice', 'alpha');
-    $maskreplacement = GETPOST('maskreplacement', 'alpha');
-    $maskcredit = GETPOST('maskcredit', 'alpha');
+	$maskinvoice = GETPOST('maskinvoice', 'alpha');
+	$maskreplacement = GETPOST('maskreplacement', 'alpha');
+	$maskcredit = GETPOST('maskcredit', 'alpha');
 	$maskdeposit = GETPOST('maskdeposit', 'alpha');
-    if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
-    if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
-    if ($maskconstcredit)  $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
+	if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
+	if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
+	if ($maskconstcredit)  $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
 	if ($maskconstdeposit)  $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
-    $modele = GETPOST('module', 'alpha');
+	$modele = GETPOST('module', 'alpha');
 
-    $facture = new Facture($db);
-    $facture->initAsSpecimen();
+	$facture = new Facture($db);
+	$facture->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/facture/doc/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($facture, $langs) > 0)
-    	{
-    		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&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);
-    }
+		$file = dol_buildpath($reldir."core/modules/facture/doc/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($facture, $langs) > 0)
+		{
+			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&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);
+	}
 }
 // Activate a model
 elseif ($action == 'set')
@@ -123,7 +123,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
+		if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
 	}
 }
 // Set default model
@@ -144,89 +144,89 @@ elseif ($action == 'setdoc')
 	}
 } elseif ($action == 'setmod')
 {
-    // TODO Verifier si module numerotation choisi peut etre active
-    // par appel methode canBeActivated
+	// TODO Verifier si module numerotation choisi peut etre active
+	// par appel methode canBeActivated
 
-    dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
 } elseif ($action == 'setribchq')
 {
 	$rib = GETPOST('rib', 'alpha');
 	$chq = GETPOST('chq', 'alpha');
 
 	$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
-    $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_FACTURE_DRAFT_WATERMARK')
 {
 	$draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha');
 
-    $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_INVOICE_FREE_TEXT')
 {
 	$freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string
 
-    $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'setforcedate')
 {
 	$forcedate = GETPOST('forcedate', 'alpha');
 
-    $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'setDefaultPDFModulesByType')
 {
-    $invoicetypemodels = GETPOST('invoicetypemodels');
-
-    if (!empty($invoicetypemodels) && is_array($invoicetypemodels))
-    {
-        $error = 0;
-
-        foreach ($invoicetypemodels as $type => $value)
-        {
-            $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
-            if (!$res > 0) $error++;
-        }
-
-        if (!$error)
-        {
-            setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-        } else {
-            setEventMessages($langs->trans("Error"), null, 'errors');
-        }
-    }
+	$invoicetypemodels = GETPOST('invoicetypemodels');
+
+	if (!empty($invoicetypemodels) && is_array($invoicetypemodels))
+	{
+		$error = 0;
+
+		foreach ($invoicetypemodels as $type => $value)
+		{
+			$res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
+			if (!$res > 0) $error++;
+		}
+
+		if (!$error)
+		{
+			setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+		} else {
+			setEventMessages($langs->trans("Error"), null, 'errors');
+		}
+	}
 }
 
 
@@ -267,144 +267,144 @@ clearstatcache();
 foreach ($dirmodels as $reldir)
 {
 	$dir = dol_buildpath($reldir."core/modules/facture/");
-    if (is_dir($dir))
-    {
-        $handle = opendir($dir);
-        if (is_resource($handle))
-        {
-            while (($file = readdir($handle)) !== false)
-            {
-                if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
-                {
-                    $filebis = $file;
-                    $classname = preg_replace('/\.php$/', '', $file);
-                    // For compatibility
-                    if (!is_file($dir.$filebis))
-                    {
-                        $filebis = $file."/".$file.".modules.php";
-                        $classname = "mod_facture_".$file;
-                    }
-                    // Check if there is a filter on country
-                    preg_match('/\-(.*)_(.*)$/', $classname, $reg);
-                    if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
-
-                    $classname = preg_replace('/\-.*$/', '', $classname);
-                    if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
-                    {
-                        // Charging the numbering class
-                        require_once $dir.$filebis;
-
-                        $module = new $classname($db);
-
-                        // Show modules according to features level
-                        if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
-                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
-                        if ($module->isEnabled())
-                        {
-                            print '<tr class="oddeven"><td width="100">';
-                            echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
-                            print "</td><td>\n";
-
-                            print $module->info();
-
-                            print '</td>';
-
-                            // Show example of numbering module
-                            print '<td class="nowrap">';
-                            $tmp = $module->getExample();
-                            if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                            elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                            else print $tmp;
-                            print '</td>'."\n";
-
-                            print '<td class="center">';
-                            //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
-                            if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file)
-                            {
-                                print img_picto($langs->trans("Activated"), 'switch_on');
-                            } else {
-                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-                            }
-                            print '</td>';
-
-                            $facture = new Facture($db);
-                            $facture->initAsSpecimen();
-
-                            // Example for standard invoice
-                            $htmltooltip = '';
-                            $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-                            $facture->type = 0;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval.'<br>';
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error).'<br>';
-                                }
-                            }
-                            // Example for remplacement
-                            $facture->type = 1;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval.'<br>';
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error).'<br>';
-                                }
-                            }
-
-                            // Example for credit invoice
-                            $facture->type = 2;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval.'<br>';
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error).'<br>';
-                                }
-                            }
-                            // Example for deposit invoice
-                            $facture->type = 3;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval;
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error);
-                                }
-                            }
-
-                            print '<td class="center">';
-                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-
-                            if ($conf->global->FACTURE_ADDON.'.php' == $file)  // If module is the one used, we show existing errors
-                            {
-                                if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
-                            }
-
-                            print '</td>';
-
-                            print "</tr>\n";
-                        }
-                    }
-                }
-            }
-            closedir($handle);
-        }
-    }
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+			while (($file = readdir($handle)) !== false)
+			{
+				if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
+				{
+					$filebis = $file;
+					$classname = preg_replace('/\.php$/', '', $file);
+					// For compatibility
+					if (!is_file($dir.$filebis))
+					{
+						$filebis = $file."/".$file.".modules.php";
+						$classname = "mod_facture_".$file;
+					}
+					// Check if there is a filter on country
+					preg_match('/\-(.*)_(.*)$/', $classname, $reg);
+					if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
+
+					$classname = preg_replace('/\-.*$/', '', $classname);
+					if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
+					{
+						// Charging the numbering class
+						require_once $dir.$filebis;
+
+						$module = new $classname($db);
+
+						// Show modules according to features level
+						if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+						if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
+						if ($module->isEnabled())
+						{
+							print '<tr class="oddeven"><td width="100">';
+							echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
+							print "</td><td>\n";
+
+							print $module->info();
+
+							print '</td>';
+
+							// Show example of numbering module
+							print '<td class="nowrap">';
+							$tmp = $module->getExample();
+							if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+							elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+							else print $tmp;
+							print '</td>'."\n";
+
+							print '<td class="center">';
+							//print "> ".$conf->global->FACTURE_ADDON." - ".$file;
+							if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file)
+							{
+								print img_picto($langs->trans("Activated"), 'switch_on');
+							} else {
+								print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+							}
+							print '</td>';
+
+							$facture = new Facture($db);
+							$facture->initAsSpecimen();
+
+							// Example for standard invoice
+							$htmltooltip = '';
+							$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+							$facture->type = 0;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForInvoices").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval.'<br>';
+								} else {
+									$htmltooltip .= $langs->trans($module->error).'<br>';
+								}
+							}
+							// Example for remplacement
+							$facture->type = 1;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForReplacements").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval.'<br>';
+								} else {
+									$htmltooltip .= $langs->trans($module->error).'<br>';
+								}
+							}
+
+							// Example for credit invoice
+							$facture->type = 2;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval.'<br>';
+								} else {
+									$htmltooltip .= $langs->trans($module->error).'<br>';
+								}
+							}
+							// Example for deposit invoice
+							$facture->type = 3;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForDeposit").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval;
+								} else {
+									$htmltooltip .= $langs->trans($module->error);
+								}
+							}
+
+							print '<td class="center">';
+							print $form->textwithpicto('', $htmltooltip, 1, 0);
+
+							if ($conf->global->FACTURE_ADDON.'.php' == $file)  // If module is the one used, we show existing errors
+							{
+								if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
+							}
+
+							print '</td>';
+
+							print "</tr>\n";
+						}
+					}
+				}
+			}
+			closedir($handle);
+		}
+	}
 }
 
 print '</table>';
@@ -426,16 +426,16 @@ $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++;
-    }
+	$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);
+	dol_print_error($db);
 }
 
 print '<table class="noborder centpercent">';
@@ -454,156 +454,156 @@ $activatedModels = array();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/facture".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        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)
-	                        {
-	                            print '<tr class="oddeven"><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 class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->FACTURE_ADDON_PDF == "$name")
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), '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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-	                            $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("Discounts").': '.yn($module->option_escompte, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/facture".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		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)
+							{
+								print '<tr class="oddeven"><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 class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->FACTURE_ADDON_PDF == "$name")
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), '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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+								$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("Discounts").': '.yn($module->option_escompte, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 print '</table>';
 
 if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
 {
-    /*
+	/*
      *  Document templates generators
      */
-    print '<br>';
-    print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
-    print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
-    print '<input type="hidden" name="token" value="'.newToken().'" />';
-    print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
-    print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
-    print '<tr class="liste_titre">';
-    print '<td>'.$langs->trans("Type").'</td>';
-    print '<td>'.$langs->trans("Name").'</td>';
-    print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
-    print "</tr>\n";
-
-    $listtype = array(
-        Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
-        Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
-        Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
-        Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
-    );
-    if (!empty($conf->global->INVOICE_USE_SITUATION))
-    {
-        $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
-    }
-
-    foreach ($listtype as $type => $trans)
-    {
-        $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
-        $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
-        print '<tr >';
-        print '<td>'.$trans.'</td>';
-        print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
-        print "</tr>\n";
-    }
-
-    print '</table>';
-    print "</form>";
+	print '<br>';
+	print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
+	print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
+	print '<input type="hidden" name="token" value="'.newToken().'" />';
+	print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
+	print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
+	print '<tr class="liste_titre">';
+	print '<td>'.$langs->trans("Type").'</td>';
+	print '<td>'.$langs->trans("Name").'</td>';
+	print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+	print "</tr>\n";
+
+	$listtype = array(
+		Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
+		Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
+		Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
+		Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
+	);
+	if (!empty($conf->global->INVOICE_USE_SITUATION))
+	{
+		$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
+	}
+
+	foreach ($listtype as $type => $trans)
+	{
+		$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
+		$current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
+		print '<tr >';
+		print '<td>'.$trans.'</td>';
+		print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
+		print "</tr>\n";
+	}
+
+	print '</table>';
+	print "</form>";
 }
 
 /*
@@ -629,37 +629,37 @@ print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
 print "<td>";
 if (!empty($conf->banque->enabled))
 {
-    $sql = "SELECT rowid, label";
-    $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
-    $sql .= " WHERE clos = 0";
-    $sql .= " AND courant = 1";
-    $sql .= " AND entity IN (".getEntity('bank_account').")";
-    $resql = $db->query($sql);
-    if ($resql)
-    {
-        $num = $db->num_rows($resql);
-        $i = 0;
-        if ($num > 0)
-        {
-        	print '<select name="rib" class="flat" id="rib">';
-        	print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
-            while ($i < $num)
-            {
-                $row = $db->fetch_row($resql);
-
-                print '<option value="'.$row[0].'"';
-                print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
-                print '>'.$row[1].'</option>';
-
-                $i++;
-            }
-            print "</select>";
-        } else {
-        	print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
-        }
-    }
+	$sql = "SELECT rowid, label";
+	$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
+	$sql .= " WHERE clos = 0";
+	$sql .= " AND courant = 1";
+	$sql .= " AND entity IN (".getEntity('bank_account').")";
+	$resql = $db->query($sql);
+	if ($resql)
+	{
+		$num = $db->num_rows($resql);
+		$i = 0;
+		if ($num > 0)
+		{
+			print '<select name="rib" class="flat" id="rib">';
+			print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
+			while ($i < $num)
+			{
+				$row = $db->fetch_row($resql);
+
+				print '<option value="'.$row[0].'"';
+				print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
+				print '>'.$row[1].'</option>';
+
+				$i++;
+			}
+			print "</select>";
+		} else {
+			print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
+		}
+	}
 } else {
-    print $langs->trans("BankModuleNotActive");
+	print $langs->trans("BankModuleNotActive");
 }
 print "</td></tr>";
 
@@ -679,18 +679,18 @@ $sql .= " AND entity IN (".getEntity('bank_account').")";
 $resql = $db->query($sql);
 if ($resql)
 {
-    $num = $db->num_rows($resql);
-    $i = 0;
-    while ($i < $num)
-    {
-        $row = $db->fetch_row($resql);
-
-        print '<option value="'.$row[0].'"';
-        print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
-        print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
-
-        $i++;
-    }
+	$num = $db->num_rows($resql);
+	$i = 0;
+	while ($i < $num)
+	{
+		$row = $db->fetch_row($resql);
+
+		print '<option value="'.$row[0].'"';
+		print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
+		print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
+
+		$i++;
+	}
 }
 print "</select>";
 print "</td></tr>";
@@ -735,11 +735,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra
 $variablename = 'INVOICE_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';

+ 143 - 143
htdocs/admin/holiday.php

@@ -43,7 +43,7 @@ $type = 'contract';
 
 if (empty($conf->global->HOLIDAY_ADDON))
 {
-    $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
+	$conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
 }
 
 
@@ -55,18 +55,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-    $maskconst = GETPOST('maskconstholiday', 'alpha');
-    $maskvalue = GETPOST('maskholiday', 'alpha');
-    if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
+	$maskconst = GETPOST('maskconstholiday', 'alpha');
+	$maskvalue = GETPOST('maskholiday', 'alpha');
+	if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen') // For contract
 {
 	$modele = GETPOST('module', 'alpha');
@@ -79,7 +79,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -117,7 +117,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity);
+		if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -154,11 +154,11 @@ elseif ($action == 'setdoc')
 	if (!$res1 > 0 || !$res2 > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $holiday);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -282,11 +282,11 @@ print '<br>';
 
 
 if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
-    dol_fiche_end();
-    // End of page
-    llxFooter();
-    $db->close();
-    exit;
+	dol_fiche_end();
+	// End of page
+	llxFooter();
+	$db->close();
+	exit;
 }
 
 /*
@@ -304,8 +304,8 @@ $sql .= " AND entity = ".$conf->entity;
 $resql = $db->query($sql);
 if ($resql)
 {
-    $i = 0;
-    $num_rows = $db->num_rows($resql);
+	$i = 0;
+	$num_rows = $db->num_rows($resql);
 	while ($i < $num_rows)
 	{
 		$array = $db->fetch_array($resql);
@@ -332,111 +332,111 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/holiday".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        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)
-	                        {
-	                            print '<tr class="oddeven"><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 class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Default
-	                            print '<td class="center">';
-	                            if ($conf->global->HOLIDAY_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-			                    $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 class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="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";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/holiday".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		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)
+							{
+								print '<tr class="oddeven"><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 class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Default
+								print '<td class="center">';
+								if ($conf->global->HOLIDAY_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+								$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 class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="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>';
@@ -473,11 +473,11 @@ print '<br>';
 $variablename = 'HOLIDAY_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td></tr>'."\n";
 

Разлика између датотеке није приказан због своје велике величине
+ 471 - 471
htdocs/admin/mails_templates.php


+ 574 - 0
htdocs/admin/mails_ticket.php

@@ -0,0 +1,574 @@
+<?php
+/* Copyright (C) 2007-2017 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2009-2012 Regis Houssin        <regis.houssin@inodbox.com>
+ * Copyright (C) 2013	   Juanjo Menent		<jmenent@2byte.es>
+ * Copyright (C) 2016      Jonathan TISSEAU     <jonathan.tisseau@86dev.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 <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/admin/mails_ticket.php
+ *       \brief      Page to setup mails for ticket
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'errors'));
+
+$action = GETPOST('action', 'alpha');
+
+if (!$user->admin) accessforbidden();
+
+$usersignature = $user->signature;
+// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
+if ($action == 'test' || $action == 'send')
+{
+	$usersignature = dol_string_nohtmltag($usersignature);
+}
+
+$substitutionarrayfortest = array(
+'__LOGIN__' => $user->login,
+'__ID__' => 'TESTIdRecord',
+'__EMAIL__' => 'TESTEMail',
+'__LASTNAME__' => 'TESTLastname',
+'__FIRSTNAME__' => 'TESTFirstname',
+'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''),
+//'__PERSONALIZED__' => 'TESTPersonalized'	// Hiden because not used yet
+);
+complete_substitutions_array($substitutionarrayfortest, $langs);
+
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'update' && empty($_POST["cancel"]))
+{
+    // Send mode parameters
+	dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_TICKET", GETPOST("MAIN_MAIL_SMTPS_ID_TICKET"), 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET"), 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity);
+
+	header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
+	exit;
+}
+
+
+// Actions to send emails
+$id = 0;
+$actiontypecode = ''; // Not an event for agenda
+$triggersendname = ''; // Disable triggers
+$paramname = 'id';
+$mode = 'emailfortest';
+$trackid = (($action == 'testhtml') ? "testhtml" : "test");
+$sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket
+include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
+
+if ($action == 'presend' && GETPOST('trackid') == 'test')       $action = 'test';
+if ($action == 'presend' && GETPOST('trackid') == 'testhtml')   $action = 'testhtml';
+
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$linuxlike = 1;
+if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0;
+if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0;
+
+if (empty($conf->global->MAIN_MAIL_SENDMODE_TICKET)) $conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default';
+$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get('smtp_port');
+if (!$port) $port = 25;
+$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get('SMTP');
+if (!$server) $server = '127.0.0.1';
+
+
+$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
+llxHeader('', $langs->trans("Setup"), $wikihelp);
+
+print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
+
+$head = email_admin_prepare_head();
+
+// List of sending methods
+$listofmethods = array();
+$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
+$listofmethods['mail'] = 'PHP mail function';
+//$listofmethods['simplemail']='Simplemail class';
+$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
+$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
+
+
+if ($action == 'edit')
+{
+	if ($conf->use_javascript_ajax)
+	{
+		print "\n".'<script type="text/javascript" language="javascript">';
+		print 'jQuery(document).ready(function () {
+                    function initfields()
+                    {
+                        if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
+                        {
+                            jQuery(".hideifdefault").hide();
+						}
+						else
+						{
+                            jQuery(".hideifdefault").show();
+						}
+
+						if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
+                        {
+                            jQuery(".drag").hide();
+                            jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
+                            jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
+                            jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
+                            jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
+                            ';
+		if ($linuxlike)
+		{
+			print '
+			               jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
+			               jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
+			               jQuery("#smtp_server_mess").show();
+			               jQuery("#smtp_port_mess").show();
+			               ';
+		} else {
+			print '
+			               jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
+			               jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
+			               jQuery("#smtp_server_mess").hide();
+			               jQuery("#smtp_port_mess").hide();
+			               ';
+		}
+		print '
+                        }
+                        if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
+                        {
+                            jQuery(".drag").show();
+                            jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.');
+                            jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET.');
+                            jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
+                            jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
+                            jQuery("#smtp_server_mess").hide();
+			                jQuery("#smtp_port_mess").hide();
+						}
+                        if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
+                        {
+                            jQuery(".drag").show();
+                            jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.');
+                            jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET.');
+                            jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
+                            jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
+                            jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
+                            jQuery("#smtp_server_mess").hide();
+                            jQuery("#smtp_port_mess").hide();
+                        }
+                    }
+                    initfields();
+                    jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
+                        initfields();
+                    });
+					jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
+						if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
+							jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
+					});
+					jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
+						if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
+							jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
+					});
+               })';
+		print '</script>'."\n";
+	}
+
+	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+	print '<input type="hidden" name="token" value="'.newToken().'">';
+	print '<input type="hidden" name="action" value="update">';
+
+	dol_fiche_head($head, 'common_ticket', '', -1);
+
+	print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
+	print "<br>\n";
+
+
+	clearstatcache();
+
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+	// Method
+
+	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
+
+	// SuperAdministrator access only
+	if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
+	{
+		print $form->selectarray('MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
+	} else {
+		$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET];
+		if (empty($text)) $text = $langs->trans("Undefined");
+		$htmltext = $langs->trans("ContactSuperAdminForChange");
+		print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
+		print '<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="'.$conf->global->MAIN_MAIL_SENDMODE_TICKET.'">';
+	}
+	print '</td></tr>';
+
+	// Host server
+
+	print '<tr class="oddeven hideifdefault"><td>';
+	if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')
+	{
+		print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
+		print '</td><td>';
+		print $langs->trans("SeeLocalSendMailSetup");
+	} else {
+		$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '');
+		$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
+		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
+		else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
+		print '</td><td>';
+		// SuperAdministrator access only
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.'">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.'">';
+			print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
+		} else {
+			$text = !empty($mainserver) ? $mainserver : $smtpserver;
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.'">';
+		}
+	}
+	print '</td></tr>';
+
+	// Port
+
+	print '<tr class="oddeven hideifdefault"><td>';
+	if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')
+	{
+		print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
+		print '</td><td>';
+		print $langs->trans("SeeLocalSendMailSetup");
+	} else {
+		$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '');
+		$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
+		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
+		else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
+		print '</td><td>';
+		// SuperAdministrator access only
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.'">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.'">';
+			print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
+		} else {
+			$text = (!empty($mainport) ? $mainport : $smtpport);
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.'">';
+		}
+	}
+	print '</td></tr>';
+
+	// ID
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))))
+	{
+		$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : '');
+		print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
+		// SuperAdministrator access only
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.'">';
+		} else {
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1, 'superadmin');
+			print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.'">';
+		}
+		print '</td></tr>';
+	}
+
+	// PW
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))))
+	{
+		$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : '');
+		print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
+		// SuperAdministrator access only
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.'">';
+		} else {
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1, 'superadmin');
+			print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.'">';
+		}
+		print '</td></tr>';
+	}
+
+	// TLS
+
+	print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))))
+	{
+		if (function_exists('openssl_open'))
+		{
+			print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
+		} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
+	} else print yn(0).' ('.$langs->trans("NotSupported").')';
+	print '</td></tr>';
+
+	// STARTTLS
+
+	print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))))
+	{
+		if (function_exists('openssl_open'))
+		{
+			print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
+		} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
+	} else print yn(0).' ('.$langs->trans("NotSupported").')';
+	print '</td></tr>';
+
+    print '</table>';
+
+    dol_fiche_end();
+
+    print '<br><div class="center">';
+    print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
+    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+    print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
+    print '</div>';
+
+	print '</form>';
+} else {
+    dol_fiche_head($head, 'common_ticket', '', -1);
+
+    print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
+    print "<br>\n";
+
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+	// Method
+	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
+	$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET];
+	if (empty($text)) $text = $langs->trans("Undefined").img_warning();
+	print $text;
+	print '</td></tr>';
+
+	if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default')
+	{
+		// Host server
+		if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail'))
+		{
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
+		} else {
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '').'</td></tr>';
+		}
+
+		// Port
+		if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail'))
+		{
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
+		} else {
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '').'</td></tr>';
+		}
+
+		// SMTPS ID
+		if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))
+		{
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'</td></tr>';
+		}
+
+		// SMTPS PW
+		if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))
+		{
+			print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).'</td></tr>';
+		}
+
+		// TLS
+		print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
+		if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))
+		{
+			if (function_exists('openssl_open'))
+			{
+				print yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET);
+			} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
+		} else print yn(0).' ('.$langs->trans("NotSupported").')';
+		print '</td></tr>';
+
+		// STARTTLS
+		print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
+		if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))
+		{
+			if (function_exists('openssl_open'))
+			{
+				print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET);
+			} else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
+		} else print yn(0).' ('.$langs->trans("NotSupported").')';
+		print '</td></tr>';
+	}
+
+	print '</table>';
+
+	dol_fiche_end();
+
+
+    if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
+    {
+        print '<br>';
+        /*
+	    // Warning 1
+    	if ($linuxlike)
+    	{
+    		$sendmailoption=ini_get('mail.force_extra_parameters');
+    		if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
+    		{
+    			print info_admin($langs->trans("SendmailOptionNotComplete"));
+    		}
+    	}*/
+    	// Warning 2
+   	    print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
+    }
+
+
+    // Buttons for actions
+
+	print '<div class="tabsAction">';
+
+	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+
+	if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default')
+	{
+		if ($conf->global->MAIN_MAIL_SENDMODE_TICKET != 'mail' || !$linuxlike)
+		{
+			if (function_exists('fsockopen') && $port && $server)
+			{
+				print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
+			}
+		} else {
+			print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
+		}
+
+		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
+
+		if (!empty($conf->fckeditor->enabled))
+		{
+			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
+		}
+	}
+
+	print '</div>';
+
+
+	if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml')))
+	{
+        $text = $langs->trans("WarningPHPMail");
+	    print info_admin($text);
+	}
+
+	// Run the test to connect
+	if ($action == 'testconnect')
+	{
+		print load_fiche_titre($langs->trans("DoTestServerAvailability"));
+
+		include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+		$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
+
+		$result = $mail->check_server_port($server, $port);
+		if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
+		else {
+			$errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
+
+			if ($mail->error) {
+				$errormsg .= ' - '.$mail->error;
+			}
+
+			setEventMessages($errormsg, null, 'errors');
+		}
+		print '<br>';
+	}
+
+	// Show email send test form
+	if ($action == 'test' || $action == 'testhtml')
+	{
+	    print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
+		print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
+
+		dol_fiche_head('');
+
+		// Cree l'objet formulaire mail
+		include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+		$formmail = new FormMail($db);
+		$formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
+		$formmail->withfromreadonly = 0;
+		$formmail->withsubstit = 0;
+		$formmail->withfrom = 1;
+		$formmail->witherrorsto = 1;
+		$formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1));
+		$formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty
+		$formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty
+		$formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test"));
+		$formmail->withtopicreadonly = 0;
+		$formmail->withfile = 2;
+		$formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
+		$formmail->withbodyreadonly = 0;
+		$formmail->withcancel = 1;
+		$formmail->withdeliveryreceipt = 1;
+		$formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
+		$formmail->ckeditortoolbar = 'dolibarr_mailings';
+		// Tableau des substitutions
+		$formmail->substit = $substitutionarrayfortest;
+		// Tableau des parametres complementaires du post
+		$formmail->param["action"] = "send";
+		$formmail->param["models"] = "body";
+		$formmail->param["mailid"] = 0;
+		$formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
+
+		// Init list of files
+        if (GETPOST("mode") == 'init')
+		{
+			$formmail->clear_attached_files();
+		}
+
+		print $formmail->get_form('addfile', 'removefile');
+
+		dol_fiche_end();
+	}
+}
+
+// End of page
+llxFooter();
+$db->close();

+ 1 - 3
htdocs/admin/menus/edit.php

@@ -89,7 +89,6 @@ if ($action == 'update')
         $result = $menu->fetch(GETPOST('menuId', 'int'));
         if ($result > 0)
         {
-            $menu->titre = GETPOST('titre', 'alpha'); // deprecated
             $menu->title = GETPOST('titre', 'alpha');
             $menu->leftmenu = GETPOST('leftmenu', 'aZ09');
             $menu->url = GETPOST('url', 'alpha');
@@ -200,7 +199,6 @@ if ($action == 'add')
         $menu = new Menubase($db);
         $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09'));
         $menu->type = GETPOST('type', 'alpha');
-        $menu->titre = GETPOST('titre', 'alpha'); // deprecated
         $menu->title = GETPOST('titre', 'alpha');
         $menu->url = GETPOST('url', 'alpha');
         $menu->langs = GETPOST('langs', 'alpha');
@@ -478,7 +476,7 @@ if ($action == 'create')
     //print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
 
     // Title
-    print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->titre ? $menu->titre : $menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
+    print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" class="minwidth300" name="titre" value="'.dol_escape_htmltag($menu->title).'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
 
     // Url
     print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" class="quatrevingtpercent" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';

+ 141 - 141
htdocs/admin/mrp.php

@@ -56,11 +56,11 @@ if ($action == 'updateMask')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
 	$modele = GETPOST('module', 'alpha');
@@ -73,7 +73,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -111,7 +111,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
+		if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -145,11 +145,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_MRP_MO_FREE_TEXT')
 {
 	$freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string
@@ -159,11 +159,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -212,7 +212,7 @@ foreach ($dirmodels as $reldir)
 		{
 			while (($file = readdir($handle)) !== false)
 			{
-			    if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
+				if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
 				{
 					$file = substr($file, 0, dol_strlen($file) - 4);
 
@@ -230,13 +230,13 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering model
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                        elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						// Show example of numbering model
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+						elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->MRP_MO_ADDON == $file)
@@ -257,16 +257,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$mrp->type = 0;
 						$nextval = $module->getNextValue($mysoc, $mrp);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -325,108 +325,108 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/mrp".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        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)
-	                        {
-	                            print '<tr class="oddeven"><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 class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Default
-	                            print '<td class="center">';
-	                            if ($conf->global->MRP_MO_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-			                    $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/mrp".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		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)
+							{
+								print '<tr class="oddeven"><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 class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Default
+								print '<td class="center">';
+								if ($conf->global->MRP_MO_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+								$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -458,11 +458,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("A
 $variablename = 'MRP_MO_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

+ 125 - 125
htdocs/admin/reception_setup.php

@@ -45,13 +45,13 @@ $type = 'reception';
 
 if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION))
 {
-    // This option should always be set to on when module is on.
-    dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
+	// This option should always be set to on when module is on.
+	dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
 }
 
 if (empty($conf->global->RECEPTION_ADDON_NUMBER))
 {
-    $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl';
+	$conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl';
 }
 
 
@@ -108,7 +108,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -146,7 +146,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity);
+		if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -236,14 +236,14 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering module
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) {
+						// Show example of numbering module
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) {
 							$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
 						} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->RECEPTION_ADDON_NUMBER == "$file")
@@ -263,16 +263,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $reception);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -333,110 +333,110 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/reception".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        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)
-	                        {
-	                            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);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->RECEPTION_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-			                    $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 class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/reception".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		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)
+							{
+								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);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->RECEPTION_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$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>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+								$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 class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';

+ 143 - 143
htdocs/admin/stock.php

@@ -51,42 +51,42 @@ $reg = array();
 
 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
 {
-    $code = $reg[1];
-
-    // If constant is for a unique choice, delete other choices
-    if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) {
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity);
-    }
-    if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) {
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity);
-    }
-
-    if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
-    {
-    	header("Location: ".$_SERVER["PHP_SELF"]);
-        exit;
-    } else {
-        dol_print_error($db);
-    }
+	$code = $reg[1];
+
+	// If constant is for a unique choice, delete other choices
+	if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) {
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity);
+	}
+	if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) {
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity);
+	}
+
+	if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
+	{
+		header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	} else {
+		dol_print_error($db);
+	}
 }
 
 if (preg_match('/del_([a-z0-9_\-]+)/i', $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);
-    }
+	$code = $reg[1];
+	if (dolibarr_del_const($db, $code, $conf->entity) > 0)
+	{
+		header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	} else {
+		dol_print_error($db);
+	}
 }
 
 if ($action == 'warehouse')
@@ -224,14 +224,14 @@ print '<td>'.$langs->trans("DeStockOnBill").'</td>';
 print '<td class="right">';
 if (!empty($conf->facture->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -242,14 +242,14 @@ print '<td>'.$langs->trans("DeStockOnValidateOrder").'</td>';
 print '<td class="right">';
 if (!empty($conf->commande->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -262,14 +262,14 @@ print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
 print '<td class="right">';
 if (!empty($conf->expedition->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -280,14 +280,14 @@ print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
 print '<td class="right">';
 if (!empty($conf->expedition->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -312,14 +312,14 @@ print '<td>'.$langs->trans("ReStockOnBill").'</td>';
 print '<td class="right">';
 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -331,14 +331,14 @@ print '<td>'.$langs->trans("ReStockOnValidateOrder").'</td>';
 print '<td class="right">';
 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -347,43 +347,43 @@ if (!empty($conf->reception->enabled))
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockOnReception").'</td>';
-    print '<td class="right">';
+	print '<td class="right">';
 
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
+	}
 
 	print "</td>\n</tr>\n";
 	$found++;
 
 
-    print '<tr class="oddeven">';
+	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockOnReceptionOnClosing").'</td>';
-    print '<td class="right">';
-
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
-    }
+	print '<td class="right">';
+
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
+	}
 	print "</td>\n</tr>\n";
 	$found++;
 } else {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
-    print '<td class="right">';
+	print '<td class="right">';
 	if (!empty($conf->fournisseur->enabled))
 	{
-        if ($conf->use_javascript_ajax) {
-        	print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1);
-        } else {
-            $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-            print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
-        }
+		if ($conf->use_javascript_ajax) {
+			print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1);
+		} else {
+			$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+			print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
+		}
 	} else {
 		print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
 	}
@@ -406,10 +406,10 @@ print '<tr class="oddeven">';
 print '<td>'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER');
+	print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER);
 }
 print "</td>\n";
 print "</tr>\n";
@@ -419,28 +419,28 @@ if ($conf->invoice->enabled)
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE);
-    }
-    print "</td>\n";
-    print "</tr>\n";
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE);
+	}
+	print "</td>\n";
+	print "</tr>\n";
 }
 
 if ($conf->order->enabled)
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER);
-    }
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER);
+	}
 	print "</td>\n";
 	print "</tr>\n";
 }
@@ -449,13 +449,13 @@ if ($conf->expedition->enabled)
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT);
-    }
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT);
+	}
 	print "</td>\n";
 	print "</tr>\n";
 }
@@ -471,26 +471,26 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
 	|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
 	|| !empty($conf->mrp->enabled))
 {
-    $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
+	$virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
 }
 
 if ($virtualdiffersfromphysical)
 {
-    print '<table class="noborder centpercent">';
-    print '<tr class="liste_titre">';
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre">';
 	print "<td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
-    print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
+	print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
 	print '</tr>'."\n";
 
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("UseVirtualStockByDefault").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK);
-    }
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK);
+	}
 	print "</td>\n";
 	print "</tr>\n";
 	print '</table>';
@@ -725,10 +725,10 @@ print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans(
 print '</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_SUPPORTS_SERVICES');
+	print ajax_constantonoff('STOCK_SUPPORTS_SERVICES');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES);
 }
 print "</td>\n";
 print "</tr>\n";
@@ -737,10 +737,10 @@ print '<tr class="oddeven">';
 print '<td>'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE');
+	print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE);
 }
 print "</td>\n";
 print "</tr>\n";
@@ -749,10 +749,10 @@ print '<tr class="oddeven">';
 print '<td>'.$langs->trans("AlwaysShowFullArbo").'</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO');
+	print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO);
 }
 print "</td>\n";
 print "</tr>\n";

+ 174 - 174
htdocs/bom/bom_card.php

@@ -61,7 +61,7 @@ $search_all = GETPOST("search_all", 'alpha');
 $search = array();
 foreach ($object->fields as $key => $val)
 {
-    if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
+	if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
 }
 
 if (empty($action) && empty($id) && empty($ref)) $action = 'view';
@@ -92,18 +92,18 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
 
 if (empty($reshook))
 {
-    $error = 0;
+	$error = 0;
 
-    $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
+	$backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
 
-    if (empty($backtopage) || ($cancel && empty($id))) {
-    	if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
-    		if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
-    		else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
-    	}
-    }
+	if (empty($backtopage) || ($cancel && empty($id))) {
+		if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+			if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
+			else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
+		}
+	}
 
-    $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
+	$triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
 
 	// Actions cancel, add, update, delete or clone
 	include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
@@ -149,39 +149,39 @@ if (empty($reshook))
 		}
 
 		if ($object->fk_product == $idprod) {
-		    setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors');
-		    $error++;
+			setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors');
+			$error++;
 		}
 
 		if (!$error)
 		{
 			$lastposition = 0;
 
-    		$bomline = new BOMLine($db);
-    		$bomline->fk_bom = $id;
-    		$bomline->fk_product = $idprod;
-    		$bomline->qty = $qty;
-    		$bomline->qty_frozen = (int) $qty_frozen;
-    		$bomline->disable_stock_change = (int) $disable_stock_change;
-    		$bomline->efficiency = $efficiency;
+			$bomline = new BOMLine($db);
+			$bomline->fk_bom = $id;
+			$bomline->fk_product = $idprod;
+			$bomline->qty = $qty;
+			$bomline->qty_frozen = (int) $qty_frozen;
+			$bomline->disable_stock_change = (int) $disable_stock_change;
+			$bomline->efficiency = $efficiency;
 
-    		// Rang to use
+			// Rang to use
    			$rangmax = $object->line_max(0);
    			$ranktouse = $rangmax + 1;
 
    			$bomline->position = ($ranktouse + 1);
 
-    		$result = $bomline->create($user);
-    		if ($result <= 0)
-    		{
-    			setEventMessages($bomline->error, $bomline->errors, 'errors');
-    			$action = '';
-    		} else {
-    			unset($_POST['idprod']);
-    			unset($_POST['qty']);
-    			unset($_POST['qty_frozen']);
-    		    unset($_POST['disable_stock_change']);
-    		}
+			$result = $bomline->create($user);
+			if ($result <= 0)
+			{
+				setEventMessages($bomline->error, $bomline->errors, 'errors');
+				$action = '';
+			} else {
+				unset($_POST['idprod']);
+				unset($_POST['qty']);
+				unset($_POST['qty_frozen']);
+				unset($_POST['disable_stock_change']);
+			}
 		}
 	}
 
@@ -218,9 +218,9 @@ if (empty($reshook))
 			unset($_POST['idprod']);
 			unset($_POST['qty']);
 			unset($_POST['qty_frozen']);
-		    unset($_POST['disable_stock_change']);
+			unset($_POST['disable_stock_change']);
 
-		    $object->fetchLines();
+			$object->fetchLines();
 		}
 	}
 }
@@ -290,7 +290,7 @@ if (($id || $ref) && $action == 'edit')
 	print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes');
 
 	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
-    print '<input type="hidden" name="token" value="'.newToken().'">';
+	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="action" value="update">';
 	print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
 	print '<input type="hidden" name="id" value="'.$object->id.'">';
@@ -321,7 +321,7 @@ if (($id || $ref) && $action == 'edit')
 // Part to show record
 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
 {
-    $res = $object->fetch_optionals();
+	$res = $object->fetch_optionals();
 
 	$head = bomPrepareHead($object);
 	dol_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom');
@@ -331,7 +331,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	// Confirmation to delete
 	if ($action == 'delete')
 	{
-	    $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1);
+		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1);
 	}
 	// Confirmation to delete line
 	if ($action == 'deleteline')
@@ -451,7 +451,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 		$text = $langs->trans('ConfirmSetToDraft', $object->ref);
 
 		$formquestion = array();
-	    $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220);
+		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220);
 	}
 
 	// Call Hook formConfirm
@@ -543,129 +543,129 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	if (!empty($object->table_element_line))
 	{
-	    print '	<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '').'" method="POST">
+		print '	<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '').'" method="POST">
     	<input type="hidden" name="token" value="' . newToken().'">
     	<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
     	<input type="hidden" name="mode" value="">
     	<input type="hidden" name="id" value="' . $object->id.'">
     	';
 
-	    if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
-	        include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
-	    }
-
-	    print '<div class="div-table-responsive-no-min">';
-	    if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
-	    {
-	        print '<table id="tablelines" class="noborder noshadow" width="100%">';
-	    }
+		if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
+			include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
+		}
 
-	    if (!empty($object->lines))
-	    {
-	        $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
-	    }
+		print '<div class="div-table-responsive-no-min">';
+		if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
+		{
+			print '<table id="tablelines" class="noborder noshadow" width="100%">';
+		}
 
-	    // Form to add new line
-	    if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
-	    {
-	        if ($action != 'editline')
-	        {
-	            // Add products/services form
-	            $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl');
+		if (!empty($object->lines))
+		{
+			$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
+		}
 
-	            $parameters = array();
-	            $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-	        }
-	    }
+		// Form to add new line
+		if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
+		{
+			if ($action != 'editline')
+			{
+				// Add products/services form
+				$object->formAddObjectLine(1, $mysoc, null, '/bom/tpl');
+
+				$parameters = array();
+				$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+			}
+		}
 
-	    if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
-	    {
-	        print '</table>';
-	    }
-	    print '</div>';
+		if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
+		{
+			print '</table>';
+		}
+		print '</div>';
 
-	    print "</form>\n";
+		print "</form>\n";
 	}
 
 
 	// Buttons for actions
 
 	if ($action != 'presend' && $action != 'editline') {
-    	print '<div class="tabsAction">'."\n";
-    	$parameters = array();
-    	$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-    	if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
-    	if (empty($reshook))
-    	{
-    	    // Send
-    		//if (empty($user->socid)) {
-    		//	print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
-    		//}
-
-    		// Back to draft
-    		if ($object->status == $object::STATUS_VALIDATED)
-    		{
-	    		if ($permissiontoadd)
-	    		{
-	    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=setdraft">'.$langs->trans("SetToDraft").'</a>';
-	    		}
-    		}
+		print '<div class="tabsAction">'."\n";
+		$parameters = array();
+		$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
-            // Modify
-    		if ($object->status == $object::STATUS_DRAFT)
-    		{
-	    		if ($permissiontoadd)
-	    		{
-	    			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
-	    		} else {
-	    			print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
-	    		}
-    		}
-
-    		// Validate
-    		if ($object->status == $object::STATUS_DRAFT)
-    		{
-	    		if ($permissiontoadd)
-	    		{
-	    			if (is_array($object->lines) && count($object->lines) > 0)
-	    			{
-	    				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
-	    			} else {
-	    				$langs->load("errors");
-	    				print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
-	    			}
-	    		}
-    		}
-
-    		// Close / Cancel
-    		if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
-    		{
-    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
-    		}
-
-    		// Re-open
-    		if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
-    		{
-    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
-    		}
-
-    		// Create MO
-    		if ($conf->mrp->enabled)
-    		{
-	    		if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write))
-	    		{
-	    			print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopageforcancel='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
-	    		}
-    		}
-
-    		// Clone
-    		if ($permissiontoadd)
-    		{
-    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
-    		}
-
-    		/*
+		if (empty($reshook))
+		{
+			// Send
+			//if (empty($user->socid)) {
+			//	print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
+			//}
+
+			// Back to draft
+			if ($object->status == $object::STATUS_VALIDATED)
+			{
+				if ($permissiontoadd)
+				{
+					print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=setdraft">'.$langs->trans("SetToDraft").'</a>';
+				}
+			}
+
+			// Modify
+			if ($object->status == $object::STATUS_DRAFT)
+			{
+				if ($permissiontoadd)
+				{
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
+				} else {
+					print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
+				}
+			}
+
+			// Validate
+			if ($object->status == $object::STATUS_DRAFT)
+			{
+				if ($permissiontoadd)
+				{
+					if (is_array($object->lines) && count($object->lines) > 0)
+					{
+						print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
+					} else {
+						$langs->load("errors");
+						print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
+					}
+				}
+			}
+
+			// Close / Cancel
+			if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
+			{
+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
+			}
+
+			// Re-open
+			if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
+			{
+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
+			}
+
+			// Create MO
+			if ($conf->mrp->enabled)
+			{
+				if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write))
+				{
+					print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopageforcancel='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
+				}
+			}
+
+			// Clone
+			if ($permissiontoadd)
+			{
+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
+			}
+
+			/*
     		if ($user->rights->bom->write)
     		{
     			if ($object->status == 1)
@@ -679,14 +679,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
     		}
     		*/
 
-    		if ($permissiontodelete)
-    		{
-    			print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
-    		} else {
-    			print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
-    		}
-    	}
-    	print '</div>'."\n";
+			if ($permissiontodelete)
+			{
+				print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
+			} else {
+				print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
+			}
+		}
+		print '</div>'."\n";
 	}
 
 
@@ -697,41 +697,41 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	if ($action != 'presend')
 	{
-	    print '<div class="fichecenter"><div class="fichehalfleft">';
-	    print '<a name="builddoc"></a>'; // ancre
+		print '<div class="fichecenter"><div class="fichehalfleft">';
+		print '<a name="builddoc"></a>'; // ancre
 
-	    // Documents
-	    $objref = dol_sanitizeFileName($object->ref);
-	    $relativepath = $objref.'/'.$objref.'.pdf';
-	    $filedir = $conf->bom->dir_output.'/'.$objref;
-	    $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
-	    $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
-	    $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card
-	    print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
+		// Documents
+		$objref = dol_sanitizeFileName($object->ref);
+		$relativepath = $objref.'/'.$objref.'.pdf';
+		$filedir = $conf->bom->dir_output.'/'.$objref;
+		$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
+		$genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
+		$delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card
+		print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
 
-	    // Show links to link elements
-	    $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
-	    $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
+		// Show links to link elements
+		$linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
+		$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
 
 
-	    print '</div><div class="fichehalfright"><div class="ficheaddleft">';
+		print '</div><div class="fichehalfright"><div class="ficheaddleft">';
 
-	    $MAXEVENT = 10;
+		$MAXEVENT = 10;
 
-	    $morehtmlright = '<a href="'.dol_buildpath('/bom/bom_agenda.php', 1).'?id='.$object->id.'">';
-	    $morehtmlright .= $langs->trans("SeeAll");
-	    $morehtmlright .= '</a>';
+		$morehtmlright = '<a href="'.dol_buildpath('/bom/bom_agenda.php', 1).'?id='.$object->id.'">';
+		$morehtmlright .= $langs->trans("SeeAll");
+		$morehtmlright .= '</a>';
 
-	    // List of actions on element
-	    include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
-	    $formactions = new FormActions($db);
-	    $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
+		// List of actions on element
+		include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+		$formactions = new FormActions($db);
+		$somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
 
-	    print '</div></div></div>';
+		print '</div></div></div>';
 	}
 
 	//Select mail models is same action as presend
-    if (GETPOST('modelselected')) $action = 'presend';
+	if (GETPOST('modelselected')) $action = 'presend';
 
 	// Presend form
 	$modelmail = 'bom';

+ 15 - 15
htdocs/bom/tpl/objectline_create.tpl.php

@@ -31,8 +31,8 @@
 
 // Protection to avoid direct call of template
 if (empty($object) || !is_object($object)) {
-    print "Error: this template page cannot be called directly as an URL";
-    exit;
+	print "Error: this template page cannot be called directly as an URL";
+	exit;
 }
 
 
@@ -52,34 +52,34 @@ print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
 
 $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
 if ($nolinesbefore) {
-    print '<tr class="liste_titre nodrag nodrop">';
-    if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
-        print '<td class="linecolnum center"></td>';
-    }
-    print '<td class="linecoldescription minwidth500imp">';
+	print '<tr class="liste_titre nodrag nodrop">';
+	if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
+		print '<td class="linecolnum center"></td>';
+	}
+	print '<td class="linecoldescription minwidth500imp">';
 	print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
 	print '</td>';
 	print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
 	if ($conf->global->PRODUCT_USE_UNITS)
 	{
-	    print '<td class="linecoluseunit left">';
-	    print '<span id="title_units">';
-	    print $langs->trans('Unit');
-	    print '</span></td>';
+		print '<td class="linecoluseunit left">';
+		print '<span id="title_units">';
+		print $langs->trans('Unit');
+		print '</span></td>';
 	}
 	print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
 	print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
 	print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
 	print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
-    print '</tr>';
+	print '</tr>';
 }
 print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
 $coldisplay = 0;
 
 // Adds a line numbering column
 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
-    $coldisplay++;
-    echo '<td class="bordertop nobottom linecolnum center"></td>';
+	$coldisplay++;
+	echo '<td class="bordertop nobottom linecolnum center"></td>';
 }
 
 $coldisplay++;
@@ -111,7 +111,7 @@ print '</td>';
 
 if ($conf->global->PRODUCT_USE_UNITS)
 {
-    $coldisplay++;
+	$coldisplay++;
 	print '<td class="nobottom linecoluseunit left">';
 	print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
 	print '</td>';

Разлика између датотеке није приказан због своје велике величине
+ 712 - 712
htdocs/categories/class/api_categories.class.php


Разлика између датотеке није приказан због своје велике величине
+ 278 - 278
htdocs/categories/class/categorie.class.php


+ 66 - 51
htdocs/comm/action/card.php

@@ -58,23 +58,23 @@ $origin = GETPOST('origin', 'alpha');
 $originid = GETPOST('originid', 'int');
 $confirm = GETPOST('confirm', 'alpha');
 
-$fulldayevent = GETPOST('fullday');
+$fulldayevent = GETPOST('fullday', 'alpha');
 
-$aphour = GETPOST('aphour');
-$apmin = GETPOST('apmin');
-$p2hour = GETPOST('p2hour');
-$p2min = GETPOST('p2min');
+$aphour = GETPOST('aphour', 'int');
+$apmin = GETPOST('apmin', 'int');
+$p2hour = GETPOST('p2hour', 'int');
+$p2min = GETPOST('p2min', 'int');
 
-$addreminder = GETPOST('addreminder');
-$offsetvalue = GETPOST('offsetvalue');
-$offsetunit = GETPOST('offsetunittype_duration');
-$remindertype = GETPOST('selectremindertype');
-$modelmail = GETPOST('actioncommsendmodel_mail');
+$addreminder = GETPOST('addreminder', 'alpha');
+$offsetvalue = GETPOST('offsetvalue', 'int');
+$offsetunit = GETPOST('offsetunittype_duration', 'aZ09');
+$remindertype = GETPOST('selectremindertype', 'aZ09');
+$modelmail = GETPOST('actioncommsendmodel_mail', 'int');
 
 //var_dump($_POST); exit;
 
-$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear"));
-$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year"));
+$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'));
+$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'));
 
 // Security check
 $socid = GETPOST('socid', 'int');
@@ -391,21 +391,9 @@ if (empty($reshook) && $action == 'add')
                 if ($addreminder == 'on'){
                     $actionCommReminder = new ActionCommReminder($db);
 
-                    if ($offsetunit == 'minute'){
-                        $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i');
-                    } elseif ($offsetunit == 'hour'){
-                        $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h');
-                    } elseif ($offsetunit == 'day') {
-                        $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd');
-                    } elseif ($offsetunit == 'week') {
-                        $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'w');
-                    } elseif ($offsetunit == 'month') {
-                        $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'm');
-                    } elseif ($offsetunit == 'year') {
-                        $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y');
-                    }
+                    $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i');
 
-                    $actionCommReminder->dateremind = $db->idate($dateremind);
+                    $actionCommReminder->dateremind = $dateremind;
                     $actionCommReminder->typeremind = $remindertype;
                     $actionCommReminder->fk_user = $user;
                     $actionCommReminder->offsetunit = $offsetunit;
@@ -418,15 +406,20 @@ if (empty($reshook) && $action == 'add')
 
                     if ($res <= 0){
                         // If error
-                        $db->rollback();
+                        $error++;
                         $langs->load("errors");
-                        $error = $langs->trans('ErrorReminderActionCommCreation');
-                        setEventMessages($error, null, 'errors');
+                        $error = $langs->trans('ErrorReminderActionCommCreation').' '.$actionCommReminder->error;
+                        setEventMessages($error, $actionCommReminder->errors, 'errors');
                         $action = 'create'; $donotclearsession = 1;
                     }
                 }
 
-				$db->commit();
+                if ($error) {
+                	$db->rollback();
+                } else {
+					$db->commit();
+                }
+
 				if (!empty($backtopage))
 				{
 					dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : ''));
@@ -904,31 +897,48 @@ if ($action == 'create')
     // Full day
     print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td><input type="checkbox" id="fullday" name="fullday" '.(GETPOST('fullday') ? ' checked' : '').'></td></tr>';
 
-	// Date start
-	$datep = ($datep ? $datep : $object->datep);
-	if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0);
-	print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").'</span></td><td>';
+    $datep = ($datep ? $datep : $object->datep);
+    if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0);
+    $datef = ($datef ? $datef : $object->datef);
+    if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0);
+    if (empty($datef) && !empty($datep))
+    {
+    	if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
+    		$datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h');
+    	}
+    }
+
+    // Date start
+	print '<tr><td class="nowrap">';
+	print '<span class="fieldrequired">'.$langs->trans("DateActionStart").'</span>';
+	print ' - ';
+	print '<span id="dateend"'.(GETPOST("actioncode", 'aZ09') == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span>';
+	print '</td><td>';
 	if (GETPOST("afaire") == 1) {
         print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart');	// Empty value not allowed for start date and hours if "todo"
     } else {
         print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart');
     }
-	print '</td></tr>';
+    print ' <span class="hideonsmartphone">&nbsp; &nbsp; - &nbsp; &nbsp;</span> ';
+	//print ' - ';
+    if (GETPOST("afaire") == 1) {
+    	print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend');
+    } else {
+    	print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend');
+    }
+    print '</td></tr>';
 
 	// Date end
-	$datef = ($datef ? $datef : $object->datef);
-    if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0);
-	if (empty($datef) && !empty($datep) && !empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS))
-	{
-		$datef = dol_time_plus_duree($datep, $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS, 'h');
-	}
-	print '<tr><td><span id="dateend"'.(GETPOST("actioncode", 'aZ09') == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span></td><td>';
+	/*print '<tr><td>';
+	print '<span id="dateend"'.(GETPOST("actioncode", 'aZ09') == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span>';
+	print '</td>';
+	print '<td>';
 	if (GETPOST("afaire") == 1) {
         print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend');
     } else {
         print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend');
     }
-	print '</td></tr>';
+	print '</td></tr>';*/
 
     // Dev in progress
 	$userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
@@ -1173,13 +1183,14 @@ if ($action == 'create')
     if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER)
     {
         //checkbox create reminder
-        print '<br>';
-        print '<tr><td>'.$langs->trans("AddReminder").'</td><td colspan="3"><input type="checkbox" id="addreminder" name="addreminder"></td></tr>';
+        print '<hr>';
+    	print '<br>';
+        print '<label for="addreminder">'.$langs->trans("AddReminder").'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
 
         print '<div class="reminderparameters" style="display: none;">';
 
-        print '<hr>';
-        print load_fiche_titre($langs->trans("AddReminder"), '', '');
+        //print '<hr>';
+        //print load_fiche_titre($langs->trans("AddReminder"), '', '');
 
         print '<table class="border centpercent">';
 
@@ -1190,7 +1201,7 @@ if ($action == 'create')
 
         //Time Type
         print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("TimeType").'</td><td colspan="3">';
-        print $form->selectTypeDuration('offsetunit');
+        print $form->selectTypeDuration('offsetunit', 'i');
         print '</td></tr>';
 
         //Reminder Type
@@ -1203,7 +1214,7 @@ if ($action == 'create')
 
         //Mail Model
         print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("EMailTemplates").'</td><td colspan="3">';
-        print $form->selectModelMail('actioncommsend', 'actioncomm_send');
+        print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1);
         print '</td></tr>';
 
 
@@ -1235,9 +1246,13 @@ if ($action == 'create')
     dol_fiche_end();
 
 	print '<div class="center">';
-	print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
+	print '<input type="submit" class="button" name="save" value="'.$langs->trans("Add").'">';
 	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-	print '<input type="button" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
+	if (empty($backtopage)) {
+		print '<input type="button" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
+	} else {
+		print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+	}
 	print '</div>';
 
 	print "</form>";

Разлика између датотеке није приказан због своје велике величине
+ 454 - 448
htdocs/comm/action/class/actioncomm.class.php


+ 4 - 4
htdocs/comm/action/class/actioncommreminder.class.php

@@ -50,6 +50,9 @@ class ActionCommReminder extends CommonObject
 	 */
 	public $picto = 'generic';
 
+	const STATUS_TODO = 0;
+	const STATUS_DONE = 1;
+
 
 	/**
 	 *  'type' if the field format.
@@ -79,7 +82,7 @@ class ActionCommReminder extends CommonObject
 		'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",),
 		'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,),
 		'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,),
-		'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"m, h, d, w",),
+		'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"y, m, d, w, h, i",),
 		'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')),
 		'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1, 'index'=>1,),
 		'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>0),
@@ -121,9 +124,6 @@ class ActionCommReminder extends CommonObject
 	 */
 	public $fk_email_template;
 
-    const STATUS_TODO = 0;
-    const STATUS_DONE = 1;
-
 	// END MODULEBUILDER PROPERTIES
 
 

+ 297 - 278
htdocs/comm/action/index.php

@@ -76,7 +76,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden();
 if (!$user->rights->agenda->allactions->read) $canedit = 0;
 if (!$user->rights->agenda->allactions->read || $filter == 'mine')  // If no permission to see all, we show only affected to me
 {
-    $filtert = $user->id;
+	$filtert = $user->id;
 }
 
 $action = GETPOST('action', 'alpha');
@@ -91,19 +91,19 @@ $type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST
 $maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
 
-$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
+$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
 if ($dateselect > 0)
 {
-	$day=GETPOST('dateselectday', 'int');
-	$month=GETPOST('dateselectmonth', 'int');
-	$year=GETPOST('dateselectyear', 'int');
+	$day = GETPOST('dateselectday', 'int');
+	$month = GETPOST('dateselectmonth', 'int');
+	$year = GETPOST('dateselectyear', 'int');
 }
 
 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
 if (GETPOST('search_actioncode', 'array'))
 {
-    $actioncode = GETPOST('search_actioncode', 'array', 3);
-    if (!count($actioncode)) $actioncode = '0';
+	$actioncode = GETPOST('search_actioncode', 'array', 3);
+	if (!count($actioncode)) $actioncode = '0';
 } else {
 	$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
 }
@@ -119,13 +119,13 @@ if ($action == 'default')	// When action is default, we want a calendar view and
 	$action = (($defaultview != 'show_list') ? $defaultview : 'show_month');
 }
 if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') {
-    $action = 'show_month'; $day = '';
+	$action = 'show_month'; $day = '';
 } // View by month
 if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') {
-    $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
+	$action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
 } // View by week
 if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') {
-    $action = 'show_day'; $day = ($day ? $day : date("d"));
+	$action = 'show_day'; $day = ($day ? $day : date("d"));
 } // View by day
 
 // Load translation files required by the page
@@ -141,46 +141,46 @@ $hookmanager->initHooks(array('agenda'));
 
 if (GETPOST("viewlist", 'alpha') || $action == 'show_list')
 {
-    $param = '';
-    if (is_array($_POST))
-    {
-        foreach ($_POST as $key => $val)
-        {
-            if ($key == 'token') continue;
-            $param .= '&'.$key.'='.urlencode($val);
-        }
-    }
-    if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list';
-    //print $param;
-    header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param);
-    exit;
+	$param = '';
+	if (is_array($_POST))
+	{
+		foreach ($_POST as $key => $val)
+		{
+			if ($key == 'token') continue;
+			$param .= '&'.$key.'='.urlencode($val);
+		}
+	}
+	if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list';
+	//print $param;
+	header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param);
+	exit;
 }
 
 if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser')
 {
-    $param = '';
-    if (is_array($_POST))
-    {
-        foreach ($_POST as $key => $val)
-        {
-            if ($key == 'token') continue;
-            $param .= '&'.$key.'='.urlencode($val);
-        }
-    }
-    //print $param;
-    header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param);
-    exit;
+	$param = '';
+	if (is_array($_POST))
+	{
+		foreach ($_POST as $key => $val)
+		{
+			if ($key == 'token') continue;
+			$param .= '&'.$key.'='.urlencode($val);
+		}
+	}
+	//print $param;
+	header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param);
+	exit;
 }
 
 if ($action == 'delete_action')
 {
-    $event = new ActionComm($db);
-    $event->fetch($actionid);
-    $event->fetch_optionals();
-    $event->fetch_userassigned();
-    $event->oldcopy = clone $event;
+	$event = new ActionComm($db);
+	$event->fetch($actionid);
+	$event->fetch_optionals();
+	$event->fetch_userassigned();
+	$event->oldcopy = clone $event;
 
-    $result = $event->delete();
+	$result = $event->delete();
 }
 
 
@@ -226,21 +226,21 @@ $listofextcals = array();
 // Define list of external calendars (global admin setup)
 if (empty($conf->global->AGENDA_DISABLE_EXT))
 {
-    $i = 0;
-    while ($i < $MAXAGENDA)
-    {
-        $i++;
-        $source = 'AGENDA_EXT_SRC'.$i;
-        $name = 'AGENDA_EXT_NAME'.$i;
-        $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
-        $color = 'AGENDA_EXT_COLOR'.$i;
-        $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
-        if (!empty($conf->global->$source) && !empty($conf->global->$name))
-        {
-        	// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
-        	$listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0));
-        }
-    }
+	$i = 0;
+	while ($i < $MAXAGENDA)
+	{
+		$i++;
+		$source = 'AGENDA_EXT_SRC'.$i;
+		$name = 'AGENDA_EXT_NAME'.$i;
+		$offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
+		$color = 'AGENDA_EXT_COLOR'.$i;
+		$buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
+		if (!empty($conf->global->$source) && !empty($conf->global->$name))
+		{
+			// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
+			$listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0));
+		}
+	}
 }
 // Define list of external calendars (user setup)
 if (empty($user->conf->AGENDA_DISABLE_EXT))
@@ -251,7 +251,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT))
 		$i++;
 		$source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i;
 		$name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i;
-        $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
+		$offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
 		$color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i;
 		$enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i;
 		$buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i;
@@ -265,65 +265,65 @@ if (empty($user->conf->AGENDA_DISABLE_EXT))
 
 if (empty($action) || $action == 'show_month')
 {
-    $prev = dol_get_prev_month($month, $year);
-    $prev_year  = $prev['year'];
-    $prev_month = $prev['month'];
-    $next = dol_get_next_month($month, $year);
-    $next_year  = $next['year'];
-    $next_month = $next['month'];
-
-    $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month
-    $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
-    // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
-    $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday
-    $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
-    if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
-    // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
-    $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year);
-    $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
-    if ($next_day < 6) $next_day += 7;
-    $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
+	$prev = dol_get_prev_month($month, $year);
+	$prev_year  = $prev['year'];
+	$prev_month = $prev['month'];
+	$next = dol_get_next_month($month, $year);
+	$next_year  = $next['year'];
+	$next_month = $next['month'];
+
+	$max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month
+	$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
+	// tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
+	$tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday
+	$tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
+	if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
+	// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
+	$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year);
+	$next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
+	if ($next_day < 6) $next_day += 7;
+	$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
 }
 if ($action == 'show_week')
 {
-    $prev = dol_get_first_day_week($day, $month, $year);
-    $prev_year  = $prev['prev_year'];
-    $prev_month = $prev['prev_month'];
-    $prev_day   = $prev['prev_day'];
-    $first_day  = $prev['first_day'];
-    $first_month = $prev['first_month'];
-    $first_year = $prev['first_year'];
-
-    $week = $prev['week'];
-
-    $day = (int) $day;
-    $next = dol_get_next_week($first_day, $week, $first_month, $first_year);
-    $next_year  = $next['year'];
-    $next_month = $next['month'];
-    $next_day   = $next['day'];
-
-    // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
-    $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
+	$prev = dol_get_first_day_week($day, $month, $year);
+	$prev_year  = $prev['prev_year'];
+	$prev_month = $prev['prev_month'];
+	$prev_day   = $prev['prev_day'];
+	$first_day  = $prev['first_day'];
+	$first_month = $prev['first_month'];
+	$first_year = $prev['first_year'];
+
+	$week = $prev['week'];
+
+	$day = (int) $day;
+	$next = dol_get_next_week($first_day, $week, $first_month, $first_year);
+	$next_year  = $next['year'];
+	$next_month = $next['month'];
+	$next_day   = $next['day'];
+
+	// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
+	$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
 	$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
 
-    $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
+	$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
 
-    $tmpday = $first_day;
+	$tmpday = $first_day;
 }
 if ($action == 'show_day')
 {
-    $prev = dol_get_prev_day($day, $month, $year);
-    $prev_year  = $prev['year'];
-    $prev_month = $prev['month'];
-    $prev_day   = $prev['day'];
-    $next = dol_get_next_day($day, $month, $year);
-    $next_year  = $next['year'];
-    $next_month = $next['month'];
-    $next_day   = $next['day'];
-
-    // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
-    $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year);
-    $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
+	$prev = dol_get_prev_day($day, $month, $year);
+	$prev_year  = $prev['year'];
+	$prev_month = $prev['month'];
+	$prev_day   = $prev['day'];
+	$next = dol_get_next_day($day, $month, $year);
+	$next_year  = $next['year'];
+	$next_month = $next['month'];
+	$next_day   = $next['day'];
+
+	// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
+	$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year);
+	$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
 }
 //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
 //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
@@ -356,30 +356,30 @@ $param .= "&maxprint=".urlencode($maxprint);
 // Show navigation bar
 if (empty($action) || $action == 'show_month')
 {
-    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
-    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
-    $nav .= " </span>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> ";
-    $picto = 'calendar';
+	$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
+	$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
+	$nav .= " </span>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> ";
+	$picto = 'calendar';
 }
 if ($action == 'show_week')
 {
-    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp;\n";
-    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
-    $nav .= " </span>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
-    $picto = 'calendarweek';
+	$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp;\n";
+	$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
+	$nav .= " </span>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
+	$picto = 'calendarweek';
 }
 if ($action == 'show_day')
 {
-    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
-    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
-    $nav .= " </span>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
-    $picto = 'calendarday';
+	$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
+	$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
+	$nav .= " </span>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
+	$picto = 'calendarday';
 }
 
 $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
@@ -467,25 +467,25 @@ if (!empty($conf->use_javascript_ajax))	// If javascript on
 	$s .= "\n".'<!-- Div to calendars selectors -->'."\n";
 	$s .= '<script type="text/javascript">'."\n";
 	$s .= 'jQuery(document).ready(function () {'."\n";
-	$s .= 'jQuery("#check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });'."\n";
+	$s .= 'jQuery(".check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });'."\n";
 	$s .= 'jQuery(".family_birthday").toggle();'."\n";
 	if ($action == "show_week" || $action == "show_month" || empty($action))
 	{
-        // Code to enable drag and drop
+		// Code to enable drag and drop
 		$s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
-        // Code to submit form
+		// Code to submit form
 		$s .= 'console.log("submit form to record new event");'."\n";
-        //$s.='console.log(event.target);';
+		//$s.='console.log(event.target);';
 		$s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n";
 		$s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n";
 		$s .= 'var frm=jQuery("#searchFormList");'."\n";
 		$s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
 		$s .= 'console.log(newurl);'."\n";
 		$s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
-        $s .= '});'."\n";
-    }
-    $s .= '});'."\n";
-    $s .= '</script>'."\n";
+		$s .= '});'."\n";
+	}
+	$s .= '});'."\n";
+	$s .= '</script>'."\n";
 
 	// Local calendar
 	$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
@@ -510,29 +510,29 @@ if (!empty($conf->use_javascript_ajax))	// If javascript on
 	}
 
 	// Birthdays
-	$s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
+	$s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"> <span class="check_birthday_text">'.$langs->trans("AgendaShowBirthdayEvents").'</span> &nbsp; </div>';
 
 	// Calendars from hooks
-    $parameters = array(); $object = null;
+	$parameters = array(); $object = null;
 	$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
-    if (empty($reshook))
-    {
+	if (empty($reshook))
+	{
 		$s .= $hookmanager->resPrint;
-    } elseif ($reshook > 1)
+	} elseif ($reshook > 1)
 	{
-    	$s = $hookmanager->resPrint;
-    }
+		$s = $hookmanager->resPrint;
+	}
 } else // If javascript off
 {
 	$newparam = $param; // newparam is for birthday links
-    $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
-    if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1';
-    $link = '<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']);
-    $link .= '?'.dol_escape_htmltag($newparam);
-    $link .= '">';
-    if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents");
-    else $link .= $langs->trans("AgendaHideBirthdayEvents");
-    $link .= '</a>';
+	$newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
+	if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1';
+	$link = '<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']);
+	$link .= '?'.dol_escape_htmltag($newparam);
+	$link .= '">';
+	if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents");
+	else $link .= $langs->trans("AgendaHideBirthdayEvents");
+	$link .= '</a>';
 }
 
 // Load events from database into $eventarray
@@ -561,26 +561,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
 // Condition on actioncode
 if (!empty($actioncode))
 {
-    if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
-    {
-        if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
-        elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
-        else {
-            if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
-            if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
-        }
-    } else {
-        if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
-        elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
-        else {
-            if (is_array($actioncode))
-            {
-	        	$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
-            } else {
-	        	$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
-            }
-        }
-    }
+	if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
+	{
+		if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
+		elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
+		else {
+			if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
+			if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
+		}
+	} else {
+		if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
+		elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
+		else {
+			if (is_array($actioncode))
+			{
+				$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
+			} else {
+				$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
+			}
+		}
+	}
 }
 if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
 if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid);
@@ -590,28 +590,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid;
 if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
 if ($action == 'show_day')
 {
-    $sql .= " AND (";
-    $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
-    $sql .= " OR ";
-    $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
-    $sql .= " OR ";
-    $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
-    $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
-    $sql .= ')';
+	$sql .= " AND (";
+	$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
+	$sql .= " OR ";
+	$sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
+	$sql .= " OR ";
+	$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
+	$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
+	$sql .= ')';
 } else {
-    // To limit array
-    $sql .= " AND (";
-    $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31
-    $sql .= " OR ";
-    $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
-    $sql .= " OR ";
-    $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
-    $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
-    $sql .= ')';
+	// To limit array
+	$sql .= " AND (";
+	$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31
+	$sql .= " OR ";
+	$sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
+	$sql .= " OR ";
+	$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
+	$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
+	$sql .= ')';
 }
 if ($type) $sql .= " AND ca.id = ".$type;
 if ($status == '0') { $sql .= " AND a.percent = 0"; }
@@ -622,10 +622,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; }
 // We must filter on assignement table
 if ($filtert > 0 || $usergroup > 0)
 {
-    $sql .= " AND (";
-    if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert;
-    if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
-    $sql .= ")";
+	$sql .= " AND (";
+	if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert;
+	if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
+	$sql .= ")";
 }
 // Sort on date
 $sql .= ' ORDER BY datep';
@@ -1090,8 +1090,8 @@ if (count($listofextcals))
                     // Transparency (see https://www.kanzaki.com/docs/ical/transp.html)
                     if ($icalevent['TRANSP'])
                     {
-                        if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0;     // 0 = available / free
-                        if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1;          // 1 = busy
+                        if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free
+                        if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy
 
                         // TODO: MS outlook states
                         // X-MICROSOFT-CDO-BUSYSTATUS:FREE      + TRANSP:TRANSPARENT => Available / Free
@@ -1156,12 +1156,12 @@ if (count($listofextcals))
 $parameters = array(); $object = null;
 $reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action);
 if (!empty($hookmanager->resArray['eventarray'])) {
-    foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) {
-        if (!isset($eventarray[$keyDate])) {
-            $eventarray[$keyDate] = array();
-        }
-        $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
-    }
+	foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) {
+		if (!isset($eventarray[$keyDate])) {
+			$eventarray[$keyDate] = array();
+		}
+		$eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
+	}
 }
 
 // Sort events
@@ -1180,7 +1180,7 @@ $cacheusers = array();
 $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
 if (is_readable($color_file))
 {
-    include_once $color_file;
+	include_once $color_file;
 }
 if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
 
@@ -1207,13 +1207,15 @@ if (empty($action) || $action == 'show_month')      // View by month
     print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
     print '</div>';
 
-    print '<div class="div-table-responsive-no-min">';
+    print '<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
     print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
     print ' <tr class="liste_titre">';
+	// Column title of weeks numbers
+	echo '  <td align="center">#</td>';
     $i = 0;
     while ($i < 7)
     {
-        print '  <td class="center bold uppercase">';
+        print '  <td class="center bold uppercase tdfordaytitle">';
         $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7);
         if (!empty($conf->dol_optimize_smallscreen))
         {
@@ -1232,6 +1234,24 @@ if (empty($action) || $action == 'show_month')      // View by month
     //var_dump($eventarray);
     for ($iter_week = 0; $iter_week < 6; $iter_week++) {
         echo " <tr>\n";
+		// Get date of the current day, format 'yyyy-mm-dd'
+		if ($tmpday <= 0) // If number of the current day is in previous month
+		{
+			$currdate0 = sprintf("%04d", $prev_year).sprintf("%02d", $prev_month).sprintf("%02d", $max_day_in_prev_month + $tmpday);
+		}
+		elseif ($tmpday <= $max_day_in_month) // If number of the current day is in current month
+		{
+			$currdate0 = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $tmpday);
+		}
+		else // If number of the current day is in next month
+		{
+			$currdate0 = sprintf("%04d", $next_year).sprintf("%02d", $next_month).sprintf("%02d", $tmpday - $max_day_in_month);
+		}
+		// Get week number for the targeted date '$currdate0'
+		$numweek0 = date("W", strtotime(date($currdate0)));
+		// Show the week number, and define column width
+		echo ' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.'</td>';
+
         for ($iter_day = 0; $iter_day < 7; $iter_day++) {
             if ($tmpday <= 0) {
                 /* Show days before the beginning of the current month (previous month)  */
@@ -1288,12 +1308,12 @@ if (empty($action) || $action == 'show_month')      // View by month
     print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
     print '</div></div>';
 
-    print '<div class="div-table-responsive-no-min">';
+    print '<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
     print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
     print ' <tr class="liste_titre">';
     $i = 0;
     while ($i < 7) {
-        echo '  <td class="center bold uppercase">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."</td>\n";
+        echo '  <td class="center bold uppercase tdfordaytitle">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."</td>\n";
         $i++;
     }
     echo " </tr>\n";
@@ -1348,11 +1368,10 @@ if (empty($action) || $action == 'show_month')      // View by month
     print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
     print '</div></div>';
 
-    print '<div class="div-table-responsive-no-min">';
+    print '<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
     echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
 
     echo ' <tr class="tagtr liste_titre">';
-    echo '  <td class="tagtd width100"></td>';
     echo '  <td class="tagtd center bold uppercase">'.$langs->trans("Day".$arraytimestamp['wday'])."</td>\n";
     echo " </td>\n";
 
@@ -1365,39 +1384,39 @@ if (empty($action) || $action == 'show_month')      // View by month
     echo " </div>\n";
 	*/
 
-    echo '</table>';
+	echo '</table>';
 	print '</div>';
 
-    /* WIP View per hour */
-    $useviewhour = 0;
-    if ($useviewhour)
-    {
-    	print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
+	/* WIP View per hour */
+	$useviewhour = 0;
+	if ($useviewhour)
+	{
+		print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
 
-    	$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file
+		$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file
 
-	    echo '<div style="max-height: '.$maxheightwin.'px;">';
+		echo '<div style="max-height: '.$maxheightwin.'px;">';
 		echo '<div class="tagtable centpercent calendarviewcontainer">';
 
-	    $maxnbofchar = 80;
+		$maxnbofchar = 80;
 
-	    $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
-	    $minhour = round($tmp[0], 0);
-	    $maxhour = round($tmp[1], 0);
-	    if ($minhour > 23) $minhour = 23;
-	    if ($maxhour < 1)  $maxhour = 1;
-	    if ($maxhour <= $minhour) { $maxhour = $minhour + 1; }
+		$tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
+		$minhour = round($tmp[0], 0);
+		$maxhour = round($tmp[1], 0);
+		if ($minhour > 23) $minhour = 23;
+		if ($maxhour < 1)  $maxhour = 1;
+		if ($maxhour <= $minhour) { $maxhour = $minhour + 1; }
 
-	    $i = 0;
-	    $j = 0;
+		$i = 0;
+		$j = 0;
 		while ($i < 24)
 		{
-		    echo ' <div class="tagtr calendarviewcontainertr">'."\n";
-		    echo '  <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
-		    echo '  <div class="tagtd '.$style.' tdtop"></div>'."\n";
-		    echo ' </div>'."\n";
-		    $i++;
-		    $j++;
+			echo ' <div class="tagtr calendarviewcontainertr">'."\n";
+			echo '  <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
+			echo '  <div class="tagtd '.$style.' tdtop"></div>'."\n";
+			echo ' </div>'."\n";
+			$i++;
+			$j++;
 		}
 
 		echo '</div></div>';
@@ -1405,13 +1424,13 @@ if (empty($action) || $action == 'show_month')      // View by month
 		show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
 
 		print '</div>';
-    } else {
-    	print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
+	} else {
+		print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
 
-    	show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
+		show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
 
-    	print '</div>';
-    }
+		print '</div>';
+	}
 }
 
 print "\n".'</form>';
@@ -1852,11 +1871,11 @@ function dol_color_minus($color, $minus, $minusunit = 16)
 	$newcolor = $color;
 	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));
+		$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
+		// Not yet implemented
 	}
 	return $newcolor;
 }
@@ -1871,39 +1890,39 @@ function dol_color_minus($color, $minus, $minusunit = 16)
 function sort_events_by_date($a, $b)
 {
 	// Sort holidays at first
-    if ($a->type_code === 'HOLIDAY')
-    {
-        return -1;
-    }
+	if ($a->type_code === 'HOLIDAY')
+	{
+		return -1;
+	}
 
-    if ($b->type_code === 'HOLIDAY')
-    {
-        return 1;
-    }
+	if ($b->type_code === 'HOLIDAY')
+	{
+		return 1;
+	}
 
-    // datep => Event start time
-    // datef => Event end time
+	// datep => Event start time
+	// datef => Event end time
 
-    // Events have different start time
-    if ($a->datep !== $b->datep)
-    {
-        return $a->datep - $b->datep;
-    }
+	// Events have different start time
+	if ($a->datep !== $b->datep)
+	{
+		return $a->datep - $b->datep;
+	}
 
-    // Events have same start time and no end time
-    if ((!is_numeric($b->datef)) || (!is_numeric($a->datef)))
-    {
-        return sort_events_by_percentage($a, $b);
-    }
+	// Events have same start time and no end time
+	if ((!is_numeric($b->datef)) || (!is_numeric($a->datef)))
+	{
+		return sort_events_by_percentage($a, $b);
+	}
 
-    // Events have the same start time and same end time
-    if ($b->datef === $a->datef)
-    {
-        return sort_events_by_percentage($a, $b);
-    }
+	// Events have the same start time and same end time
+	if ($b->datef === $a->datef)
+	{
+		return sort_events_by_percentage($a, $b);
+	}
 
-    // Events have the same start time, but have different end time -> longest event first
-    return $b->datef - $a->datef;
+	// Events have the same start time, but have different end time -> longest event first
+	return $b->datef - $a->datef;
 }
 
 /**
@@ -1915,18 +1934,18 @@ function sort_events_by_date($a, $b)
  */
 function sort_events_by_percentage($a, $b)
 {
-    // Sort events with no percentage before each other
-    // (usefull to sort holidays, sick days or similar on the top)
+	// Sort events with no percentage before each other
+	// (usefull to sort holidays, sick days or similar on the top)
 
-    if ($a->percentage < 0)
-    {
-        return -1;
-    }
+	if ($a->percentage < 0)
+	{
+		return -1;
+	}
 
-    if ($b->percentage < 0)
-    {
-        return 1;
-    }
+	if ($b->percentage < 0)
+	{
+		return 1;
+	}
 
-    return $b->percentage - $a->percentage;
+	return $b->percentage - $a->percentage;
 }

+ 2 - 2
htdocs/comm/action/list.php

@@ -160,7 +160,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
 
 if (GETPOST('cancel', 'alpha'))
 {
-	$action='list'; $massaction='';
+	$action = 'list'; $massaction = '';
 }
 
 if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
@@ -708,7 +708,7 @@ if ($resql)
 				$labeltype = $langs->trans("Message");
 			} else {
 				if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
-				if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code];		// Use code in priority on type_code
+				if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
 			}
 			print dol_trunc($labeltype, 28);
 			print '</td>';

+ 5 - 5
htdocs/comm/index.php

@@ -142,7 +142,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useles
 
 
 /*
- * Draft proposals
+ * Draft customer proposals
  */
 if (!empty($conf->propal->enabled) && $user->rights->propal->lire)
 {
@@ -256,7 +256,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
         print '<div class="div-table-responsive-no-min">';
         print '<table class="noborder centpercent">';
         print '<tr class="liste_titre">';
-        print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
+        print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").' <a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?search_status=0"><span class="badge">'.$num.'</span></a></th></tr>';
 
         if ($num > 0)
         {
@@ -309,7 +309,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
 
 
 /*
- * Draft orders
+ * Draft customer orders
  */
 if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
 {
@@ -338,7 +338,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
 		print '<div class="div-table-responsive-no-min">';
 		print '<table class="noborder centpercent">';
 		print '<tr class="liste_titre">';
-		print '<th colspan="3">'.$langs->trans("DraftOrders").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
+		print '<th colspan="3">'.$langs->trans("DraftOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status=0"><span class="badge">'.$num.'</span></a></th></tr>';
 
 		if ($num > 0)
 		{
@@ -425,7 +425,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
         print '<div class="div-table-responsive-no-min">';
         print '<table class="noborder centpercent">';
         print '<tr class="liste_titre">';
-        print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
+		print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").' <a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?search_status=0"><span class="badge">'.$num.'</span></a></th></tr>';
 
         if ($num > 0)
         {

+ 0 - 1
htdocs/comm/mailing/card.php

@@ -211,7 +211,6 @@ if (empty($reshook))
 						$substitutionarray['__OTHER4__'] = $other4;
 						$substitutionarray['__OTHER5__'] = $other5;
 						$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
-						$substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility
 						$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
 						$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
 

+ 9 - 9
htdocs/comm/propal/card.php

@@ -603,7 +603,7 @@ if (empty($reshook))
 	{
 		$db->begin();
 
-		$result = $object->cloture($user, Propal::STATUS_BILLED, '');
+		$result = $object->cloture($user, $object::STATUS_BILLED, '');
 		if ($result < 0)
 		{
 			setEventMessages($object->error, $object->errors, 'errors');
@@ -617,13 +617,13 @@ if (empty($reshook))
 			$db->rollback();
 		}
 	} // Close proposal
-	elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) {
+	elseif ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) {
 		if (!(GETPOST('statut', 'int') > 0)) {
 			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
-			$action = 'statut';
+			$action = 'closeas';
 		} else {
 			// prevent browser refresh from closing proposal several times
-			if ($object->statut == Propal::STATUS_VALIDATED)
+			if ($object->statut == $object::STATUS_VALIDATED)
 			{
 				$db->begin();
 
@@ -1824,11 +1824,11 @@ if ($action == 'create')
 		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
 	}
 
-	if ($action == 'statut')
+	if ($action == 'closeas')
 	{
 		//Form to close proposal (signed or not)
 		$formquestion = array(
-			array('type' => 'select', 'name' => 'statut', 'label' => '<span class="fieldrequired">'.$langs->trans("CloseAs").'</span>', 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))),
+			array('type' => 'select', 'name' => 'statut', 'label' => '<span class="fieldrequired">'.$langs->trans("CloseAs").'</span>', 'values' => array(2=>$object->LibStatut($object::STATUS_SIGNED), 3=>$object->LibStatut($object::STATUS_NOTSIGNED))),
 			array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '')				// Field to complete private note (not replace)
 		);
 
@@ -1841,7 +1841,7 @@ if ($action == 'create')
 			));
 		}
 
-		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250);
+		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_closeas', $formquestion, '', 1, 250);
 	} // Confirm delete
 	elseif ($action == 'delete') {
 		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1);
@@ -2483,9 +2483,9 @@ if ($action == 'create')
 					}
 				}
 
-				// Set accepted/refused
+				// Close as accepted/refused
 				if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) {
-					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"';
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=closeas'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"';
 					print '>'.$langs->trans('SetAcceptedRefused').'</a>';
 				}
 

+ 6 - 6
htdocs/comm/propal/class/propal.class.php

@@ -2504,12 +2504,12 @@ class Propal extends CommonObject
 	 *	Close the commercial proposal
 	 *
 	 *	@param      User	$user		Object user that close
-	 *	@param      int		$statut		Statut
+	 *	@param      int		$status		Status
 	 *	@param      string	$note		Complete private note with this note
 	 *  @param		int		$notrigger	1=Does not execute triggers, 0=Execute triggers
 	 *	@return     int         		<0 if KO, >0 if OK
 	 */
-    public function cloture($user, $statut, $note = "", $notrigger = 0)
+    public function cloture($user, $status, $note = "", $notrigger = 0)
 	{
 		global $langs, $conf;
 
@@ -2521,7 +2521,7 @@ class Propal extends CommonObject
 		$newprivatenote = dol_concatdesc($this->note_private, $note);
 
 		$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
-		$sql .= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($newprivatenote)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id;
+		$sql .= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($newprivatenote)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id;
 		$sql .= " WHERE rowid = ".$this->id;
 
 		$resql = $this->db->query($sql);
@@ -2530,7 +2530,7 @@ class Propal extends CommonObject
 			$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf;
 			$triggerName = 'PROPAL_CLOSE_REFUSED';
 
-			if ($statut == self::STATUS_SIGNED)
+			if ($status == self::STATUS_SIGNED)
 			{
 				$triggerName = 'PROPAL_CLOSE_SIGNED';
 				$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf;
@@ -2547,7 +2547,7 @@ class Propal extends CommonObject
 					return -2;
 				}
 			}
-			if ($statut == self::STATUS_BILLED)	// Why this ?
+			if ($status == self::STATUS_BILLED)	// ->cloture() can also be called when we set it to billed, after setting it to signed
 			{
 				$triggerName = 'PROPAL_CLASSIFY_BILLED';
 			}
@@ -2569,7 +2569,7 @@ class Propal extends CommonObject
 			if (!$error)
 			{
 				$this->oldcopy = clone $this;
-				$this->statut = $statut;
+				$this->statut = $status;
 				$this->date_cloture = $now;
 				$this->note_private = $newprivatenote;
 			}

+ 78 - 4
htdocs/comm/propal/list.php

@@ -472,6 +472,8 @@ if ($resql)
 		'generate_doc'=>$langs->trans("ReGeneratePDF"),
 		'builddoc'=>$langs->trans("PDFMerge"),
 		'presend'=>$langs->trans("SendByMail"),
+		'prevalidate'=>$langs->trans("Validate"),
+		'presign'=>$langs->trans("Sign"),
 	);
 	if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
 	if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close");
@@ -502,6 +504,16 @@ if ($resql)
 	$trackid = 'pro'.$object->id;
 	include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
 
+	if ($massaction == 'prevalidate')
+	{
+		print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
+	}
+
+	if ($massaction == 'presign')
+	{
+		print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1);
+	}
+
 	if ($sall)
 	{
 		foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
@@ -1270,10 +1282,72 @@ if ($resql)
 	$delallowed = $user->rights->propal->creer;
 
 	print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
+
+	if ($action == 'validate') {
+		if (GETPOST('confirm') == 'yes') {
+			$tmpproposal = new Propal($db);
+			$db->begin();
+			$error = 0;
+			foreach ($toselect as $checked) {
+				if ($tmpproposal->fetch($checked)) {
+					if ($tmpproposal->statut == 0) {
+						if ($tmpproposal->valid($user)){
+							setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs');
+						} else {
+							setEventMessage($langs->trans('CantBeValidated'), 'errors');
+							$error++;
+						}
+					} else {
+						setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors');
+						$error++;
+					}
+				}
+				dol_print_error($db);
+				$error++;
+			}
+			if ($error){
+				$db->rollback();
+			} else {
+				$db->commit();
+			}
+		}
+	}
+
+	if ($action == "sign") {
+		if (GETPOST('confirm') == 'yes') {
+			$tmpproposal = new Propal($db);
+			$db->begin();
+			$error = 0;
+			foreach ($toselect as $checked) {
+				if ($tmpproposal->fetch($checked)) {
+					if ($tmpproposal->statut == 1) {
+						$tmpproposal->statut = 2;
+						if ($tmpproposal->update($user)) {
+							setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs');
+						} else {
+							dol_print_error($db);
+							$error++;
+						}
+					} else {
+						setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors');
+						$error++;
+					}
+				} else {
+					dol_print_error($db);
+					$error++;
+				}
+			}
+			if ($error){
+				$db->rollback();
+			} else {
+				$db->commit();
+			}
+		}
+	}
 } else {
-	dol_print_error($db);
+		dol_print_error($db);
 }
 
-// End of page
-llxFooter();
-$db->close();
+	// End of page
+	llxFooter();
+	$db->close();

+ 61 - 10
htdocs/commande/class/api_orders.class.php

@@ -348,7 +348,8 @@ class Orders extends DolibarrApi
                         $request_data->fk_unit,
                         $request_data->origin,
                         $request_data->origin_id,
-                        $request_data->multicurrency_subprice
+                        $request_data->multicurrency_subprice,
+                        $request_data->ref_ext
         );
 
         if ($updateRes > 0) {
@@ -406,7 +407,9 @@ class Orders extends DolibarrApi
             $request_data->special_code,
             $request_data->array_options,
             $request_data->fk_unit,
-      		$request_data->multicurrency_subprice
+      		$request_data->multicurrency_subprice,
+			0,
+      		$request_data->ref_ext
         );
 
         if ($updateRes > 0) {
@@ -456,6 +459,40 @@ class Orders extends DolibarrApi
         }
     }
 
+    /**
+     * Get contacts of given order
+     *
+     * Return an array with contact informations
+     *
+     * @param int    $id   ID of order
+	 * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
+     *
+     * @url	GET {id}/contacts
+     *
+     * @return 	array data without useless information
+     *
+     * @throws 	RestException
+     */
+    public function getContacts($id, $type = '')
+    {
+        if (! DolibarrApiAccess::$user->rights->commande->lire) {
+            throw new RestException(401);
+        }
+
+        $result = $this->commande->fetch($id);
+        if ( ! $result ) {
+            throw new RestException(404, 'Order not found');
+        }
+
+        if ( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+
+        $contacts = $this->commande->liste_contact(-1, 'external', 0, $type);
+
+        return $this->_cleanObjectDatas($contacts);
+    }
+
     /**
 	 * Add a contact type of given order
 	 *
@@ -487,15 +524,24 @@ class Orders extends DolibarrApi
 
         $result = $this->commande->add_contact($contactid, $type, 'external');
 
-        if (!$result) {
+        if ($result < 0) {
             throw new RestException(500, 'Error when added the contact');
         }
 
-        return $this->commande;
+        if ($result == 0) {
+            throw new RestException(304, 'contact already added');
+        }
+
+        return array(
+            'success' => array(
+                'code' => 200,
+                'message' => 'Contact linked to the order'
+            )
+        );
     }
 
     /**
-	 * Delete a contact type of given order
+	 * Unlink a contact type of given order
 	 *
 	 * @param int    $id             Id of order to update
 	 * @param int    $rowid          Row key of the contact in the array contact_ids.
@@ -510,26 +556,31 @@ class Orders extends DolibarrApi
 	 */
     public function deleteContact($id, $rowid)
     {
-        if (!DolibarrApiAccess::$user->rights->commande->creer) {
+        if (! DolibarrApiAccess::$user->rights->commande->creer) {
 			throw new RestException(401);
 		}
 
         $result = $this->commande->fetch($id);
-        if (!$result) {
+        if (! $result) {
             throw new RestException(404, 'Order not found');
         }
 
-		if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+		if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
 		}
 
-        $result = $this->commande->delete_contact($rowid);
+        $result = $this->commande->delete_linked_contact($rowid);
 
         if (!$result) {
             throw new RestException(500, 'Error when deleted the contact');
         }
 
-        return $this->commande;
+        return array(
+            'success' => array(
+                'code' => 200,
+                'message' => 'Contact unlinked from order'
+            )
+        );
     }
 
     /**

+ 37 - 8
htdocs/commande/class/commande.class.php

@@ -1004,6 +1004,11 @@ class Commande extends CommonOrder
 						$origintype = $this->element;
 					}
 
+					// ref_ext
+					if (empty($line->ref_ext)) {
+						$line->ref_ext = '';
+					}
+
                     $result = $this->addline(
 						$line->desc,
 						$line->subprice,
@@ -1029,7 +1034,9 @@ class Commande extends CommonOrder
 						$line->array_options,
 						$line->fk_unit,
 	                    $origintype,
-	                    $originid
+	                    $originid,
+						0,
+	                    $line->ref_ext
 					);
 					if ($result < 0)
 					{
@@ -1215,6 +1222,13 @@ class Commande extends CommonOrder
 		$this->date_validation    = '';
 		if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = '';
 
+		// Do not clone ref_ext
+		$num = count($this->lines);
+		for ($i = 0; $i < $num; $i++)
+		{
+			$this->lines[$i]->ref_ext = '';
+		}
+
 		// Create clone
 		$this->context['createfromclone'] = 'createfromclone';
 		$result = $this->create($user);
@@ -1423,6 +1437,7 @@ class Commande extends CommonOrder
 	 * 	@param		string		    $origin				Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'....
 	 *  @param		int			    $origin_id			Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id
 	 * 	@param		double			$pu_ht_devise		Unit price in currency
+	 * 	@param		string			$ref_ext		    line external reference
 	 *	@return     int             					>0 if OK, <0 if KO
 	 *
 	 *	@see        add_product()
@@ -1432,13 +1447,13 @@ class Commande extends CommonOrder
 	 *	par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
 	 *	et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
 	 */
-	public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0)
+	public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $ref_ext = '')
 	{
 		global $mysoc, $conf, $langs, $user;
 
 		$logtext = "::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent";
 		$logtext .= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start";
-		$logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise";
+		$logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise, ref_ext=$ref_ext";
 		dol_syslog(get_class($this).$logtext, LOG_DEBUG);
 
 		if ($this->statut == self::STATUS_DRAFT)
@@ -1446,6 +1461,7 @@ class Commande extends CommonOrder
 			include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
 
 			// Clean parameters
+
 			if (empty($remise_percent)) $remise_percent = 0;
 			if (empty($qty)) $qty = 0;
 			if (empty($info_bits)) $info_bits = 0;
@@ -1455,6 +1471,7 @@ class Commande extends CommonOrder
 			if (empty($txlocaltax2)) $txlocaltax2 = 0;
 			if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0;
 			if (empty($this->fk_multicurrency)) $this->fk_multicurrency = 0;
+			if (empty($ref_ext)) $ref_ext = '';
 
 			$remise_percent = price2num($remise_percent);
 			$qty = price2num($qty);
@@ -1570,6 +1587,7 @@ class Commande extends CommonOrder
 			$this->line->label = $label;
 			$this->line->desc = $desc;
 			$this->line->qty = $qty;
+			$this->line->ref_ext = $ref_ext;
 
 			$this->line->vat_src_code = $vat_src_code;
 			$this->line->tva_tx = $txtva;
@@ -1977,7 +1995,7 @@ class Commande extends CommonOrder
         // phpcs:enable
 		$this->lines = array();
 
-		$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,';
+		$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,';
 		$sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
 		$sql .= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
 		$sql .= ' l.fk_unit,';
@@ -2012,6 +2030,7 @@ class Commande extends CommonOrder
 				$line->description      = $objp->description; // Description line
 				$line->product_type     = $objp->product_type;
 				$line->qty              = $objp->qty;
+				$line->ref_ext          = $objp->ref_ext;
 
 				$line->vat_src_code     = $objp->vat_src_code;
 				$line->tva_tx           = $objp->tva_tx;
@@ -2981,13 +3000,14 @@ class Commande extends CommonOrder
 	 * 	@param 		string			$fk_unit 			Code of the unit to use. Null to use the default one
 	 *  @param		double			$pu_ht_devise		Amount in currency
 	 * 	@param		int				$notrigger			disable line update trigger
+	 * 	@param		string			$ref_ext			external reference
 	 *  @return   	int              					< 0 if KO, > 0 if OK
 	 */
-	public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0)
+	public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '')
 	{
 		global $conf, $mysoc, $langs, $user;
 
-		dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
+		dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code, ref_ext=$ref_ext");
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
 
 		if ($this->statut == Commande::STATUS_DRAFT)
@@ -3000,6 +3020,7 @@ class Commande extends CommonOrder
 			if (empty($txlocaltax2)) $txlocaltax2 = 0;
 			if (empty($remise_percent)) $remise_percent = 0;
 			if (empty($special_code) || $special_code == 3) $special_code = 0;
+			if (empty($ref_ext)) $ref_ext = '';
 
 			if ($date_start && $date_end && $date_start > $date_end) {
 				$langs->load("errors");
@@ -3104,6 +3125,7 @@ class Commande extends CommonOrder
 			$this->line->label = $label;
 			$this->line->desc = $desc;
 			$this->line->qty = $qty;
+			$this->line->ref_ext = $ref_ext;
 
 			$this->line->vat_src_code = $vat_src_code;
 			$this->line->tva_tx         = $txtva;
@@ -3970,6 +3992,8 @@ class OrderLine extends CommonOrderLine
 	 */
 	public $label;
 
+	public $ref_ext;
+
 	public $fk_remise_except;
 	public $rang = 0;
 	public $fk_fournprice;
@@ -4014,7 +4038,7 @@ class OrderLine extends CommonOrderLine
 	public function fetch($rowid)
 	{
 		$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
-		$sql .= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
+		$sql .= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice, cd.ref_ext,';
 		$sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,';
 		$sql .= ' cd.fk_unit,';
 		$sql .= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,';
@@ -4036,6 +4060,7 @@ class OrderLine extends CommonOrderLine
 			$this->qty              = $objp->qty;
 			$this->price            = $objp->price;
 			$this->subprice         = $objp->subprice;
+			$this->ref_ext          = $objp->ref_ext;
 			$this->vat_src_code     = $objp->vat_src_code;
 			$this->tva_tx           = $objp->tva_tx;
 			$this->localtax1_tx		= $objp->localtax1_tx;
@@ -4205,6 +4230,7 @@ class OrderLine extends CommonOrderLine
 		if (empty($this->special_code)) $this->special_code = 0;
 		if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
 		if (empty($this->pa_ht)) $this->pa_ht = 0;
+		if (empty($this->ref_ext)) $this->ref_ext = '';
 
 		// if buy price not defined, define buyprice as configured in margin admin
 		if ($this->pa_ht == 0 && $pa_ht_isemptystring)
@@ -4224,7 +4250,7 @@ class OrderLine extends CommonOrderLine
 
 		// Insertion dans base de la ligne
 		$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
-		$sql .= ' (fk_commande, fk_parent_line, label, description, qty, ';
+		$sql .= ' (fk_commande, fk_parent_line, label, description, qty, ref_ext,';
 		$sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
 		$sql .= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
 		$sql .= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
@@ -4237,6 +4263,7 @@ class OrderLine extends CommonOrderLine
 		$sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
 		$sql .= " '".$this->db->escape($this->desc)."',";
 		$sql .= " '".price2num($this->qty)."',";
+		$sql .= " '".$this->db->escape($this->ref_ext)."',";
 		$sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").",";
 		$sql .= " '".price2num($this->tva_tx)."',";
 		$sql .= " '".price2num($this->localtax1_tx)."',";
@@ -4347,6 +4374,7 @@ class OrderLine extends CommonOrderLine
 		if (empty($this->product_type)) $this->product_type = 0;
 		if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
 		if (empty($this->pa_ht)) $this->pa_ht = 0;
+		if (empty($this->ref_ext)) $this->ref_ext = '';
 
 		// if buy price not defined, define buyprice as configured in margin admin
 		if ($this->pa_ht == 0 && $pa_ht_isemptystring)
@@ -4372,6 +4400,7 @@ class OrderLine extends CommonOrderLine
 		$sql .= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'";
 		$sql .= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'";
 		$sql .= " , qty=".price2num($this->qty);
+		$sql .= " , ref_ext='".$this->db->escape($this->ref_ext)."'";
 		$sql .= " , subprice=".price2num($this->subprice)."";
 		$sql .= " , remise_percent=".price2num($this->remise_percent)."";
 		$sql .= " , price=".price2num($this->price).""; // TODO A virer

+ 26 - 20
htdocs/compta/facture/card.php

@@ -3397,13 +3397,16 @@ if ($action == 'create')
 	print '</td></tr>';
 
 	// Bank Account
-	if (GETPOSTISSET('fk_account')) {
-		$fk_account = GETPOST('fk_account');
-	}
+	if (!empty($conf->banque->enabled))
+	{
+		if (GETPOSTISSET('fk_account')) {
+			$fk_account = GETPOST('fk_account');
+		}
 
-	print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">';
-	$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
-	print '</td></tr>';
+		print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">';
+		$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
+		print '</td></tr>';
+	}
 
 	// Project
 	if (!empty($conf->projet->enabled))
@@ -4264,22 +4267,25 @@ if ($action == 'create')
 	}
 
 	// Bank Account
-	print '<tr><td class="nowrap">';
-	print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
-	print $langs->trans('BankAccount');
-	print '<td>';
-	if (($action != 'editbankaccount') && $usercancreate)
-		print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
-	print '</tr></table>';
-	print '</td><td>';
-	if ($action == 'editbankaccount')
+	if (!empty($conf->banque->enabled))
 	{
-		$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
-	} else {
-		$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
+		print '<tr><td class="nowrap">';
+		print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
+		print $langs->trans('BankAccount');
+		print '<td>';
+		if (($action != 'editbankaccount') && $usercancreate)
+			print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
+		print '</tr></table>';
+		print '</td><td>';
+		if ($action == 'editbankaccount')
+		{
+			$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
+		} else {
+			$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
+		}
+		print "</td>";
+		print '</tr>';
 	}
-	print "</td>";
-	print '</tr>';
 
 	// Incoterms
 	if (!empty($conf->incoterm->enabled))

+ 32 - 7
htdocs/compta/facture/class/facture.class.php

@@ -818,6 +818,11 @@ class Facture extends CommonInvoice
 							$origintype = $this->element;
 						}
 
+						// init ref_ext
+						if (empty($line->ref_ext)) {
+							$line->ref_ext = '';
+						}
+
                         $result = $this->addline(
 							$line->desc,
 							$line->subprice,
@@ -847,7 +852,8 @@ class Facture extends CommonInvoice
 							$line->situation_percent,
 							$line->fk_prev_id,
 							$line->fk_unit,
-							$line->pu_ht_devise
+							$line->pu_ht_devise,
+							$line->ref_ext
 						);
 						if ($result < 0)
 						{
@@ -1073,6 +1079,7 @@ class Facture extends CommonInvoice
 				$facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1;
 				$facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2;
 				$facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc;
+				$facture->lines[$i]->ref_ext = '';
 			}
 		}
 
@@ -1190,6 +1197,8 @@ class Facture extends CommonInvoice
 					$object->lines[$i]->date_end = $newLast;
 				}
 			}
+
+			$object->lines[$i]->ref_ext = ''; // Do not clone ref_ext
 		}
 
 		// Create clone
@@ -1658,7 +1667,7 @@ class Facture extends CommonInvoice
 		$this->lines = array();
 
 		$sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
-		$sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
+		$sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice, l.ref_ext,';
 		$sql .= ' l.situation_percent, l.fk_prev_id,';
 		$sql .= ' l.rang, l.special_code,';
 		$sql .= ' l.date_start as date_start, l.date_end as date_end,';
@@ -1697,6 +1706,7 @@ class Facture extends CommonInvoice
 				$line->fk_product_type  = $objp->fk_product_type; // Type of product
 				$line->qty              = $objp->qty;
 				$line->subprice         = $objp->subprice;
+				$line->ref_ext          = $objp->ref_ext; // line external ref
 
                 $line->vat_src_code = $objp->vat_src_code;
 				$line->tva_tx           = $objp->tva_tx;
@@ -1819,6 +1829,7 @@ class Facture extends CommonInvoice
 		// Clean parameters
 		if (empty($this->type)) $this->type = self::TYPE_STANDARD;
 		if (isset($this->ref)) $this->ref = trim($this->ref);
+		if (isset($this->ref_ext)) $this->ref_ext = trim($this->ref_ext);
 		if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client);
 		if (isset($this->increment)) $this->increment = trim($this->increment);
 		if (isset($this->close_code)) $this->close_code = trim($this->close_code);
@@ -1837,6 +1848,7 @@ class Facture extends CommonInvoice
 		// Update request
 		$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET";
 		$sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").",";
+		$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
 		$sql .= " type=".(isset($this->type) ? $this->db->escape($this->type) : "null").",";
 		$sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").",";
 		$sql .= " increment=".(isset($this->increment) ? "'".$this->db->escape($this->increment)."'" : "null").",";
@@ -2930,6 +2942,7 @@ class Facture extends CommonInvoice
 	 *  @param      int         $fk_prev_id         Previous situation line id reference
 	 *  @param 		string		$fk_unit 			Code of the unit to use. Null to use the default one
 	 *  @param		double		$pu_ht_devise		Unit price in currency
+	 *  @param		string		$ref_ext		    External reference of the line
 	 *  @return    	int             				<0 if KO, Id of line if OK
 	 */
     public function addline(
@@ -2961,7 +2974,8 @@ class Facture extends CommonInvoice
         $situation_percent = 100,
         $fk_prev_id = 0,
         $fk_unit = null,
-        $pu_ht_devise = 0
+        $pu_ht_devise = 0,
+        $ref_ext = ''
     ) {
 		// Deprecation warning
 		if ($label) {
@@ -2989,6 +3003,7 @@ class Facture extends CommonInvoice
 			if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0;
 			if (empty($fk_prev_id)) $fk_prev_id = 'null';
 			if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
+			if (empty($ref_ext)) $ref_ext = '';
 
 			$remise_percent = price2num($remise_percent);
 			$qty = price2num($qty);
@@ -3082,6 +3097,7 @@ class Facture extends CommonInvoice
 			$this->line->fk_facture = $this->id;
 			$this->line->label = $label; // deprecated
 			$this->line->desc = $desc;
+			$this->line->ref_ext = $ref_ext;
 
 			$this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative
 			$this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise
@@ -3157,7 +3173,7 @@ class Facture extends CommonInvoice
 				return -2;
 			}
 		} else {
-			dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
+			dol_syslog(get_class($this)."::addline status of invoice must be Draft to allow use of ->addline()", LOG_ERR);
 			return -3;
 		}
 	}
@@ -3189,9 +3205,10 @@ class Facture extends CommonInvoice
 	 * 	@param 		string		$fk_unit 			Code of the unit to use. Null to use the default one
 	 * 	@param		double		$pu_ht_devise		Unit price in currency
 	 * 	@param		int			$notrigger			disable line update trigger
+	 *  @param		string		$ref_ext		    External reference of the line
 	 *  @return    	int             				< 0 if KO, > 0 if OK
 	 */
-    public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0)
+    public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '')
 	{
 		global $conf, $user;
 		// Deprecation warning
@@ -3229,6 +3246,7 @@ class Facture extends CommonInvoice
 			if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0;
 			if (empty($special_code) || $special_code == 3) $special_code = 0;
 			if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
+			if (empty($ref_ext)) $ref_ext = '';
 
 			$remise_percent = price2num($remise_percent);
 			$qty			= price2num($qty);
@@ -3319,6 +3337,7 @@ class Facture extends CommonInvoice
 			$this->line->rowid				= $rowid;
 			$this->line->label				= $label;
 			$this->line->desc = $desc;
+			$this->line->ref_ext			= $ref_ext;
 			$this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative
 
 			$this->line->vat_src_code = $vat_src_code;
@@ -4722,6 +4741,7 @@ class FactureLigne extends CommonInvoiceLine
 	public $label;
 	//! Description ligne
 	public $desc;
+	public $ref_ext; // External reference of the line
 
 	public $localtax1_type; // Local tax 1 type
 	public $localtax2_type; // Local tax 2 type
@@ -4792,7 +4812,7 @@ class FactureLigne extends CommonInvoiceLine
     public function fetch($rowid)
 	{
 		$sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,';
-		$sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,';
+		$sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice, fd.ref_ext,';
 		$sql .= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,';
 		$sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,';
 		$sql .= ' fd.fk_code_ventilation,';
@@ -4820,6 +4840,7 @@ class FactureLigne extends CommonInvoiceLine
 			$this->desc					= $objp->description;
 			$this->qty = $objp->qty;
 			$this->subprice = $objp->subprice;
+			$this->ref_ext = $objp->ref_ext;
 			$this->vat_src_code = $objp->vat_src_code;
 			$this->tva_tx = $objp->tva_tx;
 			$this->localtax1_tx			= $objp->localtax1_tx;
@@ -4902,6 +4923,7 @@ class FactureLigne extends CommonInvoiceLine
 		if (empty($this->remise_percent)) $this->remise_percent = 0;
 		if (empty($this->info_bits)) $this->info_bits = 0;
 		if (empty($this->subprice)) $this->subprice = 0;
+		if (empty($this->ref_ext)) $this->ref_ext = '';
 		if (empty($this->special_code)) $this->special_code = 0;
 		if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
 		if (empty($this->fk_prev_id)) $this->fk_prev_id = 0;
@@ -4948,7 +4970,7 @@ class FactureLigne extends CommonInvoiceLine
 		$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet';
 		$sql .= ' (fk_facture, fk_parent_line, label, description, qty,';
 		$sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
-		$sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,';
+		$sql .= ' fk_product, product_type, remise_percent, subprice, ref_ext, fk_remise_except,';
 		$sql .= ' date_start, date_end, fk_code_ventilation, ';
 		$sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
 		$sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
@@ -4971,6 +4993,7 @@ class FactureLigne extends CommonInvoiceLine
 		$sql .= " ".((int) $this->product_type).",";
 		$sql .= " ".price2num($this->remise_percent).",";
 		$sql .= " ".price2num($this->subprice).",";
+		$sql .= " '".$this->db->escape($this->ref_ext)."',";
 		$sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").',';
 		$sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").",";
 		$sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").",";
@@ -5097,6 +5120,7 @@ class FactureLigne extends CommonInvoiceLine
 
 		// Clean parameters
 		$this->desc = trim($this->desc);
+		if (empty($this->ref_ext)) $this->ref_ext = '';
 		if (empty($this->tva_tx)) $this->tva_tx = 0;
 		if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
 		if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
@@ -5136,6 +5160,7 @@ class FactureLigne extends CommonInvoiceLine
         // Mise a jour ligne en base
         $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
         $sql .= " description='".$this->db->escape($this->desc)."'";
+        $sql .= " ref_ext='".$this->db->escape($this->ref_ext)."'";
         $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null");
         $sql .= ", subprice=".price2num($this->subprice)."";
         $sql .= ", remise_percent=".price2num($this->remise_percent)."";

+ 59 - 20
htdocs/compta/index.php

@@ -7,6 +7,7 @@
  * Copyright (C) 2015      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
  * Copyright (C) 2016      Marcos García        <marcosgdf@gmail.com>
  * Copyright (C) 2019      Nicolas ZABOURI      <info@inovea-conseil.com>
+ * Copyright (C) 2020      Tobias Sekan         <tobias.sekan@startmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,12 +33,9 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
-if (!empty($conf->commande->enabled))
-	require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-if (!empty($conf->commande->enabled))
-	require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
-if (!empty($conf->tax->enabled))
-	require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
+require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
 
 // L'espace compta/treso doit toujours etre actif car c'est un espace partage
 // par de nombreux modules (banque, facture, commande a facturer, etc...) independamment
@@ -148,7 +146,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
 	$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
+	$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT;
 	$sql .= " AND f.entity IN (".getEntity('invoice').")";
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 
@@ -161,8 +159,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
 	$reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters);
 	$sql .= $hookmanager->resPrint;
 
-	$sql.= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, ";
-	$sql.= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
+	$sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, ";
+	$sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
 
 	// Add Group from hooks
 	$parameters = array();
@@ -175,10 +173,18 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
 	{
 		$num = $db->num_rows($resql);
 
-        print '<div class="div-table-responsive-no-min">';
+		print '<div class="div-table-responsive-no-min">';
 		print '<table class="noborder centpercent">';
+
 		print '<tr class="liste_titre">';
-		print '<th colspan="3">'.$langs->trans("CustomersDraftInvoices").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
+		print '<th colspan="3">';
+		print $langs->trans("CustomersDraftInvoices").' ';
+		print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?search_status='.Facture::STATUS_DRAFT.'">';
+		print '<span class="badge marginleftonlyshort">'.$num.'</span>';
+		print '</a>';
+		print '</th>';
+		print '</tr>';
+
 		if ($num)
 		{
 			$companystatic = new Societe($db);
@@ -244,7 +250,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
     $sql .= ", cc.rowid as country_id, cc.code as country_code";
     $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
+	$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT;
 	$sql .= " AND f.entity IN (".getEntity('invoice').')';
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 	if ($socid)	$sql .= " AND f.fk_soc = ".$socid;
@@ -258,10 +264,18 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
 	{
 		$num = $db->num_rows($resql);
 
-        print '<div class="div-table-responsive-no-min">';
+		print '<div class="div-table-responsive-no-min">';
 		print '<table class="noborder centpercent">';
+
 		print '<tr class="liste_titre">';
-		print '<th colspan="3">'.$langs->trans("SuppliersDraftInvoices").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
+		print '<th colspan="3">';
+		print $langs->trans("SuppliersDraftInvoices").' ';
+		print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?search_status='.FactureFournisseur::STATUS_DRAFT.'">';
+		print '<span class="badge marginleftonlyshort">'.$num.'</span>';
+		print '</a>';
+		print '</th>';
+		print '</tr>';
+
 		if ($num)
 		{
 			$companystatic = new Societe($db);
@@ -709,7 +723,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
 	$sql .= " AND c.entity = ".$conf->entity;
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 	if ($socid)	$sql .= " AND c.fk_soc = ".$socid;
-	$sql .= " AND c.fk_statut = 3";
+	$sql .= " AND c.fk_statut = ".Commande::STATUS_CLOSED;
 	$sql .= " AND c.facture = 0";
 	// Add where from hooks
 	$parameters = array();
@@ -729,8 +743,15 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
 
             print '<div class="div-table-responsive-no-min">';
 			print '<table class="noborder centpercent">';
+
 			print "<tr class=\"liste_titre\">";
-			print '<th colspan="2">'.$langs->trans("OrdersDeliveredToBill").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status=3&amp;billed=0"><span class="badge">'.$num.'</span></a></th>';
+			print '<th colspan="2">';
+			print $langs->trans("OrdersDeliveredToBill").' ';
+			print '<a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_CLOSED.'&amp;billed=0">';
+			print '<span class="badge">'.$num.'</span>';
+			print '</a>';
+			print '</th>';
+
 			if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>';
 			print '<th class="right">'.$langs->trans("AmountTTC").'</th>';
 			print '<th class="right">'.$langs->trans("ToBill").'</th>';
@@ -822,7 +843,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
 	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f";
 	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
+	$sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED;
 	$sql .= " AND f.entity IN (".getEntity('invoice').')';
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 	if ($socid) $sql .= " AND f.fk_soc = ".$socid;
@@ -843,7 +864,15 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
 
 		print '<div class="div-table-responsive-no-min">';
 		print '<table class="noborder centpercent">';
-		print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BillsCustomersUnpaid", $num).' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th>';
+
+		print '<tr class="liste_titre">';
+		print '<th colspan="2">';
+		print $langs->trans("BillsCustomersUnpaid", $num).' ';
+		print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?search_status='.Facture::STATUS_VALIDATED.'">';
+		print '<span class="badge">'.$num.'</span>';
+		print '</a>';
+		print '</th>';
+
 		print '<th class="right">'.$langs->trans("DateDue").'</th>';
 		if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>';
 		print '<th class="right">'.$langs->trans("AmountTTC").'</th>';
@@ -954,7 +983,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
 	$sql .= " WHERE s.rowid = ff.fk_soc";
 	$sql .= " AND ff.entity = ".$conf->entity;
 	$sql .= " AND ff.paye = 0";
-	$sql .= " AND ff.fk_statut = 1";
+	$sql .= " AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
 	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 	if ($socid) $sql .= " AND ff.fk_soc = ".$socid;
 	// Add where from hooks
@@ -973,7 +1002,17 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
 
 		print '<div class="div-table-responsive-no-min">';
 		print '<table class="noborder centpercent">';
-		print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BillsSuppliersUnpaid", $num).' <a href="'.DOL_URL_ROOT.'/fourn/facture/impayees.php"><span class="badge">'.$num.'</span></a></th>';
+
+		print '<tr class="liste_titre">';
+		print '<th colspan="2">';
+		print $langs->trans("BillsSuppliersUnpaid", $num).' ';
+		print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?search_status='.FactureFournisseur::STATUS_VALIDATED.'">';
+		// TODO: "impayees.php" looks very outdatetd and should be set to deprecated or directly remove in the next version
+		// <a href="'.DOL_URL_ROOT.'/fourn/facture/impayees.php">
+		print '<span class="badge">'.$num.'</span>';
+		print '</a>';
+		print '</th>';
+
 		print '<th class="right">'.$langs->trans("DateDue").'</th>';
 		if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>';
 		print '<th class="right">'.$langs->trans("AmountTTC").'</th>';

+ 39 - 39
htdocs/compta/prelevement/card.php

@@ -81,38 +81,38 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
 
 if (empty($reshook))
 {
-    if ($action == 'confirm_delete')
-    {
-        $res = $object->delete($user);
-        if ($res > 0)
-        {
-        	if ($object->type == 'bank-transfer') {
-        		header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
-        	} else {
-        		header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
-        	}
-            exit;
-        }
-    }
+	if ($action == 'confirm_delete')
+	{
+		$res = $object->delete($user);
+		if ($res > 0)
+		{
+			if ($object->type == 'bank-transfer') {
+				header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
+			} else {
+				header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
+			}
+			exit;
+		}
+	}
 
-    // Seems to no be used and replaced with $action == 'infocredit'
-    if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes')
-    {
-        $res = $object->set_credite();
-        if ($res >= 0)
-        {
-            header("Location: card.php?id=".$id);
-            exit;
-        }
-    }
+	// Seems to no be used and replaced with $action == 'infocredit'
+	if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes')
+	{
+		$res = $object->set_credite();
+		if ($res >= 0)
+		{
+			header("Location: card.php?id=".$id);
+			exit;
+		}
+	}
 
-    if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
-    {
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
+	{
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 		$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
 
-        /*
+		/*
         if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
         {
             $dir = $conf->prelevement->dir_output.'/receipts';
@@ -133,24 +133,24 @@ if (empty($reshook))
 
 		$error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
 
-        if ($error)
-        {
-            header("Location: card.php?id=".$id."&error=$error");
-            exit;
-        }
-    }
+		if ($error)
+		{
+			header("Location: card.php?id=".$id."&error=$error");
+			exit;
+		}
+	}
 
 	// Set direct debit order to credited, create payment and close invoices
 	if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
 	{
 		$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
 
-        $error = $object->set_infocredit($user, $dt);
-        if ($error)
-        {
-        	setEventMessages($object->error, $object->errors, 'errors');
-        }
-    }
+		$error = $object->set_infocredit($user, $dt);
+		if ($error)
+		{
+			setEventMessages($object->error, $object->errors, 'errors');
+		}
+	}
 }
 
 

+ 9 - 9
htdocs/compta/prelevement/class/bonprelevement.class.php

@@ -318,7 +318,7 @@ class BonPrelevement extends CommonObject
 				$this->type           = $obj->type;
 
 				$this->status         = $obj->status;
-				$this->statut         = $obj->status;	// For backward compatibility
+				$this->statut         = $obj->status; // For backward compatibility
 
 				$this->fetched = 1;
 
@@ -510,7 +510,7 @@ class BonPrelevement extends CommonObject
 					$paiement->num_paiement = $this->ref; // For backward compatibility
 					$paiement->id_prelevement = $this->id;
 
-					$paiement_id = $paiement->create($user);		// This use ->paiementid, that is ID of payment mode
+					$paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode
 					if ($paiement_id < 0)
 					{
 						$error++;
@@ -540,7 +540,7 @@ class BonPrelevement extends CommonObject
 
 				// Update withdrawal line
 				// TODO: Translate to ligneprelevement.class.php
-				if (! $error) {
+				if (!$error) {
 					$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes";
 					$sql .= " SET statut = 2";
 					$sql .= " WHERE fk_prelevement_bons = ".$this->id;
@@ -884,7 +884,7 @@ class BonPrelevement extends CommonObject
 				$sql .= " AND f.rowid = pfd.fk_facture_fourn";
 			}
 			$sql .= " AND s.rowid = f.fk_soc";
-			$sql .= " AND f.fk_statut = 1";			// Invoice validated
+			$sql .= " AND f.fk_statut = 1"; // Invoice validated
 			$sql .= " AND f.paye = 0";
 			$sql .= " AND pfd.traite = 0";
 			$sql .= " AND f.total_ttc > 0";
@@ -1179,7 +1179,7 @@ class BonPrelevement extends CommonObject
 			/*
 			 * Update total defined after generation of file
 			 */
-			if (! $error) {
+			if (!$error) {
 				$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
 				$sql .= " SET amount = ".price2num($this->total);
 				$sql .= " WHERE rowid = ".$this->id;
@@ -1542,7 +1542,7 @@ class BonPrelevement extends CommonObject
 					{
 						$obj = $this->db->fetch_object($resql);
 
-						if (! empty($cachearraytotestduplicate[$obj->idfac])) {
+						if (!empty($cachearraytotestduplicate[$obj->idfac])) {
 							$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
 							$this->invoice_in_error[$obj->idfac] = $this->error;
 							$result = -2;
@@ -1657,7 +1657,7 @@ class BonPrelevement extends CommonObject
 					{
 						$obj = $this->db->fetch_object($resql);
 
-						if (! empty($cachearraytotestduplicate[$obj->idfac])) {
+						if (!empty($cachearraytotestduplicate[$obj->idfac])) {
 							$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
 							$this->invoice_in_error[$obj->idfac] = $this->error;
 							$result = -2;
@@ -2192,7 +2192,7 @@ class BonPrelevement extends CommonObject
 				 $XML_SEPA_INFO .= '					<AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
 				 $XML_SEPA_INFO .= '				</PstlAdr>'.$CrLf;
 				 $XML_SEPA_INFO .= '			</UltmtCdtr>'.$CrLf;*/
-				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf;		// Field "Responsible of fees". Must be SLEV
+				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
 				$XML_SEPA_INFO .= '			<CdtrSchmeId>'.$CrLf;
 				$XML_SEPA_INFO .= '				<Id>'.$CrLf;
 				$XML_SEPA_INFO .= '					<PrvtId>'.$CrLf;
@@ -2254,7 +2254,7 @@ class BonPrelevement extends CommonObject
 				 $XML_SEPA_INFO .= '					<AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
 				 $XML_SEPA_INFO .= '				</PstlAdr>'.$CrLf;
 				 $XML_SEPA_INFO .= '			</UltmtCdtr>'.$CrLf;*/
-				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf;		// Field "Responsible of fees". Must be SLEV
+				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
 				/*$XML_SEPA_INFO .= '			<CdtrSchmeId>'.$CrLf;
 				$XML_SEPA_INFO .= '				<Id>'.$CrLf;
 				$XML_SEPA_INFO .= '					<PrvtId>'.$CrLf;

+ 35 - 35
htdocs/compta/prelevement/create.php

@@ -84,10 +84,10 @@ if (empty($reshook))
 			$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
 		}
 		$bprev = new BonPrelevement($db);
-	    $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
+		$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
 
-	    // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
-	    $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
+		// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
+		$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
 		if ($result < 0) {
 			setEventMessages($bprev->error, $bprev->errors, 'errors');
 		} elseif ($result == 0) {
@@ -188,30 +188,30 @@ print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="type" value="'.$type.'">';
 if ($nb) {
-    if ($pricetowithdraw) {
-        print $langs->trans('ExecutionDate').' ';
-        $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
-        print $form->selectDate($datere, 're');
-
-        if ($mysoc->isInEEC()) {
-        	$title = $langs->trans("CreateForSepa");
-        	if ($type == 'bank-transfer') {
-        		$title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
-        	}
-
-        	if ($type != 'bank-transfer') {
-            	print '<select name="format">';
-            	print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
-            	print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
-            	print '</select>';
-        	}
-            print '<input class="butAction" type="submit" value="'.$title.'"/>';
-        } else {
-        	$title = $langs->trans("CreateAll");
-        	if ($type == 'bank-transfer') {
-        		$title = $langs->trans("CreateFileForPaymentByBankTransfer");
-        	}
-        	print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL&type='.$type.'">'.$title."</a>\n";
+	if ($pricetowithdraw) {
+		print $langs->trans('ExecutionDate').' ';
+		$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+		print $form->selectDate($datere, 're');
+
+		if ($mysoc->isInEEC()) {
+			$title = $langs->trans("CreateForSepa");
+			if ($type == 'bank-transfer') {
+				$title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
+			}
+
+			if ($type != 'bank-transfer') {
+				print '<select name="format">';
+				print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
+				print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
+				print '</select>';
+			}
+			print '<input class="butAction" type="submit" value="'.$title.'"/>';
+		} else {
+			$title = $langs->trans("CreateAll");
+			if ($type == 'bank-transfer') {
+				$title = $langs->trans("CreateFileForPaymentByBankTransfer");
+			}
+			print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL&type='.$type.'">'.$title."</a>\n";
 		}
 	} else {
 		if ($mysoc->isInEEC())
@@ -301,12 +301,12 @@ if ($resql)
 	$num = $db->num_rows($resql);
 	$i = 0;
 
-    $param = '';
+	$param = '';
 	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
 	if ($socid) $param .= '&socid='.urlencode($socid);
-    if ($option) $param .= "&option=".urlencode($option);
+	if ($option) $param .= "&option=".urlencode($option);
 
-    print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
+	print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="page" value="'.$page.'">';
 	if (!empty($limit)) {
@@ -317,12 +317,12 @@ if ($resql)
 	if ($type == 'bank-transfer') {
 		$title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
 	}
-    print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
+	print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
 
-    $tradinvoice = "Invoice";
-    if ($type == 'bank-transfer') {
-    	$tradinvoice = "SupplierInvoice";
-    }
+	$tradinvoice = "Invoice";
+	if ($type == 'bank-transfer') {
+		$tradinvoice = "SupplierInvoice";
+	}
 
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre">';

+ 56 - 56
htdocs/compta/prelevement/factures.php

@@ -82,8 +82,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts"));
 if ($id > 0 || $ref)
 {
   	if ($object->fetch($id, $ref) >= 0)
-    {
-    	$head = prelevement_prepare_head($object);
+	{
+		$head = prelevement_prepare_head($object);
 		dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
 
 		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
@@ -151,9 +151,9 @@ if ($id > 0 || $ref)
 		print '</div>';
 
 		dol_fiche_end();
-    } else {
-      	dol_print_error($db);
-    }
+	} else {
+	  	dol_print_error($db);
+	}
 }
 
 
@@ -191,13 +191,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $resql = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($resql);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$resql = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($resql);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -212,13 +212,13 @@ if ($resql)
 
 	// Lines of title fields
 	print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
-    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
+	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
 	print '<input type="hidden" name="token" value="'.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 '<input type="hidden" name="page" value="'.$page.'">';
+	print '<input type="hidden" name="page" value="'.$page.'">';
 	print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
 	print '<input type="hidden" name="id" value="'.$id.'">';
 
@@ -245,38 +245,38 @@ if ($resql)
 	$invoicetmpsupplier = new FactureFournisseur($db);
 
   	while ($i < min($num, $limit))
-    {
-     	$obj = $db->fetch_object($resql);
+	{
+	 	$obj = $db->fetch_object($resql);
 
-     	if ($obj->type == 'bank-transfer') {
-     		$invoicetmp = $invoicetmpsupplier;
-     	} else {
-     		$invoicetmp = $invoicetmpcustomer;
-     	}
-     	$invoicetmp->fetch($obj->facid);
+	 	if ($obj->type == 'bank-transfer') {
+	 		$invoicetmp = $invoicetmpsupplier;
+	 	} else {
+	 		$invoicetmp = $invoicetmpcustomer;
+	 	}
+	 	$invoicetmp->fetch($obj->facid);
 
-     	$thirdpartytmp->fetch($obj->socid);
+	 	$thirdpartytmp->fetch($obj->socid);
 
-      	print '<tr class="oddeven">';
+	  	print '<tr class="oddeven">';
 
-      	print "<td>";
-      	print $invoicetmp->getNomUrl(1);
-        print "</td>\n";
+	  	print "<td>";
+	  	print $invoicetmp->getNomUrl(1);
+		print "</td>\n";
 
-      	print '<td>';
-      	print $thirdpartytmp->getNomUrl(1);
-      	print "</td>\n";
+	  	print '<td>';
+	  	print $thirdpartytmp->getNomUrl(1);
+	  	print "</td>\n";
 
-      	// Amount of invoice
-      	print '<td class="right">'.price($obj->total_ttc)."</td>\n";
+	  	// Amount of invoice
+	  	print '<td class="right">'.price($obj->total_ttc)."</td>\n";
 
-      	// Amount requested
-      	print '<td class="right">'.price($obj->amount_requested)."</td>\n";
+	  	// Amount requested
+	  	print '<td class="right">'.price($obj->amount_requested)."</td>\n";
 
-      	// Status of requests
-      	print '<td class="center">';
+	  	// Status of requests
+	  	print '<td class="center">';
 
-      	if ($obj->statut == 0) {
+	  	if ($obj->statut == 0) {
 	  		print '-';
 		} elseif ($obj->statut == 2) {
 			if ($obj->type == 'bank-transfer') {
@@ -288,34 +288,34 @@ if ($resql)
 	  		print '<b>'.$langs->trans("StatusRefused").'</b>';
 		}
 
-      	print "</td>";
+	  	print "</td>";
 
-      	print "<td></td>";
+	  	print "<td></td>";
 
-      	print "</tr>\n";
+	  	print "</tr>\n";
 
-      	$totalinvoices += $obj->total_ttc;
-      	$totalamount_requested += $obj->amount_requested;
+	  	$totalinvoices += $obj->total_ttc;
+	  	$totalamount_requested += $obj->amount_requested;
 
-      	$i++;
-    }
+	  	$i++;
+	}
 
   	if ($num > 0)
-    {
-      	print '<tr class="liste_total">';
-     	print '<td>'.$langs->trans("Total").'</td>';
-      	print '<td>&nbsp;</td>';
-      	print '<td class="right">';
+	{
+	  	print '<tr class="liste_total">';
+	 	print '<td>'.$langs->trans("Total").'</td>';
+	  	print '<td>&nbsp;</td>';
+	  	print '<td class="right">';
 		//if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");		// It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only.
-      	if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");
+	  	if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");
 		print "</td>\n";
-      	print '<td class="right">';
+	  	print '<td class="right">';
 		print price($totalamount_requested);
-      	print "</td>\n";
-      	print '<td>&nbsp;</td>';
-      	print '<td>&nbsp;</td>';
-      	print "</tr>\n";
-    }
+	  	print "</td>\n";
+	  	print '<td>&nbsp;</td>';
+	  	print '<td>&nbsp;</td>';
+	  	print "</tr>\n";
+	}
 
   	print "</table>";
   	print '</div>';

+ 33 - 33
htdocs/compta/prelevement/fiche-rejet.php

@@ -76,8 +76,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts"));
 if ($prev_id > 0 || $ref)
 {
   	if ($object->fetch($prev_id, $ref) >= 0)
-    {
-    	$head = prelevement_prepare_head($object);
+	{
+		$head = prelevement_prepare_head($object);
 		dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
 
 		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
@@ -145,9 +145,9 @@ if ($prev_id > 0 || $ref)
 		print '</div>';
 
 		dol_fiche_end();
-    } else {
-      	dol_print_error($db);
-    }
+	} else {
+	  	dol_print_error($db);
+	}
 }
 
 
@@ -205,44 +205,44 @@ if ($resql)
 
 	if ($num > 0)
 	{
-      	$i = 0;
-	    while ($i < $num)
-        {
-    		$obj = $db->fetch_object($resql);
+	  	$i = 0;
+		while ($i < $num)
+		{
+			$obj = $db->fetch_object($resql);
 
-    		print '<tr class="oddeven"><td>';
+			print '<tr class="oddeven"><td>';
 
-    		print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
-    		print img_picto('', 'statut'.$obj->statut).' ';
-    		print substr('000000'.$obj->rowid, -6);
-    		print '</a></td>';
-    		print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
+			print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
+			print img_picto('', 'statut'.$obj->statut).' ';
+			print substr('000000'.$obj->rowid, -6);
+			print '</a></td>';
+			print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
 
-    		print '<td class="right">'.price($obj->amount)."</td>\n";
-    		print '<td>'.$rej->motifs[$obj->motif].'</td>';
+			print '<td class="right">'.price($obj->amount)."</td>\n";
+			print '<td>'.$rej->motifs[$obj->motif].'</td>';
 
-    		print '<td class="center">'.yn($obj->afacturer).'</td>';
-    		print '<td class="center">'.$obj->fk_facture.'</td>';
-    		print "</tr>\n";
+			print '<td class="center">'.yn($obj->afacturer).'</td>';
+			print '<td class="center">'.$obj->fk_facture.'</td>';
+			print "</tr>\n";
 
-    		$total += $obj->amount;
+			$total += $obj->amount;
 
-    		$i++;
-    	}
+			$i++;
+		}
 	} else {
-	    print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
+		print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
 	}
 
   	if ($num > 0)
-    {
-    	print '<tr class="liste_total"><td>&nbsp;</td>';
-    	print '<td class="liste_total">'.$langs->trans("Total").'</td>';
-    	print '<td class="right">'.price($total)."</td>\n";
-    	print '<td colspan="3">&nbsp;</td>';
-    	print "</tr>\n";
-    }
-    print "</table>\n";
-    print '</div>';
+	{
+		print '<tr class="liste_total"><td>&nbsp;</td>';
+		print '<td class="liste_total">'.$langs->trans("Total").'</td>';
+		print '<td class="right">'.price($total)."</td>\n";
+		print '<td colspan="3">&nbsp;</td>';
+		print "</tr>\n";
+	}
+	print "</table>\n";
+	print '</div>';
 
 	$db->free($resql);
 } else {

Разлика између датотеке није приказан због своје велике величине
+ 544 - 544
htdocs/contact/card.php


+ 23 - 23
htdocs/contact/list.php

@@ -184,7 +184,7 @@ $arrayfields = array(
 	'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
 	'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
 );
-if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
+if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
 	$arrayfields['p.fk_prospectcontactlevel'] = array('label'=>"ProspectLevelShort", 'checked'=>1, 'position'=>210);
 	$arrayfields['p.fk_stcommcontact'] = array('label'=>"StatusProsp", 'checked'=>1, 'position'=>215);
 }
@@ -270,8 +270,8 @@ if (empty($reshook))
 			}
 		}
 		$search_priv = "";
-		$search_stcomm='';
-		$search_level='';
+		$search_stcomm = '';
+		$search_level = '';
 		$search_status = -1;
 		$search_categ = '';
 		$search_categ_thirdparty = '';
@@ -314,7 +314,7 @@ $formother = new FormOther($db);
 $formcompany = new FormCompany($db);
 $contactstatic = new Contact($db);
 
-if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
+if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
 	$contactstatic->loadCacheOfProspStatus();
 }
 
@@ -323,17 +323,17 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C
 // Select every potentiels, and note each potentiels which fit in search parameters
 $tab_level = array();
 $sql = "SELECT code, label, sortorder";
-$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
-$sql.= " WHERE active > 0";
-$sql.= " ORDER BY sortorder";
+$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
+$sql .= " WHERE active > 0";
+$sql .= " ORDER BY sortorder";
 $resql = $db->query($sql);
 if ($resql)
 {
 	while ($obj = $db->fetch_object($resql))
 	{
 		// Compute level text
-		$level=$langs->trans($obj->code);
-		if ($level == $obj->code) $level=$langs->trans($obj->label);
+		$level = $langs->trans($obj->code);
+		if ($level == $obj->code) $level = $langs->trans($obj->label);
 		$tab_level[$obj->code] = $level;
 	}
 }
@@ -343,7 +343,7 @@ $sql = "SELECT s.rowid as socid, s.nom as name,";
 $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,";
 $sql .= " p.socialnetworks, p.photo,";
 $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,";
-$sql.= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
+$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
 $sql .= " co.label as country, co.code as country_code";
 // Add fields from extrafields
 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -357,7 +357,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
 if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ
 if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
 if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
@@ -469,7 +469,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 $sql .= $db->plimit($limit + 1, $offset);
 
 $resql = $db->query($sql);
-if (! $resql)
+if (!$resql)
 {
 	dol_print_error($db);
 	exit;
@@ -515,10 +515,10 @@ if ($search_email != '') $param .= '&amp;search_email='.urlencode($search_email)
 if ($search_no_email != '') $param .= '&amp;search_no_email='.urlencode($search_no_email);
 if ($search_status != '') $param .= '&amp;search_status='.urlencode($search_status);
 if ($search_priv == '0' || $search_priv == '1') $param .= "&amp;search_priv=".urlencode($search_priv);
-if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm);
+if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm);
 if (is_array($search_level) && count($search_level)) {
 	foreach ($search_level as $slevel) {
-		$param.='&search_level[]='.urlencode($slevel);
+		$param .= '&search_level[]='.urlencode($slevel);
 	}
 }
 if ($search_import_key != '') $param .= '&amp;search_import_key='.urlencode($search_import_key);
@@ -739,20 +739,20 @@ if (!empty($arrayfields['p.priv']['checked']))
     print '</td>';
 }
 // Prospect level
-if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
+if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
 {
 	print '<td class="liste_titre center">';
 	print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
 	print '</td>';
 }
 // Prospect status
-if (! empty($arrayfields['p.fk_stcommcontact']['checked']))
+if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
 {
 	print '<td class="liste_titre maxwidthonsmartphone center">';
-	$arraystcomm=array();
+	$arraystcomm = array();
 	foreach ($contactstatic->cacheprospectstatus as $key => $val)
 	{
-		$arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
+		$arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
 	}
 	print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap ');
 	print '</td>';
@@ -877,7 +877,7 @@ while ($i < min($num, $limit))
 	$contactstatic->country_code = $obj->country_code;
 	$contactstatic->photo = $obj->photo;
 
-	$contactstatic->fk_prospectlevel=$obj->fk_prospectcontactlevel;
+	$contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel;
 
 	print '<tr class="oddeven">';
 
@@ -1007,7 +1007,7 @@ while ($i < min($num, $limit))
 		if (!$i) $totalarray['nbfield']++;
 	}
 
-	if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
+	if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
 	{
 		// Prospect level
 		print '<td class="center">';
@@ -1016,16 +1016,16 @@ while ($i < min($num, $limit))
 		if (!$i) $totalarray['nbfield']++;
 	}
 
-	if (! empty($arrayfields['p.fk_stcommcontact']['checked']))
+	if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
 	{
 		// Prospect status
 		print '<td class="center nowrap"><div class="nowrap">';
-		print '<div class="inline-block">' . $contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
+		print '<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
 		print '</div> - <div class="inline-block">';
 		foreach ($contactstatic->cacheprospectstatus as $key => $val) {
 			$titlealt = 'default';
 			if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
-			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="' . $_SERVER["PHP_SELF"] . '?stcommcontactid=' . $obj->rowid . '&stcomm=' . $val['code'] . '&action=setstcomm' . $param . ($page ? '&page=' . urlencode($page) : '') . '">' . img_action($titlealt, $val['code'], $val['picto']) . '</a>';
+			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommcontactid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
 		}
 		print '</div></div></td>';
 		if (!$i) $totalarray['nbfield']++;

+ 14 - 14
htdocs/core/actions_addupdatedelete.inc.php

@@ -85,7 +85,7 @@ if ($action == 'add' && !empty($permissiontoadd))
 		$object->$key = $value;
 		if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)')
 		{
-		    $object->$key = '(PROV)';
+			$object->$key = '(PROV)';
 		}
 		if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
 		{
@@ -105,7 +105,7 @@ if ($action == 'add' && !empty($permissiontoadd))
 		$result = $object->create($user);
 		if ($result > 0)
 		{
-		    // Creation OK
+			// Creation OK
 			$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
 			$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
 			header("Location: ".$urltogo);
@@ -154,7 +154,7 @@ if ($action == 'update' && !empty($permissiontoadd))
 				$value = '';
 			}
 		} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
-            $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
+			$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
 		} elseif ($object->fields[$key]['type'] == 'boolean') {
 			$value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
 		} else {
@@ -223,11 +223,11 @@ if ($action == "update_extras" && !empty($permissiontoadd))
 // Action to delete
 if ($action == 'confirm_delete' && !empty($permissiontodelete))
 {
-    if (!($object->id > 0))
-    {
-        dol_print_error('', 'Error, object must be fetched before being deleted');
-        exit;
-    }
+	if (!($object->id > 0))
+	{
+		dol_print_error('', 'Error, object must be fetched before being deleted');
+		exit;
+	}
 
 	$result = $object->delete($user);
 	if ($result > 0)
@@ -246,7 +246,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete))
 if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
 {
 	if (method_exists('deleteline', $object)) {
-		$result = $object->deleteline($user, $lineid);		// For backward compatibility
+		$result = $object->deleteline($user, $lineid); // For backward compatibility
 	} else {
 		$result = $object->deleteLine($user, $lineid);
 	}
@@ -385,11 +385,11 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
 	{
 		setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
 	} else {
-	    $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
+		$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
 		//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
-        // ...
-	    $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
-	    if (is_object($result) || $result > 0)
+		// ...
+		$result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
+		if (is_object($result) || $result > 0)
 		{
 			$newid = 0;
 			if (is_object($result)) $newid = $result->id;
@@ -397,7 +397,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
 			header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
 			exit;
 		} else {
-		    setEventMessages($objectutil->error, $objectutil->errors, 'errors');
+			setEventMessages($objectutil->error, $objectutil->errors, 'errors');
 			$action = '';
 		}
 	}

+ 7 - 7
htdocs/core/actions_sendmails.inc.php

@@ -263,12 +263,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
 
 		if (dol_strlen($sendto))
 		{
-            // Define $urlwithroot
-            $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
-            $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
-            //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
+			// Define $urlwithroot
+			$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+			$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+			//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
 
-		    require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+			require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 
 			$langs->load("commercial");
 
@@ -419,7 +419,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
 					// Initialisation of datas of object to call trigger
 					if (is_object($object))
 					{
-					    if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
+						if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
 
 						$object->socid = $sendtosocid; // To link to a company
 						$object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
@@ -456,7 +456,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
 
 							if ($error) {
 								setEventMessages($object->error, $object->errors, 'errors');
-    						}
+							}
 						}
 						// End call of triggers
 					}

+ 194 - 194
htdocs/core/ajax/ajaxdirpreview.php

@@ -34,28 +34,28 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
 
 if (!isset($mode) || $mode != 'noajax')    // For ajax call
 {
-    require_once '../../main.inc.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-    require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
-
-    $action = GETPOST('action', 'aZ09');
-    $file = urldecode(GETPOST('file', 'alpha'));
-    $section = GETPOST("section", 'alpha');
-    $module = GETPOST("module", 'alpha');
-    $urlsource = GETPOST("urlsource", 'alpha');
-    $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
-
-    $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-    $sortfield = GETPOST("sortfield", 'alpha');
-    $sortorder = GETPOST("sortorder", 'alpha');
-    $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-    if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
-    $offset = $limit * $page;
-    $pageprev = $page - 1;
-    $pagenext = $page + 1;
-    if (!$sortorder) $sortorder = "ASC";
-    if (!$sortfield) $sortfield = "name";
+	require_once '../../main.inc.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+	require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
+
+	$action = GETPOST('action', 'aZ09');
+	$file = urldecode(GETPOST('file', 'alpha'));
+	$section = GETPOST("section", 'alpha');
+	$module = GETPOST("module", 'alpha');
+	$urlsource = GETPOST("urlsource", 'alpha');
+	$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
+
+	$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+	$sortfield = GETPOST("sortfield", 'alpha');
+	$sortorder = GETPOST("sortorder", 'alpha');
+	$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+	if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
+	$offset = $limit * $page;
+	$pageprev = $page - 1;
+	$pagenext = $page + 1;
+	if (!$sortorder) $sortorder = "ASC";
+	if (!$sortfield) $sortfield = "name";
 
 	$rootdirfordoc = $conf->ecm->dir_output;
 
@@ -63,30 +63,30 @@ if (!isset($mode) || $mode != 'noajax')    // For ajax call
 
 	$ecmdir = new EcmDirectory($db);
 	if ($section > 0) {
-	    $result = $ecmdir->fetch($section);
-	    if (!$result > 0)
-	    {
-	        //dol_print_error($db,$ecmdir->error);
-	        //exit;
-	    }
+		$result = $ecmdir->fetch($section);
+		if (!$result > 0)
+		{
+			//dol_print_error($db,$ecmdir->error);
+			//exit;
+		}
 	}
 } else // For no ajax call
 {
 	$rootdirfordoc = $conf->ecm->dir_output;
 
 	$ecmdir = new EcmDirectory($db);
-    $relativepath = '';
-    if ($section > 0)
-    {
-        $result = $ecmdir->fetch($section);
-        if (!$result > 0)
-        {
-            dol_print_error($db, $ecmdir->error);
-            exit;
-        }
-
-        $relativepath = $ecmdir->getRelativePath(); // Example   'mydir/'
-    } elseif (GETPOST('section_dir'))
+	$relativepath = '';
+	if ($section > 0)
+	{
+		$result = $ecmdir->fetch($section);
+		if (!$result > 0)
+		{
+			dol_print_error($db, $ecmdir->error);
+			exit;
+		}
+
+		$relativepath = $ecmdir->getRelativePath(); // Example   'mydir/'
+	} elseif (GETPOST('section_dir'))
 	{
 		$relativepath = GETPOST('section_dir');
 	}
@@ -113,10 +113,10 @@ if ($user->socid > 0) $socid = $user->socid;
 // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
 if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir))
 {
-    dol_syslog("Refused to deliver file ".$upload_dir);
-    // Do no show plain path in shown error message
-    dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir));
-    exit;
+	dol_syslog("Refused to deliver file ".$upload_dir);
+	// Do no show plain path in shown error message
+	dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir));
+	exit;
 }
 
 // Check permissions
@@ -145,10 +145,10 @@ if ($modulepart == 'medias')
 if (!isset($mode) || $mode != 'noajax')
 {
 	// Ajout directives pour resoudre bug IE
-    header('Cache-Control: Public, must-revalidate');
-    header('Pragma: public');
+	header('Cache-Control: Public, must-revalidate');
+	header('Pragma: public');
 
-    top_httphead();
+	top_httphead();
 }
 
 $type = 'directory';
@@ -156,8 +156,8 @@ $type = 'directory';
 // This test if file exists should be useless. We keep it to find bug more easily
 if (!dol_is_dir($upload_dir))
 {
-    //dol_mkdir($upload_dir);
-    /*$langs->load("install");
+	//dol_mkdir($upload_dir);
+	/*$langs->load("install");
     dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
     exit;*/
 }
@@ -173,76 +173,76 @@ if (!empty($pageid))     $param .= '&pageid='.urlencode($pageid);
 // Dir scan
 if ($type == 'directory')
 {
-    $formfile = new FormFile($db);
-
-    $maxlengthname = 40;
-    $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$');
-    $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC);
-
-    // Right area. If module is defined here, we are in automatic ecm.
-    $automodules = array(
-    	'company',
-    	'invoice',
-    	'invoice_supplier',
-    	'propal',
-    	'supplier_proposal',
-    	'order',
-    	'order_supplier',
-    	'contract',
-    	'product',
-    	'tax',
-    	'project',
-    	'fichinter',
-    	'user',
-    	'expensereport',
-    	'holiday',
-    	'recruitment-recruitmentcandidature',
-	    'banque',
-    	'mrp-mo'
-    );
-
-    // TODO change for multicompany sharing
-    if ($module == 'company') $upload_dir = $conf->societe->dir_output;
-    elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
-    elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
-    elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output;
-    elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
-    elseif ($module == 'order') $upload_dir = $conf->commande->dir_output;
-    elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
-    elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
-    elseif ($module == 'product') $upload_dir = $conf->product->dir_output;
-    elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output;
-    elseif ($module == 'project') $upload_dir = $conf->projet->dir_output;
-    elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
-    elseif ($module == 'user') $upload_dir = $conf->user->dir_output;
-    elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
-    elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
-    elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
-    elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output;
-    elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo';
-
-    // Automatic list
-    if (in_array($module, $automodules))
-    {
-        $param .= '&module='.$module;
-        if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref);
-
-        $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
-
-        if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
-
-        $filter = preg_quote($search_doc_ref, '/');
-        $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
-
-        $perm = $user->rights->ecm->upload;
-
-        $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1);
-    }
-    // Manual list
-    else {
-    	if ($module == 'medias')
-    	{
-    		/*
+	$formfile = new FormFile($db);
+
+	$maxlengthname = 40;
+	$excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$');
+	$sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC);
+
+	// Right area. If module is defined here, we are in automatic ecm.
+	$automodules = array(
+		'company',
+		'invoice',
+		'invoice_supplier',
+		'propal',
+		'supplier_proposal',
+		'order',
+		'order_supplier',
+		'contract',
+		'product',
+		'tax',
+		'project',
+		'fichinter',
+		'user',
+		'expensereport',
+		'holiday',
+		'recruitment-recruitmentcandidature',
+		'banque',
+		'mrp-mo'
+	);
+
+	// TODO change for multicompany sharing
+	if ($module == 'company') $upload_dir = $conf->societe->dir_output;
+	elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
+	elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
+	elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output;
+	elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
+	elseif ($module == 'order') $upload_dir = $conf->commande->dir_output;
+	elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
+	elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
+	elseif ($module == 'product') $upload_dir = $conf->product->dir_output;
+	elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output;
+	elseif ($module == 'project') $upload_dir = $conf->projet->dir_output;
+	elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
+	elseif ($module == 'user') $upload_dir = $conf->user->dir_output;
+	elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
+	elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
+	elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
+	elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output;
+	elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo';
+
+	// Automatic list
+	if (in_array($module, $automodules))
+	{
+		$param .= '&module='.$module;
+		if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref);
+
+		$textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
+
+		if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
+
+		$filter = preg_quote($search_doc_ref, '/');
+		$filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
+
+		$perm = $user->rights->ecm->upload;
+
+		$formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1);
+	}
+	// Manual list
+	else {
+		if ($module == 'medias')
+		{
+			/*
     		   $_POST is array like
     		  'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
 			  'action' => string 'file_manager' (length=12)
@@ -253,82 +253,82 @@ if ($type == 'directory')
 			  'max_file_size' => string '2097152' (length=7)
 			  'sendit' => string 'Envoyer fichier' (length=15)
     		 */
-    		$relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
-    		if ($relativepath && $relativepath != '/') $relativepath .= '/';
-    		$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
-    		if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
-	    	{
-	    		$param .= '&file_manager=1';
-	    		if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
-	    		if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
-	    		//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
-	    	}
-    	} else {
-        	$relativepath = $ecmdir->getRelativePath();
-        	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
-    	}
-
-        // If $section defined with value 0
+			$relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
+			if ($relativepath && $relativepath != '/') $relativepath .= '/';
+			$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
+			if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
+			{
+				$param .= '&file_manager=1';
+				if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
+				if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
+				//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
+			}
+		} else {
+			$relativepath = $ecmdir->getRelativePath();
+			$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+		}
+
+		// If $section defined with value 0
 		if (($section === '0' || empty($section)) && ($module != 'medias'))
-        {
-            $filearray = array();
-        } else {
-        	$filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
-        }
-
-        if ($section)
-        {
-            $param .= '&section='.$section;
-        	if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
-
-            $textifempty = $langs->trans('NoFileFound');
-        } elseif ($section === '0')
-        {
-        	if ($module == 'ecm') $textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
-        	else $textifempty = $langs->trans('NoFileFound');
-        } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
-
-        if ($module == 'medias')
-        {
-            $useinecm = 6;
-            $modulepart = 'medias';
-            $perm = ($user->rights->website->write || $user->rights->emailing->creer);
-            $title = 'none';
-        } elseif ($module == 'ecm') // DMS/ECM -> manual structure
-        {
-            if ($user->rights->ecm->read)
-            {
-                // Buttons: Preview
-                $useinecm = 2;
-            }
-
-            if ($user->rights->ecm->upload)
-            {
-                // Buttons: Preview + Delete
-                $useinecm = 4;
-            }
-
-            if ($user->rights->ecm->setup)
-            {
-                // Buttons: Preview + Delete + Edit
-                $useinecm = 5;
-            }
-
-            $perm = $user->rights->ecm->upload;
-            $modulepart = 'ecm';
-            $title = ''; // Use default
-        } else {
-            $useinecm = 5;
-            $modulepart = 'ecm';
-            $perm = $user->rights->ecm->upload;
-            $title = ''; // Use default
-        }
-
-        // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
-        // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
-        //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
-        $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
-    }
+		{
+			$filearray = array();
+		} else {
+			$filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
+		}
+
+		if ($section)
+		{
+			$param .= '&section='.$section;
+			if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
+
+			$textifempty = $langs->trans('NoFileFound');
+		} elseif ($section === '0')
+		{
+			if ($module == 'ecm') $textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
+			else $textifempty = $langs->trans('NoFileFound');
+		} else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
+
+		if ($module == 'medias')
+		{
+			$useinecm = 6;
+			$modulepart = 'medias';
+			$perm = ($user->rights->website->write || $user->rights->emailing->creer);
+			$title = 'none';
+		} elseif ($module == 'ecm') // DMS/ECM -> manual structure
+		{
+			if ($user->rights->ecm->read)
+			{
+				// Buttons: Preview
+				$useinecm = 2;
+			}
+
+			if ($user->rights->ecm->upload)
+			{
+				// Buttons: Preview + Delete
+				$useinecm = 4;
+			}
+
+			if ($user->rights->ecm->setup)
+			{
+				// Buttons: Preview + Delete + Edit
+				$useinecm = 5;
+			}
+
+			$perm = $user->rights->ecm->upload;
+			$modulepart = 'ecm';
+			$title = ''; // Use default
+		} else {
+			$useinecm = 5;
+			$modulepart = 'ecm';
+			$perm = $user->rights->ecm->upload;
+			$title = ''; // Use default
+		}
+
+		// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
+		// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
+		//var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
+		$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
+	}
 }
 
 

+ 176 - 168
htdocs/core/class/CMailFile.class.php

@@ -41,47 +41,47 @@ class CMailFile
 	public $sendmode;
 	public $sendsetup;
 
-    public $subject; // Topic:       Subject of email
-    public $addr_from; // From:		Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
+	public $subject; // Topic:       Subject of email
+	public $addr_from; // From:		Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
 	// Sender:      Who send the email ("Sender" has sent emails on behalf of "From").
 	//              Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain.
 	// Return-Path: Email where to send bounds.
-    public $reply_to; // Reply-To:	Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined)
-    public $errors_to; // Errors-To:	Email where to send errors.
-    public $addr_to;
-    public $addr_cc;
-    public $addr_bcc;
-    public $trackid;
+	public $reply_to; // Reply-To:	Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined)
+	public $errors_to; // Errors-To:	Email where to send errors.
+	public $addr_to;
+	public $addr_cc;
+	public $addr_bcc;
+	public $trackid;
 
-    public $mixed_boundary;
-    public $related_boundary;
-    public $alternative_boundary;
-    public $deliveryreceipt;
+	public $mixed_boundary;
+	public $related_boundary;
+	public $alternative_boundary;
+	public $deliveryreceipt;
 
-    public $eol;
-    public $eol2;
+	public $eol;
+	public $eol2;
 
 	/**
 	 * @var string Error code (or message)
 	 */
 	public $error = '';
 
-    public $smtps; // Contains SMTPs object (if this method is used)
-    public $phpmailer; // Contains PHPMailer object (if this method is used)
+	public $smtps; // Contains SMTPs object (if this method is used)
+	public $phpmailer; // Contains PHPMailer object (if this method is used)
 
 	/**
 	 * @var string CSS
 	 */
 	public $css;
 	//! Defined css style for body background
-    public $styleCSS;
+	public $styleCSS;
 	//! Defined background directly in body tag
-    public $bodyCSS;
+	public $bodyCSS;
 
-    public $msgid;
-    public $headers;
-    public $message;
-    /**
+	public $msgid;
+	public $headers;
+	public $message;
+	/**
 	 * @var array fullfilenames list (full path of filename on file system)
 	 */
 	public $filename_list = array();
@@ -95,21 +95,21 @@ class CMailFile
 	public $mimefilename_list = array();
 
 	// Image
-    public $html;
-    public $image_boundary;
-    public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used).
-    public $html_images = array();
-    public $images_encoded = array();
-    public $image_types = array(
-        'gif'  => 'image/gif',
+	public $html;
+	public $image_boundary;
+	public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used).
+	public $html_images = array();
+	public $images_encoded = array();
+	public $image_types = array(
+		'gif'  => 'image/gif',
 		'jpg'  => 'image/jpeg',
 		'jpeg' => 'image/jpeg',
 		'jpe'  => 'image/jpeg',
 		'bmp'  => 'image/bmp',
 		'png'  => 'image/png',
 		'tif'  => 'image/tiff',
-        'tiff' => 'image/tiff',
-    );
+		'tiff' => 'image/tiff',
+	);
 
 
 	/**
@@ -147,7 +147,7 @@ class CMailFile
 		// Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
 		if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
 
-        $this->subject = $subject;
+		$this->subject = $subject;
 		$this->addr_to = $to;
 		$this->addr_from = $from;
 		$this->msg = $msg;
@@ -168,9 +168,13 @@ class CMailFile
 
 		// Define this->sendmode
 		$this->sendmode = '';
-		if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default')
-		{
-			$this->sendmode = $conf->global->MAIN_MAIL_SENDMODE_EMAILING;
+		if (!empty($this->sendcontext)) {
+			$smtpContextKey = strtoupper($this->sendcontext);
+			$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey;
+			$smtpContextSendMode = $conf->global->{$keyForSMTPSendMode};
+			if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
+				$this->sendmode = $smtpContextSendMode;
+			}
 		}
 		if (empty($this->sendmode)) $this->sendmode = $conf->global->MAIN_MAIL_SENDMODE;
 		if (empty($this->sendmode)) $this->sendmode = 'mail';
@@ -206,8 +210,8 @@ class CMailFile
 		}
 		if (empty($msg))
 		{
-		    dol_syslog("CMailFile::CMailfile: Try to send an email with empty body");
-		    $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure)
+			dol_syslog("CMailFile::CMailfile: Try to send an email with empty body");
+			$msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure)
 		}
 
 		// Detect if message is HTML (use fast method)
@@ -287,7 +291,7 @@ class CMailFile
 
 		// Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
 		if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
-			$addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
+			$addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
 		}
 
 		// We set all data according to choosed sending method.
@@ -407,40 +411,40 @@ class CMailFile
 			$this->smtps = $smtps;
 		} elseif ($this->sendmode == 'swiftmailer') {
 			// Use Swift Mailer library
-            $host = dol_getprefix('email');
-
-            require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php';
-
-            // egulias autoloader lib
-            require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php';
-
-            require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
-
-            // Create the message
-            //$this->message = Swift_Message::newInstance();
-            $this->message = new Swift_Message();
-            //$this->message = new Swift_SignedMessage();
-            // Adding a trackid header to a message
-            $headers = $this->message->getHeaders();
-            $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
-            $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
-            $headerID = $this->msgid;
-            $msgid = $headers->get('Message-ID');
-            $msgid->setId($headerID);
-            $headers->addIdHeader('References', $headerID);
-            // TODO if (! empty($moreinheader)) ...
-
-            // Give the message a subject
-            try {
-                $result = $this->message->setSubject($this->subject);
-            } catch (Exception $e) {
-                $this->errors[] = $e->getMessage();
-            }
-
-            // Set the From address with an associative array
-            //$this->message->setFrom(array('john@doe.com' => 'John Doe'));
-            if (! empty($this->addr_from)) {
-                try {
+			$host = dol_getprefix('email');
+
+			require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php';
+
+			// egulias autoloader lib
+			require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php';
+
+			require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
+
+			// Create the message
+			//$this->message = Swift_Message::newInstance();
+			$this->message = new Swift_Message();
+			//$this->message = new Swift_SignedMessage();
+			// Adding a trackid header to a message
+			$headers = $this->message->getHeaders();
+			$headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
+			$this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
+			$headerID = $this->msgid;
+			$msgid = $headers->get('Message-ID');
+			$msgid->setId($headerID);
+			$headers->addIdHeader('References', $headerID);
+			// TODO if (! empty($moreinheader)) ...
+
+			// Give the message a subject
+			try {
+				$result = $this->message->setSubject($this->subject);
+			} catch (Exception $e) {
+				$this->errors[] = $e->getMessage();
+			}
+
+			// Set the From address with an associative array
+			//$this->message->setFrom(array('john@doe.com' => 'John Doe'));
+			if (! empty($this->addr_from)) {
+				try {
 					if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
 						// Prevent email spoofing for smtp server with a strict configuration
 						$regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string
@@ -455,35 +459,35 @@ class CMailFile
 					} else {
 						$result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
 					}
-                } catch (Exception $e) {
-                    $this->errors[] = $e->getMessage();
-                }
-            }
-
-            // Set the To addresses with an associative array
-            if (! empty($this->addr_to)) {
-                try {
-                    $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
-                } catch (Exception $e) {
-                    $this->errors[] = $e->getMessage();
-                }
-            }
-
-            if (! empty($this->reply_to)) {
-                try {
-                	$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
-                } catch (Exception $e) {
-                    $this->errors[] = $e->getMessage();
-                }
-            }
-
-            try {
-                $result = $this->message->setCharSet($conf->file->character_set_client);
-            } catch (Exception $e) {
-                $this->errors[] = $e->getMessage();
-            }
-
-            if (!empty($this->html)) {
+				} catch (Exception $e) {
+					$this->errors[] = $e->getMessage();
+				}
+			}
+
+			// Set the To addresses with an associative array
+			if (! empty($this->addr_to)) {
+				try {
+					$result = $this->message->setTo($this->getArrayAddress($this->addr_to));
+				} catch (Exception $e) {
+					$this->errors[] = $e->getMessage();
+				}
+			}
+
+			if (! empty($this->reply_to)) {
+				try {
+					$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
+				} catch (Exception $e) {
+					$this->errors[] = $e->getMessage();
+				}
+			}
+
+			try {
+				$result = $this->message->setCharSet($conf->file->character_set_client);
+			} catch (Exception $e) {
+				$this->errors[] = $e->getMessage();
+			}
+
+			if (!empty($this->html)) {
 				if (!empty($css)) {
 					$this->css = $css;
 					$this->buildCSS();
@@ -574,26 +578,26 @@ class CMailFile
 			$sendingmode = $this->sendmode;
 			if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
 			{
-			    // List of sending methods
-			    $listofmethods = array();
-			    $listofmethods['mail'] = 'PHP mail function';
-			    //$listofmethods['simplemail']='Simplemail class';
-			    $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
-
-			    // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
-			    // You ensure that every user is using its own SMTP server when using the mass emailing module.
-			    $linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
-			    $linktoadminemailend = '</a>';
-			    $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
-			    $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
-			    $this->error .= '<br>'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
-			    $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
-			    if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
-			    {
-			        $this->error .= '<br>'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
-			        $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
-			    }
-                return false;
+				// List of sending methods
+				$listofmethods = array();
+				$listofmethods['mail'] = 'PHP mail function';
+				//$listofmethods['simplemail']='Simplemail class';
+				$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
+
+				// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
+				// You ensure that every user is using its own SMTP server when using the mass emailing module.
+				$linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
+				$linktoadminemailend = '</a>';
+				$this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
+				$this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
+				$this->error .= '<br>'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
+				$this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
+				if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
+				{
+					$this->error .= '<br>'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
+					$this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
+				}
+				return false;
 			}
 
 			// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
@@ -635,14 +639,18 @@ class CMailFile
 			$keyforsmtppw    = 'MAIN_MAIL_SMTPS_PW';
 			$keyfortls       = 'MAIN_MAIL_EMAIL_TLS';
 			$keyforstarttls  = 'MAIN_MAIL_EMAIL_STARTTLS';
-			if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default')
-			{
-				$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_EMAILING';
-				$keyforsmtpport  = 'MAIN_MAIL_SMTP_PORT_EMAILING';
-				$keyforsmtpid    = 'MAIN_MAIL_SMTPS_ID_EMAILING';
-				$keyforsmtppw    = 'MAIN_MAIL_SMTPS_PW_EMAILING';
-				$keyfortls       = 'MAIN_MAIL_EMAIL_TLS_EMAILING';
-				$keyforstarttls  = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
+			if (!empty($this->sendcontext)) {
+				$smtpContextKey = strtoupper($this->sendcontext);
+				$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey;
+				$smtpContextSendMode = $conf->global->{$keyForSMTPSendMode};
+				if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
+					$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey;
+					$keyforsmtpport   = 'MAIN_MAIL_SMTP_PORT_' . $smtpContextKey;
+					$keyforsmtpid     = 'MAIN_MAIL_SMTPS_ID_' . $smtpContextKey;
+					$keyforsmtppw     = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey;
+					$keyfortls        = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey;
+					$keyforstarttls   = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey;
+				}
 			}
 
 			// Action according to choosed sending method
@@ -820,9 +828,9 @@ class CMailFile
 				}
 			} elseif ($this->sendmode == 'swiftmailer')
 			{
-                // Use Swift Mailer library
-                // ------------------------------------------
-                require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
+				// Use Swift Mailer library
+				// ------------------------------------------
+				require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
 
 				// Clean parameters
 				if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP');
@@ -841,22 +849,22 @@ class CMailFile
 				//$smtps->_msgReplyTo  = 'reply@web.com';
 
 				// Switch content encoding to base64 - avoid the doubledot issue with quoted-printable
-                $contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
-                $this->message->setEncoder($contentEncoderBase64);
+				$contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
+				$this->message->setEncoder($contentEncoderBase64);
 
 				// Create the Mailer using your created Transport
 				$this->mailer = new Swift_Mailer($this->transport);
 
-                // DKIM SIGN
-                if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) {
-                    $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
-                    $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
-                    $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
-                    $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector);
-                    $this->message->attachSigner($signer->ignoreHeader('Return-Path'));
-                }
+				// DKIM SIGN
+				if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) {
+					$privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
+					$domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
+					$selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
+					$signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector);
+					$this->message->attachSigner($signer->ignoreHeader('Return-Path'));
+				}
 
-                if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
+				if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
 					// To use the ArrayLogger
 					$this->logger = new Swift_Plugins_Loggers_ArrayLogger();
 					// Or to use the Echo Logger
@@ -916,7 +924,7 @@ class CMailFile
 		return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?=';
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Read a file on disk and return encoded content for emails (mode = 'mail')
 	 *
@@ -925,7 +933,7 @@ class CMailFile
 	 */
 	private function _encode_file($sourcefile)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$newsourcefile = dol_osencode($sourcefile);
 
 		if (is_readable($newsourcefile))
@@ -941,7 +949,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Write content of a SMTP request into a dump file (mode = all)
 	 *  Used for debugging.
@@ -951,7 +959,7 @@ class CMailFile
 	 */
 	public function dump_mail()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $dolibarr_main_data_root;
 
 		if (@is_writeable($dolibarr_main_data_root))	// Avoid fatal error on fopen with open_basedir
@@ -1032,7 +1040,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Create SMTP headers (mode = 'mail')
 	 *
@@ -1040,7 +1048,7 @@ class CMailFile
 	 */
 	public function write_smtpheaders()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 		$out = "";
 
@@ -1096,7 +1104,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Create header MIME (mode = 'mail')
 	 *
@@ -1106,7 +1114,7 @@ class CMailFile
 	 */
 	public function write_mimeheaders($filename_list, $mimefilename_list)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$mimedone = 0;
 		$out = "";
 
@@ -1127,7 +1135,7 @@ class CMailFile
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Return email content (mode = 'mail')
 	 *
@@ -1136,7 +1144,7 @@ class CMailFile
 	 */
 	public function write_body($msgtext)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$out = '';
@@ -1227,7 +1235,7 @@ class CMailFile
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Attach file to email (mode = 'mail')
 	 *
@@ -1238,7 +1246,7 @@ class CMailFile
 	 */
 	public function write_files($filename_list, $mimetype_list, $mimefilename_list)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$out = '';
 
 		$filename_list_size = count($filename_list);
@@ -1274,7 +1282,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Attach an image to email (mode = 'mail')
 	 *
@@ -1283,7 +1291,7 @@ class CMailFile
 	 */
 	public function write_images($images_list)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$out = '';
 
 		if (is_array($images_list))
@@ -1307,7 +1315,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Try to create a socket connection
 	 *
@@ -1317,7 +1325,7 @@ class CMailFile
 	 */
 	public function check_server_port($host, $port)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$_retVal = 0;
@@ -1348,7 +1356,7 @@ class CMailFile
 
 			dol_syslog("Try socket connection to host=".$host." port=".$port);
 			//See if we can connect to the SMTP server
-            if ($socket = @fsockopen(
+			if ($socket = @fsockopen(
 					$host, // Host to test, IP or domain. Add ssl:// for SSL/TLS.
 					$port, // which Port number to use
 					$errno, // actual system level error
@@ -1369,7 +1377,7 @@ class CMailFile
 		return $_retVal;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * This function has been modified as provided by SirSir to allow multiline responses when
 	 * using SMTP Extensions.
@@ -1380,7 +1388,7 @@ class CMailFile
 	 */
 	public function server_parse($socket, $response)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$_retVal = true; // Indicates if Object was created or not
 		$server_response = '';
 
@@ -1504,8 +1512,8 @@ class CMailFile
 	 *										     If format 2: 'john@doe.com'
 	 *										     If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>'
 	 *                                           If format 4: 'John Doe' or 'john@doe.com' if no label exists
-     *                                           If format 5: <a href="mailto:john@doe.com">John Doe</a> or <a href="mailto:john@doe.com">john@doe.com</a> if no label exists
-     * @see getArrayAddress()
+	 *                                           If format 5: <a href="mailto:john@doe.com">John Doe</a> or <a href="mailto:john@doe.com">john@doe.com</a> if no label exists
+	 * @see getArrayAddress()
 	 */
 	public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0)
 	{
@@ -1533,10 +1541,10 @@ class CMailFile
 				$i++;
 
 				$newemail = '';
-                if ($format == 5) {
-                    $newemail = $name ? $name : $email;
-                    $newemail = '<a href="mailto:'.$email.'">'.$newemail.'</a>';
-                }
+				if ($format == 5) {
+					$newemail = $name ? $name : $email;
+					$newemail = '<a href="mailto:'.$email.'">'.$newemail.'</a>';
+				}
 				if ($format == 4)
 				{
 					$newemail = $name ? $name : $email;

Разлика између датотеке није приказан због своје велике величине
+ 209 - 207
htdocs/core/class/commonobject.class.php


+ 1 - 1
htdocs/core/class/extrafields.class.php

@@ -1231,7 +1231,7 @@ class ExtraFields
                             } else {
                                 if (!$notrans) {
                                     $translabel = $langs->trans($obj->{$InfoFieldList[1]});
-                                    $labeltoshow = dol_trunc($translabel, 18);
+                                    $labeltoshow =$translabel;
                                 }
                                 if (empty($labeltoshow)) $labeltoshow = '(not defined)';
 

Разлика између датотеке није приказан због своје велике величине
+ 248 - 248
htdocs/core/class/html.form.class.php


+ 251 - 251
htdocs/core/class/html.formactions.class.php

@@ -29,58 +29,58 @@
  */
 class FormActions
 {
-    /**
-     * @var DoliDB Database handler.
-     */
-    public $db;
+	/**
+	 * @var DoliDB Database handler.
+	 */
+	public $db;
 
-    /**
+	/**
 	 * @var string Error code (or message)
 	 */
 	public $error = '';
 
 
-    /**
+	/**
 	 *	Constructor
 	 *
-     *  @param      DoliDB		$db      Database handler
-     */
-    public function __construct($db)
-    {
-        $this->db = $db;
-    }
-
-
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Show list of action status
-     *
-     * 	@param	string	$formname		Name of form where select is included
-     * 	@param	string	$selected		Preselected value (-1..100)
-     * 	@param	int		$canedit		1=can edit, 0=read only
-     *  @param  string	$htmlname   	Name of html prefix for html fields (selectX and valX)
-     *  @param	integer	$showempty		Show an empty line if select is used
-     *  @param	integer	$onlyselect		0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
-     *  @param  string  $morecss        More css on select field
-     * 	@return	void
-     */
-    public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100')
-    {
-        // phpcs:enable
-        global $langs, $conf;
-
-        $listofstatus = array(
-            '-1' => $langs->trans("ActionNotApplicable"),
-            '0' => $langs->trans("ActionsToDoShort"),
-            '50' => $langs->trans("ActionRunningShort"),
-            '100' => $langs->trans("ActionDoneShort")
-        );
+	 *  @param      DoliDB		$db      Database handler
+	 */
+	public function __construct($db)
+	{
+		$this->db = $db;
+	}
+
+
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Show list of action status
+	 *
+	 * 	@param	string	$formname		Name of form where select is included
+	 * 	@param	string	$selected		Preselected value (-1..100)
+	 * 	@param	int		$canedit		1=can edit, 0=read only
+	 *  @param  string	$htmlname   	Name of html prefix for html fields (selectX and valX)
+	 *  @param	integer	$showempty		Show an empty line if select is used
+	 *  @param	integer	$onlyselect		0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
+	 *  @param  string  $morecss        More css on select field
+	 * 	@return	void
+	 */
+	public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100')
+	{
+		// phpcs:enable
+		global $langs, $conf;
+
+		$listofstatus = array(
+			'-1' => $langs->trans("ActionNotApplicable"),
+			'0' => $langs->trans("ActionsToDoShort"),
+			'50' => $langs->trans("ActionRunningShort"),
+			'100' => $langs->trans("ActionDoneShort")
+		);
 		// +ActionUncomplete
 
-        if (!empty($conf->use_javascript_ajax))
-        {
-            print "\n";
-            print "<script type=\"text/javascript\">
+		if (!empty($conf->use_javascript_ajax))
+		{
+			print "\n";
+			print "<script type=\"text/javascript\">
                 var htmlname = '".$htmlname."';
 
                 $(document).ready(function () {
@@ -124,142 +124,142 @@ class FormActions
                     }
                 }
                 </script>\n";
-        }
-        if (!empty($conf->use_javascript_ajax) || $onlyselect)
-        {
-        	//var_dump($selected);
-        	if ($selected == 'done') $selected = '100';
-            print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
-            if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>';
-            foreach ($listofstatus as $key => $val)
-            {
-                print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
-                if ($key == '50' && $onlyselect == 2)
-                {
-                	print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>';
-                }
-            }
-            print '</select>';
-            if ($selected == 0 || $selected == 100) $canedit = 0;
-
-            if (empty($onlyselect))
-            {
-	            print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
-    	        print '<span class="hideonsmartphone hideifna">%</span>';
-            }
-        } else {
-            print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
-        }
-    }
-
-
-    /**
-     *  Show list of actions for element
-     *
-     *  @param	Object	$object					Object
-     *  @param  string	$typeelement			'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter'
-     *	@param	int		$socid					Socid of user
-     *  @param	int		$forceshowtitle			Show title even if there is no actions to show
-     *  @param  string  $morecss        		More css on table
-     *  @param	int		$max					Max number of record
-     *  @param	string	$moreparambacktopage	More param for the backtopage
-     *  @param	string	$morehtmlcenter			More html text on center of title line
-     *	@return	int								<0 if KO, >=0 if OK
-     */
-    public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '')
-    {
-        global $langs, $conf, $user;
-
-        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
-
-        $sortfield = 'a.datep,a.id';
-        $sortorder = 'DESC,DESC';
-
-        $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
-        if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions');
-
-        $num = count($listofactions);
-        if ($num || $forceshowtitle)
-        {
-        	if ($typeelement == 'invoice')               $title = $langs->trans('ActionsOnBill');
-        	elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill');
-        	elseif ($typeelement == 'propal')            $title = $langs->trans('ActionsOnPropal');
-        	elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal');
-        	elseif ($typeelement == 'order')             $title = $langs->trans('ActionsOnOrder');
-        	elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order')   $title = $langs->trans('ActionsOnOrder');
-        	elseif ($typeelement == 'shipping')          $title = $langs->trans('ActionsOnShipping');
-            elseif ($typeelement == 'fichinter')         $title = $langs->trans('ActionsOnFicheInter');
-            elseif ($typeelement == 'project')           $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
-            elseif ($typeelement == 'task')              $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
-            elseif ($typeelement == 'member')            $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
-            else $title = $langs->trans("LatestLinkedEvents", $max ? $max : '');
-
-            $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : '');
-
-            $projectid = $object->fk_project;
-            if ($typeelement == 'project') $projectid = $object->id;
-
-            $newcardbutton = '';
-            if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create))
+		}
+		if (!empty($conf->use_javascript_ajax) || $onlyselect)
+		{
+			//var_dump($selected);
+			if ($selected == 'done') $selected = '100';
+			print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
+			if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>';
+			foreach ($listofstatus as $key => $val)
+			{
+				print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
+				if ($key == '50' && $onlyselect == 2)
+				{
+					print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>';
+				}
+			}
+			print '</select>';
+			if ($selected == 0 || $selected == 100) $canedit = 0;
+
+			if (empty($onlyselect))
 			{
-                $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage));
+				print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
+				print '<span class="hideonsmartphone hideifna">%</span>';
 			}
+		} else {
+			print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
+		}
+	}
 
 
-        	print '<!-- formactions->showactions -->'."\n";
-        	print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter);
+	/**
+	 *  Show list of actions for element
+	 *
+	 *  @param	Object	$object					Object
+	 *  @param  string	$typeelement			'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter'
+	 *	@param	int		$socid					Socid of user
+	 *  @param	int		$forceshowtitle			Show title even if there is no actions to show
+	 *  @param  string  $morecss        		More css on table
+	 *  @param	int		$max					Max number of record
+	 *  @param	string	$moreparambacktopage	More param for the backtopage
+	 *  @param	string	$morehtmlcenter			More html text on center of title line
+	 *	@return	int								<0 if KO, >=0 if OK
+	 */
+	public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '')
+	{
+		global $langs, $conf, $user;
 
-        	$page = 0; $param = '';
+		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 
-        	print '<div class="div-table-responsive-no-min">';
-        	print '<table class="centpercent noborder'.($morecss ? ' '.$morecss : '').'">';
-        	print '<tr class="liste_titre">';
-        	print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
-        	print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
-        	print '</tr>';
-        	print "\n";
+		$sortfield = 'a.datep,a.id';
+		$sortorder = 'DESC,DESC';
 
-        	if (is_array($listofactions) && count($listofactions))
-        	{
-        		$cacheusers = array();
+		$listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
+		if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions');
 
-	        	$cursorevent = 0;
-	        	foreach ($listofactions as $actioncomm)
-	        	{
-	        		if ($max && $cursorevent >= $max) break;
+		$num = count($listofactions);
+		if ($num || $forceshowtitle)
+		{
+			if ($typeelement == 'invoice')               $title = $langs->trans('ActionsOnBill');
+			elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill');
+			elseif ($typeelement == 'propal')            $title = $langs->trans('ActionsOnPropal');
+			elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal');
+			elseif ($typeelement == 'order')             $title = $langs->trans('ActionsOnOrder');
+			elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order')   $title = $langs->trans('ActionsOnOrder');
+			elseif ($typeelement == 'shipping')          $title = $langs->trans('ActionsOnShipping');
+			elseif ($typeelement == 'fichinter')         $title = $langs->trans('ActionsOnFicheInter');
+			elseif ($typeelement == 'project')           $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
+			elseif ($typeelement == 'task')              $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
+			elseif ($typeelement == 'member')            $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
+			else $title = $langs->trans("LatestLinkedEvents", $max ? $max : '');
+
+			$urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : '');
+
+			$projectid = $object->fk_project;
+			if ($typeelement == 'project') $projectid = $object->id;
+
+			$newcardbutton = '';
+			if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create))
+			{
+				$newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage));
+			}
+
+
+			print '<!-- formactions->showactions -->'."\n";
+			print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter);
+
+			$page = 0; $param = '';
+
+			print '<div class="div-table-responsive-no-min">';
+			print '<table class="centpercent noborder'.($morecss ? ' '.$morecss : '').'">';
+			print '<tr class="liste_titre">';
+			print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
+			print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
+			print '</tr>';
+			print "\n";
+
+			if (is_array($listofactions) && count($listofactions))
+			{
+				$cacheusers = array();
 
-	        		$ref = $actioncomm->getNomUrl(1, -1);
-	        		$label = $actioncomm->getNomUrl(0, 38);
+				$cursorevent = 0;
+				foreach ($listofactions as $actioncomm)
+				{
+					if ($max && $cursorevent >= $max) break;
 
-	        		print '<tr class="oddeven">';
-	        		// Ref
+					$ref = $actioncomm->getNomUrl(1, -1);
+					$label = $actioncomm->getNomUrl(0, 38);
+
+					print '<tr class="oddeven">';
+					// Ref
 					print '<td class="nowraponall">'.$ref.'</td>';
 					// Onwer
-	        		print '<td class="tdoverflowmax150">';
-	        		if (!empty($actioncomm->userownerid))
-	        		{
-	        			if (is_object($cacheusers[$actioncomm->userownerid]))
-	        			{
-	        				$tmpuser = $cacheusers[$actioncomm->userownerid];
-	        			} else {
-	        				$tmpuser = new User($this->db);
-	        				$tmpuser->fetch($actioncomm->userownerid);
-	        				$cacheusers[$actioncomm->userownerid] = $tmpuser;
-	        			}
-	        			if ($tmpuser->id > 0)
-	        			{
-	        				print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
-	        			}
-	        		}
-	        		print '</td>';
+					print '<td class="tdoverflowmax150">';
+					if (!empty($actioncomm->userownerid))
+					{
+						if (is_object($cacheusers[$actioncomm->userownerid]))
+						{
+							$tmpuser = $cacheusers[$actioncomm->userownerid];
+						} else {
+							$tmpuser = new User($this->db);
+							$tmpuser->fetch($actioncomm->userownerid);
+							$cacheusers[$actioncomm->userownerid] = $tmpuser;
+						}
+						if ($tmpuser->id > 0)
+						{
+							print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
+						}
+					}
+					print '</td>';
 
 					// Type
-	        		print '<td>';
-	        		// TODO Code common with code into comm/action/list.php
+					print '<td>';
+					// TODO Code common with code into comm/action/list.php
 					$imgpicto = '';
 					if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
 					{
@@ -281,100 +281,100 @@ class FormActions
 					} else {
 						print $actioncomm->type_short ? $actioncomm->type_short : $actioncomm->type;
 					}
-	        		print '</td>';
-	        		// Label
-	        		print '<td>'.$label.'</td>';
-	        		// Date
-	        		print '<td class="center">'.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel');
-	        		if ($actioncomm->datef)
-	        		{
-		        		$tmpa = dol_getdate($actioncomm->datep);
-		        		$tmpb = dol_getdate($actioncomm->datef);
-		        		if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
-		        		{
-		        			if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel');
-		        		} else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel');
-	        		}
-	        		print '</td>';
-	        		print '<td class="right">';
-        			print $actioncomm->getLibStatut(3);
-	        		print '</td>';
-	        		print '</tr>';
-
-	        		$cursorevent++;
-	        	}
-        	} else {
-        		print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
-        	}
-
-        	if ($max && $num > $max)
-        	{
-        		print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>';
-        	}
-
-        	print '</table>';
-        	print '</div>';
-        }
-
-        return $num;
-    }
-
-
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Output html select list of type of event
-     *
-     *  @param	array|string	$selected       Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too.
-     *  @param  string		    $htmlname       Name of select field
-     *  @param	string		    $excludetype	A type to exclude ('systemauto', 'system', '')
-     *  @param	integer		    $onlyautoornot	1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual"
-     *  @param	int		        $hideinfohelp	1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value
-     *  @param  int		        $multiselect    1=Allow multiselect of action type
-     *  @param  int             $nooutput       1=No output
-     *  @param	string			$morecss		More css to add to SELECT component.
-     * 	@return	string
-     */
-    public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '')
-    {
-        // phpcs:enable
-        global $langs, $user, $form, $conf;
-
-        if (!is_object($form)) $form = new Form($this->db);
-
-        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
-        require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
-        $caction = new CActionComm($this->db);
-
-        // Suggest a list with manual events or all auto events
-        $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot);
-        if (empty($multiselect)) {
-            // Add empty line at start only if no multiselect
-            array_unshift($arraylist, '&nbsp;');
-        }
-        //asort($arraylist);
-
-       	if ($selected == 'manual') $selected = 'AC_OTH';
-       	if ($selected == 'auto')   $selected = 'AC_OTH_AUTO';
-
-       	if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']);
-
-       	$out = '';
+					print '</td>';
+					// Label
+					print '<td>'.$label.'</td>';
+					// Date
+					print '<td class="center">'.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel');
+					if ($actioncomm->datef)
+					{
+						$tmpa = dol_getdate($actioncomm->datep);
+						$tmpb = dol_getdate($actioncomm->datef);
+						if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
+						{
+							if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel');
+						} else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel');
+					}
+					print '</td>';
+					print '<td class="right">';
+					print $actioncomm->getLibStatut(3);
+					print '</td>';
+					print '</tr>';
+
+					$cursorevent++;
+				}
+			} else {
+				print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
+			}
+
+			if ($max && $num > $max)
+			{
+				print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>';
+			}
+
+			print '</table>';
+			print '</div>';
+		}
+
+		return $num;
+	}
+
+
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Output html select list of type of event
+	 *
+	 *  @param	array|string	$selected       Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too.
+	 *  @param  string		    $htmlname       Name of select field
+	 *  @param	string		    $excludetype	A type to exclude ('systemauto', 'system', '')
+	 *  @param	integer		    $onlyautoornot	1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual"
+	 *  @param	int		        $hideinfohelp	1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value
+	 *  @param  int		        $multiselect    1=Allow multiselect of action type
+	 *  @param  int             $nooutput       1=No output
+	 *  @param	string			$morecss		More css to add to SELECT component.
+	 * 	@return	string
+	 */
+	public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '')
+	{
+		// phpcs:enable
+		global $langs, $user, $form, $conf;
+
+		if (!is_object($form)) $form = new Form($this->db);
+
+		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
+		require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
+		$caction = new CActionComm($this->db);
+
+		// Suggest a list with manual events or all auto events
+		$arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot);
+		if (empty($multiselect)) {
+			// Add empty line at start only if no multiselect
+			array_unshift($arraylist, '&nbsp;');
+		}
+		//asort($arraylist);
+
+	   	if ($selected == 'manual') $selected = 'AC_OTH';
+	   	if ($selected == 'auto')   $selected = 'AC_OTH_AUTO';
+
+	   	if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']);
+
+	   	$out = '';
 
 		if (!empty($multiselect))
 		{
-	        if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected);
+			if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected);
 			$out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0);
 		} else {
 			$out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'.($morecss ? ' '.$morecss : ''), 1);
 		}
 
-        if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0)
-        {
-            $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1);
-        }
+		if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0)
+		{
+			$out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1);
+		}
 
-        if ($nooutput) return $out;
-        else print $out;
-        return '';
-    }
+		if ($nooutput) return $out;
+		else print $out;
+		return '';
+	}
 }

+ 200 - 200
htdocs/core/class/html.formcompany.class.php

@@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
 class FormCompany extends Form
 {
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    	Return list of labels (translated) of third parties type
 	 *
@@ -50,7 +50,7 @@ class FormCompany extends Form
 	 */
 	public function typent_array($mode = 0, $filter = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $langs, $mysoc;
 
 		$effs = array();
@@ -83,7 +83,7 @@ class FormCompany extends Form
 		return $effs;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
 	 *
@@ -93,7 +93,7 @@ class FormCompany extends Form
 	 */
 	public function effectif_array($mode = 0, $filter = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$effs = array();
 
 		$sql = "SELECT id, code, libelle";
@@ -123,7 +123,7 @@ class FormCompany extends Form
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Affiche formulaire de selection des modes de reglement
 	 *
@@ -135,7 +135,7 @@ class FormCompany extends Form
 	 */
 	public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs;
 
 		print '<form method="post" action="'.$page.'">';
@@ -225,12 +225,12 @@ class FormCompany extends Form
 		print '</form>';
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
-     *   In the case of an all-country list, the display breaks on the country.
-     *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
-     *   Thus the links with the departments are done on a department independently of its name.
+	 *   In the case of an all-country list, the display breaks on the country.
+	 *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
+	 *   Thus the links with the departments are done on a department independently of its name.
 	 *
 	 *   @param     string	$selected        	Code state preselected
 	 *   @param     int		$country_codeid     0=list for all countries, otherwise country code or country rowid to show
@@ -239,16 +239,16 @@ class FormCompany extends Form
 	 */
 	public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		print $this->select_state($selected, $country_codeid, $htmlname);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
-     *   In the case of an all-country list, the display breaks on the country.
-     *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
-     *   Thus the links with the departments are done on a department independently of its name.
+	 *   In the case of an all-country list, the display breaks on the country.
+	 *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
+	 *   Thus the links with the departments are done on a department independently of its name.
 	 *
 	 *    @param	int		$selected        	Code state preselected (mus be state id)
 	 *    @param    integer	$country_codeid    	Country code or id: 0=list for all countries, otherwise country code or country rowid to show
@@ -258,7 +258,7 @@ class FormCompany extends Form
 	 */
 	public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user;
 
 		dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG);
@@ -349,7 +349,7 @@ class FormCompany extends Form
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Retourne la liste deroulante des regions actives dont le pays est actif
 	 *   La cle de la liste est le code (il peut y avoir plusieurs entree pour
@@ -362,7 +362,7 @@ class FormCompany extends Form
 	 */
 	public function select_region($selected = '', $htmlname = 'region_id')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs;
 		$langs->load("dict");
 
@@ -412,7 +412,7 @@ class FormCompany extends Form
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Return combo list with people title
 	 *
@@ -424,7 +424,7 @@ class FormCompany extends Form
 	 */
 	public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user;
 		$langs->load("dict");
 
@@ -473,7 +473,7 @@ class FormCompany extends Form
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
 	 *    Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays.
@@ -487,25 +487,25 @@ class FormCompany extends Form
 	 */
 	public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		print $this->select_juridicalstatus($selected, $country_codeid, $filter);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
 	 *    Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
 	 *
 	 *    @param	string		$selected        	Preselected code of juridical type
 	 *    @param    int			$country_codeid     0=list for all countries, otherwise list only country requested
-     *    @param    string		$filter          	Add a SQL filter on list
-     *    @param	string		$htmlname			HTML name of select
-     *    @param	string		$morecss			More CSS
-     *    @return	string							String with HTML select
+	 *    @param    string		$filter          	Add a SQL filter on list
+	 *    @param	string		$htmlname			HTML name of select
+	 *    @param	string		$morecss			More CSS
+	 *    @return	string							String with HTML select
 	 */
 	public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user;
 		$langs->load("dict");
 
@@ -578,9 +578,9 @@ class FormCompany extends Form
 			$out .= '</select>';
 			if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 
-		    // Make select dynamic
-        	include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
-	        $out .= ajax_combobox($htmlname);
+			// Make select dynamic
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+			$out .= ajax_combobox($htmlname);
 
 			$out .= '</div>';
 		} else {
@@ -600,8 +600,8 @@ class FormCompany extends Form
 	 *  @param  string		$htmlname       Name of HTML form
 	 * 	@param	array		$limitto		Disable answers that are not id in this array list
 	 *  @param	int			$forceid		This is to force another object id than object->id
-     *  @param	string		$moreparam		String with more param to add into url when noajax search is used.
-     *  @param	string		$morecss		More CSS on select component
+	 *  @param	string		$moreparam		String with more param to add into url when noajax search is used.
+	 *  @param	string		$morecss		More CSS on select component
 	 * 	@return int 						The selected third party ID
 	 */
 	public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '')
@@ -746,21 +746,21 @@ class FormCompany extends Form
 		}
 	}
 
-    /**
-     *  Return a select list with types of contacts
-     *
-     *  @param	object		$object         Object to use to find type of contact
-     *  @param  string		$selected       Default selected value
-     *  @param  string		$htmlname		HTML select name
-     *  @param  string		$source			Source ('internal' or 'external')
-     *  @param  string		$sortorder		Sort criteria ('position', 'code', ...)
-     *  @param  int			$showempty      1=Add en empty line
-     *  @param  string      $morecss        Add more css to select component
-     *  @return	void
-     */
-    public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '')
+	/**
+	 *  Return a select list with types of contacts
+	 *
+	 *  @param	object		$object         Object to use to find type of contact
+	 *  @param  string		$selected       Default selected value
+	 *  @param  string		$htmlname		HTML select name
+	 *  @param  string		$source			Source ('internal' or 'external')
+	 *  @param  string		$sortorder		Sort criteria ('position', 'code', ...)
+	 *  @param  int			$showempty      1=Add en empty line
+	 *  @param  string      $morecss        Add more css to select component
+	 *  @return	void
+	 */
+	public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '')
 	{
-	    global $user, $langs;
+		global $user, $langs;
 
 		if (is_object($object) && method_exists($object, 'liste_type_contact'))
 		{
@@ -822,7 +822,7 @@ class FormCompany extends Form
 		return 'ErrorBadValueForParameterRenderMode'; // Should not happened
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    Return a select list with zip codes and their town
 	 *
@@ -837,7 +837,7 @@ class FormCompany extends Form
 	 */
 	public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$out = '';
@@ -855,155 +855,155 @@ class FormCompany extends Form
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...)
-     *
-     *  @param	int		$idprof         1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
-     *  @param  string	$htmlname       Name of HTML select
-     *  @param  string	$preselected    Default value to show
-     *  @param  string	$country_code   FR, IT, ...
-     *  @param  string  $morecss        More css
-     *  @return	string					HTML string with prof id
-     */
-    public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent')
-    {
-        // phpcs:enable
-        global $conf, $langs, $hookmanager;
-
-        $formlength = 0;
-        if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
-        	if ($country_code == 'FR')
-        	{
-        		if (isset($idprof)) {
-        			if ($idprof == 1) $formlength = 9;
-        			elseif ($idprof == 2) $formlength = 14;
-        			elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
-        			elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id
-        		}
-        	} elseif ($country_code == 'ES')
-        	{
-        		if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits
-        		if ($idprof == 2) $formlength = 12; //NASS 12 digits without /
-        		if ($idprof == 3) $formlength = 5; //CNAE 5 digits
-        		if ($idprof == 4) $formlength = 32; //depend of college
-        	}
-        }
-
-        $selected = $preselected;
-        if (!$selected && isset($idprof)) {
-        	if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1;
-        	elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2;
-        	elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3;
-        	elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4;
-        }
-
-        $maxlength = $formlength;
-        if (empty($formlength)) { $formlength = 24; $maxlength = 128; }
-
-        $out = '';
-
-        // Execute hook getInputIdProf to complete or replace $out
-        $parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code);
-        $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
-        if (empty($reshook))
-        {
-        	$out .= '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">';
-        }
-        $out .= $hookmanager->resPrint;
-
-        return $out;
-    }
-
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     * Return a HTML select with localtax values for thirdparties
-     *
-     * @param 	int 		$local			LocalTax
-     * @param 	int 		$selected		Preselected value
-     * @param 	string      $htmlname		HTML select name
-     * @return	void
-     */
-    public function select_localtax($local, $selected, $htmlname)
-    {
-        // phpcs:enable
-        $tax = get_localtax_by_third($local);
-
-        $num = $this->db->num_rows($tax);
-        $i = 0;
-    	if ($num)
-    	{
-    		$valors = explode(":", $tax);
-
-    		if (count($valors) > 1)
-    		{
-    			//montar select
-    			print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
-    			while ($i <= (count($valors)) - 1)
-    			{
-    				if ($selected == $valors[$i])
-    				{
-    					print '<option value="'.$valors[$i].'" selected>';
-    				} else {
-    					print '<option value="'.$valors[$i].'">';
-    				}
-    				print $valors[$i];
-    				print '</option>';
-    				$i++;
-    			}
-    			print'</select>';
-    		}
-    	}
-    }
-
-    /**
-     * Return a HTML select for thirdparty type
-     *
-     * @param int $selected selected value
-     * @param string $htmlname HTML select name
-     * @param string $htmlidname HTML select id
-     * @param string $typeinput HTML output
-     * @param string $morecss More css
-     * @return string HTML string
-     */
-    public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '')
-    {
-
-    	global $conf, $langs;
-
-    	$out = '<select class="flat '.$morecss.'" name="'.$htmlname.'" id="'.$htmlidname.'">';
-    	if ($typeinput == 'form') {
-    		if ($selected == '' || $selected == '-1') $out .= '<option value="-1">&nbsp;</option>';
-	    	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
-	    		$out .= '<option value="2"'.($selected == 2 ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
-	    	}
-	    	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
-	    		$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
-	    	}
-	    	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
-	    		$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
-	    	}
-	    	$out .= '<option value="0"'.((string) $selected == '0' ? ' selected' : '').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
-    	} elseif ($typeinput == 'list') {
-    		$out .= '<option value="-1"'.(($selected == '' || $selected == '-1') ? ' selected' : '').'>&nbsp;</option>';
-    		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
-    			$out .= '<option value="2,3"'.($selected == '2,3' ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
-    		}
-    		if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
-    			$out .= '<option value="1,3"'.($selected == '1,3' ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
-    		}
-    		$out .= '<option value="4"'.($selected == '4' ? ' selected' : '').'>'.$langs->trans('Supplier').'</option>';
-    		$out .= '<option value="0"'.($selected == '0' ? ' selected' : '').'>'.$langs->trans('Other').'</option>';
-    	} elseif ($typeinput == 'admin') {
-    		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
-    			$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
-    		}
-    		if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
-    			$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
-    		}
-    	}
-    	$out .= '</select>';
-
-    	return $out;
-    }
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...)
+	 *
+	 *  @param	int		$idprof         1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
+	 *  @param  string	$htmlname       Name of HTML select
+	 *  @param  string	$preselected    Default value to show
+	 *  @param  string	$country_code   FR, IT, ...
+	 *  @param  string  $morecss        More css
+	 *  @return	string					HTML string with prof id
+	 */
+	public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent')
+	{
+		// phpcs:enable
+		global $conf, $langs, $hookmanager;
+
+		$formlength = 0;
+		if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
+			if ($country_code == 'FR')
+			{
+				if (isset($idprof)) {
+					if ($idprof == 1) $formlength = 9;
+					elseif ($idprof == 2) $formlength = 14;
+					elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
+					elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id
+				}
+			} elseif ($country_code == 'ES')
+			{
+				if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits
+				if ($idprof == 2) $formlength = 12; //NASS 12 digits without /
+				if ($idprof == 3) $formlength = 5; //CNAE 5 digits
+				if ($idprof == 4) $formlength = 32; //depend of college
+			}
+		}
+
+		$selected = $preselected;
+		if (!$selected && isset($idprof)) {
+			if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1;
+			elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2;
+			elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3;
+			elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4;
+		}
+
+		$maxlength = $formlength;
+		if (empty($formlength)) { $formlength = 24; $maxlength = 128; }
+
+		$out = '';
+
+		// Execute hook getInputIdProf to complete or replace $out
+		$parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code);
+		$reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
+		if (empty($reshook))
+		{
+			$out .= '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">';
+		}
+		$out .= $hookmanager->resPrint;
+
+		return $out;
+	}
+
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 * Return a HTML select with localtax values for thirdparties
+	 *
+	 * @param 	int 		$local			LocalTax
+	 * @param 	int 		$selected		Preselected value
+	 * @param 	string      $htmlname		HTML select name
+	 * @return	void
+	 */
+	public function select_localtax($local, $selected, $htmlname)
+	{
+		// phpcs:enable
+		$tax = get_localtax_by_third($local);
+
+		$num = $this->db->num_rows($tax);
+		$i = 0;
+		if ($num)
+		{
+			$valors = explode(":", $tax);
+
+			if (count($valors) > 1)
+			{
+				//montar select
+				print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
+				while ($i <= (count($valors)) - 1)
+				{
+					if ($selected == $valors[$i])
+					{
+						print '<option value="'.$valors[$i].'" selected>';
+					} else {
+						print '<option value="'.$valors[$i].'">';
+					}
+					print $valors[$i];
+					print '</option>';
+					$i++;
+				}
+				print'</select>';
+			}
+		}
+	}
+
+	/**
+	 * Return a HTML select for thirdparty type
+	 *
+	 * @param int $selected selected value
+	 * @param string $htmlname HTML select name
+	 * @param string $htmlidname HTML select id
+	 * @param string $typeinput HTML output
+	 * @param string $morecss More css
+	 * @return string HTML string
+	 */
+	public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '')
+	{
+
+		global $conf, $langs;
+
+		$out = '<select class="flat '.$morecss.'" name="'.$htmlname.'" id="'.$htmlidname.'">';
+		if ($typeinput == 'form') {
+			if ($selected == '' || $selected == '-1') $out .= '<option value="-1">&nbsp;</option>';
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
+				$out .= '<option value="2"'.($selected == 2 ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
+				$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+				$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
+			}
+			$out .= '<option value="0"'.((string) $selected == '0' ? ' selected' : '').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
+		} elseif ($typeinput == 'list') {
+			$out .= '<option value="-1"'.(($selected == '' || $selected == '-1') ? ' selected' : '').'>&nbsp;</option>';
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
+				$out .= '<option value="2,3"'.($selected == '2,3' ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+				$out .= '<option value="1,3"'.($selected == '1,3' ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
+			}
+			$out .= '<option value="4"'.($selected == '4' ? ' selected' : '').'>'.$langs->trans('Supplier').'</option>';
+			$out .= '<option value="0"'.($selected == '0' ? ' selected' : '').'>'.$langs->trans('Other').'</option>';
+		} elseif ($typeinput == 'admin') {
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
+				$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+				$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
+			}
+		}
+		$out .= '</select>';
+
+		return $out;
+	}
 }

+ 76 - 76
htdocs/core/class/html.formfile.class.php

@@ -58,7 +58,7 @@ class FormFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show form to upload a new file.
 	 *
@@ -70,8 +70,8 @@ class FormFile
 	 *  @param  int			$size          	Length of input file area. Deprecated.
 	 *  @param	Object		$object			Object to use (when attachment is done on an element)
 	 *  @param	string		$options		Add an option column
-     *  @param  integer     $useajax        Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option).
-     *                                      Deprecated 2 should never be used and if 1 is used, option should no be enabled.
+	 *  @param  integer     $useajax        Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option).
+	 *                                      Deprecated 2 should never be used and if 1 is used, option should no be enabled.
 	 *  @param	string		$savingdocmask	Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
 	 *  @param	integer		$linkfiles		1=Also add form to link files, 0=Do not show form to link files
 	 *  @param	string		$htmlname		Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
@@ -83,14 +83,14 @@ class FormFile
 	 */
 	public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0, $capture = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $hookmanager;
 		$hookmanager->initHooks(array('formfile'));
 
-        // Deprecation warning
-        if ($useajax == 2) {
-            dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
-        }
+		// Deprecation warning
+		if ($useajax == 2) {
+			dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
+		}
 
 		if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0;
 
@@ -114,15 +114,15 @@ class FormFile
 
 			if (empty($usewithoutform))		// Try to avoid this and set instead the form by the caller.
 			{
-    			$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
-    			$out .= '<input type="hidden" name="token" value="'.newToken().'">';
-    			$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
-    			$out .= '<input type="hidden" id="'.$htmlname.'_section_id"  name="section_id" value="'.$sectionid.'">';
-    			$out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'alpha').'">';
-    			$out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09').'">';
+				$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
+				$out .= '<input type="hidden" name="token" value="'.newToken().'">';
+				$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
+				$out .= '<input type="hidden" id="'.$htmlname.'_section_id"  name="section_id" value="'.$sectionid.'">';
+				$out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'alpha').'">';
+				$out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09').'">';
 			}
 
-			$out .= '<table class="nobordernopadding cenpercent">';
+			$out .= '<table class="nobordernopadding centpercent">';
 			$out .= '<tr>';
 
 			if (!empty($options)) $out .= '<td>'.$options.'</td>';
@@ -201,24 +201,24 @@ class FormFile
 			$out .= "</td></tr>";
 
 			if ($savingdocmask)
-            {
-            	//add a global variable for disable the auto renaming on upload
-                $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : '');
+			{
+				//add a global variable for disable the auto renaming on upload
+				$rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : '');
 
-                $out .= '<tr>';
-   	            if (!empty($options)) $out .= '<td>'.$options.'</td>';
-	            $out .= '<td valign="middle" class="nowrap">';
+				$out .= '<tr>';
+   				if (!empty($options)) $out .= '<td>'.$options.'</td>';
+				$out .= '<td valign="middle" class="nowrap">';
 				$out .= '<input type="checkbox" '.$rename.' class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName"));
-            	$out .= '</td>';
-            	$out .= '</tr>';
-            }
+				$out .= '</td>';
+				$out .= '</tr>';
+			}
 
 			$out .= "</table>";
 
 			if (empty($usewithoutform))
 			{
-    			$out .= '</form>';
-	       		if (empty($sectionid)) $out .= '<br>';
+				$out .= '</form>';
+		   		if (empty($sectionid)) $out .= '<br>';
 			}
 
 			$out .= "\n</div><!-- End form attach new file -->\n";
@@ -232,10 +232,10 @@ class FormFile
 
 				if (empty($usewithoutform))
 				{
-    				$out .= '<form name="'.$htmlname.'_link" id="'.$htmlname.'_link" action="'.$url.'" method="POST">'."\n";
-    				$out .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
-    				$out .= '<input type="hidden" id="'.$htmlname.'_link_section_dir" name="link_section_dir" value="">'."\n";
-    				$out .= '<input type="hidden" id="'.$htmlname.'_link_section_id"  name="link_section_id" value="'.$sectionid.'">'."\n";
+					$out .= '<form name="'.$htmlname.'_link" id="'.$htmlname.'_link" action="'.$url.'" method="POST">'."\n";
+					$out .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
+					$out .= '<input type="hidden" id="'.$htmlname.'_link_section_dir" name="link_section_dir" value="">'."\n";
+					$out .= '<input type="hidden" id="'.$htmlname.'_link_section_id"  name="link_section_id" value="'.$sectionid.'">'."\n";
 				}
 
 				$out .= '<div class="valignmiddle">';
@@ -257,8 +257,8 @@ class FormFile
 				$out .= '</div>';
 				if (empty($usewithoutform))
 				{
-    				$out .= '<div class="clearboth"></div>';
-                    $out .= '</form><br>';
+					$out .= '<div class="clearboth"></div>';
+					$out .= '</form><br>';
 				}
 
 				$out .= "\n</div><!-- End form link new url -->\n";
@@ -268,7 +268,7 @@ class FormFile
 			$res = $hookmanager->executeHooks('formattachOptions', $parameters, $object);
 			if (empty($res))
 			{
-			    print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">';
+				print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">';
 				print $out;
 				print '</div>';
 			}
@@ -278,7 +278,7 @@ class FormFile
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *      Show the box with list of available documents for object
 	 *
@@ -303,7 +303,7 @@ class FormFile
 	 */
 	public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$this->numoffiles = 0;
 		print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
 		return $this->numoffiles;
@@ -454,13 +454,13 @@ class FormFile
 					$modellist = ModelePDFExpedition::liste_modeles($this->db);
 				}
 			} elseif ($modulepart == 'reception')
-            {
-                if (is_array($genallowed)) $modellist = $genallowed;
-                else {
+			{
+				if (is_array($genallowed)) $modellist = $genallowed;
+				else {
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
 					$modellist = ModelePdfReception::liste_modeles($this->db);
 				}
-            } elseif ($modulepart == 'livraison')
+			} elseif ($modulepart == 'livraison')
 			{
 				if (is_array($genallowed)) $modellist = $genallowed;
 				else {
@@ -611,16 +611,16 @@ class FormFile
 					$modellist = ModelePDFUserGroup::liste_modeles($this->db);
 				}
 			} else {
-			    $submodulepart = $modulepart;
+				$submodulepart = $modulepart;
 
-			    // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject'
-			    $tmp = explode(':', $modulepart);
-			    if (!empty($tmp[1])) {
-			    	$modulepart = $tmp[0];
-			    	$submodulepart = $tmp[1];
-			    }
+				// modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject'
+				$tmp = explode(':', $modulepart);
+				if (!empty($tmp[1])) {
+					$modulepart = $tmp[0];
+					$submodulepart = $tmp[1];
+				}
 
-			    // For normalized standard modules
+				// For normalized standard modules
 				$file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
 				if (file_exists($file))
 				{
@@ -628,7 +628,7 @@ class FormFile
 				}
 				// For normalized external modules.
 				else {
-				    $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
+					$file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
 					$res = include_once $file;
 				}
 
@@ -992,7 +992,7 @@ class FormFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show list of documents in $filearray (may be they are all in same directory but may not)
 	 *  This also sync database if $upload_dir is defined.
@@ -1027,7 +1027,7 @@ class FormFile
 	 */
 	public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $conf, $langs, $hookmanager;
 		global $sortfield, $sortorder, $maxheightmini;
 		global $dolibarr_main_url_root;
@@ -1049,7 +1049,7 @@ class FormFile
 		// For backward compatiblity, we detect file stored into an old path
 		if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos')
 		{
-		    $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/';
+			$relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/';
 		}
 		// Defined relative dir to DOL_DATA_ROOT
 		$relativedir = '';
@@ -1233,13 +1233,13 @@ class FormFile
 						print '<td class="center">';
 						if (image_format_supported($file['name']) >= 0)
 						{
-						    if ($useinecm == 5 || $useinecm == 6)
-						    {
-						    	$smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir.
-						    } else {
-						        $smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original
-						    }
-						    if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
+							if ($useinecm == 5 || $useinecm == 6)
+							{
+								$smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir.
+							} else {
+								$smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original
+							}
+							if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
 							//print $file['path'].'/'.$smallfile.'<br>';
 
 							$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
@@ -1353,7 +1353,7 @@ class FormFile
 							   	print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>';
 							   	print '</td>';
 							}
-					    }
+						}
 					} else {
 						print '<td class="right">';
 						print '<input type="hidden" name="ecmfileid" value="'.$filearray[$key]['rowid'].'">';
@@ -1398,7 +1398,7 @@ class FormFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show list of documents in a directory
 	 *
@@ -1419,7 +1419,7 @@ class FormFile
 	 */
 	public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permissiontodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $conf, $langs, $form;
 		global $sortfield, $sortorder;
 		global $search_doc_ref;
@@ -1532,8 +1532,8 @@ class FormFile
 			$object_instance = new RecruitmentCandidature($this->db);
 		} elseif ($modulepart == 'banque')
 		{
-		    include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-		    $object_instance = new Account($this->db);
+			include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+			$object_instance = new Account($this->db);
 		} elseif ($modulepart == 'mrp-mo')
 		{
 			include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
@@ -1574,7 +1574,7 @@ class FormFile
 					'banque'))) {
 					preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : '');
 				} else {
-				    //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n";
+					//print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n";
 				}
 
 				if (!$id && !$ref) continue;
@@ -1733,7 +1733,7 @@ class FormFile
 
 		print '<table width="100%" class="liste noborder nobottom">';
 		print '<tr class="liste_titre">';
-        print_liste_field_titre(
+		print_liste_field_titre(
 			$langs->trans("Links"),
 			$_SERVER['PHP_SELF'],
 			"name",
@@ -1742,20 +1742,20 @@ class FormFile
 			'',
 			$sortfield,
 			$sortorder,
-            ''
+			''
 		);
-        print_liste_field_titre(
+		print_liste_field_titre(
 			"",
 			"",
 			"",
 			"",
 			"",
 			'',
-            '',
-            '',
-            'right '
+			'',
+			'',
+			'right '
 		);
-        print_liste_field_titre(
+		print_liste_field_titre(
 			$langs->trans("Date"),
 			$_SERVER['PHP_SELF'],
 			"date",
@@ -1764,18 +1764,18 @@ class FormFile
 			'',
 			$sortfield,
 			$sortorder,
-            'center '
+			'center '
 		);
-        print_liste_field_titre(
+		print_liste_field_titre(
 			'',
 			$_SERVER['PHP_SELF'],
 			"",
 			"",
 			$param,
 			'',
-            '',
-            '',
-            'center '
+			'',
+			'',
+			'center '
 		);
 		print_liste_field_titre('', '', '');
 		print '</tr>';

+ 86 - 84
htdocs/core/class/html.formmail.class.php

@@ -37,75 +37,75 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
 class FormMail extends Form
 {
 	/**
-     * @var DoliDB Database handler.
-     */
-    public $db;
-
-    /**
-     * @var int 1 = Include HTML form tag and show submit button
-     *          0 = Do not include form tag and submit button
-     *          -1 = Do not include form tag but include submit button
-     */
+	 * @var DoliDB Database handler.
+	 */
+	public $db;
+
+	/**
+	 * @var int 1 = Include HTML form tag and show submit button
+	 *          0 = Do not include form tag and submit button
+	 *          -1 = Do not include form tag but include submit button
+	 */
 	public $withform;
 
-    /**
-     * @var string name from
-     */
+	/**
+	 * @var string name from
+	 */
 	public $fromname;
 
-    /**
-     * @var string email from
-     */
+	/**
+	 * @var string email from
+	 */
 	public $frommail;
 
-    /**
-     * @var string user, company, robot
-     */
-    public $fromtype;
-
-    /**
-     * @var int from ID
-     */
-    public $fromid;
-
-    /**
-     * @var int also from robot
-     */
-    public $fromalsorobot;
-
-    /**
-     * @var string thirdparty etc
-     */
-    public $totype;
-
-    /**
-     * @var int ID
-     */
-    public $toid;
-
-    /**
-     * @var string replyto name
-     */
-    public $replytoname;
-
-    /**
-     * @var string replyto email
-     */
+	/**
+	 * @var string user, company, robot
+	 */
+	public $fromtype;
+
+	/**
+	 * @var int from ID
+	 */
+	public $fromid;
+
+	/**
+	 * @var int also from robot
+	 */
+	public $fromalsorobot;
+
+	/**
+	 * @var string thirdparty etc
+	 */
+	public $totype;
+
+	/**
+	 * @var int ID
+	 */
+	public $toid;
+
+	/**
+	 * @var string replyto name
+	 */
+	public $replytoname;
+
+	/**
+	 * @var string replyto email
+	 */
 	public $replytomail;
 
-    /**
-     * @var string to name
-     */
+	/**
+	 * @var string to name
+	 */
 	public $toname;
 
-    /**
-     * @var string to email
-     */
+	/**
+	 * @var string to email
+	 */
 	public $tomail;
 
-    /**
-     * @var string trackid
-     */
+	/**
+	 * @var string trackid
+	 */
 	public $trackid;
 
 	public $withsubstit; // Show substitution array
@@ -180,7 +180,7 @@ class FormMail extends Form
 		$this->withfckeditor = -1; // -1 = Auto
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Clear list of attached files in send mail form (also stored in session)
 	 *
@@ -188,7 +188,7 @@ class FormMail extends Form
 	 */
 	public function clear_attached_files()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $user;
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
@@ -203,7 +203,7 @@ class FormMail extends Form
 		unset($_SESSION["listofmimes".$keytoavoidconflict]);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Add a file into the list of attached files (stored in SECTION array)
 	 *
@@ -214,7 +214,7 @@ class FormMail extends Form
 	 */
 	public function add_attached_files($path, $file = '', $type = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$listofpaths = array();
 		$listofnames = array();
 		$listofmimes = array();
@@ -237,7 +237,7 @@ class FormMail extends Form
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Remove a file from the list of attached files (stored in SECTION array)
 	 *
@@ -246,7 +246,7 @@ class FormMail extends Form
 	 */
 	public function remove_attached_files($keytodelete)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$listofpaths = array();
 		$listofnames = array();
 		$listofmimes = array();
@@ -267,7 +267,7 @@ class FormMail extends Form
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Return list of attached files (stored in SECTION array)
 	 *
@@ -275,7 +275,7 @@ class FormMail extends Form
 	 */
 	public function get_attached_files()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$listofpaths = array();
 		$listofnames = array();
 		$listofmimes = array();
@@ -287,7 +287,7 @@ class FormMail extends Form
 		return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show the form to input an email
 	 *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@@ -299,11 +299,11 @@ class FormMail extends Form
 	 */
 	public function show_form($addfileaction = 'addfile', $removefileaction = 'removefile')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		print $this->get_form($addfileaction, $removefileaction);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Get the form to input an email
 	 *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@@ -316,17 +316,17 @@ class FormMail extends Form
 	 */
 	public function get_form($addfileaction = 'addfile', $removefileaction = 'removefile')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user, $hookmanager, $form;
 
-        // Required to show preview of mail attachments
-        require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-        $formfile = new Formfile($this->db);
+		// Required to show preview of mail attachments
+		require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+		$formfile = new Formfile($this->db);
 
 		if (!is_object($form)) $form = new Form($this->db);
 
 		// Load translation files required by the page
-        $langs->loadLangs(array('other', 'mails'));
+		$langs->loadLangs(array('other', 'mails'));
 
 		// Clear temp files. Must be done at beginning, before call of triggers
 		if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
@@ -464,7 +464,7 @@ class FormMail extends Form
 					'propal_send', 'order_send', 'facture_send',
 					'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send',
 					'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all'
-                )))
+				)))
 			{
 				// If list of template is empty
 				$out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
@@ -486,7 +486,7 @@ class FormMail extends Form
 			if (is_array($this->substit) && count($this->substit)) $helpforsubstitution .= $langs->trans('AvailableVariables').' :<br>'."\n";
 			foreach ($this->substit as $key => $val)
 			{
-				$helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'<br>';
+				$helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'<br>';
 			}
 			if (!empty($this->withsubstit))		// Unset or set ->withsubstit=0 to disable this.
 			{
@@ -733,7 +733,7 @@ class FormMail extends Form
 				{
 					$out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : "";
 				} else {
-				    $out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
+					$out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
 					if (!empty($this->withtocc) && is_array($this->withtocc))
 					{
 						$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
@@ -854,10 +854,10 @@ class FormMail extends Form
 						foreach ($listofpaths as $key => $val)
 						{
 							$out .= '<div id="attachfile_'.$key.'">';
-                            // Preview of attachment
-                            preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params);
+							// Preview of attachment
+							preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params);
 							$out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
-                            $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
+							$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
 							if (!$this->withfilereadonly)
 							{
 								$out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
@@ -1060,7 +1060,7 @@ class FormMail extends Form
 		if (!empty($this->withtocccreadonly)) {
 			$out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : "";
 		} else {
-		    $out .= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.(GETPOST("sendtoccc", "alpha") ? GETPOST("sendtoccc", "alpha") : ((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />';
+			$out .= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.(GETPOST("sendtoccc", "alpha") ? GETPOST("sendtoccc", "alpha") : ((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />';
 			if (!empty($this->withtoccc) && is_array($this->withtoccc)) {
 				$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
 				// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
@@ -1185,7 +1185,7 @@ class FormMail extends Form
 	 */
 	public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '')
 	{
-        $ret = new ModelMail();
+		$ret = new ModelMail();
 
 		if ($id == -2 && empty($label)) {
 			$this->error = 'LabelIsMandatoryWhenIdIs-2';
@@ -1253,6 +1253,8 @@ class FormMail extends Form
 					$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping");
 				} elseif ($type_template == 'fichinter_send') {
 					$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter");
+				} elseif ($type_template == 'actioncomm_send') {
+					$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendActionComm");
 				} elseif (!empty($type_template)) {
 					$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentGeneric");
 				}
@@ -1511,9 +1513,9 @@ class ModelMail
 	public $id;
 
 	/**
-     * @var string Model mail label
-     */
-    public $label;
+	 * @var string Model mail label
+	 */
+	public $label;
 
 	public $topic;
 	public $content;

+ 3 - 3
htdocs/core/class/html.formticket.class.php

@@ -993,9 +993,9 @@ class FormTicket
         $defaultmessage = str_replace('\n', "\n", $defaultmessage);
 
 		// Deal with format differences between message and signature (text / HTML)
-		if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) {
-			$this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']);
-		} elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) {
+		if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
+			$this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']);
+		} elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
 			$defaultmessage = dol_nl2br($defaultmessage);
 		}
 		if (isset($_POST["message"]) && !$_POST['modelselected']) {

+ 6 - 8
htdocs/core/class/menubase.class.php

@@ -184,7 +184,7 @@ class Menubase
         $this->position = (int) $this->position;
         $this->url = trim($this->url);
         $this->target = trim($this->target);
-        $this->titre = trim($this->titre);
+        $this->title = trim($this->title);
         $this->langs = trim($this->langs);
         $this->perms = trim($this->perms);
         $this->enabled = trim($this->enabled);
@@ -264,7 +264,7 @@ class Menubase
 		        $sql .= " ".((int) $this->position).",";
 		        $sql .= " '".$this->db->escape($this->url)."',";
 		        $sql .= " '".$this->db->escape($this->target)."',";
-		        $sql .= " '".$this->db->escape($this->titre)."',";
+		        $sql .= " '".$this->db->escape($this->title)."',";
 		        $sql .= " '".$this->db->escape($this->langs)."',";
 		        $sql .= " '".$this->db->escape($this->perms)."',";
 		        $sql .= " '".$this->db->escape($this->enabled)."',";
@@ -317,7 +317,7 @@ class Menubase
         $this->position = (int) $this->position;
         $this->url = trim($this->url);
         $this->target = trim($this->target);
-        $this->titre = trim($this->titre);
+        $this->title = trim($this->title);
         $this->langs = trim($this->langs);
         $this->perms = trim($this->perms);
         $this->enabled = trim($this->enabled);
@@ -339,7 +339,7 @@ class Menubase
         $sql .= " position=".($this->position > 0 ? $this->position : 0).",";
         $sql .= " url='".$this->db->escape($this->url)."',";
         $sql .= " target='".$this->db->escape($this->target)."',";
-        $sql .= " titre='".$this->db->escape($this->titre)."',";
+        $sql .= " titre='".$this->db->escape($this->title)."',";
         $sql .= " langs='".$this->db->escape($this->langs)."',";
         $sql .= " perms='".$this->db->escape($this->perms)."',";
         $sql .= " enabled='".$this->db->escape($this->enabled)."',";
@@ -383,7 +383,7 @@ class Menubase
         $sql .= " t.position,";
         $sql .= " t.url,";
         $sql .= " t.target,";
-        $sql .= " t.titre,";
+        $sql .= " t.titre as title,";
         $sql .= " t.langs,";
         $sql .= " t.perms,";
         $sql .= " t.enabled,";
@@ -414,7 +414,7 @@ class Menubase
                 $this->position = $obj->position;
                 $this->url = $obj->url;
                 $this->target = $obj->target;
-                $this->titre = $obj->titre;
+                $this->title = $obj->title;
                 $this->langs = $obj->langs;
                 $this->perms = $obj->perms;
                 $this->enabled = str_replace("\"", "'", $obj->enabled);
@@ -475,10 +475,8 @@ class Menubase
         $this->position = '';
         $this->url = 'http://dummy';
         $this->target = '';
-        $this->titre = 'Specimen menu'; // deprecated
         $this->title = 'Specimen menu';
         $this->langs = '';
-        $this->level = '';
         $this->leftmenu = '';
         $this->perms = '';
         $this->enabled = '';

+ 8 - 0
htdocs/core/lib/admin.lib.php

@@ -1769,6 +1769,14 @@ function email_admin_prepare_head()
 			$head[$h][2] = 'common_emailing';
 			$h++;
 		}
+
+		if ($conf->ticket->enabled)
+		{
+			$head[$h][0] = DOL_URL_ROOT."/admin/mails_ticket.php";
+			$head[$h][1] = $langs->trans("OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv("Ticket"));
+			$head[$h][2] = 'common_ticket';
+			$h++;
+		}
 	}
 
 	$head[$h][0] = DOL_URL_ROOT."/admin/mails_templates.php";

+ 21 - 21
htdocs/core/lib/ajax.lib.php

@@ -46,16 +46,16 @@
  */
 function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '')
 {
-    if (empty($minLength)) $minLength = 1;
+	if (empty($minLength)) $minLength = 1;
 
-    $dataforrenderITem = 'ui-autocomplete';
-    $dataforitem = 'ui-autocomplete-item';
-    // Allow two constant to use other values for backward compatibility
-    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
-    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM');
+	$dataforrenderITem = 'ui-autocomplete';
+	$dataforitem = 'ui-autocomplete-item';
+	// Allow two constant to use other values for backward compatibility
+	if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
+	if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM');
 
-    // Input search_htmlname is original field
-    // Input htmlname is a second input field used when using ajax autocomplete.
+	// Input search_htmlname is original field
+	// Input htmlname is a second input field used when using ajax autocomplete.
 	$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" '.($moreparams ? $moreparams : '').' />';
 
 	$script .= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
@@ -348,7 +348,7 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
 	$msg = '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">';
 	$msg .= $message;
 	$msg .= '</div>'."\n";
-    $msg .= '<script>
+	$msg .= '<script>
     jQuery(function() {
         jQuery("#dialog-info").dialog({
 	        resizable: false,
@@ -364,9 +364,9 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
 	});
 	</script>';
 
-    $msg .= "\n";
+	$msg .= "\n";
 
-    return $msg;
+	return $msg;
 }
 
 
@@ -397,8 +397,8 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
 
 	if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0;
 
-    $tmpplugin = 'select2';
-    $msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
+	$tmpplugin = 'select2';
+	$msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
           <script>
         	$(document).ready(function () {
         		$(\''.(preg_match('/^\./', $htmlname) ? $htmlname : '#'.$htmlname).'\').'.$tmpplugin.'({
@@ -477,9 +477,9 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
 	}
 
 	$msg .= '});'."\n";
-    $msg .= "</script>\n";
+	$msg .= "</script>\n";
 
-    return $msg;
+	return $msg;
 }
 
 /**
@@ -500,7 +500,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
 	global $conf, $langs, $user;
 
 	$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
-	if (! isset($input)) $input = array();
+	if (!isset($input)) $input = array();
 
 	if (empty($conf->use_javascript_ajax) || $forcenoajax)
 	{
@@ -566,9 +566,9 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
  */
 function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array())
 {
-    global $langs;
+	global $langs;
 
-    $out = '<script>
+	$out = '<script>
         $(function() {
             var input = '.json_encode($input).';
 
@@ -633,8 +633,8 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
             });
         });
     </script>';
-    $out .= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
-    $out .= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>';
+	$out .= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
+	$out .= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>';
 
-    return $out;
+	return $out;
 }

Разлика између датотеке није приказан због своје велике величине
+ 512 - 512
htdocs/core/lib/company.lib.php


+ 10 - 10
htdocs/core/lib/expedition.lib.php

@@ -60,9 +60,9 @@ function expedition_prepare_head(Expedition $object)
 
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'order');
 
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**
@@ -95,18 +95,18 @@ function expedition_admin_prepare_head()
 
 	if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFields");
-	    $head[$h][2] = 'attributes_shipment';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFields");
+		$head[$h][2] = 'attributes_shipment';
+		$h++;
 	}
 
 	if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFieldsLines");
-	    $head[$h][2] = 'attributeslines_shipment';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFieldsLines");
+		$head[$h][2] = 'attributeslines_shipment';
+		$h++;
 	}
 
 	if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON))

+ 4 - 4
htdocs/core/lib/files.lib.php

@@ -958,11 +958,11 @@ function dolCheckVirus($src_file)
 		if (!class_exists('AntiVir')) {
 			require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php';
 		}
-		$antivir=new AntiVir($db);
+		$antivir = new AntiVir($db);
 		$result = $antivir->dol_avscan_file($src_file);
 		if ($result < 0)	// If virus or error, we stop here
 		{
-			$reterrors=$antivir->errors;
+			$reterrors = $antivir->errors;
 			return $reterrors;
 		}
 	}
@@ -1049,7 +1049,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
 		{
 			// $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too.
 			$publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity];
-			if (! preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash.='/';
+			if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/';
 
 			if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) {	// We never add .noexe on files into media directory
 				$file_name .= '.noexe';
@@ -2771,7 +2771,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
 		if (preg_match('/^specimen/i', $original_file))	$accessallowed = 1; // If link to a file called specimen. Test must be done before changing $original_file int full path.
 		if ($fuser->admin) $accessallowed = 1; // If user is admin
 		$tmpmodulepart = explode('-', $modulepart);
-		if (! empty($tmpmodulepart[1])) {
+		if (!empty($tmpmodulepart[1])) {
 				$modulepart = $tmpmodulepart[0];
 				$original_file = $tmpmodulepart[1].'/'.$original_file;
 		}

Разлика између датотеке није приказан због своје велике величине
+ 341 - 341
htdocs/core/lib/functions.lib.php


Разлика између датотеке није приказан због своје велике величине
+ 463 - 463
htdocs/core/lib/functions2.lib.php


+ 1 - 1
htdocs/core/lib/functionsnumtoword.lib.php

@@ -259,7 +259,7 @@ function hundreds2text($hundreds, $tens, $units)
 	$decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA ");
 	$veintis = array("VEINTE", "VEINTIUN", "VEINTID&OacuteS", "VEINTITR&EacuteS", "VEINTICUATRO", "VEINTICINCO", "VEINTIS&EacuteIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE");
 	$diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECIS&EacuteIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE");
-    $unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
+	$unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
 	$entexto = "";
 	if ($hundreds != 0) {
 		$entexto .= $centenas[$hundreds - 1];

+ 19 - 19
htdocs/core/lib/hrm.lib.php

@@ -43,8 +43,8 @@ function establishment_prepare_head($object)
 
 	// Show more tabs from modules
 	// Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment');
 
 	$head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id;
@@ -64,30 +64,30 @@ function establishment_prepare_head($object)
  */
 function hrm_admin_prepare_head()
 {
-    global $langs, $conf, $user;
+	global $langs, $conf, $user;
 
-    $langs->load('hrm');
+	$langs->load('hrm');
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
 	$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_hrm.php';
-    $head[$h][1] = $langs->trans("Parameters");
-    $head[$h][2] = 'parameters';
-    $h++;
+	$head[$h][1] = $langs->trans("Parameters");
+	$head[$h][2] = 'parameters';
+	$h++;
 
 	$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php';
-    $head[$h][1] = $langs->trans("Establishments");
-    $head[$h][2] = 'establishments';
-    $h++;
+	$head[$h][1] = $langs->trans("Establishments");
+	$head[$h][2] = 'establishments';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin');
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove');
 
-    return $head;
+	return $head;
 }

+ 84 - 84
htdocs/core/lib/images.lib.php

@@ -40,39 +40,39 @@ function image_format_supported($file, $acceptsvg = 0)
 {
 	global $conf;
 
-    $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
-    if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
-    	$regeximgext .= '|\.svg';		// Not allowed by default. SVG can contains javascript
-    }
-
-    // Case filename is not a format image
-    $reg = array();
-    if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1;
-
-    // Case filename is a format image but not supported by this PHP
-    $imgfonction = '';
-    if (strtolower($reg[1]) == '.gif')  $imgfonction = 'imagecreatefromgif';
-    if (strtolower($reg[1]) == '.jpg')  $imgfonction = 'imagecreatefromjpeg';
-    if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
-    if (strtolower($reg[1]) == '.png')  $imgfonction = 'imagecreatefrompng';
-    if (strtolower($reg[1]) == '.bmp')  $imgfonction = 'imagecreatefromwbmp';
-    if (strtolower($reg[1]) == '.webp')  $imgfonction = 'imagecreatefromwebp';
-    if (strtolower($reg[1]) == '.xpm')  $imgfonction = 'imagecreatefromxpm';
-    if (strtolower($reg[1]) == '.xbm')  $imgfonction = 'imagecreatefromxbm';
-    if (strtolower($reg[1]) == '.svg')  $imgfonction = 'imagecreatefromsvg'; // Never available
-    if ($imgfonction)
-    {
-        if (!function_exists($imgfonction))
-        {
-            // Fonctions of conversion not available in this PHP
-            return 0;
-        }
-
-        // Filename is a format image and supported for conversion by this PHP
-        return 1;
-    }
-
-    return 0;
+	$regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
+	if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
+		$regeximgext .= '|\.svg';		// Not allowed by default. SVG can contains javascript
+	}
+
+	// Case filename is not a format image
+	$reg = array();
+	if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1;
+
+	// Case filename is a format image but not supported by this PHP
+	$imgfonction = '';
+	if (strtolower($reg[1]) == '.gif')  $imgfonction = 'imagecreatefromgif';
+	if (strtolower($reg[1]) == '.jpg')  $imgfonction = 'imagecreatefromjpeg';
+	if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
+	if (strtolower($reg[1]) == '.png')  $imgfonction = 'imagecreatefrompng';
+	if (strtolower($reg[1]) == '.bmp')  $imgfonction = 'imagecreatefromwbmp';
+	if (strtolower($reg[1]) == '.webp')  $imgfonction = 'imagecreatefromwebp';
+	if (strtolower($reg[1]) == '.xpm')  $imgfonction = 'imagecreatefromxpm';
+	if (strtolower($reg[1]) == '.xbm')  $imgfonction = 'imagecreatefromxbm';
+	if (strtolower($reg[1]) == '.svg')  $imgfonction = 'imagecreatefromsvg'; // Never available
+	if ($imgfonction)
+	{
+		if (!function_exists($imgfonction))
+		{
+			// Fonctions of conversion not available in this PHP
+			return 0;
+		}
+
+		// Filename is a format image and supported for conversion by this PHP
+		return 1;
+	}
+
+	return 0;
 }
 
 
@@ -97,9 +97,9 @@ function dol_getImageSize($file, $url = false)
 
 	if ($filetoread)
 	{
-    	$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
-    	$ret['width'] = $infoImg[0]; // Largeur de l'image
-    	$ret['height'] = $infoImg[1]; // Hauteur de l'image
+		$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
+		$ret['width'] = $infoImg[0]; // Largeur de l'image
+		$ret['height'] = $infoImg[1]; // Hauteur de l'image
 	}
 
 	return $ret;
@@ -305,7 +305,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
 	if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
 
 	// Free memory. This does not delete image.
-    imagedestroy($img);
+	imagedestroy($img);
 	imagedestroy($imgThumb);
 
 	clearstatcache(); // File was replaced by a modified one, so we clear file caches.
@@ -441,20 +441,20 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 	} elseif (!file_exists($file))
 	{
 		// Si le fichier passe en parametre n'existe pas
-        dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR);
-	    return $langs->trans("ErrorFileNotFound", $file);
+		dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR);
+		return $langs->trans("ErrorFileNotFound", $file);
 	} elseif (image_format_supported($file) < 0)
 	{
-        dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING);
-	    return 'ErrorBadImageFormat';
+		dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING);
+		return 'ErrorBadImageFormat';
 	} elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) {
 		// Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
-        dol_syslog('Wrong value for parameter maxWidth', LOG_ERR);
-	    return 'Error: Wrong value for parameter maxWidth';
+		dol_syslog('Wrong value for parameter maxWidth', LOG_ERR);
+		return 'Error: Wrong value for parameter maxWidth';
 	} elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) {
 		// Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
-        dol_syslog('Wrong value for parameter maxHeight', LOG_ERR);
-	    return 'Error: Wrong value for parameter maxHeight';
+		dol_syslog('Wrong value for parameter maxHeight', LOG_ERR);
+		return 'Error: Wrong value for parameter maxHeight';
 	}
 
 	$filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image
@@ -495,7 +495,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			$imgfonction = 'imagecreatefrompng';
 			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
+			// Not supported by PHP GD
 			break;
 		case IMAGETYPE_WBMP:	// 15
 			$imgfonction = 'imagecreatefromwbmp';
@@ -531,7 +531,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			$extImg = '.png';
 			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
+			// Not supported by PHP GD
 			$extImg = '.bmp';
 			break;
 		case IMAGETYPE_WBMP:	// 15
@@ -540,14 +540,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			break;
 	}
 
-    if (!is_resource($img))
-    {
-        dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
-        return 0;
-    }
+	if (!is_resource($img))
+	{
+		dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
+		return 0;
+	}
 
 	$exifAngle = false;
-    if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) {
+	if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) {
 		switch ($ort)
 		{
 			case 3: // 180 rotate left
@@ -568,12 +568,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 		}
 	}
 
-    if ($exifAngle)
-    {
+	if ($exifAngle)
+	{
 		$rotated = false;
 
-    	if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case
-    	{
+		if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case
+		{
 			imagealphablending($img, false);
 			imagesavealpha($img, true);
 			$rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127));
@@ -583,9 +583,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			$rotated = imagerotate($img, $exifAngle, 0);
 		}
 
-    	// replace image with good orientation
-    	if (!empty($rotated)) {
-    		$img = $rotated;
+		// replace image with good orientation
+		if (!empty($rotated)) {
+			$img = $rotated;
 			$imgWidth = $trueImgWidth;
 			$imgHeight = $trueImgHeight;
 		}
@@ -612,8 +612,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 	$thumbHeight = round($thumbHeight);
 	$thumbWidth = round($thumbWidth);
 
-    // Define target format
-    if (empty($targetformat)) $targetformat = $infoImg[2];
+	// Define target format
+	if (empty($targetformat)) $targetformat = $infoImg[2];
 
 	// Create empty image
 	if ($targetformat == IMAGETYPE_GIF)
@@ -643,31 +643,31 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 		case IMAGETYPE_GIF:	    // 1
 			$trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
 			imagecolortransparent($imgThumb, $trans_colour);
-            $extImgTarget = '.gif';
-            $newquality = 'NU';
-            break;
+			$extImgTarget = '.gif';
+			$newquality = 'NU';
+			break;
 		case IMAGETYPE_JPEG:    // 2
-            $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
-            $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg');
-            $newquality = $quality;
-            break;
+			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
+			$extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg');
+			$newquality = $quality;
+			break;
 		case IMAGETYPE_PNG:	    // 3
 			imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme
 			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel
-            $extImgTarget = '.png';
-            $newquality = $quality - 100;
-            $newquality = round(abs($quality - 100) * 9 / 100);
-            break;
+			$extImgTarget = '.png';
+			$newquality = $quality - 100;
+			$newquality = round(abs($quality - 100) * 9 / 100);
+			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
-            $extImgTarget = '.bmp';
-            $newquality = 'NU';
-            break;
+			// Not supported by PHP GD
+			$extImgTarget = '.bmp';
+			$newquality = 'NU';
+			break;
 		case IMAGETYPE_WBMP:	// 15
 			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
-            $extImgTarget = '.bmp';
-            $newquality = 'NU';
-            break;
+			$extImgTarget = '.bmp';
+			$newquality = 'NU';
+			break;
 	}
 	if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
 
@@ -698,7 +698,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			imagepng($imgThumb, $imgThumbName, $newquality);
 			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
+			// Not supported by PHP GD
 			break;
 		case IMAGETYPE_WBMP:    // 15
 			imagewbmp($imgThumb, $imgThumbName);
@@ -708,9 +708,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 	// Set permissions on file
 	if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
 
-    // Free memory. This does not delete image.
-    imagedestroy($img);
-    imagedestroy($imgThumb);
+	// Free memory. This does not delete image.
+	imagedestroy($img);
+	imagedestroy($imgThumb);
 
 	return $imgThumbName;
 }

+ 111 - 111
htdocs/core/lib/member.lib.php

@@ -63,46 +63,46 @@ function member_prepare_head(Adherent $object)
 		$h++;
 	}
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
-
-    $nbNote = 0;
-    if (!empty($object->note)) $nbNote++;
-    if (!empty($object->note_private)) $nbNote++;
-    if (!empty($object->note_public)) $nbNote++;
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
+
+	$nbNote = 0;
+	if (!empty($object->note)) $nbNote++;
+	if (!empty($object->note_private)) $nbNote++;
+	if (!empty($object->note_public)) $nbNote++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
 	$head[$h][1] = $langs->trans("Note");
 	$head[$h][2] = 'note';
-    if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
+	if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
 	$h++;
 
-    // Attachments
-    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-    $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
-    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
-    $nbLinks = Link::count($db, $object->element, $object->id);
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
-    $head[$h][1] = $langs->trans('Documents');
-    if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
-    $head[$h][2] = 'document';
-    $h++;
+	// Attachments
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+	$upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+	$nbLinks = Link::count($db, $object->element, $object->id);
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
+	$head[$h][1] = $langs->trans('Documents');
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
+	$head[$h][2] = 'document';
+	$h++;
 
 	// Show agenda tab
 	if (!empty($conf->agenda->enabled))
 	{
-	    $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
-	    $head[$h][1] = $langs->trans("Events");
-	    if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
-	    {
-	        $head[$h][1] .= '/';
-	        $head[$h][1] .= $langs->trans("Agenda");
-	    }
-	    $head[$h][2] = 'agenda';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
+		$head[$h][1] = $langs->trans("Events");
+		if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
+		{
+			$head[$h][1] .= '/';
+			$head[$h][1] .= $langs->trans("Agenda");
+		}
+		$head[$h][2] = 'agenda';
+		$h++;
 	}
 
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
@@ -148,11 +148,11 @@ function member_type_prepare_head(AdherentType $object)
 		$h++;
 	}
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
 
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
 
@@ -166,45 +166,45 @@ function member_type_prepare_head(AdherentType $object)
  */
 function member_admin_prepare_head()
 {
-    global $langs, $conf, $user;
+	global $langs, $conf, $user;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
-    $head[$h][1] = $langs->trans("Miscellaneous");
-    $head[$h][2] = 'general';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
+	$head[$h][1] = $langs->trans("Miscellaneous");
+	$head[$h][2] = 'general';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
-    $head[$h][1] = $langs->trans("EMails");
-    $head[$h][2] = 'emails';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
+	$head[$h][1] = $langs->trans("EMails");
+	$head[$h][2] = 'emails';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
-    $head[$h][1] = $langs->trans("ExtraFieldsMember");
-    $head[$h][2] = 'attributes';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
+	$head[$h][1] = $langs->trans("ExtraFieldsMember");
+	$head[$h][2] = 'attributes';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
-    $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
-    $head[$h][2] = 'attributes_type';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
+	$head[$h][1] = $langs->trans("ExtraFieldsMemberType");
+	$head[$h][2] = 'attributes_type';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
-    $head[$h][1] = $langs->trans("BlankSubscriptionForm");
-    $head[$h][2] = 'website';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
+	$head[$h][1] = $langs->trans("BlankSubscriptionForm");
+	$head[$h][2] = 'website';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
 
-    return $head;
+	return $head;
 }
 
 
@@ -216,50 +216,50 @@ function member_admin_prepare_head()
  */
 function member_stats_prepare_head($object)
 {
-    global $langs, $conf, $user;
-
-    $h = 0;
-    $head = array();
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
-    $head[$h][1] = $langs->trans("Subscriptions");
-    $head[$h][2] = 'statssubscription';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
-    $head[$h][1] = $langs->trans("Country");
-    $head[$h][2] = 'statscountry';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
-    $head[$h][1] = $langs->trans("Region");
-    $head[$h][2] = 'statsregion';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
-    $head[$h][1] = $langs->trans("State");
-    $head[$h][2] = 'statsstate';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
-    $head[$h][1] = $langs->trans('Town');
-    $head[$h][2] = 'statstown';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
-    $head[$h][1] = $langs->trans('ByProperties');
-    $head[$h][2] = 'statsbyproperties';
-    $h++;
-
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
-
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
-
-    return $head;
+	global $langs, $conf, $user;
+
+	$h = 0;
+	$head = array();
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
+	$head[$h][1] = $langs->trans("Subscriptions");
+	$head[$h][2] = 'statssubscription';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
+	$head[$h][1] = $langs->trans("Country");
+	$head[$h][2] = 'statscountry';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
+	$head[$h][1] = $langs->trans("Region");
+	$head[$h][2] = 'statsregion';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
+	$head[$h][1] = $langs->trans("State");
+	$head[$h][2] = 'statsstate';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
+	$head[$h][1] = $langs->trans('Town');
+	$head[$h][2] = 'statstown';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
+	$head[$h][1] = $langs->trans('ByProperties');
+	$head[$h][2] = 'statsbyproperties';
+	$h++;
+
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
+
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
+
+	return $head;
 }
 
 /**

+ 9 - 9
htdocs/core/lib/multicurrency.lib.php

@@ -30,21 +30,21 @@
  */
 function multicurrencyAdminPrepareHead()
 {
-    global $langs, $conf;
+	global $langs, $conf;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1);
-    $head[$h][1] = $langs->trans("Parameters");
-    $head[$h][2] = 'settings';
-    $h++;
+	$head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1);
+	$head[$h][1] = $langs->trans("Parameters");
+	$head[$h][2] = 'settings';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency');
 
 	complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**

+ 24 - 24
htdocs/core/lib/reception.lib.php

@@ -49,18 +49,18 @@ function reception_prepare_head(Reception $object)
 
 	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
 	{
-	    $objectsrc = $object;
-	    if ($object->origin == 'commande' && $object->origin_id > 0)
-	    {
-	        $objectsrc = new Commande($db);
-	        $objectsrc->fetch($object->origin_id);
-	    }
-	    $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
-	    $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
-    	$head[$h][1] = $langs->trans("ContactsAddresses");
+		$objectsrc = $object;
+		if ($object->origin == 'commande' && $object->origin_id > 0)
+		{
+			$objectsrc = new Commande($db);
+			$objectsrc->fetch($object->origin_id);
+		}
+		$nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
+		$head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
+		$head[$h][1] = $langs->trans("ContactsAddresses");
 		if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
-    	$head[$h][2] = 'contact';
-    	$h++;
+		$head[$h][2] = 'contact';
+		$h++;
 	}
 
 	// Show more tabs from modules
@@ -69,18 +69,18 @@ function reception_prepare_head(Reception $object)
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception');
 
-    $nbNote = 0;
-    if (!empty($object->note_private)) $nbNote++;
-    if (!empty($object->note_public)) $nbNote++;
+	$nbNote = 0;
+	if (!empty($object->note_private)) $nbNote++;
+	if (!empty($object->note_public)) $nbNote++;
 	$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
 	$head[$h][1] = $langs->trans("Notes");
 	if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
 	$head[$h][2] = 'note';
 	$h++;
 
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**
@@ -105,18 +105,18 @@ function reception_admin_prepare_head()
 
 	if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFields");
-	    $head[$h][2] = 'attributes_reception';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFields");
+		$head[$h][2] = 'attributes_reception';
+		$h++;
 	}
 
 	if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFieldsLines");
-	    $head[$h][2] = 'attributeslines_reception';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFieldsLines");
+		$head[$h][2] = 'attributeslines_reception';
+		$h++;
 	}
 
 	complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');

+ 3 - 3
htdocs/core/lib/resource.lib.php

@@ -37,13 +37,13 @@ function resource_prepare_head($object)
 
 	$head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id;
 	$head[$h][1] = $langs->trans("ResourceCard");
-    $head[$h][2] = 'resource';
+	$head[$h][2] = 'resource';
 	$h++;
 
 	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)))
 	{
-	    $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
-	    $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
+		$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
+		$head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
 		$head[$h][1] = $langs->trans('ContactsAddresses');
 		if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
 		$head[$h][2] = 'contact';

+ 46 - 46
htdocs/core/lib/salaries.lib.php

@@ -27,41 +27,41 @@
  */
 function salaries_prepare_head($object)
 {
-    global $db, $langs, $conf;
+	global $db, $langs, $conf;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
-    $head[$h][1] = $langs->trans("SalaryPayment");
-    $head[$h][2] = 'card';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
+	$head[$h][1] = $langs->trans("SalaryPayment");
+	$head[$h][2] = 'card';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
 
-    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-    $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
-    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
-    $nbLinks = Link::count($db, $object->element, $object->id);
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
-    $head[$h][1] = $langs->trans('Documents');
-    if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge ">'.($nbFiles + $nbLinks).'</span>';
-    $head[$h][2] = 'documents';
-    $h++;
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+	$upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+	$nbLinks = Link::count($db, $object->element, $object->id);
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
+	$head[$h][1] = $langs->trans('Documents');
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge ">'.($nbFiles + $nbLinks).'</span>';
+	$head[$h][2] = 'documents';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
-    $head[$h][1] = $langs->trans("Info");
-    $head[$h][2] = 'info';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
+	$head[$h][1] = $langs->trans("Info");
+	$head[$h][2] = 'info';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**
@@ -71,28 +71,28 @@ function salaries_prepare_head($object)
  */
 function salaries_admin_prepare_head()
 {
-    global $langs, $conf, $user;
+	global $langs, $conf, $user;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
-    $head[$h][1] = $langs->trans("Miscellaneous");
-    $head[$h][2] = 'general';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
+	$head[$h][1] = $langs->trans("Miscellaneous");
+	$head[$h][2] = 'general';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
-    $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
-    $head[$h][2] = 'attributes';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
+	$head[$h][1] = $langs->trans("ExtraFieldsSalaries");
+	$head[$h][2] = 'attributes';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
 
-    return $head;
+	return $head;
 }

+ 2 - 2
htdocs/core/lib/security.lib.php

@@ -309,7 +309,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
 						break;
 					}
 				}
-			} elseif (!empty($feature))	{												// This is for permissions on 2 levels ('creer' or 'write')
+			} elseif (!empty($feature)) {												// This is for permissions on 2 levels ('creer' or 'write')
 				//print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; exit;
 				if (empty($user->rights->$feature->creer)
 				&& empty($user->rights->$feature->write)
@@ -541,7 +541,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
 			if ($feature == 'agenda')// Also check owner or attendee for users without allactions->read
 			{
 				if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
-					require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
+					require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 					$action = new ActionComm($db);
 					$action->fetch($objectid);
 					if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {

+ 1 - 1
htdocs/core/lib/takepos.lib.php

@@ -71,5 +71,5 @@ function takepos_admin_prepare_head()
 
 	complete_head_from_modules($conf, $langs, null, $head, $h, 'takepos_admin', 'remove');
 
-    return $head;
+	return $head;
 }

Разлика између датотеке није приказан због своје велике величине
+ 526 - 526
htdocs/core/lib/ticket.lib.php


+ 9 - 9
htdocs/core/menus/init_menu_auguria.sql

@@ -273,15 +273,15 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
 	-- Accounting period
 	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__,  'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__);
 	-- Binding
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled))', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_expensereport', 2400__+MAX_llx_menu__, '/accountancy/expensereport/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport', 'ExpenseReportsVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2421__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
-	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2422__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_expensereport', 2400__+MAX_llx_menu__, '/accountancy/expensereport/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_expensereport', 'ExpenseReportsVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2421__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
+	insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2422__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
 	-- Journals
 	--insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2705__+MAX_llx_menu__, 'accountancy', '', 2400__+MAX_llx_menu__, '', 'Journalization', 1, 'main', '$user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__);
 	--insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2707__+MAX_llx_menu__, 'accountancy', '', 2705__+MAX_llx_menu__, '/accountancy/journal/bankjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal=3', 'BankJournal', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__);

+ 6 - 3
htdocs/core/menus/standard/auguria.lib.php

@@ -385,10 +385,13 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t
 					$nature = '';
 
 					// Must match array $sourceList defined into journals_list.php
-					if ($objp->nature == 2 && ! empty($conf->facture->enabled)) $nature="sells";
-					if ($objp->nature == 3 && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled))) $nature="purchases";
+					if ($objp->nature == 2 && ! empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) $nature="sells";
+					if ($objp->nature == 3
+						&& (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled))
+						&& empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES))
+						$nature = "purchases";
 					if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank";
-					if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) $nature="expensereports";
+					if ($objp->nature == 5 && ! empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) $nature="expensereports";
 					if ($objp->nature == 1) $nature="various";
 					if ($objp->nature == 8) $nature="inventory";
 					if ($objp->nature == 9) $nature="hasnew";

Разлика између датотеке није приказан због своје велике величине
+ 299 - 296
htdocs/core/menus/standard/eldy.lib.php


+ 0 - 1
htdocs/core/modules/DolibarrModules.class.php

@@ -1867,7 +1867,6 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
             $menu->type = $this->menu[$key]['type'];
             $menu->mainmenu = isset($this->menu[$key]['mainmenu']) ? $this->menu[$key]['mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu : '');
             $menu->leftmenu = isset($this->menu[$key]['leftmenu']) ? $this->menu[$key]['leftmenu'] : '';
-            $menu->titre = $this->menu[$key]['titre']; // deprecated
             $menu->title = $this->menu[$key]['titre'];
             $menu->url = $this->menu[$key]['url'];
             $menu->langs = $this->menu[$key]['langs'];

+ 40 - 40
htdocs/core/modules/bank/doc/pdf_ban.modules.php

@@ -41,8 +41,8 @@ class pdf_ban extends ModeleBankAccountDoc
 	public $emetteur;
 
 	/**
-     * @var string Dolibarr version of the loaded document
-     */
+	 * @var string Dolibarr version of the loaded document
+	 */
 	public $version = 'development';
 
 	/**
@@ -50,12 +50,12 @@ class pdf_ban extends ModeleBankAccountDoc
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	 */
-    public function __construct($db)
+	public function __construct($db)
 	{
 		global $conf, $langs, $mysoc;
 
 		// Load translation files required by the page
-        $langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
+		$langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
 
 		$this->db = $db;
 		$this->name = "ban";
@@ -89,7 +89,7 @@ class pdf_ban extends ModeleBankAccountDoc
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Fonction generant le projet sur le disque
 	 *
@@ -97,9 +97,9 @@ class pdf_ban extends ModeleBankAccountDoc
 	 *	@param	Translate	$outputlangs	Lang output object
 	 *	@return	int         				1 if OK, <=0 if KO
 	 */
-    public function write_file($object, $outputlangs)
+	public function write_file($object, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $hookmanager, $langs, $user;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -113,16 +113,16 @@ class pdf_ban extends ModeleBankAccountDoc
 		{
 			//$nblines = count($object->lines);  // This is set later with array of tasks
 
-		    // Definition of $dir and $file
-		    if ($object->specimen)
-		    {
-		        $dir = $conf->bank->dir_output;
-		        $file = $dir."/SPECIMEN.pdf";
-		    } else {
-		        $objectref = dol_sanitizeFileName($object->ref);
-		        $dir = $conf->bank->dir_output."/".$objectref;
-		        $file = $dir."/".$objectref.".pdf";
-		    }
+			// Definition of $dir and $file
+			if ($object->specimen)
+			{
+				$dir = $conf->bank->dir_output;
+				$file = $dir."/SPECIMEN.pdf";
+			} else {
+				$objectref = dol_sanitizeFileName($object->ref);
+				$dir = $conf->bank->dir_output."/".$objectref;
+				$file = $dir."/".$objectref.".pdf";
+			}
 
 			if (!file_exists($dir))
 			{
@@ -146,20 +146,20 @@ class pdf_ban extends ModeleBankAccountDoc
 				global $action;
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -185,7 +185,7 @@ class pdf_ban extends ModeleBankAccountDoc
 				$tab_top = 50;
 				$tab_height = 200;
 				$tab_top_newpage = 40;
-                $tab_height_newpage = 210;
+				$tab_height_newpage = 210;
 
 				// Affiche notes
 				if (!empty($object->note_public))
@@ -246,8 +246,8 @@ class pdf_ban extends ModeleBankAccountDoc
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -280,12 +280,12 @@ class pdf_ban extends ModeleBankAccountDoc
 	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-    protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
+	protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
 	{
 		// phpcs:enable
 		global $conf, $mysoc;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@@ -310,7 +310,7 @@ class pdf_ban extends ModeleBankAccountDoc
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 		$posy = $this->marge_haute;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
@@ -321,8 +321,8 @@ class pdf_ban extends ModeleBankAccountDoc
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -376,7 +376,7 @@ class pdf_ban extends ModeleBankAccountDoc
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Project		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

+ 92 - 92
htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php

@@ -43,9 +43,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	public $emetteur;
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
@@ -53,7 +53,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	 */
-    public function __construct($db)
+	public function __construct($db)
 	{
 		global $conf, $langs, $mysoc;
 
@@ -88,22 +88,22 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
 	 *  Fonction generant le projet sur le disque
 	 *
 	 *	@param	    Project		$object   		    Object project a generer
 	 *	@param	    Translate	$outputlangs	    Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details (not used for this template)
-     *  @param		int			$hidedesc			Do not show desc (not used for this template)
-     *  @param		int			$hideref			Do not show ref (not used for this template)
-     *  @param      null|array  $moreparams         More parameters
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details (not used for this template)
+	 *  @param		int			$hidedesc			Do not show desc (not used for this template)
+	 *  @param		int			$hideref			Do not show ref (not used for this template)
+	 *  @param      null|array  $moreparams         More parameters
 	 *	@return	    int         				    1 if OK, <=0 if KO
 	 */
-    public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $hookmanager, $langs, $user, $mysoc;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -117,18 +117,18 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		{
 			//$nblines = count($object->lines);  // This is set later with array of tasks
 
-		    // Definition of $dir and $file
-		    if ($object->specimen)
-		    {
-		        if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
-		        else $dir = $conf->bank->dir_output;
-		        $file = $dir."/SPECIMEN.pdf";
-		    } else {
-		        $objectref = dol_sanitizeFileName($object->ref);
-		        if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
-		        else $dir = $conf->bank->dir_output."/".$objectref;
-		        $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
-		    }
+			// Definition of $dir and $file
+			if ($object->specimen)
+			{
+				if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
+				else $dir = $conf->bank->dir_output;
+				$file = $dir."/SPECIMEN.pdf";
+			} else {
+				$objectref = dol_sanitizeFileName($object->ref);
+				if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
+				else $dir = $conf->bank->dir_output."/".$objectref;
+				$file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
+			}
 
 			if (!file_exists($dir))
 			{
@@ -152,20 +152,20 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				global $action;
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -191,7 +191,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$tab_top = 50;
 				$tab_height = 200;
 				$tab_top_newpage = 40;
-                $tab_height_newpage = 210;
+				$tab_height_newpage = 210;
 
 				// Show notes
 				if (!empty($object->note_public))
@@ -271,7 +271,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$sepaname = '______________________________________________';
 				if ($thirdparty->id > 0)
 				{
-				    $sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : '');
+					$sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : '');
 				}
 				$posY = $pdf->GetY();
 				$posY += 3;
@@ -292,7 +292,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$address = '______________________________________________';
 				if ($thirdparty->id > 0)
 				{
-				    $address = $thirdparty->getFullAddress();
+					$address = $thirdparty->getFullAddress();
 				}
 				$posY = $pdf->GetY();
 				$posY += 1;
@@ -302,9 +302,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
 				if (preg_match('/_____/', $address))
 				{
-    				$posY += 6;
-    				$pdf->SetXY(80, $posY);
-    				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
+					$posY += 6;
+					$pdf->SetXY(80, $posY);
+					$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
 				}
 
 				$ban = '__________________________________________________';
@@ -346,10 +346,10 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
 				if (empty($object->frstrecur))
 				{
-    				$posY += 6;
-    				$pdf->SetXY(80, $posY);
-				    $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
-    				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
+					$posY += 6;
+					$pdf->SetXY(80, $posY);
+					$txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
+					$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
 				}
 
 				$posY = $pdf->GetY();
@@ -399,8 +399,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -433,12 +433,12 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-    protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
+	protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
 	{
 		// phpcs:enable
 		global $conf, $mysoc;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 	}
 
 
@@ -455,27 +455,27 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 */
 	protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
-        global $conf, $mysoc;
+		// phpcs:enable
+		global $conf, $mysoc;
 
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-	    $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
+		$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
 
-	    $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
+		$posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
 
-	    $pdf->SetXY($this->marge_gauche, $posy);
-	    $pdf->SetFont('', '', $default_font_size);
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
-	    $posy = $pdf->GetY() + 2;
+		$pdf->SetXY($this->marge_gauche, $posy);
+		$pdf->SetFont('', '', $default_font_size);
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
+		$posy = $pdf->GetY() + 2;
 
-	    $pdf->SetXY($this->marge_gauche, $posy);
-	    $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
-	    $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
+		$pdf->SetXY($this->marge_gauche, $posy);
+		$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+		$pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
 		$pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0);
 		$posy = $pdf->GetY() + 2;
 
-	    return $posy;
+		return $posy;
 	}
 
 
@@ -493,33 +493,33 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 */
 	protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
-	    $tab_top = $posy + 4;
-	    $tab_hl = 4;
+		// phpcs:enable
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
+		$tab_top = $posy + 4;
+		$tab_hl = 4;
 
-	    $posx = $this->marge_gauche;
-	    $pdf->SetXY($posx, $tab_top + 0);
+		$posx = $this->marge_gauche;
+		$pdf->SetXY($posx, $tab_top + 0);
 
-	    $pdf->SetFont('', '', $default_font_size - 2);
+		$pdf->SetFont('', '', $default_font_size - 2);
 
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
-	    $pdf->MultiCell(100, 3, ' ');
-	    $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
+		$pdf->MultiCell(100, 3, ' ');
+		$pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
 
-	    $posx = 120;
-	    $largcol = ($this->page_largeur - $this->marge_droite - $posx);
-	    $useborder = 0;
-	    $index = 0;
-	    // Total HT
-	    $pdf->SetFillColor(255, 255, 255);
-	    $pdf->SetXY($posx, $tab_top + 0);
-	    $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
+		$posx = 120;
+		$largcol = ($this->page_largeur - $this->marge_droite - $posx);
+		$useborder = 0;
+		$index = 0;
+		// Total HT
+		$pdf->SetFillColor(255, 255, 255);
+		$pdf->SetXY($posx, $tab_top + 0);
+		$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
 
-	    $pdf->SetXY($posx, $tab_top + $tab_hl);
-	    $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
+		$pdf->SetXY($posx, $tab_top + $tab_hl);
+		$pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
 
-	    return ($tab_hl * 7);
+		return ($tab_hl * 7);
 	}
 
 
@@ -545,7 +545,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 		$posy = $this->marge_haute;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
@@ -556,8 +556,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -578,7 +578,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		$daterum = '__________________';
 		if (!empty($object->date_rum))
 		{
-            $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
+			$daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
 		} else $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved.
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R');
 		/*$posy+=6;
@@ -616,7 +616,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Project		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

+ 89 - 89
htdocs/core/modules/cheque/doc/pdf_blochet.class.php

@@ -68,17 +68,17 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
 		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
 
-        // Retrieves transmitter
-        $this->emetteur = $mysoc;
-        if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
+		// Retrieves transmitter
+		$this->emetteur = $mysoc;
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
 
-        // Define column position
-        $this->line_height = 5;
+		// Define column position
+		$this->line_height = 5;
 		$this->line_per_page = 40;
 		$this->tab_height = 200; //$this->line_height * $this->line_per_page;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Fonction to generate document on disk
 	 *
@@ -86,19 +86,19 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	 *	@param	string			$_dir			Directory
 	 *	@param	string			$number			Number
 	 *	@param	Translate		$outputlangs	Lang output object
-     *	@return	int     						1=ok, 0=ko
+	 *	@return	int     						1=ok, 0=ko
 	 */
 	public function write_file($object, $_dir, $number, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $conf, $langs, $hookmanager;
 
-        if (!is_object($outputlangs)) $outputlangs = $langs;
-        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
-        $sav_charset_output = $outputlangs->charset_output;
-        if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
+		if (!is_object($outputlangs)) $outputlangs = $langs;
+		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+		$sav_charset_output = $outputlangs->charset_output;
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
 
-        // Load traductions files required by page
+		// Load traductions files required by page
 		$outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta"));
 
 		$dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number;
@@ -128,19 +128,19 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
 		// Create PDF instance
-        $pdf = pdf_getInstance($this->format);
-        $heightforinfotot = 50; // Height reserved to output the info and total part
-        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-        $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-        if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-        $pdf->SetAutoPageBreak(1, 0);
-
-        if (class_exists('TCPDF'))
-        {
-            $pdf->setPrintHeader(false);
-            $pdf->setPrintFooter(false);
-        }
-        $pdf->SetFont(pdf_getPDFFont($outputlangs));
+		$pdf = pdf_getInstance($this->format);
+		$heightforinfotot = 50; // Height reserved to output the info and total part
+		$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+		$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+		if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+		$pdf->SetAutoPageBreak(1, 0);
+
+		if (class_exists('TCPDF'))
+		{
+			$pdf->setPrintHeader(false);
+			$pdf->setPrintFooter(false);
+		}
+		$pdf->SetFont(pdf_getPDFFont($outputlangs));
 
 		$pdf->Open();
 		$pagenb = 0;
@@ -170,7 +170,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		}
 
 		$pdf->AddPage();
-        $pagenb++;
+		$pagenb++;
 		$this->Header($pdf, $pagenb, $pages, $outputlangs);
 
 		$this->Body($pdf, $pagenb, $pages, $outputlangs);
@@ -195,8 +195,8 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 		if ($reshook < 0)
 		{
-		    $this->error = $hookmanager->error;
-		    $this->errors = $hookmanager->errors;
+			$this->error = $hookmanager->error;
+			$this->errors = $hookmanager->errors;
 		}
 
 		if (!empty($conf->global->MAIN_UMASK))
@@ -204,12 +204,12 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 
 		$this->result = array('fullpath'=>$file);
 
-        $outputlangs->charset_output = $sav_charset_output;
-	    return 1; // No error
+		$outputlangs->charset_output = $sav_charset_output;
+		return 1; // No error
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Generate Header
 	 *
@@ -221,7 +221,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	 */
 	public function Header(&$pdf, $page, $pages, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $langs;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -230,47 +230,47 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 
 		$title = $outputlangs->transnoentities("CheckReceipt");
 		$pdf->SetFont('', 'B', $default_font_size);
-        $pdf->SetXY(10, 8);
-        $pdf->MultiCell(0, 2, $title, 0, 'L');
+		$pdf->SetXY(10, 8);
+		$pdf->MultiCell(0, 2, $title, 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 15);
+		$pdf->SetXY(10, 15);
 		$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Ref"), 0, 'L');
-        $pdf->SetXY(32, 15);
+		$pdf->SetXY(32, 15);
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L');
+		$pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 20);
-        $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L');
-        $pdf->SetXY(32, 20);
-        $pdf->SetFont('', '', $default_font_size);
-        $pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs));
+		$pdf->SetXY(10, 20);
+		$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L');
+		$pdf->SetXY(32, 20);
+		$pdf->SetFont('', '', $default_font_size);
+		$pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs));
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 26);
-        $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L');
+		$pdf->SetXY(10, 26);
+		$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L');
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(32, 26);
-        $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
+		$pdf->SetXY(32, 26);
+		$pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 32);
-        $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L');
-        pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
+		$pdf->SetXY(10, 32);
+		$pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L');
+		pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(114, 15);
+		$pdf->SetXY(114, 15);
 		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L');
 
-        $pdf->Rect(9, 14, 192, 35);
-        $pdf->line(9, 19, 112, 19);
-        $pdf->line(9, 25, 112, 25);
-        //$pdf->line(9, 31, 201, 31);
-        $pdf->line(9, 31, 112, 31);
+		$pdf->Rect(9, 14, 192, 35);
+		$pdf->line(9, 19, 112, 19);
+		$pdf->line(9, 25, 112, 25);
+		//$pdf->line(9, 31, 201, 31);
+		$pdf->line(9, 31, 112, 31);
 
-        $pdf->line(30, 14, 30, 49);
-        $pdf->line(112, 14, 112, 49);
+		$pdf->line(30, 14, 30, 49);
+		$pdf->line(112, 14, 112, 49);
 
 		// Number of cheques
 		$posy = 51;
@@ -284,11 +284,11 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L');
 
 		$pdf->SetFont('', 'B', $default_font_size);
-        $pdf->SetXY(57, $posy + 1);
-        $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L');
+		$pdf->SetXY(57, $posy + 1);
+		$pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(148, $posy + 1);
+		$pdf->SetXY(148, $posy + 1);
 		$pdf->MultiCell(40, 2, $langs->trans("Total"));
 
 		$pdf->SetFont('', 'B', $default_font_size);
@@ -302,11 +302,11 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
 
 		$pdf->SetXY(41, $this->tab_top + 2);
-        $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L');
+		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L');
 		$pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
 
-        $pdf->SetXY(101, $this->tab_top + 2);
-        $pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L');
+		$pdf->SetXY(101, $this->tab_top + 2);
+		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L');
 		$pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
 
 		$pdf->SetXY(180, $this->tab_top + 2);
@@ -317,7 +317,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Output array
 	 *
@@ -329,7 +329,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	 */
 	public function Body(&$pdf, $pagenb, $pages, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		// x=10 - Num
 		// x=30 - Banque
 		// x=100 - Emetteur
@@ -342,30 +342,30 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$num = count($this->lines);
 		for ($j = 0; $j < $num; $j++)
 		{
-            // Dynamic max line heigh calculation
-            $dynamic_line_height = array();
-            $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
-            $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
-            $max_line_height = max($dynamic_line_height);
-            // Calculate number of line used function of estimated line size
-            if ($max_line_height > $this->line_height) $nb_lines = floor($max_line_height / $this->line_height) + 1;
-            else $nb_lines = 1;
-
-            // Add page break if we do not have space to add current line
+			// Dynamic max line heigh calculation
+			$dynamic_line_height = array();
+			$dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
+			$dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
+			$max_line_height = max($dynamic_line_height);
+			// Calculate number of line used function of estimated line size
+			if ($max_line_height > $this->line_height) $nb_lines = floor($max_line_height / $this->line_height) + 1;
+			else $nb_lines = 1;
+
+			// Add page break if we do not have space to add current line
 			if ($lineinpage >= ($this->line_per_page - 1))
 			{
-			    $lineinpage = 0; $yp = 0;
-
-                // New page
-                $pdf->AddPage();
-                $pagenb++;
-                $this->Header($pdf, $pagenb, $pages, $outputlangs);
-                $pdf->SetFont('', '', $default_font_size - 1);
-                $pdf->MultiCell(0, 3, ''); // Set interline to 3
-                $pdf->SetTextColor(0, 0, 0);
+				$lineinpage = 0; $yp = 0;
+
+				// New page
+				$pdf->AddPage();
+				$pagenb++;
+				$this->Header($pdf, $pagenb, $pages, $outputlangs);
+				$pdf->SetFont('', '', $default_font_size - 1);
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
+				$pdf->SetTextColor(0, 0, 0);
 			}
 
-            $lineinpage += $nb_lines;
+			$lineinpage += $nb_lines;
 
 			$pdf->SetXY(1, $this->tab_top + 10 + $yp);
 			$pdf->MultiCell(8, $this->line_height, $j + 1, 0, 'R', 0);
@@ -382,14 +382,14 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 			$pdf->SetXY(180, $this->tab_top + 10 + $yp);
 			$pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0);
 
-            $yp = $yp + ($this->line_height * $nb_lines);
+			$yp = $yp + ($this->line_height * $nb_lines);
 		}
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param	TCPDF		$pdf     			PDF
 	 *  @param	Object		$object				Object to show
 	 *  @param	Translate	$outputlangs		Object lang for output
@@ -410,7 +410,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT';
 		if (!empty($conf->global->$paramfreetext))
 		{
-		    $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
+			$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
 		}
 
 		return pdf_pagefoot($pdf, $outputlangs, $newfreetext, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);

+ 104 - 104
htdocs/core/modules/contract/doc/pdf_strato.modules.php

@@ -41,70 +41,70 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 class pdf_strato extends ModelePDFContract
 {
 	/**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -160,21 +160,21 @@ class pdf_strato extends ModelePDFContract
 		$this->posxdesc = $this->marge_gauche + 1;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Function to build pdf onto disk
-     *
-     *  @param		CommonObject	$object				Id of object to generate
-     *  @param		object			$outputlangs		Lang output object
-     *  @param		string			$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int				$hidedetails		Do not show line details
-     *  @param		int				$hidedesc			Do not show desc
-     *  @param		int				$hideref			Do not show ref
-     *  @return		int									1=OK, 0=KO
-     */
-    public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
-    {
-        // phpcs:enable
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		CommonObject	$object				Id of object to generate
+	 *  @param		object			$outputlangs		Lang output object
+	 *  @param		string			$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int				$hidedetails		Do not show line details
+	 *  @param		int				$hidedesc			Do not show desc
+	 *  @param		int				$hideref			Do not show ref
+	 *  @return		int									1=OK, 0=KO
+	 */
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+	{
+		// phpcs:enable
 		global $user, $langs, $conf, $hookmanager, $mysoc;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -186,7 +186,7 @@ class pdf_strato extends ModelePDFContract
 
 		if ($conf->contrat->dir_output)
 		{
-            $object->fetch_thirdparty();
+			$object->fetch_thirdparty();
 
 			// Definition of $dir and $file
 			if ($object->specimen)
@@ -221,26 +221,26 @@ class pdf_strato extends ModelePDFContract
 				global $action;
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -341,12 +341,12 @@ class pdf_strato extends ModelePDFContract
 						}
 
 						$txtpredefinedservice = '';
-                        $txtpredefinedservice = $objectligne->product_label;
-                        if ($objectligne->product_label)
-                        {
-                        	$txtpredefinedservice .= ' - ';
-                        	$txtpredefinedservice .= $objectligne->product_label;
-                        }
+						$txtpredefinedservice = $objectligne->product_label;
+						if ($objectligne->product_label)
+						{
+							$txtpredefinedservice .= ' - ';
+							$txtpredefinedservice .= $objectligne->product_label;
+						}
 
 						$desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines)
 						$txt = '';
@@ -359,7 +359,7 @@ class pdf_strato extends ModelePDFContract
 						if (empty($conf->global->CONTRACT_HIDE_REAL_DATE_ON_PDF))
 						{
 							$txt .= '<br>';
-	                        $txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
+							$txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
 							if ($objectligne->date_cloture) $txt .= " - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
 						}
 
@@ -476,8 +476,8 @@ class pdf_strato extends ModelePDFContract
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -518,7 +518,7 @@ class pdf_strato extends ModelePDFContract
 		if ($hidetop) $hidetop = -1;
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
-        /*
+		/*
 		$pdf->SetXY($this->marge_gauche, $tab_top);
 		$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
 		$pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
@@ -548,16 +548,16 @@ class pdf_strato extends ModelePDFContract
 		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3); // Rect takes a length in 3rd parameter and 4th parameter
 	}
 
-    /**
-     * Show footer signature of page
-     * @param   TCPDF       $pdf            Object PDF
-     * @param   int         $tab_top        tab height position
-     * @param   int         $tab_height     tab height
-     * @param   Translate   $outputlangs    Object language for output
-     * @return void
-     */
+	/**
+	 * Show footer signature of page
+	 * @param   TCPDF       $pdf            Object PDF
+	 * @param   int         $tab_top        tab height position
+	 * @param   int         $tab_height     tab height
+	 * @param   Translate   $outputlangs    Object language for output
+	 * @return void
+	 */
 	protected function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
-    {
+	{
 		$pdf->SetDrawColor(128, 128, 128);
 		$posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2);
 		$posy = $tab_top + $tab_height + 3 + 3;
@@ -573,20 +573,20 @@ class pdf_strato extends ModelePDFContract
 
 		$pdf->SetXY($posmiddle + 5, $posy + 5);
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, '', 1);
-    }
+	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    /**
-     *  Show top header of page.
-     *
-     *  @param	TCPDF		$pdf     		Object PDF
-     *  @param  CommonObject	$object     	Object to show
-     *  @param  int	    	$showaddress    0=no, 1=yes
-     *  @param  Translate	$outputlangs	Object lang for output
-     *  @return	void
-     */
+	/**
+	 *  Show top header of page.
+	 *
+	 *  @param	TCPDF		$pdf     		Object PDF
+	 *  @param  CommonObject	$object     	Object to show
+	 *  @param  int	    	$showaddress    0=no, 1=yes
+	 *  @param  Translate	$outputlangs	Object lang for output
+	 *  @return	void
+	 */
 	protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
-    {
+	{
 		global $conf, $langs;
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -617,8 +617,8 @@ class pdf_strato extends ModelePDFContract
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -754,7 +754,7 @@ class pdf_strato extends ModelePDFContract
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	PDF			$pdf     			PDF
 	 * 		@param	CommonObject		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

Неке датотеке нису приказане због велике количине промена