Browse Source

Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
Scrutinizer Auto-Fixer 5 years ago
parent
commit
8a527631a0
100 changed files with 8278 additions and 8278 deletions
  1. 68 68
      htdocs/accountancy/admin/card.php
  2. 24 24
      htdocs/accountancy/admin/categories.php
  3. 28 28
      htdocs/accountancy/admin/export.php
  4. 31 31
      htdocs/accountancy/admin/fiscalyear.php
  5. 38 38
      htdocs/accountancy/admin/fiscalyear_card.php
  6. 59 59
      htdocs/accountancy/admin/index.php
  7. 48 48
      htdocs/accountancy/admin/productaccount.php
  8. 31 31
      htdocs/accountancy/bookkeeping/balancebymonth.php
  9. 29 29
      htdocs/accountancy/closure/index.php
  10. 35 35
      htdocs/accountancy/closure/validate.php
  11. 26 26
      htdocs/accountancy/customer/card.php
  12. 146 146
      htdocs/accountancy/customer/index.php
  13. 30 30
      htdocs/accountancy/expensereport/card.php
  14. 99 99
      htdocs/accountancy/expensereport/index.php
  15. 28 28
      htdocs/accountancy/supplier/card.php
  16. 109 109
      htdocs/accountancy/supplier/index.php
  17. 54 54
      htdocs/adherents/subscription/card.php
  18. 103 103
      htdocs/adherents/type.php
  19. 24 24
      htdocs/adherents/type_translation.php
  20. 26 26
      htdocs/admin/agenda.php
  21. 73 73
      htdocs/admin/bank.php
  22. 18 18
      htdocs/admin/dav.php
  23. 71 71
      htdocs/admin/defaultvalues.php
  24. 32 32
      htdocs/admin/delais.php
  25. 360 360
      htdocs/admin/dict.php
  26. 32 32
      htdocs/admin/ldap_groups.php
  27. 30 30
      htdocs/admin/ldap_members_types.php
  28. 7 7
      htdocs/admin/loan.php
  29. 101 101
      htdocs/admin/menus/edit.php
  30. 12 12
      htdocs/admin/multicurrency.php
  31. 43 43
      htdocs/admin/notification.php
  32. 11 11
      htdocs/admin/oauth.php
  33. 54 54
      htdocs/admin/oauthlogintokens.php
  34. 36 36
      htdocs/admin/pdf.php
  35. 40 40
      htdocs/admin/security.php
  36. 28 28
      htdocs/admin/security_file.php
  37. 35 35
      htdocs/admin/sms.php
  38. 73 73
      htdocs/admin/system/dolibarr.php
  39. 11 11
      htdocs/admin/system/index.php
  40. 6 6
      htdocs/admin/system/web.php
  41. 37 37
      htdocs/admin/ticket.php
  42. 34 34
      htdocs/admin/ticket_public.php
  43. 13 13
      htdocs/admin/website_options.php
  44. 23 23
      htdocs/admin/workflow.php
  45. 8 8
      htdocs/asset/admin/setup.php
  46. 69 69
      htdocs/asset/type.php
  47. 11 11
      htdocs/bom/admin/setup.php
  48. 15 15
      htdocs/cashdesk/admin/cashdesk.php
  49. 34 34
      htdocs/categories/traduction.php
  50. 337 337
      htdocs/comm/action/index.php
  51. 215 215
      htdocs/comm/index.php
  52. 69 69
      htdocs/comm/mailing/advtargetemailing.php
  53. 88 88
      htdocs/comm/mailing/cibles.php
  54. 20 20
      htdocs/comm/mailing/index.php
  55. 16 16
      htdocs/comm/multiprix.php
  56. 93 93
      htdocs/comm/propal/index.php
  57. 63 63
      htdocs/comm/prospect/index.php
  58. 35 35
      htdocs/comm/remise.php
  59. 277 277
      htdocs/comm/remx.php
  60. 117 117
      htdocs/commande/index.php
  61. 16 16
      htdocs/compta/bank/account_statement_document.php
  62. 117 117
      htdocs/compta/bank/card.php
  63. 305 305
      htdocs/compta/index.php
  64. 86 86
      htdocs/compta/sociales/payments.php
  65. 200 200
      htdocs/contact/card.php
  66. 29 29
      htdocs/core/lib/bank.lib.php
  67. 227 227
      htdocs/core/lib/company.lib.php
  68. 24 24
      htdocs/core/lib/doleditor.lib.php
  69. 248 248
      htdocs/core/lib/pdf.lib.php
  70. 213 213
      htdocs/core/lib/project.lib.php
  71. 92 92
      htdocs/core/lib/usergroups.lib.php
  72. 97 97
      htdocs/core/lib/website2.lib.php
  73. 191 191
      htdocs/core/menus/standard/eldy.lib.php
  74. 249 249
      htdocs/core/modules/facture/doc/pdf_crabe.modules.php
  75. 193 193
      htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
  76. 194 194
      htdocs/core/tpl/advtarget.tpl.php
  77. 4 4
      htdocs/core/tpl/document_actions_post_headers.tpl.php
  78. 12 12
      htdocs/datapolicy/admin/setup.php
  79. 43 43
      htdocs/expensereport/index.php
  80. 251 251
      htdocs/exports/export.php
  81. 10 10
      htdocs/exports/index.php
  82. 105 105
      htdocs/fichinter/card-rec.php
  83. 188 188
      htdocs/fichinter/card.php
  84. 81 81
      htdocs/fichinter/index.php
  85. 231 231
      htdocs/fourn/commande/dispatch.php
  86. 178 178
      htdocs/fourn/facture/paiement.php
  87. 33 33
      htdocs/holiday/month_report.php
  88. 14 14
      htdocs/hrm/admin/admin_hrm.php
  89. 247 247
      htdocs/imports/import.php
  90. 54 54
      htdocs/margin/checkMargins.php
  91. 76 76
      htdocs/margin/customerMargins.php
  92. 29 29
      htdocs/modulebuilder/admin/setup.php
  93. 20 20
      htdocs/modulebuilder/template/admin/setup.php
  94. 18 18
      htdocs/opensurvey/wizard/create_survey.php
  95. 135 135
      htdocs/projet/activity/index.php
  96. 203 203
      htdocs/projet/card.php
  97. 28 28
      htdocs/projet/comment.php
  98. 29 29
      htdocs/projet/graph_opportunities.inc.php
  99. 83 83
      htdocs/projet/stats/index.php
  100. 42 42
      htdocs/projet/tasks/stats/index.php

+ 68 - 68
htdocs/accountancy/admin/card.php

@@ -24,15 +24,15 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancysystem.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 $error = 0;
 
 // Load translation files required by the page
-$langs->loadLangs(array("bills","accountancy"));
+$langs->loadLangs(array("bills", "accountancy"));
 
 $mesg = '';
 $action = GETPOST('action', 'aZ09');
@@ -55,24 +55,24 @@ $object = new AccountingAccount($db);
 
 if (GETPOST('cancel', 'alpha'))
 {
-	$urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php', 1);
+	$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
 	header("Location: ".$urltogo);
 	exit;
 }
 
 if ($action == 'add' && $user->rights->accounting->chartofaccount)
 {
-	if (! $cancel) {
-		$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
+	if (!$cancel) {
+		$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
 
-		dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
+		dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
 		$result = $db->query($sql);
 		$obj = $db->fetch_object($result);
 
 		// Clean code
 
 		// To manage zero or not at the end of the accounting account
-		if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
+		if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
 		{
 			$account_number = GETPOST('account_number', 'string');
 		}
@@ -116,28 +116,28 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
 		    setEventMessages($object->error, $object->errors, 'errors');
 		    $action = "create";
 		}
-		if (! $error)
+		if (!$error)
 		{
 		    setEventMessages("RecordCreatedSuccessfully", null, 'mesgs');
-		    $urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php', 1);
+		    $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
 		    header("Location: ".$urltogo);
 		    exit;
 		}
 	}
 } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
-	if (! $cancel) {
+	if (!$cancel) {
 		$result = $object->fetch($id);
 
-		$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
+		$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
 
-		dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
+		dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
 		$result2 = $db->query($sql);
 		$obj = $db->fetch_object($result2);
 
 		// Clean code
 
 		// To manage zero or not at the end of the accounting account
-		if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
+		if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
 		{
 			$account_number = GETPOST('account_number', 'string');
 		}
@@ -166,21 +166,21 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
 		$result = $object->update($user);
 
 		if ($result > 0) {
-		    $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
-		    header("Location: " . $urltogo);
+		    $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
+		    header("Location: ".$urltogo);
 			exit();
 		} else {
 			$mesg = $object->error;
 		}
 	} else {
-	    $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
-	    header("Location: " . $urltogo);
+	    $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
+	    header("Location: ".$urltogo);
 		exit();
 	}
 } elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) {
 	$result = $object->fetch($id);
 
-	if (! empty($object->id)) {
+	if (!empty($object->id)) {
 		$result = $object->delete($user);
 
 		if ($result > 0) {
@@ -205,7 +205,7 @@ $formaccounting = new FormAccounting($db);
 $accountsystem = new AccountancySystem($db);
 $accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
 
-$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card');
+$title = $langs->trans('AccountAccounting')." - ".$langs->trans('Card');
 $helpurl = '';
 llxheader('', $title, $helpurl);
 
@@ -214,8 +214,8 @@ llxheader('', $title, $helpurl);
 if ($action == 'create') {
 	print load_fiche_titre($langs->trans('NewAccountingAccount'));
 
-	print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
-	print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+	print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<input type="hidden" name="action" value="add">';
 
 	dol_fiche_head();
@@ -223,41 +223,41 @@ if ($action == 'create') {
 	print '<table class="border centpercent">';
 
 	// Chart of account
-	print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("Chartofaccounts") . '</span></td>';
+	print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Chartofaccounts").'</span></td>';
 	print '<td>';
 	print $accountsystem->ref;
 	print '</td></tr>';
 
 	// Account number
-	print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
-	print '<td><input name="account_number" size="30" value="' . $accountingaccount . '"></td></tr>';
+	print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("AccountNumber").'</span></td>';
+	print '<td><input name="account_number" size="30" value="'.$accountingaccount.'"></td></tr>';
 
 	// Label
-	print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
-	print '<td><input name="label" size="70" value="' . $object->label . '"></td></tr>';
+	print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
+	print '<td><input name="label" size="70" value="'.$object->label.'"></td></tr>';
 
 	// Account parent
-	print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
+	print '<tr><td>'.$langs->trans("Accountparent").'</td>';
 	print '<td>';
 	print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
 	print '</td></tr>';
 
 	// Category
-	print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
+	print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
 	print '<td>';
 	$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
 	print '</td></tr>';
 
 	// Chart of accounts type
-	print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
+	print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
 	print '<td>';
-	print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type', 'alpha'):$object->pcg_type).'">';
+	print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
 	print '</td></tr>';
 
 	// Chart of acounts subtype
-	print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
+	print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
 	print '<td>';
-	print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$object->pcg_subtype).'">';
+	print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
 	print '</td></tr>';
 
 	print '</table>';
@@ -265,9 +265,9 @@ if ($action == 'create') {
 	dol_fiche_end();
 
 	print '<div class="center">';
-	print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
+	print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
 	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-	print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
+	print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
 	print '</div>';
 
 	print '</form>';
@@ -285,24 +285,24 @@ elseif ($id > 0 || $ref) {
 		{
 			dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
 
-			print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
-			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+			print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
+			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 			print '<input type="hidden" name="action" value="edit">';
-			print '<input type="hidden" name="id" value="' . $id . '">';
-			print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
+			print '<input type="hidden" name="id" value="'.$id.'">';
+			print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
 
 			print '<table class="border centpercent">';
 
 			// Account number
-			print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
-			print '<td><input name="account_number" size="30" value="' . $object->account_number . '"</td></tr>';
+			print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("AccountNumber").'</span></td>';
+			print '<td><input name="account_number" size="30" value="'.$object->account_number.'"</td></tr>';
 
 			// Label
-			print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
-			print '<td><input name="label" size="70" value="' . $object->label . '"</td></tr>';
+			print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
+			print '<td><input name="label" size="70" value="'.$object->label.'"</td></tr>';
 
 			// Account parent
-			print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
+			print '<tr><td>'.$langs->trans("Accountparent").'</td>';
 			print '<td>';
 			print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
 			print '</td></tr>';
@@ -314,15 +314,15 @@ elseif ($id > 0 || $ref) {
 			print '</td></tr>';
 
 			// Chart of accounts type
-			print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
+			print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
 			print '<td>';
-			print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type', 'alpha'):$object->pcg_type).'">';
+			print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
 			print '</td></tr>';
 
 			// Chart of accounts subtype
-			print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
+			print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
 			print '<td>';
-			print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$object->pcg_subtype).'">';
+			print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
 			print '</td></tr>';
 
 			print '</table>';
@@ -330,15 +330,15 @@ elseif ($id > 0 || $ref) {
 			dol_fiche_end();
 
 			print '<div class="center">';
-			print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
+			print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-			print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
+			print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
 			print '</div>';
 
 			print '</form>';
 		} else {
 			// View mode
-			$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
+			$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
 			dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
 
@@ -351,27 +351,27 @@ elseif ($id > 0 || $ref) {
 			print '<table class="border centpercent">';
 
 			// Label
-			print '<tr><td class="titlefield">' . $langs->trans("Label") . '</td>';
-			print '<td colspan="2">' . $object->label . '</td></tr>';
+			print '<tr><td class="titlefield">'.$langs->trans("Label").'</td>';
+			print '<td colspan="2">'.$object->label.'</td></tr>';
 
 			// Account parent
 			$accp = new AccountingAccount($db);
-			if (! empty($object->account_parent)) {
+			if (!empty($object->account_parent)) {
 				$accp->fetch($object->account_parent, '');
 			}
-			print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
-			print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
+			print '<tr><td>'.$langs->trans("Accountparent").'</td>';
+			print '<td colspan="2">'.$accp->account_number.' - '.$accp->label.'</td></tr>';
 
 			// Category
 			print "<tr><td>".$langs->trans("AccountingCategory")."</td><td colspan='2'>".$object->account_category_label."</td>";
 
 			// Chart of accounts type
-			print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
-			print '<td colspan="2">' . $object->pcg_type . '</td></tr>';
+			print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
+			print '<td colspan="2">'.$object->pcg_type.'</td></tr>';
 
 			// Chart of accounts subtype
-			print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
-			print '<td colspan="2">' . $object->pcg_subtype . '</td></tr>';
+			print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
+			print '<td colspan="2">'.$object->pcg_subtype.'</td></tr>';
 
 			print '</table>';
 
@@ -384,16 +384,16 @@ elseif ($id > 0 || $ref) {
 			 */
 			print '<div class="tabsAction">';
 
-			if (! empty($user->rights->accounting->chartofaccount)) {
-				print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
+			if (!empty($user->rights->accounting->chartofaccount)) {
+				print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$id.'">'.$langs->trans('Modify').'</a>';
 			} else {
-				print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Modify') . '</a>';
+				print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
 			}
 
-			if (! empty($user->rights->accounting->chartofaccount)) {
-				print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
+			if (!empty($user->rights->accounting->chartofaccount)) {
+				print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
 			} else {
-				print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Delete') . '</a>';
+				print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
 			}
 
 			print '</div>';

+ 24 - 24
htdocs/accountancy/admin/categories.php

@@ -23,14 +23,14 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 $error = 0;
 
 // Load translation files required by the page
-$langs->loadLangs(array("bills","accountancy"));
+$langs->loadLangs(array("bills", "accountancy"));
 
 $mesg = '';
 $id = GETPOST('id', 'int');
@@ -59,16 +59,16 @@ $accountingcategory = new AccountancyCategory($db);
  */
 
 // si ajout de comptes
-if (! empty($selectcpt)) {
+if (!empty($selectcpt)) {
 	$cpts = array();
 	foreach ($selectcpt as $selectedoption) {
-		if (! array_key_exists($selectedoption, $cpts))
-			$cpts[$selectedoption] = "'" . $selectedoption . "'";
+		if (!array_key_exists($selectedoption, $cpts))
+			$cpts[$selectedoption] = "'".$selectedoption."'";
 	}
 
-	$return= $accountingcategory->updateAccAcc($cat_id, $cpts);
+	$return = $accountingcategory->updateAccAcc($cat_id, $cpts);
 
-	if ($return<0) {
+	if ($return < 0) {
 		setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
 	} else {
 		setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs');
@@ -98,8 +98,8 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?res
 
 print load_fiche_titre($langs->trans('AccountingCategory'), $linkback);
 
-print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="display">';
 
 dol_fiche_head();
@@ -107,26 +107,26 @@ dol_fiche_head();
 print '<table class="border centpercent">';
 
 // Select the category
-print '<tr><td class="titlefield">' . $langs->trans("AccountingCategory") . '</td>';
+print '<tr><td class="titlefield">'.$langs->trans("AccountingCategory").'</td>';
 print '<td>';
 $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1);
-print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">';
+print '<input class="button" type="submit" value="'.$langs->trans("Select").'">';
 print '</td></tr>';
 
 // Select the accounts
-if (! empty($cat_id))
+if (!empty($cat_id))
 {
 	$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
 	if ($return < 0) {
 		setEventMessages(null, $accountingcategory->errors, 'errors');
 	}
-	print '<tr><td>' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . '</td>';
+	print '<tr><td>'.$langs->trans("AddAccountFromBookKeepingWithNoCategories").'</td>';
 	print '<td>';
 
-	$arraykeyvalue=array();
-	foreach($accountingcategory->lines_cptbk as $key => $val)
+	$arraykeyvalue = array();
+	foreach ($accountingcategory->lines_cptbk as $key => $val)
 	{
-		$arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte) . ' (' . $val->label_compte . ($val->doc_ref?' '.$val->doc_ref:'').')';
+		$arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte).' ('.$val->label_compte.($val->doc_ref ? ' '.$val->doc_ref : '').')';
 	}
 
 	if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
@@ -139,7 +139,7 @@ if (! empty($cat_id))
 		print '</select><br>';
 		print ajax_combobox('cpt_bk');
 		*/
-		print '<input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("Add") . '"> ';
+		print '<input class="button" type="submit" id="" class="action-delete" value="'.$langs->trans("Add").'"> ';
 	}
 	print '</td></tr>';
 }
@@ -158,8 +158,8 @@ if ($action == 'display' || $action == 'delete') {
 	print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>";
 	print "</tr>\n";
 
-	if (! empty($cat_id)) {
-		$return = $accountingcategory->display($cat_id);	// This load ->lines_display
+	if (!empty($cat_id)) {
+		$return = $accountingcategory->display($cat_id); // This load ->lines_display
 		if ($return < 0) {
 			setEventMessages(null, $accountingcategory->errors, 'errors');
 		}
@@ -167,10 +167,10 @@ if ($action == 'display' || $action == 'delete') {
 		if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
 			foreach ($accountingcategory->lines_display as $cpt) {
 				print '<tr class="oddeven">';
-				print '<td>' . length_accountg($cpt->account_number) . '</td>';
-				print '<td>' . $cpt->label . '</td>';
+				print '<td>'.length_accountg($cpt->account_number).'</td>';
+				print '<td>'.$cpt->label.'</td>';
 				print '<td class="right">';
-				print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=" . $cat_id . "&cptid=" . $cpt->rowid."'>";
+				print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=".$cat_id."&cptid=".$cpt->rowid."'>";
 				print $langs->trans("DeleteFromCat");
 				print img_picto($langs->trans("DeleteFromCat"), 'unlink');
 				print "</a>";

+ 28 - 28
htdocs/accountancy/admin/export.php

@@ -28,12 +28,12 @@
  */
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","bills","admin","accountancy"));
+$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
 
 // Security access
 if (empty($user->rights->accounting->chartofaccount))
@@ -57,7 +57,7 @@ $listformat = $configuration['format'];
 $listcr = $configuration['cr'];
 
 
-$model_option = array (
+$model_option = array(
     '1' => array(
         'label' => 'ACCOUNTING_EXPORT_FORMAT',
         'param' => $listformat,
@@ -86,37 +86,37 @@ if ($action == 'update') {
 
 	$modelcsv = GETPOST('ACCOUNTING_EXPORT_MODELCSV', 'int');
 
-	if (! empty($modelcsv)) {
-		if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
-			$error ++;
+	if (!empty($modelcsv)) {
+		if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
+			$error++;
 		}
 		//if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) {
 		//	dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity);
 		//}
 	} else {
-		$error ++;
+		$error++;
 	}
 
 	foreach ($main_option as $constname) {
 		$constvalue = GETPOST($constname, 'alpha');
 
-		if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
-			$error ++;
+		if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
+			$error++;
 		}
 	}
 
     foreach ($listparam[$modelcsv] as $key => $value) {
         $constante = $key;
 
-        if (strpos($constante, 'ACCOUNTING')!==false) {
+        if (strpos($constante, 'ACCOUNTING') !== false) {
             $constvalue = GETPOST($key, 'alpha');
-            if (! dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
-                $error ++;
+            if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
+                $error++;
             }
         }
     }
 
-	if (! $error) {
+	if (!$error) {
         // reload
         $configuration = AccountancyExport::getTypeConfig();
         $listparam = $configuration['param'];
@@ -138,7 +138,7 @@ $title = $langs->trans('ConfigAccountingExpert');
 llxHeader('', $title);
 
 
-$linkback='';
+$linkback = '';
 // $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
 print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy');
 
@@ -187,8 +187,8 @@ print '    });'."\n";
 print '})'."\n";
 print '</script>'."\n";
 
-print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="update">';
 
 /*
@@ -197,7 +197,7 @@ print '<input type="hidden" name="action" value="update">';
 
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td colspan="3">' . $langs->trans('Options') . '</td>';
+print '<td colspan="3">'.$langs->trans('Options').'</td>';
 print "</tr>\n";
 
 $num = count($main_option);
@@ -207,11 +207,11 @@ if ($num) {
 
 		// Param
 		$label = $langs->trans($key);
-		print '<td width="50%">' . $label . '</td>';
+		print '<td width="50%">'.$label.'</td>';
 
 		// Value
 		print '<td>';
-		print '<input type="text" size="20" id="'.$key.'" name="' . $key . '" value="' . $conf->global->$key . '">';
+		print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
 		print '</td></tr>';
 	}
 }
@@ -226,13 +226,13 @@ print "<br>\n";
 print '<table class="noborder centpercent">';
 
 print '<tr class="liste_titre">';
-print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
+print '<td colspan="2">'.$langs->trans("Modelcsv").'</td>';
 print '</tr>';
 
 
 print '<tr class="oddeven">';
-print '<td width="50%">' . $langs->trans("Selectmodelcsv") . '</td>';
-if (! $conf->use_javascript_ajax) {
+print '<td width="50%">'.$langs->trans("Selectmodelcsv").'</td>';
+if (!$conf->use_javascript_ajax) {
 	print '<td class="nowrap">';
 	print $langs->trans("NotAvailableWhenAjaxDisabled");
 	print "</td>";
@@ -256,7 +256,7 @@ $num2 = count($model_option);
 if ($num2) {
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre">';
-	print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
+	print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
 	print "</tr>\n";
 
 	foreach ($model_option as $key) {
@@ -264,14 +264,14 @@ if ($num2) {
 
         // Param
         $label = $key['label'];
-		print '<td width="50%">' . $langs->trans($label) . '</td>';
+		print '<td width="50%">'.$langs->trans($label).'</td>';
 
 		// Value
         print '<td>';
         if (is_array($key['param'])) {
             print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
         } else {
-            print '<input type="text" size="20" id="'. $label .'" name="' . $key['label'] . '" value="' . $conf->global->$label . '">';
+            print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.$conf->global->$label.'">';
         }
 
 		print '</td></tr>';
@@ -280,7 +280,7 @@ if ($num2) {
 	print "</table>\n";
 }
 
-print '<div class="center"><input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Modify')) . '" name="button"></div>';
+print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Modify')).'" name="button"></div>';
 
 print '</form>';
 

+ 31 - 31
htdocs/accountancy/admin/fiscalyear.php

@@ -22,13 +22,13 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
 
 $action = GETPOST('action', 'aZ09');
 
 // Load variable for pagination
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST('sortfield', 'alpha');
 $sortorder = GETPOST('sortorder', 'alpha');
 $page = GETPOST('page', 'int');
@@ -36,32 +36,32 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortfield) $sortfield="f.rowid"; // Set here default search field
-if (! $sortorder) $sortorder="ASC";
+if (!$sortfield) $sortfield = "f.rowid"; // Set here default search field
+if (!$sortorder) $sortorder = "ASC";
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","compta"));
+$langs->loadLangs(array("admin", "compta"));
 
 // Security check
 if ($user->socid > 0)
 	accessforbidden();
-if (! $user->rights->accounting->fiscalyear->write)              // If we can read accounting records, we should be able to see fiscal year.
+if (!$user->rights->accounting->fiscalyear->write)              // If we can read accounting records, we should be able to see fiscal year.
 	accessforbidden();
 
 $error = 0;
 
 // List of status
-static $tmpstatut2label = array (
+static $tmpstatut2label = array(
 		'0' => 'OpenFiscalYear',
 		'1' => 'CloseFiscalYear'
 );
-$statut2label = array (
+$statut2label = array(
 		''
 );
 foreach ($tmpstatut2label as $key => $val)
 	$statut2label[$key] = $langs->trans($val);
 
-$errors = array ();
+$errors = array();
 
 $object = new Fiscalyear($db);
 
@@ -85,9 +85,9 @@ $helpurl = "";
 llxHeader('', $title, $helpurl);
 
 $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
-$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f";
-$sql .= " WHERE f.entity = " . $conf->entity;
-$sql.=$db->order($sortfield, $sortorder);
+$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
+$sql .= " WHERE f.entity = ".$conf->entity;
+$sql .= $db->order($sortfield, $sortorder);
 
 // Count total nb of records
 $nbtotalofrecords = '';
@@ -102,7 +102,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 	}
 }
 
-$sql.= $db->plimit($limit+1, $offset);
+$sql .= $db->plimit($limit + 1, $offset);
 
 $result = $db->query($sql);
 if ($result)
@@ -112,7 +112,7 @@ if ($result)
 	$i = 0;
 
 
-    $addbutton.= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
+    $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
 
 
 	$title = $langs->trans('AccountingPeriods');
@@ -122,34 +122,34 @@ if ($result)
 	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste centpercent">';
 	print '<tr class="liste_titre">';
-	print '<td>' . $langs->trans("Ref") . '</td>';
-	print '<td>' . $langs->trans("Label") . '</td>';
-	print '<td>' . $langs->trans("DateStart") . '</td>';
-	print '<td>' . $langs->trans("DateEnd") . '</td>';
-	print '<td class="center">' . $langs->trans("NumberOfAccountancyEntries") . '</td>';
-	print '<td class="center">' . $langs->trans("NumberOfAccountancyMovements") . '</td>';
-	print '<td class="right">' . $langs->trans("Statut") . '</td>';
+	print '<td>'.$langs->trans("Ref").'</td>';
+	print '<td>'.$langs->trans("Label").'</td>';
+	print '<td>'.$langs->trans("DateStart").'</td>';
+	print '<td>'.$langs->trans("DateEnd").'</td>';
+	print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
+	print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
+	print '<td class="right">'.$langs->trans("Statut").'</td>';
 	print '</tr>';
 
 	if ($num) {
 		$fiscalyearstatic = new Fiscalyear($db);
 
-		while ( $i < $num && $i < $max ) {
+		while ($i < $num && $i < $max) {
 			$obj = $db->fetch_object($result);
 			$fiscalyearstatic->id = $obj->rowid;
 			print '<tr class="oddeven">';
-			print '<td><a href="fiscalyear_card.php?id=' . $obj->rowid . '">' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . '</a></td>';
-			print '<td class="left">' . $obj->label . '</td>';
-			print '<td class="left">' . dol_print_date($db->jdate($obj->date_start), 'day') . '</td>';
-			print '<td class="left">' . dol_print_date($db->jdate($obj->date_end), 'day') . '</td>';
-			print '<td class="center">' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
-			print '<td class="center">' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
-			print '<td class="right">' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '</td>';
+			print '<td><a href="fiscalyear_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowFiscalYear"), "technic").' '.$obj->rowid.'</a></td>';
+			print '<td class="left">'.$obj->label.'</td>';
+			print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
+			print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
+			print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
+			print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
+			print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->statut, 5).'</td>';
 			print '</tr>';
 			$i++;
 		}
 	} else {
-		print '<tr class="oddeven"><td colspan="7" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
+		print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
 	}
 	print '</table>';
 	print '</div>';

+ 38 - 38
htdocs/accountancy/admin/fiscalyear_card.php

@@ -24,11 +24,11 @@
 
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","compta"));
+$langs->loadLangs(array("admin", "compta"));
 
 // Security check
 if ($user->socid > 0)
@@ -43,11 +43,11 @@ $confirm = GETPOST('confirm', 'alpha');
 $id = GETPOST('id', 'int');
 
 // List of statut
-static $tmpstatut2label = array (
+static $tmpstatut2label = array(
 		'0' => 'OpenFiscalYear',
 		'1' => 'CloseFiscalYear'
 );
-$statut2label = array (
+$statut2label = array(
 		''
 );
 foreach ($tmpstatut2label as $key => $val)
@@ -74,7 +74,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
 }
 
 elseif ($action == 'add') {
-	if (! GETPOST('cancel', 'alpha')) {
+	if (!GETPOST('cancel', 'alpha')) {
 		$error = 0;
 
 		$object->date_start = $date_start;
@@ -85,14 +85,14 @@ elseif ($action == 'add') {
 
 		if (empty($object->date_start) && empty($object->date_end)) {
 			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
-			$error ++;
+			$error++;
 		}
 		if (empty($object->label)) {
 			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
-			$error ++;
+			$error++;
 		}
 
-		if (! $error) {
+		if (!$error) {
 			$db->begin();
 
 			$id = $object->create($user);
@@ -100,7 +100,7 @@ elseif ($action == 'add') {
 			if ($id > 0) {
 				$db->commit();
 
-				header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+				header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
 				exit();
 			} else {
 				$db->rollback();
@@ -119,7 +119,7 @@ elseif ($action == 'add') {
 
 // Update record
 elseif ($action == 'update') {
-	if (! GETPOST('cancel', 'alpha')) {
+	if (!GETPOST('cancel', 'alpha')) {
 		$result = $object->fetch($id);
 
 		$object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start;
@@ -130,13 +130,13 @@ elseif ($action == 'update') {
 		$result = $object->update($user);
 
 		if ($result > 0) {
-			header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+			header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
 			exit();
 		} else {
 			setEventMessages($object->error, $object->errors, 'errors');
 		}
 	} else {
-		header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+		header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
 		exit();
 	}
 }
@@ -149,7 +149,7 @@ elseif ($action == 'update') {
 
 $form = new Form($db);
 
-$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card");
+$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Card");
 $helpurl = "";
 llxHeader("", $title, $helpurl);
 
@@ -157,8 +157,8 @@ if ($action == 'create')
 {
 	print load_fiche_titre($langs->trans("NewFiscalYear"));
 
-	print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
-	print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+	print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<input type="hidden" name="action" value="add">';
 
 	dol_fiche_head();
@@ -166,15 +166,15 @@ if ($action == 'create')
 	print '<table class="border centpercent">';
 
 	// Label
-	print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Label") . '</td><td><input name="label" size="32" value="' . GETPOST('label', 'alpha') . '"></td></tr>';
+	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="32" value="'.GETPOST('label', 'alpha').'"></td></tr>';
 
 	// Date start
-	print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
+	print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
 	print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear');
 	print '</td></tr>';
 
 	// Date end
-	print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
+	print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
 	print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend');
 	print '</td></tr>';
 
@@ -192,9 +192,9 @@ if ($action == 'create')
 	dol_fiche_end();
 
 	print '<div class="center">';
-	print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
+	print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
 	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-	print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
+	print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
 	print '</div>';
 
 	print '</form>';
@@ -206,36 +206,36 @@ if ($action == 'create')
 		if ($action == 'edit') {
 			dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
 
-			print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
-			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+			print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
+			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 			print '<input type="hidden" name="action" value="update">';
-			print '<input type="hidden" name="id" value="' . $id . '">';
+			print '<input type="hidden" name="id" value="'.$id.'">';
 
 			print '<table class="border centpercent">';
 
 			// Ref
 			print "<tr>";
-			print '<td class="titlefieldcreate titlefield">' . $langs->trans("Ref") . '</td><td>';
+			print '<td class="titlefieldcreate titlefield">'.$langs->trans("Ref").'</td><td>';
 			print $object->ref;
 			print '</td></tr>';
 
 			// Label
-			print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td>';
-			print '<input name="label" class="flat" size="32" value="' . $object->label . '">';
+			print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
+			print '<input name="label" class="flat" size="32" value="'.$object->label.'">';
 			print '</td></tr>';
 
 			// Date start
-			print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
+			print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
 			print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear');
 			print '</td></tr>';
 
 			// Date end
-			print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
+			print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
 			print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
 			print '</td></tr>';
 
 			// Statut
-			print '<tr><td>' . $langs->trans("Statut") . '</td><td>';
+			print '<tr><td>'.$langs->trans("Statut").'</td><td>';
 			// print $form->selectarray('statut', $statut2label, $object->statut);
 			print $object->getLibStatut(4);
 			print '</td></tr>';
@@ -243,9 +243,9 @@ if ($action == 'create')
 			print '</table>';
 
 			print '<br><div class="center">';
-			print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
+			print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-			print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
+			print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
 			print '</div>';
 
 			print '</form>';
@@ -256,17 +256,17 @@ if ($action == 'create')
 			 * Confirm delete
 			 */
 			if ($action == 'delete') {
-				print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
+				print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
 			}
 
 			dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
 
 			print '<table class="border centpercent">';
 
-			$linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/fiscalyear.php">' . $langs->trans("BackToList") . '</a>';
+			$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/fiscalyear.php">'.$langs->trans("BackToList").'</a>';
 
 			// Ref
-			print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td width="50%">';
+			print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td width="50%">';
 			print $object->ref;
 			print '</td><td>';
 			print $linkback;
@@ -294,20 +294,20 @@ if ($action == 'create')
 			print '</td></tr>';
 
 			// Statut
-			print '<tr><td>' . $langs->trans("Status") . '</td><td colspan="2">' . $object->getLibStatut(4) . '</td></tr>';
+			print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$object->getLibStatut(4).'</td></tr>';
 
 			print "</table>";
 
 			dol_fiche_end();
 
-			if (! empty($user->rights->accounting->fiscalyear->write))
+			if (!empty($user->rights->accounting->fiscalyear->write))
 			{
     			/*
     			 * Barre d'actions
     			 */
     			print '<div class="tabsAction">';
 
-    			print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
+    			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
 
     			// print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
 

+ 59 - 59
htdocs/accountancy/admin/index.php

@@ -29,11 +29,11 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","bills","admin","accountancy"));
+$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
 
 // Security access
 if (empty($user->rights->accounting->chartofaccount))
@@ -44,9 +44,9 @@ if (empty($user->rights->accounting->chartofaccount))
 $action = GETPOST('action', 'aZ09');
 
 // Parameters ACCOUNTING_* and others
-$list = array (
+$list = array(
     'ACCOUNTING_LENGTH_GACCOUNT',
-    'ACCOUNTING_LENGTH_AACCOUNT' ,
+    '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
 );
@@ -62,13 +62,13 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' :
 if ($action == 'update') {
 	$error = 0;
 
-	if (! $error)
+	if (!$error)
 	{
 	    foreach ($list as $constname)
 	    {
 	        $constvalue = GETPOST($constname, 'alpha');
 
-	        if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
+	        if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
 	            $error++;
 	        }
 	    }
@@ -77,7 +77,7 @@ if ($action == 'update') {
 	    }
 	}
 
-    if (! $error) {
+    if (!$error) {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
 }
@@ -85,10 +85,10 @@ if ($action == 'update') {
 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 (!$res > 0)
+        $error++;
 
-    if (! $error) {
+    if (!$error) {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     } else {
         setEventMessages($langs->trans("Error"), null, 'mesgs');
@@ -98,9 +98,9 @@ if ($action == 'setlistsorttodo') {
 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) {
+    if (!$res > 0)
+        $error++;
+    if (!$error) {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     } else {
         setEventMessages($langs->trans("Error"), null, 'mesgs');
@@ -110,9 +110,9 @@ if ($action == 'setlistsortdone') {
 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) {
+    if (!$res > 0)
+        $error++;
+    if (!$error) {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     } else {
         setEventMessages($langs->trans("Error"), null, 'mesgs');
@@ -122,9 +122,9 @@ if ($action == 'setmanagezero') {
 if ($action == 'setdisabledirectinput') {
 	$setdisabledirectinput = GETPOST('value', 'int');
 	$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
-	if (! $res > 0)
-		$error ++;
-	if (! $error) {
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	} else {
 		setEventMessages($langs->trans("Error"), null, 'mesgs');
@@ -134,9 +134,9 @@ if ($action == 'setdisabledirectinput') {
 if ($action == 'setenabledraftexport') {
 	$setenabledraftexport = GETPOST('value', 'int');
 	$res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
-	if (! $res > 0)
-		$error ++;
-	if (! $error) {
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	} else {
 		setEventMessages($langs->trans("Error"), null, 'mesgs');
@@ -146,9 +146,9 @@ 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) {
+    if (!$res > 0)
+        $error++;
+    if (!$error) {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     } else {
         setEventMessages($langs->trans("Error"), null, 'mesgs');
@@ -159,15 +159,15 @@ if ($action == 'setenablesubsidiarylist') {
  * View
  */
 
-$title= $langs->trans('ConfigAccountingExpert');
+$title = $langs->trans('ConfigAccountingExpert');
 llxHeader('', $title);
 
-$linkback='';
+$linkback = '';
 //$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
 print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy');
 
-print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="update">';
 
 // Default mode for calculating turnover (parameter ACCOUNTING_MODE)
@@ -204,85 +204,85 @@ print '<br>';
 
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
+print '<td colspan="2">'.$langs->trans('OtherOptions').'</td>';
 print "</tr>\n";
 
-if (! empty($user->admin))
+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 '<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 '<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 '<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 '<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>';
 
 	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 '<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 '<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("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 '<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 '<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>';
-    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 '<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 '<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 '<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 '<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>';
     }
@@ -295,14 +295,14 @@ foreach ($list as $key)
 {
     print '<tr class="oddeven value">';
 
-    if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
+    if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
 
     // Param
     $label = $langs->trans($key);
     print '<td>'.$label.'</td>';
     // Value
     print '<td class="right">';
-    print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
+    print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
     print '</td>';
 
     print '</tr>';
@@ -311,7 +311,7 @@ foreach ($list as $key)
 
 print '</table>';
 
-print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
+print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
 
 print '<br>';
 print '<br>';

+ 48 - 48
htdocs/accountancy/admin/productaccount.php

@@ -26,22 +26,22 @@
  */
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
-require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","compta","accountancy","products"));
+$langs->loadLangs(array("companies", "compta", "accountancy", "products"));
 
 // Security check
 if (empty($conf->accounting->enabled)) {
 	accessforbidden();
 }
-if (! $user->rights->accounting->bind->write)
+if (!$user->rights->accounting->bind->write)
     accessforbidden();
 
 // search & action GETPOST
@@ -77,23 +77,23 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortfield) $sortfield="p.ref";
-if (! $sortorder) $sortorder="ASC";
+if (!$sortfield) $sortfield = "p.ref";
+if (!$sortorder) $sortorder = "ASC";
 
-if (empty($action)) $action='list';
+if (empty($action)) $action = 'list';
 
-$arrayfields=array();
+$arrayfields = array();
 
 
 /*
  * Actions
  */
 
-if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
-if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
+if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
 
-$parameters=array();
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
 // Purge search criteria
@@ -110,10 +110,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
 
 // Sales or Purchase mode ?
 if ($action == 'update') {
-	if (! empty($btn_changetype)) {
+	if (!empty($btn_changetype)) {
 		$error = 0;
 
-		$accounting_product_modes = array (
+		$accounting_product_modes = array(
 				'ACCOUNTANCY_SELL',
                 'ACCOUNTANCY_SELL_INTRA',
                 'ACCOUNTANCY_SELL_EXPORT',
@@ -121,17 +121,17 @@ if ($action == 'update') {
 		);
 
 		if (in_array($accounting_product_mode, $accounting_product_modes)) {
-			if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
-				$error ++;
+			if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
+				$error++;
 			}
 		} else {
-			$error ++;
+			$error++;
 		}
 	}
 
-	if (! empty($btn_changeaccount)) {
+	if (!empty($btn_changeaccount)) {
 		//$msg = '<div><span class="accountingprocessing">' . $langs->trans("Processing") . '...</span></div>';
-		if (! empty($chk_prod)) {
+		if (!empty($chk_prod)) {
 			$accounting = new AccountingAccount($db);
 
 			//$msg .= '<div><span  class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
@@ -140,37 +140,37 @@ if ($action == 'update') {
 			$cpt = 0; $ok = 0; $ko = 0;
 			foreach ($chk_prod as $productid)
 			{
-				$accounting_account_id = GETPOST('codeventil_' . $productid);
+				$accounting_account_id = GETPOST('codeventil_'.$productid);
 
 				$result = 0;
 				if ($accounting_account_id > 0)
 				{
-					$arrayofdifferentselectedvalues[$accounting_account_id]=$accounting_account_id;
+					$arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id;
 					$result = $accounting->fetch($accounting_account_id, null, 1);
 				}
 				if ($result <= 0) {
 					// setEventMessages(null, $accounting->errors, 'errors');
-					$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '<br/> <pre>' . $sql . '</pre></font></div>';
+					$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br/> <pre>'.$sql.'</pre></font></div>';
 					$ko++;
 				} else {
 					$db->begin();
 
-					$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
+					$sql = " UPDATE ".MAIN_DB_PREFIX."product";
 					if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
-						$sql .= " SET accountancy_code_buy = " . $accounting->account_number;
+						$sql .= " SET accountancy_code_buy = ".$accounting->account_number;
 					}
 					if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
-						$sql .= " SET accountancy_code_sell = " . $accounting->account_number;
+						$sql .= " SET accountancy_code_sell = ".$accounting->account_number;
 					}
                     if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
-                        $sql .= " SET accountancy_code_sell_intra = " . $accounting->account_number;
+                        $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number;
                     }
                     if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
-                        $sql .= " SET accountancy_code_sell_export = " . $accounting->account_number;
+                        $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
                     }
-					$sql .= " WHERE rowid = " . $productid;
+					$sql .= " WHERE rowid = ".$productid;
 
-					dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
+					dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
 					if ($db->query($sql))
 					{
 					    $ok++;
@@ -305,24 +305,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 
 $sql .= $db->plimit($limit + 1, $offset);
 
-dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
+dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG);
 $result = $db->query($sql);
 if ($result)
 {
 	$num = $db->num_rows($result);
 	$i = 0;
 
-    $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_ref > 0) $param.="&search_desc=".urlencode($search_ref);
-    if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
-    if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
-    if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
-    if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid);
-    if ($accounting_product_mode) $param.='&accounting_product_mode='.urlencode($accounting_product_mode);
-
-    print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
+    $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_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
+    if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
+    if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
+    if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account);
+    if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid);
+    if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode);
+
+    print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
     if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@@ -497,13 +497,13 @@ if ($result)
 
 		print '<td class="left">'.$obj->label.'</td>';
 
-		if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
+		if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
 		{
 		    // TODO ADJUST DESCRIPTION SIZE
     		// print '<td class="left">' . $obj->description . '</td>';
     		// TODO: we shoul set a user defined value to adjust user square / wide screen size
     		$trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
-    		print '<td>' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
+    		print '<td>'.nl2br(dol_trunc($obj->description, $trunclengh)).'</td>';
 		}
 
 		if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT')

+ 31 - 31
htdocs/accountancy/bookkeeping/balancebymonth.php

@@ -26,11 +26,11 @@
  */
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("bills","compta","accountancy","other"));
+$langs->loadLangs(array("bills", "compta", "accountancy", "other"));
 
 // Filter
 $year = GETPOST("year", 'int');
@@ -49,17 +49,17 @@ if ($year == 0) {
 
 llxHeader('', $langs->trans("Bookkeeping"));
 
-$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
-$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
+$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
+$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
 
-print load_fiche_titre($langs->trans("AccountBalanceByMonth") . ' ' . $textprevyear . ' ' . $langs->trans("Year") . ' ' . $year_start . ' ' . $textnextyear);
+print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear);
 
-$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
-$sql .= " , " . MAIN_DB_PREFIX . "facture as f";
+$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd";
+$sql .= " , ".MAIN_DB_PREFIX."facture as f";
 $sql .= " WHERE fd.fk_code_ventilation = 0";
 $sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
 
-dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql=' . $sql);
+dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql);
 $result = $db->query($sql);
 if ($result) {
 	$row = $db->fetch_row($result);
@@ -72,10 +72,10 @@ $y = $year_current;
 
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td width=150>' . $langs->trans("Label") . '</td>';
-for($i = 1; $i <= 12; $i++)
+print '<td width=150>'.$langs->trans("Label").'</td>';
+for ($i = 1; $i <= 12; $i++)
 {
-	print '<td class="right">' . $langs->trans("MonthShort".sprintf("%02s", $i)) . '</td>';
+	print '<td class="right">'.$langs->trans("MonthShort".sprintf("%02s", $i)).'</td>';
 }
 print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>';
 print '</tr>';
@@ -94,9 +94,9 @@ $sql .= "  ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',";
 $sql .= "  ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',";
 $sql .= "  ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',";
 $sql .= "  ROUND(SUM(bk.montant),2) as 'Total'";
-$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
-$sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
-$sql .= "  AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
+$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
+$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
+$sql .= "  AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
 $sql .= " GROUP BY bk.numero_compte";
 
 $resql = $db->query($sql);
@@ -104,26 +104,26 @@ if ($resql) {
 	$i = 0;
 	$num = $db->num_rows($resql);
 
-	while ( $i < $num ) {
+	while ($i < $num) {
 		$row = $db->fetch_row($resql);
 
-		print '<tr class="oddeven"><td width="14%">' . length_accountg($row[0]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[1]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[2]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[3]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[4]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[5]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[6]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[7]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[8]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[9]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[10]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[11]) . '</td>';
-		print '<td class="right" width="6.5%">' . price($row[12]) . '</td>';
-		print '<td class="right" width="8%"><strong>' . price($row[13]) . '</strong></td>';
+		print '<tr class="oddeven"><td width="14%">'.length_accountg($row[0]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[1]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[2]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[3]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[4]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[5]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[6]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[7]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[8]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[9]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[10]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[11]).'</td>';
+		print '<td class="right" width="6.5%">'.price($row[12]).'</td>';
+		print '<td class="right" width="8%"><strong>'.price($row[13]).'</strong></td>';
 		print '</tr>';
 
-		$i ++;
+		$i++;
 	}
 	$db->free($resql);
 } else {

+ 29 - 29
htdocs/accountancy/closure/index.php

@@ -23,12 +23,12 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","bills","other","main","accountancy"));
+$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
 
 // Security check
 if (empty($conf->accounting->enabled)) {
@@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) {
 }
 if ($user->socid > 0)
 	accessforbidden();
-if (! $user->rights->accounting->fiscalyear->write)
+if (!$user->rights->accounting->fiscalyear->write)
 	accessforbidden();
 
 
-$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
 if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
 else
 {
 	$year_start = dol_print_date(dol_now(), '%Y');
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--;	// If current month is lower that starting fiscal month, we start last year
+	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
 }
 $year_end = $year_start + 1;
 $month_end = $month_start - 1;
@@ -69,54 +69,54 @@ $year_current = $year_start;
 
 llxHeader('', $langs->trans("Closure"));
 
-$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
-$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
+$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
+$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
 
 
-print load_fiche_titre($langs->trans("Closure") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
+print load_fiche_titre($langs->trans("Closure")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
 
-print '<span class="opacitymedium">'.$langs->trans("DescClosure") . '</span><br>';
+print '<span class="opacitymedium">'.$langs->trans("DescClosure").'</span><br>';
 print '<br>';
 
 
 $y = $year_current;
 
-$buttonbind = '<a class="butAction" href="./validate.php">' . $langs->trans("ValidateMovements") . '</a>';
+$buttonbind = '<a class="butAction" href="./validate.php">'.$langs->trans("ValidateMovements").'</a>';
 
 print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
-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>';
+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>';
+print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
 
 $sql = "SELECT COUNT(b.rowid) as detail,";
-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(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+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(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
 }
 $sql .= " COUNT(b.rowid) as total";
-$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
-$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'";
-$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'";
-$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")";   // We don't share object for accountancy
+$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
+$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
+$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
+$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
 
-dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG);
+dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
 $resql = $db->query($sql);
 if ($resql) {
 	$num = $db->num_rows($resql);
 
 	while ($row = $db->fetch_row($resql)) {
 		print '<tr class="oddeven">';
-		for($i = 1; $i <= 12; $i ++) {
-			print '<td class="right">' . $row[$i] . '</td>';
+		for ($i = 1; $i <= 12; $i++) {
+			print '<td class="right">'.$row[$i].'</td>';
 		}
-		print '<td class="right"><b>' . $row[13] . '</b></td>';
+		print '<td class="right"><b>'.$row[13].'</b></td>';
 		print '</tr>';
 	}
 

+ 35 - 35
htdocs/accountancy/closure/validate.php

@@ -23,12 +23,12 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","bills","other","main","accountancy"));
+$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
 
 // Security check
 if (empty($conf->accounting->enabled)) {
@@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) {
 }
 if ($user->socid > 0)
 	accessforbidden();
-	if (! $user->rights->accounting->fiscalyear->write)
+	if (!$user->rights->accounting->fiscalyear->write)
 	accessforbidden();
 
 
-$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
 if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
 else
 {
 	$year_start = dol_print_date(dol_now(), '%Y');
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--;	// If current month is lower that starting fiscal month, we start last year
+	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
 }
 $year_end = $year_start + 1;
 $month_end = $month_start - 1;
@@ -68,14 +68,14 @@ if ($action == 'validate')
 
     // Update database
     $db->begin();
-    $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
-    $sql .= " SET b.date_validated = '" . $db->idate($now) . "'";
+    $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
+    $sql .= " SET b.date_validated = '".$db->idate($now)."'";
     $sql .= ' WHERE b.date_validated IS NULL';
 
     dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG);
     $resql = $db->query($sql);
-    if (! $resql1) {
-        $error ++;
+    if (!$resql1) {
+        $error++;
         $db->rollback();
         setEventMessages($db->lasterror(), null, 'errors');
     } else {
@@ -91,13 +91,13 @@ if ($action == 'validate')
 
 llxHeader('', $langs->trans("ValidateMovements"));
 
-$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
-$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
+$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
+$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
 
 
-print load_fiche_titre($langs->trans("ValidateMovements") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
+print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
 
-print $langs->trans("DescValidateMovements") . '<br>';
+print $langs->trans("DescValidateMovements").'<br>';
 print '<br>';
 
 
@@ -108,38 +108,38 @@ print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
 print '<tr class="oddeven">';
-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 class="center">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</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 class="center">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
 }
-print '<td><b>' . $langs->trans("Total") . '</b></td></tr>';
+print '<td><b>'.$langs->trans("Total").'</b></td></tr>';
 
 print '<tr class="oddeven">';
 $sql = "SELECT COUNT(b.rowid) as detail,";
-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(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+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(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
 }
 $sql .= " COUNT(b.rowid) as total";
-$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
-$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'";
-$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'";
-$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")";   // We don't share object for accountancy
+$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
+$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
+$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
+$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
 
-dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG);
+dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
 $resql = $db->query($sql);
 if ($resql) {
 	$num = $db->num_rows($resql);
 
 	while ($row = $db->fetch_row($resql)) {
-		for($i = 1; $i <= 12; $i ++) {
-			print '<td class="nowrap center">' . $row[$i] . '<br><br>';
-            print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected?' checked="checked"':'').'>';
-            print '</td>' ;
+		for ($i = 1; $i <= 12; $i++) {
+			print '<td class="nowrap center">'.$row[$i].'<br><br>';
+            print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected ? ' checked="checked"' : '').'>';
+            print '</td>';
 		}
-		print '<td class="valigntop"><b>' . $row[13] . '</b></td>';
+		print '<td class="valigntop"><b>'.$row[13].'</b></td>';
 	}
 
 	$db->free($resql);
@@ -149,7 +149,7 @@ if ($resql) {
 print '</tr>';
 print "</table>\n";
 
-print '<br><div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?month=' . $year_current . '&action=validate"">' . $langs->trans("ValidateMovements") . '</a></div>';
+print '<br><div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?month='.$year_current.'&action=validate"">'.$langs->trans("ValidateMovements").'</a></div>';
 print '</div>';
 
 // End of page

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

@@ -24,11 +24,11 @@
  */
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("bills","accountancy"));
+$langs->loadLangs(array("bills", "accountancy"));
 
 $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');
@@ -48,16 +48,16 @@ if ($user->socid > 0)
 
 if ($action == 'ventil' && $user->rights->accounting->bind->write)
 {
-	if (! $cancel)
+	if (!$cancel)
 	{
 	    if ($codeventil < 0) $codeventil = 0;
 
-		$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
-		$sql .= " SET fk_code_ventilation = " . $codeventil;
-		$sql .= " WHERE rowid = " . $id;
+		$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
+		$sql .= " SET fk_code_ventilation = ".$codeventil;
+		$sql .= " WHERE rowid = ".$id;
 
 		$resql = $db->query($sql);
-		if (! $resql) {
+		if (!$resql) {
 			setEventMessages($db->lasterror(), null, 'errors');
 		}
 		else
@@ -93,18 +93,18 @@ $form = new Form($db);
 $facture_static = new Facture($db);
 $formaccounting = new FormAccounting($db);
 
-if (! empty($id)) {
+if (!empty($id)) {
 	$sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,";
 	$sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,";
 	$sql .= " l.fk_code_ventilation, aa.account_number, aa.label";
-	$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
-	$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
-	$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
-	$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
-
-	dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
+	$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
+	$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture";
+	$sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id;
+	$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
+
+	dol_syslog("/accounting/customer/card.php sql=".$sql, LOG_DEBUG);
 	$result = $db->query($sql);
 
 	if ($result) {
@@ -114,8 +114,8 @@ if (! empty($id)) {
 		if ($num_lines) {
 			$objp = $db->fetch_object($result);
 
-			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
-			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+			print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
+			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 			print '<input type="hidden" name="action" value="ventil">';
 			print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
 
@@ -126,15 +126,15 @@ if (! empty($id)) {
 			print '<table class="border centpercent">';
 
 			// Ref facture
-			print '<tr><td>' . $langs->trans("Invoice") . '</td>';
+			print '<tr><td>'.$langs->trans("Invoice").'</td>';
 			$facture_static->ref = $objp->ref;
 			$facture_static->id = $objp->facid;
-			print '<td>' . $facture_static->getNomUrl(1) . '</td>';
+			print '<td>'.$facture_static->getNomUrl(1).'</td>';
 			print '</tr>';
 
-			print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
-			print '<td>' . nl2br($objp->description) . '</td></tr>';
-			print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
+			print '<tr><td width="20%">'.$langs->trans("Line").'</td>';
+			print '<td>'.nl2br($objp->description).'</td></tr>';
+			print '<tr><td width="20%">'.$langs->trans("Account").'</td><td>';
 			print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
 			print '</td></tr>';
 			print '</table>';
@@ -142,9 +142,9 @@ if (! empty($id)) {
 			dol_fiche_end();
 
 			print '<div class="center">';
-			print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
+			print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-			print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
+			print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
 			print '</div>';
 
 			print '</form>';

+ 146 - 146
htdocs/accountancy/customer/index.php

@@ -27,13 +27,13 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","bills","other","main","accountancy"));
+$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
 
 // Security check
 if (empty($conf->accounting->enabled)) {
@@ -41,16 +41,16 @@ if (empty($conf->accounting->enabled)) {
 }
 if ($user->socid > 0)
 	accessforbidden();
-if (! $user->rights->accounting->bind->write)
+if (!$user->rights->accounting->bind->write)
 	accessforbidden();
 
 
-$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
 if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
 else
 {
 	$year_start = dol_print_date(dol_now(), '%Y');
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--;	// If current month is lower that starting fiscal month, we start last year
+	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
 }
 $year_end = $year_start + 1;
 $month_end = $month_start - 1;
@@ -77,20 +77,20 @@ if ($action == 'clean' || $action == 'validatehistory')
 {
 	// Clean database
 	$db->begin();
-	$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
+	$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd";
 	$sql1 .= " SET fk_code_ventilation = 0";
 	$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN';
 	$sql1 .= '	(SELECT accnt.rowid ';
-	$sql1 .= '	FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
-	$sql1 .= '	INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
-	$sql1 .= '	ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
-	$sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')';
+	$sql1 .= '	FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
+	$sql1 .= '	INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
+	$sql1 .= '	ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
+	$sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')';
 	$sql1 .= ' AND fk_code_ventilation <> 0';
 
 	dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
 	$resql1 = $db->query($sql1);
-	if (! $resql1) {
-		$error ++;
+	if (!$resql1) {
+		$error++;
 		$db->rollback();
 		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
@@ -121,26 +121,26 @@ if ($action == 'validatehistory') {
 
 	// Customer Invoice lines (must be same request than into page list.php for manual binding)
 	$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
-	$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
-	$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
-	$sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
-	$sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
-	$sql.= " co.code as country_code, co.label as country_label,";
-	$sql.= " s.tva_intra";
-	$sql.= " FROM " . MAIN_DB_PREFIX . "facture as f";
-	$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
-	$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
-	$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
-	$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
-	$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa  ON p.accountancy_code_sell = aa.account_number         AND aa.active = 1  AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
-	$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number  AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity;
-	$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity;
-	$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
-	$sql.= " AND l.product_type <= 2";
+	$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
+	$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
+	$sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+	$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
+	$sql .= " co.code as country_code, co.label as country_label,";
+	$sql .= " s.tva_intra";
+	$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
+	$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
+	$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa  ON p.accountancy_code_sell = aa.account_number         AND aa.active = 1  AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number  AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity;
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity;
+	$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
+	$sql .= " AND l.product_type <= 2";
 
 	dol_syslog('htdocs/accountancy/customer/index.php');
 	$result = $db->query($sql);
-	if (! $result) {
+	if (!$result) {
 		$error++;
 		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
@@ -172,12 +172,12 @@ if ($action == 'validatehistory') {
 
 			if ($objp->aarowid_suggest > 0)
 			{
-				$sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet";
-				$sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
-				$sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
+				$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet";
+				$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
+				$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
 
 				$resqlupdate = $db->query($sqlupdate);
-				if (! $resqlupdate)
+				if (!$resqlupdate)
 				{
 					$error++;
 					setEventMessages($db->lasterror(), null, 'errors');
@@ -206,64 +206,64 @@ if ($action == 'validatehistory') {
 
 llxHeader('', $langs->trans("CustomersVentilation"));
 
-$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
-$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
+$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
+$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
 
 
-print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
+print load_fiche_titre($langs->trans("CustomersVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
 
-print '<span class="opacitymedium">'.$langs->trans("DescVentilCustomer") . '<br>';
-print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
+print '<span class="opacitymedium">'.$langs->trans("DescVentilCustomer").'<br>';
+print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
 print '</span><br>';
 
 
 $y = $year_current;
 
-$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
+$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>';
 
 print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
 //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
-print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
-print '<td width="200" class="left">' . $langs->trans("Label") . '</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 '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
+print '<td width="200" class="left">'.$langs->trans("Label").'</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 " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
-$sql .= "  " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
-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(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
+$sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
+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(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
 }
 $sql .= "  SUM(fd.total_ht) as total";
-$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
-$sql .= "  LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
-$sql .= "  LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
-$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
-$sql .= "  AND f.datef <= '" . $db->idate($search_date_end) . "'";
+$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
+$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
+$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
+$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
+$sql .= "  AND f.datef <= '".$db->idate($search_date_end)."'";
 $sql .= " AND f.fk_statut > 0";
-$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")";   // We don't share object for accountancy
+$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
 $sql .= " AND aa.account_number IS NULL";
-if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
-	$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
+if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+	$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
 } else {
-	$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
+	$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
 }
 $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
 
-dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG);
+dol_syslog('htdocs/accountancy/customer/index.php sql='.$sql, LOG_DEBUG);
 $resql = $db->query($sql);
 if ($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')
 		{
@@ -278,11 +278,11 @@ if ($resql) {
 		}
 		else print $row[1];
 		print '</td>';
-		for($i = 2; $i <= 12; $i ++) {
-			print '<td class="nowrap right">' . price($row[$i]) . '</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 '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
 		print '</tr>';
 	}
 	$db->free($resql);
@@ -301,34 +301,34 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '',
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
-print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
-print '<td width="200" class="left">' . $langs->trans("Label") . '</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 '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
+print '<td width="200" class="left">'.$langs->trans("Label").'</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 " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
-$sql .= "  " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
-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(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
+$sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
+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(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
 }
 $sql .= "  SUM(fd.total_ht) as total";
-$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
-$sql .= "  LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
-$sql .= "  LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
-$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
-$sql .= "  AND f.datef <= '" . $db->idate($search_date_end) . "'";
-$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")";   // We don't share object for accountancy
+$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
+$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
+$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
+$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
+$sql .= "  AND f.datef <= '".$db->idate($search_date_end)."'";
+$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
 $sql .= " AND f.fk_statut > 0";
-if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
-	$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
+if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+	$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
 } else {
-	$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
+	$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
 }
 $sql .= " AND aa.account_number IS NOT NULL";
 $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
@@ -338,7 +338,7 @@ $resql = $db->query($sql);
 if ($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')
 		{
@@ -355,11 +355,11 @@ if ($resql) {
 		else print $row[1];
 		print '</td>';
 
-		for($i = 2; $i <= 12; $i++) {
-			print '<td class="nowrap right">' . price($row[$i]) . '</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 '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
 		print '</tr>';
 	}
 	$db->free($resql);
@@ -380,31 +380,31 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
 
 	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("TotalVente") . '</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 '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("TotalVente").'</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>';
+	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
 
-	$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
-	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(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+	$sql = "SELECT '".$langs->trans("TotalVente")."' AS total,";
+	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(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
 	}
 	$sql .= "  SUM(fd.total_ht) as total";
-	$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
-	$sql .= "  LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
-	$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
-	$sql .= "  AND f.datef <= '" . $db->idate($search_date_end) . "'";
-	$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
+	$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
+	$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
+	$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
+	$sql .= "  AND f.datef <= '".$db->idate($search_date_end)."'";
+	$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
 	$sql .= " AND f.fk_statut > 0";
-	if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
-		$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
+	if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+		$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
 	} else {
-		$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
+		$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
 	}
 
 	dol_syslog('htdocs/accountancy/customer/index.php');
@@ -413,11 +413,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
 		$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 '<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 '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
 			print '</tr>';
 		}
 		$db->free($resql);
@@ -428,35 +428,35 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
 	print '</div>';
 
 
-	if (! empty($conf->margin->enabled)) {
+	if (!empty($conf->margin->enabled)) {
 		print "<br>\n";
 		print '<div class="div-table-responsive-no-min">';
 		print '<table class="noborder centpercent">';
-		print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</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 '<tr class="liste_titre"><td width="400">'.$langs->trans("TotalMarge").'</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>';
+		print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
 
-		$sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
-		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(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+		$sql = "SELECT '".$langs->trans("Vide")."' AS marge,";
+		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(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
 		}
 		$sql .= "  SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
-		$sql .= "  LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
-		$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
-		$sql .= "  AND f.datef <= '" . $db->idate($search_date_end) . "'";
-		$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")";   // We don't share object for accountancy
+		$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
+		$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
+		$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
+		$sql .= "  AND f.datef <= '".$db->idate($search_date_end)."'";
+		$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
 		$sql .= " AND f.fk_statut > 0";
-		if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
-			$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
+		if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+			$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
 		} else {
-			$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
+			$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
 		}
 
 		dol_syslog('htdocs/accountancy/customer/index.php');
@@ -465,11 +465,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
 			$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(price2num($row[$i])) . '</td>';
+				print '<tr><td>'.$row[0].'</td>';
+				for ($i = 1; $i <= 12; $i++) {
+					print '<td class="nowrap right">'.price(price2num($row[$i])).'</td>';
 				}
-				print '<td class="nowrap right"><b>' . price(price2num($row[13])) . '</b></td>';
+				print '<td class="nowrap right"><b>'.price(price2num($row[13])).'</b></td>';
 				print '</tr>';
 			}
 			$db->free($resql);

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

@@ -28,11 +28,11 @@
  */
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("bills","accountancy","trips"));
+$langs->loadLangs(array("bills", "accountancy", "trips"));
 
 $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');
@@ -52,16 +52,16 @@ if ($user->socid > 0)
 
 if ($action == 'ventil' && $user->rights->accounting->bind->write)
 {
-	if (! $cancel)
+	if (!$cancel)
 	{
 		if ($codeventil < 0) $codeventil = 0;
 
-		$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
-		$sql .= " SET fk_code_ventilation = " . $codeventil;
-		$sql .= " WHERE rowid = " . $id;
+		$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
+		$sql .= " SET fk_code_ventilation = ".$codeventil;
+		$sql .= " WHERE rowid = ".$id;
 
 		$resql = $db->query($sql);
-		if (! $resql) {
+		if (!$resql) {
 			setEventMessages($db->lasterror(), null, 'errors');
 		}
 		else
@@ -95,18 +95,18 @@ $form = new Form($db);
 $expensereport_static = new ExpenseReport($db);
 $formaccounting = new FormAccounting($db);
 
-if (! empty($id)) {
+if (!empty($id)) {
 	$sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
 	$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
 	$sql .= " aa.account_number, aa.label";
-	$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
-	$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
-	$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id;
-	$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")";     // We don't share object for accountancy
-
-	dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG);
+	$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
+	$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
+	$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = ".$id;
+	$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
+
+	dol_syslog("/accounting/expensereport/card.php sql=".$sql, LOG_DEBUG);
 	$result = $db->query($sql);
 
 	if ($result) {
@@ -116,8 +116,8 @@ if (! empty($id)) {
 		if ($num_lines) {
 			$objp = $db->fetch_object($result);
 
-			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
-			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+			print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
+			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 			print '<input type="hidden" name="action" value="ventil">';
 			print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
 
@@ -128,22 +128,22 @@ if (! empty($id)) {
 			print '<table class="border centpercent">';
 
 			// Ref
-			print '<tr><td class="titlefield">' . $langs->trans("ExpenseReport") . '</td>';
+			print '<tr><td class="titlefield">'.$langs->trans("ExpenseReport").'</td>';
 			$expensereport_static->ref = $objp->ref;
 			$expensereport_static->id = $objp->erid;
-			print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
+			print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
 			print '</tr>';
 
-			print '<tr><td>' . $langs->trans("Line") . '</td>';
-			print '<td>' . stripslashes(nl2br($objp->rowid)) . '</td></tr>';
+			print '<tr><td>'.$langs->trans("Line").'</td>';
+			print '<td>'.stripslashes(nl2br($objp->rowid)).'</td></tr>';
 
-			print '<tr><td>' . $langs->trans("Description") . '</td>';
-			print '<td>' . stripslashes(nl2br($objp->comments)) . '</td></tr>';
+			print '<tr><td>'.$langs->trans("Description").'</td>';
+			print '<td>'.stripslashes(nl2br($objp->comments)).'</td></tr>';
 
-			print '<tr><td>' . $langs->trans("TypeFees") . '</td>';
-			print '<td>' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '</td>';
+			print '<tr><td>'.$langs->trans("TypeFees").'</td>';
+			print '<td>'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>';
 
-			print '<tr><td>' . $langs->trans("Account") . '</td><td>';
+			print '<tr><td>'.$langs->trans("Account").'</td><td>';
 			print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
 			print '</td></tr>';
 			print '</table>';
@@ -151,9 +151,9 @@ if (! empty($id)) {
 			dol_fiche_end();
 
 			print '<div class="center">';
-			print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
+			print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-			print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
+			print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
 			print '</div>';
 
 			print '</form>';

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

@@ -25,12 +25,12 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","bills","other","main","accountancy"));
+$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
 
 // Security check
 if (empty($conf->accounting->enabled)) {
@@ -38,15 +38,15 @@ if (empty($conf->accounting->enabled)) {
 }
 if ($user->socid > 0)
 	accessforbidden();
-if (! $user->rights->accounting->bind->write)
+if (!$user->rights->accounting->bind->write)
 	accessforbidden();
 
-$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
 if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
 else
 {
 	$year_start = dol_print_date(dol_now(), '%Y');
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--;	// If current month is lower that starting fiscal month, we start last year
+	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
 }
 $year_end = $year_start + 1;
 $month_end = $month_start - 1;
@@ -72,19 +72,19 @@ if ($action == 'clean' || $action == 'validatehistory')
 {
 	// Clean database
 	$db->begin();
-	$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
+	$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd";
 	$sql1 .= " SET fk_code_ventilation = 0";
 	$sql1 .= ' WHERE erd.fk_code_ventilation NOT IN';
 	$sql1 .= '	(SELECT accnt.rowid ';
-	$sql1 .= '	FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
-	$sql1 .= '	INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
-	$sql1 .= '	ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
-	$sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'expensereport WHERE entity = '.$conf->entity.')';
+	$sql1 .= '	FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
+	$sql1 .= '	INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
+	$sql1 .= '	ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
+	$sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'expensereport WHERE entity = '.$conf->entity.')';
 	$sql1 .= ' AND fk_code_ventilation <> 0';
 	dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
 	$resql1 = $db->query($sql1);
-	if (! $resql1) {
-		$error ++;
+	if (!$resql1) {
+		$error++;
 		$db->rollback();
 		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
@@ -99,16 +99,16 @@ if ($action == 'validatehistory') {
 
 	// Now make the binding
 	if ($db->type == 'pgsql') {
-		$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
+		$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det";
 		$sql1 .= " SET fk_code_ventilation = accnt.rowid";
-		$sql1 .= " FROM " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
-		$sql1 .= " WHERE " . MAIN_DB_PREFIX . "expensereport_det.fk_c_type_fees = t.id  AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
+		$sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst";
+		$sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id  AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
 		$sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number";
-		$sql1 .= " AND " . MAIN_DB_PREFIX . "expensereport_det.fk_code_ventilation = 0";
+		$sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0";
 	} else {
-		$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd, " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
+		$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst";
 		$sql1 .= " SET erd.fk_code_ventilation = accnt.rowid";
-		$sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
+		$sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
 		$sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number";
 		$sql1 .= " AND erd.fk_code_ventilation = 0";
 	}
@@ -116,8 +116,8 @@ if ($action == 'validatehistory') {
 	dol_syslog('htdocs/accountancy/expensereport/index.php');
 
 	$resql1 = $db->query($sql1);
-	if (! $resql1) {
-		$error ++;
+	if (!$resql1) {
+		$error++;
 		$db->rollback();
 		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
@@ -133,19 +133,19 @@ if ($action == 'validatehistory') {
 
 llxHeader('', $langs->trans("ExpenseReportsVentilation"));
 
-$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
-$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
+$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
+$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
 
-print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . "&nbsp;" . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
+print load_fiche_titre($langs->trans("ExpenseReportsVentilation")."&nbsp;".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
 
-print '<span class="opacitymedium">'.$langs->trans("DescVentilExpenseReport") . '<br>';
-print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
+print '<span class="opacitymedium">'.$langs->trans("DescVentilExpenseReport").'<br>';
+print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
 print '</span><br>';
 
 
 $y = $year_current;
 
-$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
+$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>';
 
 
 print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
@@ -153,39 +153,39 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '',
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
-print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
-print '<td width="200" class="left">' . $langs->trans("Label") . '</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 '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
+print '<td width="200" class="left">'.$langs->trans("Label").'</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  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
-$sql .= "  " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
-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_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+$sql = "SELECT  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
+$sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
+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_debut)='.$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 .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
-$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
-$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
+$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
+$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
+$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
 $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
+$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
 $sql .= " AND aa.account_number IS NULL";
 $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
 
-dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql);
+dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql);
 $resql = $db->query($sql);
 if ($resql) {
 	$num = $db->num_rows($resql);
 
-	while ( $row = $db->fetch_row($resql)) {
+	while ($row = $db->fetch_row($resql)) {
 		print '<tr class="oddeven"><td>';
 		if ($row[0] == 'tobind')
 		{
@@ -200,11 +200,11 @@ if ($resql) {
 		}
 		else print $row[1];
 		print '</td>';
-    	for($i = 2; $i <= 12; $i ++) {
-            print '<td class="nowrap right">' . price($row[$i]) . '</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 '<td class="nowrap right">'.price($row[13]).'</td>';
+        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
         print '</tr>';
     }
     $db->free($resql);
@@ -224,30 +224,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '',
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
-print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
-print '<td width="200" class="left">' . $langs->trans("Label") . '</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 '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
+print '<td width="200" class="left">'.$langs->trans("Label").'</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  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
-$sql .= "  " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
-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_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
+print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+$sql = "SELECT  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
+$sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
+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_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
 }
 $sql .= " ROUND(SUM(erd.total_ht),2) as total";
-$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
-$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
-$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
+$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
+$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
+$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
 $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
+$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
 $sql .= " AND aa.account_number IS NOT NULL";
 $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
 
@@ -256,7 +256,7 @@ $resql = $db->query($sql);
 if ($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')
 		{
@@ -272,11 +272,11 @@ if ($resql) {
 		}
 		else print $row[1];
 		print '</td>';
-    	for($i = 2; $i <= 12; $i ++) {
-            print '<td class="nowrap right">' . price($row[$i]) . '</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 '<td class="nowrap right">'.price($row[13]).'</td>';
+        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
         print '</tr>';
     }
     $db->free($resql);
@@ -298,27 +298,27 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
 
 	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 '<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>';
+    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 = "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) . "'";
+    $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)."'";
     $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
+    $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);
@@ -326,11 +326,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
         $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 '<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 '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
     		print '</tr>';
     	}
 

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

@@ -28,11 +28,11 @@
  */
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("bills","accountancy"));
+$langs->loadLangs(array("bills", "accountancy"));
 
 $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');
@@ -52,16 +52,16 @@ if ($user->socid > 0)
 
 if ($action == 'ventil' && $user->rights->accounting->bind->write)
 {
-	if (! $cancel)
+	if (!$cancel)
 	{
 	    if ($codeventil < 0) $codeventil = 0;
 
-		$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
-		$sql .= " SET fk_code_ventilation = " . $codeventil;
-		$sql .= " WHERE rowid = " . $id;
+		$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
+		$sql .= " SET fk_code_ventilation = ".$codeventil;
+		$sql .= " WHERE rowid = ".$id;
 
 		$resql = $db->query($sql);
-		if (! $resql) {
+		if (!$resql) {
 			setEventMessages($db->lasterror(), null, 'errors');
 		}
 		else
@@ -95,18 +95,18 @@ $form = new Form($db);
 $facturefournisseur_static = new FactureFournisseur($db);
 $formaccounting = new FormAccounting($db);
 
-if (! empty($id)) {
+if (!empty($id)) {
 	$sql = "SELECT f.ref as ref, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
 	$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label";
 	$sql .= ", aa.account_number, aa.label";
-	$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
-	$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
-	$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
-	$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")";     // We don't share object for accountancy
-
-	dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
+	$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
+	$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
+	$sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id;
+	$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
+
+	dol_syslog("/accounting/supplier/card.php sql=".$sql, LOG_DEBUG);
 	$result = $db->query($sql);
 
 	if ($result) {
@@ -116,8 +116,8 @@ if (! empty($id)) {
 		if ($num_lines) {
 			$objp = $db->fetch_object($result);
 
-			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
-			print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+			print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
+			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 			print '<input type="hidden" name="action" value="ventil">';
 			print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
 
@@ -128,17 +128,17 @@ if (! empty($id)) {
 			print '<table class="border centpercent">';
 
 			// ref invoice
-			print '<tr><td>' . $langs->trans("BillsSuppliers") . '</td>';
+			print '<tr><td>'.$langs->trans("BillsSuppliers").'</td>';
 			$facturefournisseur_static->ref = $objp->ref;
 			$facturefournisseur_static->id = $objp->facid;
-			print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
+			print '<td>'.$facturefournisseur_static->getNomUrl(1).'</td>';
 			print '</tr>';
 
-			print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
-			print '<td>' . stripslashes(nl2br($objp->description)) . '</td></tr>';
-			print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
-			print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
-			print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
+			print '<tr><td width="20%">'.$langs->trans("Line").'</td>';
+			print '<td>'.stripslashes(nl2br($objp->description)).'</td></tr>';
+			print '<tr><td width="20%">'.$langs->trans("ProductLabel").'</td>';
+			print '<td>'.dol_trunc($objp->product_label, 24).'</td>';
+			print '<tr><td width="20%">'.$langs->trans("Account").'</td><td>';
 			print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
 			print '</td></tr>';
 			print '</table>';
@@ -146,9 +146,9 @@ if (! empty($id)) {
 			dol_fiche_end();
 
 			print '<div class="center">';
-			print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
+			print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
 			print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-			print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
+			print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
 			print '</div>';
 
 			print '</form>';

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

@@ -25,13 +25,13 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("compta","bills","other","main","accountancy"));
+$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
 
 // Security check
 if (empty($conf->accounting->enabled)) {
@@ -39,16 +39,16 @@ if (empty($conf->accounting->enabled)) {
 }
 if ($user->socid > 0)
 	accessforbidden();
-if (! $user->rights->accounting->bind->write)
+if (!$user->rights->accounting->bind->write)
 	accessforbidden();
 
 
-$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
 if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
 else
 {
 	$year_start = dol_print_date(dol_now(), '%Y');
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--;	// If current month is lower that starting fiscal month, we start last year
+	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
 }
 $year_end = $year_start + 1;
 $month_end = $month_start - 1;
@@ -75,19 +75,19 @@ if ($action == 'clean' || $action == 'validatehistory')
 {
 	// Clean database
 	$db->begin();
-	$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
+	$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as fd";
 	$sql1 .= " SET fk_code_ventilation = 0";
 	$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN';
 	$sql1 .= '	(SELECT accnt.rowid ';
-	$sql1 .= '	FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
-	$sql1 .= '	INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
-	$sql1 .= '	ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
-	$sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture_fourn WHERE entity = '.$conf->entity.')';
+	$sql1 .= '	FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
+	$sql1 .= '	INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
+	$sql1 .= '	ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
+	$sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE entity = '.$conf->entity.')';
 	$sql1 .= ' AND fk_code_ventilation <> 0';
 	dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
 	$resql1 = $db->query($sql1);
-	if (! $resql1) {
-		$error ++;
+	if (!$resql1) {
+		$error++;
 		$db->rollback();
 		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
@@ -118,24 +118,24 @@ if ($action == 'validatehistory') {
 
 	// Supplier Invoice Lines (must be same request than into page list.php for manual binding)
 	$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
-	$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
-	$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
-	$sql.= " aa.rowid as aarowid,";
-	$sql.= " co.code as country_code, co.label as country_label,";
-	$sql.= " s.tva_intra";
-	$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
-	$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
-	$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
-	$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
-	$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
-	$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
-	$sql.= " AND l.product_type <= 2";
+	$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
+	$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
+	$sql .= " aa.rowid as aarowid,";
+	$sql .= " co.code as country_code, co.label as country_label,";
+	$sql .= " s.tva_intra";
+	$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
+	$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
+	$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
+	$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
+	$sql .= " AND l.product_type <= 2";
 
 	dol_syslog('htdocs/accountancy/supplier/index.php');
 
 	$result = $db->query($sql);
-	if (! $result) {
+	if (!$result) {
 		$error++;
 		setEventMessages($db->lasterror(), null, 'errors');
 	} else {
@@ -171,12 +171,12 @@ if ($action == 'validatehistory') {
 
 			if ($objp->aarowid_suggest > 0)
 			{
-				$sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
-				$sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
-				$sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
+				$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
+				$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
+				$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
 
 				$resqlupdate = $db->query($sqlupdate);
-				if (! $resqlupdate)
+				if (!$resqlupdate)
 				{
 					$error++;
 					setEventMessages($db->lasterror(), null, 'errors');
@@ -205,18 +205,18 @@ if ($action == 'validatehistory') {
 
 llxHeader('', $langs->trans("SuppliersVentilation"));
 
-$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
-$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
+$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
+$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
 
-print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
+print load_fiche_titre($langs->trans("SuppliersVentilation")." ".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
 
-print '<span class="opacitymedium">'.$langs->trans("DescVentilSupplier") . '<br>';
-print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
+print '<span class="opacitymedium">'.$langs->trans("DescVentilSupplier").'<br>';
+print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
 print '</span><br>';
 
 $y = $year_current;
 
-$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
+$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>';
 
 
 print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
@@ -224,30 +224,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '',
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
-print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
-print '<td width="200" class="left">' . $langs->trans("Label") . '</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 '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
+print '<td width="200" class="left">'.$langs->trans("Label").'</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  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
-$sql .= "  " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
-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) . ",";
+print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+$sql = "SELECT  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
+$sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
+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 .= "  LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
-$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
-$sql .= "  AND ff.datef <= '" . $db->idate($search_date_end) . "'";
+$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 .= "  LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
+$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
+$sql .= "  AND ff.datef <= '".$db->idate($search_date_end)."'";
 $sql .= "  AND ff.fk_statut > 0";
-$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")";     // We don't share object for accountancy
+$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
 $sql .= " AND aa.account_number IS NULL";
 $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
 
@@ -256,7 +256,7 @@ $resql = $db->query($sql);
 if ($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')
 		{
@@ -271,11 +271,11 @@ if ($resql) {
 		}
 		else print $row[1];
 		print '</td>';
-		for($i = 2; $i <= 12; $i ++) {
-			print '<td class="nowrap right">' . price($row[$i]) . '</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 '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
 		print '</tr>';
 	}
 	$db->free($resql);
@@ -294,30 +294,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '',
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
-print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
-print '<td width="200" class="left">' . $langs->trans("Label") . '</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 '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
+print '<td width="200" class="left">'.$langs->trans("Label").'</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  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
-$sql .= "  " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
-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) . ",";
+print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+$sql = "SELECT  ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
+$sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
+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 .= "  LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
-$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
-$sql .= "  AND ff.datef <= '" . $db->idate($search_date_end) . "'";
+$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 .= "  LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
+$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
+$sql .= "  AND ff.datef <= '".$db->idate($search_date_end)."'";
 $sql .= "  AND ff.fk_statut > 0";
-$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")";     // We don't share object for accountancy
+$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
 $sql .= " AND aa.account_number IS NOT NULL";
 $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
 
@@ -326,7 +326,7 @@ $resql = $db->query($sql);
 if ($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')
 		{
@@ -341,11 +341,11 @@ if ($resql) {
 		}
 		else print $row[1];
 		print '</td>';
-    	for($i = 2; $i <= 12; $i++) {
-            print '<td class="nowrap right">' . price($row[$i]) . '</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 '<td class="nowrap right">'.price($row[13]).'</td>';
+        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
         print '</tr>';
     }
     $db->free($resql);
@@ -367,27 +367,27 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
 
 	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 '<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>';
+    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 = "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) . "'";
+    $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)."'";
     $sql .= "  AND ff.fk_statut > 0";
-    $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")";     // We don't share object for accountancy
+    $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);
@@ -395,11 +395,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
     	$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 '<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 '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
     		print '</tr>';
     	}
         $db->free($resql);

+ 54 - 54
htdocs/adherents/subscription/card.php

@@ -27,29 +27,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
-if (! empty($conf->banque->enabled)) {
+if (!empty($conf->banque->enabled)) {
 	require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
 }
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","members","bills","users"));
+$langs->loadLangs(array("companies", "members", "bills", "users"));
 
 $adh = new Adherent($db);
 $adht = new AdherentType($db);
 $object = new Subscription($db);
-$errmsg='';
+$errmsg = '';
 
-$action=GETPOST("action", 'alpha');
-$rowid=GETPOST("rowid", "int")?GETPOST("rowid", "int"):GETPOST("id", "int");
-$typeid=GETPOST("typeid", "int");
-$cancel=GETPOST('cancel', 'alpha');
-$confirm=GETPOST('confirm');
+$action = GETPOST("action", 'alpha');
+$rowid = GETPOST("rowid", "int") ?GETPOST("rowid", "int") : GETPOST("id", "int");
+$typeid = GETPOST("typeid", "int");
+$cancel = GETPOST('cancel', 'alpha');
+$confirm = GETPOST('confirm');
 
-if (! $user->rights->adherent->cotisation->lire)
+if (!$user->rights->adherent->cotisation->lire)
 	 accessforbidden();
 
 $permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php
-$permissiondellink=$user->rights->adherent->cotisation->creer;	// Used by the include of actions_dellink.inc.php
+$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
 $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php
 
 
@@ -57,60 +57,60 @@ $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the i
  * 	Actions
  */
 
-if ($cancel) $action='';
+if ($cancel) $action = '';
 
 //include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
 
-include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';		// Must be include, not include_once
+include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
 
 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';	// Must be include, not include_once
 
 
-if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $cancel)
+if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cancel)
 {
 	// Load current object
-	$result=$object->fetch($rowid);
+	$result = $object->fetch($rowid);
 	if ($result > 0)
 	{
 		$db->begin();
 
-		$errmsg='';
+		$errmsg = '';
 
 		if ($object->fk_bank)
 		{
-			$accountline=new AccountLine($db);
-			$result=$accountline->fetch($object->fk_bank);
+			$accountline = new AccountLine($db);
+			$result = $accountline->fetch($object->fk_bank);
 
 			// If transaction consolidated
 			if ($accountline->rappro)
 			{
-				$errmsg=$langs->trans("SubscriptionLinkedToConciliatedTransaction");
+				$errmsg = $langs->trans("SubscriptionLinkedToConciliatedTransaction");
 			}
 			else
 			{
-				$accountline->datev=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
-				$accountline->dateo=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
-				$accountline->amount=$_POST["amount"];
-				$result=$accountline->update($user);
+				$accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
+				$accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
+				$accountline->amount = $_POST["amount"];
+				$result = $accountline->update($user);
 				if ($result < 0)
 				{
-					$errmsg=$accountline->error;
+					$errmsg = $accountline->error;
 				}
 			}
 		}
 
-		if (! $errmsg)
+		if (!$errmsg)
 		{
 			// Modify values
-			$object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
-			$object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
-			$object->fk_type=$_POST["typeid"];
-			$object->note=$_POST["note"];
-			$object->amount=$_POST["amount"];
+			$object->dateh = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
+			$object->datef = dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
+			$object->fk_type = $_POST["typeid"];
+			$object->note = $_POST["note"];
+			$object->amount = $_POST["amount"];
 			//print 'datef='.$object->datef.' '.$_POST['datesubendday'];
 
-			$result=$object->update($user);
-			if ($result >= 0 && ! count($object->errors))
+			$result = $object->update($user);
+			if ($result >= 0 && !count($object->errors))
 			{
 				$db->commit();
 
@@ -123,17 +123,17 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc
 
 			    if ($object->error)
 				{
-					$errmsg=$object->error;
+					$errmsg = $object->error;
 				}
 				else
 				{
-					foreach($object->errors as $error)
+					foreach ($object->errors as $error)
 					{
-						if ($errmsg) $errmsg.='<br>';
-						$errmsg.=$error;
+						if ($errmsg) $errmsg .= '<br>';
+						$errmsg .= $error;
 					}
 				}
-				$action='';
+				$action = '';
 			}
 		}
 		else
@@ -145,8 +145,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc
 
 if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer)
 {
-	$result=$object->fetch($rowid);
-    $result=$object->delete($user);
+	$result = $object->fetch($rowid);
+    $result = $object->delete($user);
     if ($result > 0)
     {
     	header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent);
@@ -154,7 +154,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent-
     }
     else
     {
-    	$mesg=$adh->error;
+    	$mesg = $adh->error;
     }
 }
 
@@ -182,7 +182,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
 	 ********************************************/
 
     $object->fetch($rowid);
-	$result=$adh->fetch($object->fk_adherent);
+	$result = $adh->fetch($object->fk_adherent);
 
 	$head = subscription_prepare_head($object);
 
@@ -206,7 +206,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
 	print '</td></tr>';
 
 	// Member
-	$adh->ref=$adh->getFullName($langs);
+	$adh->ref = $adh->getFullName($langs);
 	print '<tr>';
 	print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
 	print '</tr>';
@@ -214,7 +214,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
 	// Type
 	print '<tr>';
 	print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
-	print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type));
+	print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"]) ? $_POST["typeid"] : $object->fk_type));
 	print'</td></tr>';
 
     // Date start subscription
@@ -238,15 +238,15 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
 	print '<input type="text" class="flat" size="60" name="note" value="'.$object->note.'"></td></tr>';
 
 	// Bank line
-	if (! empty($conf->banque->enabled))
+	if (!empty($conf->banque->enabled))
 	{
 		if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)
 		{
 			print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">';
 			if ($object->fk_bank)
 			{
-				$bankline=new AccountLine($db);
-				$result=$bankline->fetch($object->fk_bank);
+				$bankline = new AccountLine($db);
+				$result = $bankline->fetch($object->fk_bank);
 				print $bankline->getNomUrl(1, 0, 'showall');
 			}
 			else
@@ -279,8 +279,8 @@ if ($rowid && $action != 'edit')
 	 *
 	 ********************************************/
 
-    $result=$object->fetch($rowid);
-	$result=$adh->fetch($object->fk_adherent);
+    $result = $object->fetch($rowid);
+	$result = $adh->fetch($object->fk_adherent);
 
 	$head = subscription_prepare_head($object);
 
@@ -291,8 +291,8 @@ if ($rowid && $action != 'edit')
     {
 		//$formquestion=array();
         //$formquestion['text']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>';
-		$text=$langs->trans("ConfirmDeleteSubscription");
-		if (! empty($conf->banque->enabled) && ! empty($conf->global->ADHERENT_BANK_USE)) $text.='<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
+		$text = $langs->trans("ConfirmDeleteSubscription");
+		if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
 		print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1);
     }
 
@@ -310,7 +310,7 @@ if ($rowid && $action != 'edit')
     print '<table class="border centpercent">';
 
     // Member
-    $adh->ref=$adh->getFullName($langs);
+    $adh->ref = $adh->getFullName($langs);
     print '<tr>';
     print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
     print '</tr>';
@@ -345,15 +345,15 @@ if ($rowid && $action != 'edit')
     print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur">'.$object->note.'</td></tr>';
 
 	// Bank line
-	if (! empty($conf->banque->enabled))
+	if (!empty($conf->banque->enabled))
 	{
 		if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)
 		{
 			print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur">';
 			if ($object->fk_bank)
 			{
-				$bankline=new AccountLine($db);
-				$result=$bankline->fetch($object->fk_bank);
+				$bankline = new AccountLine($db);
+				$result = $bankline->fetch($object->fk_bank);
 				print $bankline->getNomUrl(1, 0, 'showall');
 			}
 			else
@@ -379,7 +379,7 @@ if ($rowid && $action != 'edit')
 
     if ($user->rights->adherent->cotisation->creer)
 	{
-		if (! $bankline->rappro)
+		if (!$bankline->rappro)
 		{
 			print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id."&action=edit\">".$langs->trans("Modify")."</a></div>";
 		}

+ 103 - 103
htdocs/adherents/type.php

@@ -41,35 +41,35 @@ $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');
 $backtopage = GETPOST('backtopage', 'alpha');
 
-$search_lastname	= GETPOST('search_lastname', 'alpha');
+$search_lastname = GETPOST('search_lastname', 'alpha');
 $search_login		= GETPOST('search_login', 'alpha');
 $search_email		= GETPOST('search_email', 'alpha');
-$type				= GETPOST('type', 'intcomma');
+$type = GETPOST('type', 'intcomma');
 $status				= GETPOST('status', 'alpha');
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');
 if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
-$offset = $limit * $page ;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortorder) {  $sortorder="DESC"; }
-if (! $sortfield) {  $sortfield="d.lastname"; }
+if (!$sortorder) {  $sortorder = "DESC"; }
+if (!$sortfield) {  $sortfield = "d.lastname"; }
 
-$label=GETPOST("label", "alpha");
-$morphy=GETPOST("morphy", "alpha");
-$statut=GETPOST("statut", "int");
-$subscription=GETPOST("subscription", "int");
+$label = GETPOST("label", "alpha");
+$morphy = GETPOST("morphy", "alpha");
+$statut = GETPOST("statut", "int");
+$subscription = GETPOST("subscription", "int");
 $duration_value = GETPOST('duration_value', 'int');
 $duration_unit = GETPOST('duration_unit', 'alpha');
-$vote=GETPOST("vote", "int");
-$comment=GETPOST("comment", 'alphanohtml');
-$mail_valid=GETPOST("mail_valid", 'none');
+$vote = GETPOST("vote", "int");
+$comment = GETPOST("comment", 'alphanohtml');
+$mail_valid = GETPOST("mail_valid", 'none');
 
 // Security check
-$result=restrictedArea($user, 'adherent', $rowid, 'adherent_type');
+$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type');
 
 $object = new AdherentType($db);
 
@@ -80,16 +80,16 @@ $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_lastname = "";
+    $search_login = "";
+    $search_email = "";
+    $type = "";
+    $sall = "";
 }
 
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('membertypecard','globalcard'));
+$hookmanager->initHooks(array('membertypecard', 'globalcard'));
 
 
 /*
@@ -97,23 +97,23 @@ $hookmanager->initHooks(array('membertypecard','globalcard'));
  */
 
 if ($cancel) {
-	$action='';
+	$action = '';
 
-	if (! empty($backtopage)) {
+	if (!empty($backtopage)) {
 		header("Location: ".$backtopage);
 		exit;
 	}
 }
 
 if ($action == 'add' && $user->rights->adherent->configurer) {
-	$object->label			= trim($label);
+	$object->label = trim($label);
 	$object->morphy         = trim($morphy);
 	$object->statut         = (int) $statut;
 	$object->subscription   = (int) $subscription;
 	$object->duration_value     	 = $duration_value;
 	$object->duration_unit      	 = $duration_unit;
 	$object->note			= trim($comment);
-	$object->mail_valid		= trim($mail_valid);
+	$object->mail_valid = trim($mail_valid);
 	$object->vote			= (int) $vote;
 
 	// Fill array 'array_options' with data from add form
@@ -137,9 +137,9 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
 		}
 	}
 
-	if (! $error)
+	if (!$error)
 	{
-		$id=$object->create($user);
+		$id = $object->create($user);
 		if ($id > 0)
 		{
 			header("Location: ".$_SERVER["PHP_SELF"]);
@@ -164,22 +164,22 @@ if ($action == 'update' && $user->rights->adherent->configurer)
 	$object->oldcopy = clone $object;
 
 	$object->label			= trim($label);
-	$object->morphy         = trim($morphy);
+	$object->morphy = trim($morphy);
 	$object->statut = (int) $statut;
 	$object->subscription = (int) $subscription;
 	$object->duration_value     	 = $duration_value;
 	$object->duration_unit      	 = $duration_unit;
 	$object->note			= trim($comment);
-	$object->mail_valid		= trim($mail_valid);
+	$object->mail_valid = trim($mail_valid);
 	$object->vote			= (boolean) trim($vote);
 
 	// Fill array 'array_options' with data from add form
 	$ret = $extrafields->setOptionalsFromPost(null, $object);
 	if ($ret < 0) $error++;
 
-	$ret=$object->update($user);
+	$ret = $object->update($user);
 
-	if ($ret >= 0 && ! count($object->errors))
+	if ($ret >= 0 && !count($object->errors))
 	{
 		setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
 	}
@@ -195,7 +195,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
 if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
 {
 	$object->fetch($rowid);
-	$res=$object->delete();
+	$res = $object->delete();
 
 	if ($res > 0)
 	{
@@ -206,7 +206,7 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
 	else
 	{
 		setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
-		$action='';
+		$action = '';
 	}
 }
 
@@ -215,20 +215,20 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 $formproduct = new FormProduct($db);
 
 llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
 
 
 // List of members type
-if (! $rowid && $action != 'create' && $action != 'edit')
+if (!$rowid && $action != 'create' && $action != 'edit')
 {
 	//dol_fiche_head('');
 
 	$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy";
-	$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
-	$sql.= " WHERE d.entity IN (".getEntity('member_type').")";
+	$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
+	$sql .= " WHERE d.entity IN (".getEntity('member_type').")";
 
 	$result = $db->query($sql);
 	if ($result)
@@ -240,10 +240,10 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 
 		$param = '';
 
-		$newcardbutton='';
+		$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"].'">';
@@ -260,7 +260,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 		$moreforfilter = '';
 
 		print '<div class="div-table-responsive">';
-		print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
+		print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 		print '<tr class="liste_titre">';
 		print '<th>'.$langs->trans("Ref").'</th>';
@@ -295,7 +295,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 			print '<td class="center">'.yn($objp->subscription).'</td>';
 			print '<td class="center">'.yn($objp->vote).'</td>';
 			print '<td class="center">';
-            if ( !empty($objp->statut) ) {
+            if (!empty($objp->statut)) {
                 print img_picto($langs->trans("InActivity"), 'statut4');
             } else {
                 print img_picto($langs->trans("ActivityCeased"), 'statut5');
@@ -343,7 +343,7 @@ if ($action == 'create')
 	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
 
 	print '<tr><td>'.$langs->trans("Status").'</td><td>';
-  	print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), 1);
+  	print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
   	print '</td></tr>';
 
     // Morphy
@@ -351,7 +351,7 @@ if ($action == 'create')
     $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, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
+	print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy);
 	print "</td></tr>";
 
   	print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
@@ -372,13 +372,13 @@ if ($action == 'create')
 
 	print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
 	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-	$doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
+	$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
 	$doleditor->Create();
 	print '</td></tr>';
 
 	// Other attributes
-	$parameters=array();
-	$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action);    // Note that $action and $object may have been modified by hook
+	$parameters = array();
+	$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
     print $hookmanager->resPrint;
 	if (empty($reshook))
 	{
@@ -433,7 +433,7 @@ if ($rowid > 0)
 		print '<table class="border centpercent">';
 
    		print '<tr><td class="titlefield">'.$langs->trans("Status").'</td><td>';
-        if ( !empty($object->statut) ) {
+        if (!empty($object->statut)) {
             print img_picto($langs->trans('TypeStatusActive'), 'statut4').' '.$langs->trans("InActivity");
         } else {
             print img_picto($langs->trans('TypeStatusInactive'), 'statut5').' '.$langs->trans("ActivityCeased");
@@ -455,13 +455,13 @@ if ($rowid > 0)
 		print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';
 		if ($object->duration_value > 1)
 		{
-			$dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
+			$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
 		}
 		elseif ($object->duration_value > 0)
 		{
-			$dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
+			$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
 		}
-		print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;";
+		print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;";
 		print '</td></tr>';
 
 		print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
@@ -471,7 +471,7 @@ if ($rowid > 0)
 		print nl2br($object->mail_valid)."</td></tr>";
 
 		// Other attributes
-		include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
 
 		print '</table>';
 		print '</div>';
@@ -491,7 +491,7 @@ if ($rowid > 0)
 		}
 
 		// Add
-        if ( $user->rights->adherent->configurer && !empty($object->statut) )
+        if ($user->rights->adherent->configurer && !empty($object->statut))
 		{
             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 {
@@ -509,55 +509,55 @@ if ($rowid > 0)
 
 		// Show list of members (nearly same code than in page list.php)
 
-		$membertypestatic=new AdherentType($db);
+		$membertypestatic = new AdherentType($db);
 
-		$now=dol_now();
+		$now = dol_now();
 
 		$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,";
-		$sql.= " d.datefin,";
-		$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
-		$sql.= " t.libelle as type, t.subscription";
-		$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
-		$sql.= " WHERE d.fk_adherent_type = t.rowid ";
-		$sql.= " AND d.entity IN (".getEntity('adherent').")";
-		$sql.= " AND t.rowid = ".$object->id;
+		$sql .= " d.datefin,";
+		$sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
+		$sql .= " t.libelle as type, t.subscription";
+		$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
+		$sql .= " WHERE d.fk_adherent_type = t.rowid ";
+		$sql .= " AND d.entity IN (".getEntity('adherent').")";
+		$sql .= " AND t.rowid = ".$object->id;
 		if ($sall)
 		{
-			$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);
+			$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'))
 			{
-		  		$sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search', 'alpha'));
+		  		$sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha'));
 		  	}
 		}
-		if (! empty($search_lastname))
+		if (!empty($search_lastname))
 		{
-			$sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname);
+			$sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname);
 		}
-		if (! empty($search_login))
+		if (!empty($search_login))
 		{
-			$sql.= natural_search("d.login", $search_login);
+			$sql .= natural_search("d.login", $search_login);
 		}
-		if (! empty($search_email))
+		if (!empty($search_email))
 		{
-			$sql.= natural_search("d.email", $search_email);
+			$sql .= natural_search("d.email", $search_email);
 		}
         if ($filter == 'uptodate')
         {
-            $sql.=" AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
+            $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
         }
         if ($filter == 'outofdate')
         {
-            $sql.=" AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
+            $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
         }
 
-		$sql.= " ".$db->order($sortfield, $sortorder);
+		$sql .= " ".$db->order($sortfield, $sortorder);
 
 		// Count total nb of records
 		$nbtotalofrecords = '';
@@ -573,7 +573,7 @@ if ($rowid > 0)
 		    }
 		}
 
-		$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
+		$sql .= " ".$db->plimit($conf->liste_limit + 1, $offset);
 
 		$resql = $db->query($sql);
 		if ($resql)
@@ -581,35 +581,35 @@ if ($rowid > 0)
 		    $num = $db->num_rows($resql);
 		    $i = 0;
 
-		    $titre=$langs->trans("MembersList");
+		    $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"); }
+		        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");
+		        $titre = $langs->trans("MembersListQualified");
 		    }
 
 		    if ($type > 0)
 		    {
-				$membertype=new AdherentType($db);
-		        $result=$membertype->fetch($type);
-				$titre.=" (".$membertype->label.")";
+				$membertype = new AdherentType($db);
+		        $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)
 		    {
@@ -617,7 +617,7 @@ if ($rowid > 0)
 		    }
 
 			print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
-            print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
+            print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">';
 			print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
 
 			print '<br>';
@@ -626,7 +626,7 @@ if ($rowid > 0)
             $moreforfilter = '';
 
             print '<div class="div-table-responsive">';
-            print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
+            print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
             // Fields title search
 			print '<tr class="liste_titre_filter">';
@@ -666,11 +666,11 @@ if ($rowid > 0)
 		    {
 		        $objp = $db->fetch_object($resql);
 
-		        $datefin=$db->jdate($objp->datefin);
+		        $datefin = $db->jdate($objp->datefin);
 
-		        $adh=new Adherent($db);
-		        $adh->lastname=$objp->lastname;
-		        $adh->firstname=$objp->firstname;
+		        $adh = new Adherent($db);
+		        $adh->lastname = $objp->lastname;
+		        $adh->firstname = $objp->firstname;
 
 		        // Lastname
 		        print '<tr class="oddeven">';
@@ -794,7 +794,7 @@ 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('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut);
+    	print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->statut);
     	print '</td></tr>';
 
         // Morphy
@@ -802,7 +802,7 @@ if ($rowid > 0)
         $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, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
+        print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy);
         print "</td></tr>";
 
     	print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
@@ -823,16 +823,16 @@ if ($rowid > 0)
 
 		print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-		$doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
+		$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
 		$doleditor->Create();
 		print "</td></tr>";
 
 		// Other attributes
-		include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
+		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
 
 		// Other attributes
-		$parameters=array();
-		$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
+		$parameters = array();
+		$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
         	print $hookmanager->resPrint;
 		if (empty($reshook))
 		{

+ 24 - 24
htdocs/adherents/type_translation.php

@@ -35,15 +35,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
 $langs->loadLangs(array('members', 'languages'));
 
 $id = GETPOST('rowid', 'int');
-$action=GETPOST('action', 'alpha');
-$cancel=GETPOST('cancel', 'alpha');
+$action = GETPOST('action', 'alpha');
+$cancel = GETPOST('cancel', 'alpha');
 
 // Security check
-$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
-$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
-if ($user->socid) $socid=$user->socid;
+$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
+$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
+if ($user->socid) $socid = $user->socid;
 // Security check
-$result=restrictedArea($user, 'adherent', $id, 'adherent_type');
+$result = restrictedArea($user, 'adherent', $id, 'adherent_type');
 
 
 /*
@@ -105,21 +105,21 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a
 
 	foreach ($object->multilangs as $key => $value) // saving new values in the object
 	{
-		if ( $key == $current_lang )
+		if ($key == $current_lang)
 		{
 			$object->label			= $_POST["libelle-".$key];
-			$object->description	= dol_htmlcleanlastbr($_POST["desc-".$key]);
+			$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
 			$object->other			= dol_htmlcleanlastbr($_POST["other-".$key]);
 		}
 		else
 		{
 			$object->multilangs[$key]["label"]			= $_POST["libelle-".$key];
-			$object->multilangs[$key]["description"]	= dol_htmlcleanlastbr($_POST["desc-".$key]);
+			$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
 			$object->multilangs[$key]["other"]			= dol_htmlcleanlastbr($_POST["other-".$key]);
 		}
 	}
 
-	if ( $object->setMultiLangs($user) > 0 )
+	if ($object->setMultiLangs($user) > 0)
 	{
 		$action = '';
 	}
@@ -135,10 +135,10 @@ if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights-
 {
 	$object = new AdherentType($db);
 	$object->fetch($id);
-	$langtodelete=GETPOST('langdel', 'alpha');
+	$langtodelete = GETPOST('langdel', 'alpha');
 
 
-	if ( $object->delMultiLangs($langtodelete, $user) > 0 )
+	if ($object->delMultiLangs($langtodelete, $user) > 0)
 	{
 		$action = '';
 	}
@@ -161,20 +161,20 @@ $title = $langs->trans('MemberTypeCard');
 $helpurl = '';
 $shortlabel = dol_trunc($object->label, 16);
 
-$title = $langs->trans('MemberType')." ". $shortlabel ." - ".$langs->trans('Translation');
-$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
+$title = $langs->trans('MemberType')." ".$shortlabel." - ".$langs->trans('Translation');
+$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
 
 llxHeader('', $title, $helpurl);
 
 $form = new Form($db);
-$formadmin=new FormAdmin($db);
+$formadmin = new FormAdmin($db);
 
 $head = member_type_prepare_head($object);
-$titre=$langs->trans("MemberType".$object->type);
+$titre = $langs->trans("MemberType".$object->type);
 
 // Calculate $cnt_trans
 $cnt_trans = 0;
-if (! empty($object->multilangs))
+if (!empty($object->multilangs))
 {
     foreach ($object->multilangs as $key => $value)
     {
@@ -224,12 +224,12 @@ if ($action == 'edit')
 	print '<input type="hidden" name="action" value="vedit">';
 	print '<input type="hidden" name="rowid" value="'.$object->id.'">';
 
-	if (! empty($object->multilangs))
+	if (!empty($object->multilangs))
 	{
 		foreach ($object->multilangs as $key => $value)
 		{
-			$s=picto_from_langcode($key);
-			print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>";
+			$s = picto_from_langcode($key);
+			print "<br>".($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>";
 
 			print '<div class="underbanner clearboth"></div>';
 			print '<table class="border centpercent">';
@@ -255,12 +255,12 @@ if ($action == 'edit')
 }
 elseif ($action != 'add')
 {
-	if (! empty($object->multilangs))
+	if (!empty($object->multilangs))
 	{
 		foreach ($object->multilangs as $key => $value)
 		{
-			$s=picto_from_langcode($key);
-			print ($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>';
+			$s = picto_from_langcode($key);
+			print ($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>';
 
 			print '<div class="fichecenter">';
 			print '<div class="underbanner clearboth"></div>';
@@ -271,7 +271,7 @@ elseif ($action != 'add')
 			print '</div>';
 		}
 	}
-	if (! $cnt_trans && $action != 'add') print '<div class="opacitymedium">'. $langs->trans('NoTranslation').'</div>';
+	if (!$cnt_trans && $action != 'add') print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
 }
 
 

+ 26 - 26
htdocs/admin/agenda.php

@@ -41,9 +41,9 @@ $search_event = GETPOST('search_event', 'alpha');
 
 // Get list of triggers available
 $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position";
-$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
-$sql.= " ORDER BY a.rang ASC";
-$resql=$db->query($sql);
+$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
+$sql .= " ORDER BY a.rang ASC";
+$resql = $db->query($sql);
 if ($resql)
 {
 	$num = $db->num_rows($resql);
@@ -51,11 +51,11 @@ if ($resql)
 	while ($i < $num)
 	{
 		$obj = $db->fetch_object($resql);
-		$triggers[$i]['rowid'] 		= $obj->rowid;
+		$triggers[$i]['rowid'] = $obj->rowid;
 		$triggers[$i]['code'] 		= $obj->code;
-		$triggers[$i]['element'] 	= $obj->elementtype;
-		$triggers[$i]['label']		= ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
-		$triggers[$i]['position'] 	= $obj->position;
+		$triggers[$i]['element'] = $obj->elementtype;
+		$triggers[$i]['label']		= ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
+		$triggers[$i]['position'] = $obj->position;
 
 		$i++;
 	}
@@ -74,35 +74,35 @@ else
  */
 
 // Purge search criteria
-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
+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_event = '';
 	$action = '';
 }
 
-if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') ||GETPOST('button_search', 'alpha'))	// To avoid the save when we click on search
+if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))	// To avoid the save when we click on search
 {
 	$action = '';
 }
 
 if ($action == "save" && empty($cancel))
 {
-    $i=0;
+    $i = 0;
 
     $db->begin();
 
 	foreach ($triggers as $trigger)
 	{
-		$keyparam='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
+		$keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
 		//print "param=".$param." - ".$_POST[$param];
 		if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam))
 		{
-			$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha')?GETPOST($keyparam, 'alpha'):''), 'chaine', 0, '', $conf->entity);
-			if (! $res > 0) $error++;
+			$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
+			if (!$res > 0) $error++;
 		}
 	}
 
- 	if (! $error)
+ 	if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
         $db->commit();
@@ -120,10 +120,10 @@ if ($action == "save" && empty($cancel))
  * View
  */
 
-$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
+$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
 llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@@ -131,23 +131,23 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="save">';
 
 $param = '';
-$param.= '&search_event='.urlencode($search_event);
+$param .= '&search_event='.urlencode($search_event);
 
-$head=agenda_prepare_head();
+$head = agenda_prepare_head();
 
 dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action');
 
 print '<span class="opacitymedium">'.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'</span><br>';
 print "<br>\n";
 
-print '<div class="div-table-responsive">';		// You can use div-table-responsive-no-min if you dont need reserved height for your table
+print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
 print '<td class="liste_titre"><input type="text" name="search_event" value="'.dol_escape_htmltag($search_event).'"></td>';
 print '<td class="liste_titre"></td>';
 // Action column
 print '<td class="liste_titre maxwidthsearch">';
-$searchpicto=$form->showFilterButtons();
+$searchpicto = $form->showFilterButtons();
 print $searchpicto;
 print '</td>';
 print '</tr>';
@@ -155,10 +155,10 @@ print '</tr>'."\n";
 
 print '<tr class="liste_titre">';
 print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</th>';
-print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param?$param:'').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param?$param:'').'">'.$langs->trans("None").'</a></th>';
+print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>';
 print '</tr>'."\n";
 // Show each trigger (list is in c_action_trigger)
-if (! empty($triggers))
+if (!empty($triggers))
 {
 	foreach ($triggers as $trigger)
 	{
@@ -170,7 +170,7 @@ if (! empty($triggers))
 		if ($module == 'proposal_supplier') $module = 'supplier_proposal';
 
 		//print 'module='.$module.'<br>';
-		if (! empty($conf->$module->enabled))
+		if (!empty($conf->$module->enabled))
 		{
 			// Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
 			if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
@@ -182,9 +182,9 @@ if (! empty($triggers))
 				print '<td>'.$trigger['code'].'</td>';
 				print '<td>'.$trigger['label'].'</td>';
 				print '<td class="right" width="40">';
-				$key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
-				$value=$conf->global->$key;
-				print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action=='selectall'||$value) && $action!="selectnone")?' checked':'').'>';
+				$key = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
+				$value = $conf->global->$key;
+				print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action == 'selectall' || $value) && $action != "selectnone") ? ' checked' : '').'>';
 				print '</td></tr>'."\n";
 			}
 		}

+ 73 - 73
htdocs/admin/bank.php

@@ -25,20 +25,20 @@
  * 		\brief      Page to setup the bank module
  */
 require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
-require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","companies","bills","other","banks"));
+$langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
 
 if (!$user->admin)
     accessforbidden();
 
 $action = GETPOST('action', 'alpha');
-$actionsave=GETPOST('save', 'alpha');
+$actionsave = GETPOST('save', 'alpha');
 $value = GETPOST('value', 'alpha');
 $label = GETPOST('label', 'alpha');
 $scandir = GETPOST('scan_dir', 'alpha');
@@ -53,7 +53,7 @@ $type = 'bankaccount';
 if ($action == 'setbankorder') {
     if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0)
     {
-        header("Location: " . $_SERVER["PHP_SELF"]);
+        header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
     }
     else {
@@ -65,7 +65,7 @@ if ($action == 'setbankorder') {
 if ($action == 'setreportlastnumreleve') {
     if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0)
     {
-        header("Location: " . $_SERVER["PHP_SELF"]);
+        header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
     }
     else {
@@ -75,7 +75,7 @@ if ($action == 'setreportlastnumreleve') {
 elseif ($action == 'unsetreportlastnumreleve') {
     if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0)
     {
-        header("Location: " . $_SERVER["PHP_SELF"]);
+        header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
     }
     else {
@@ -87,7 +87,7 @@ elseif ($action == 'unsetreportlastnumreleve') {
 if ($action == 'setbankcolorizemovement') {
     if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0)
     {
-        header("Location: " . $_SERVER["PHP_SELF"]);
+        header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
     }
     else {
@@ -97,7 +97,7 @@ if ($action == 'setbankcolorizemovement') {
 elseif ($action == 'unsetbankcolorizemovement') {
     if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0)
     {
-        header("Location: " . $_SERVER["PHP_SELF"]);
+        header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
     }
     else {
@@ -109,21 +109,21 @@ if ($actionsave)
 {
     $db->begin();
 
-    $i=1; $errorsaved=0;
-    $error=0;
+    $i = 1; $errorsaved = 0;
+    $error = 0;
 
     // Save colors
     while ($i <= 2)
     {
-        $color=trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'));
-        if ($color=='-1') $color='';
+        $color = trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'));
+        if ($color == '-1') $color = '';
 
-        $res=dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
-        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
+        if (!$res > 0) $error++;
         $i++;
     }
 
-    if (! $error)
+    if (!$error)
     {
         $db->commit();
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -153,10 +153,10 @@ if ($action == 'specimen') {
     $filefound = 0;
     $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
     foreach ($dirmodels as $reldir) {
-        $file = dol_buildpath($reldir . "core/modules/bank/doc/pdf_" . $modele . ".modules.php", 0);
+        $file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0);
         if (file_exists($file)) {
             $filefound = 1;
-            $classname = "pdf_" . $modele;
+            $classname = "pdf_".$modele;
             break;
         }
     }
@@ -167,7 +167,7 @@ if ($action == 'specimen') {
         $module = new $classname($db);
 
         if ($module->write_file($object, $langs) > 0) {
-            header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=bank&file=SPECIMEN.pdf");
+            header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf");
             return;
         }
         else {
@@ -214,13 +214,13 @@ elseif ($action == 'setdoc') {
  */
 
 $form = new Form($db);
-$formother=new FormOther($db);
+$formother = new FormOther($db);
 
 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 
 llxHeader("", $langs->trans("BankSetupModule"));
 
-$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup');
 
 print '<form name="bankmovementcolorconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
@@ -235,10 +235,10 @@ print load_fiche_titre($langs->trans("BankOrderShow"), '', '');
 
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td width="140">' . $langs->trans("Name") . '</td>';
-print '<td>' . $langs->trans("Description") . '</td>';
-print '<td>' . $langs->trans("Example") . '</td>';
-print '<td class="center">' . $langs->trans("Status") . '</td>';
+print '<td width="140">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '<td class="center">'.$langs->trans("Status").'</td>';
 print '<td class="center" width="60">&nbsp;</td>';
 print "</tr>\n";
 
@@ -254,7 +254,7 @@ $i = 0;
 $nbofbank = count($bankorder);
 while ($i < $nbofbank) {
     print '<tr class="oddeven">';
-    print '<td>' . $bankorder[$i][0] . "</td><td>\n";
+    print '<td>'.$bankorder[$i][0]."</td><td>\n";
     print $bankorder[$i][1];
     print '</td>';
     print '<td class="nowrap">';
@@ -272,16 +272,16 @@ while ($i < $nbofbank) {
         print '</td>';
     }
     else {
-        print '<td class="center"><a href="' . $_SERVER['PHP_SELF'] . '?action=setbankorder&amp;value=' . $i . '">';
+        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";
+    print '</tr>'."\n";
     $i++;
 }
 
-print '</table>' . "\n";
+print '</table>'."\n";
 
 print '<br><br>';
 
@@ -296,9 +296,9 @@ print load_fiche_titre($langs->trans("BankAccountModelModule"), '', '');
 // Load array def with activated templates
 $def = array();
 $sql = "SELECT nom";
-$sql .= " FROM " . MAIN_DB_PREFIX . "document_model";
-$sql .= " WHERE type = '" . $type . "'";
-$sql .= " AND entity = " . $conf->entity;
+$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql .= " WHERE type = '".$type."'";
+$sql .= " AND entity = ".$conf->entity;
 $resql = $db->query($sql);
 if ($resql) {
     $i = 0;
@@ -315,19 +315,19 @@ else {
 
 print "<table class=\"noborder\" width=\"100%\">\n";
 print "<tr class=\"liste_titre\">\n";
-print '<td>' . $langs->trans("Name") . '</td>';
-print '<td>' . $langs->trans("Description") . '</td>';
-print '<td class="center" width="60">' . $langs->trans("Status") . "</td>\n";
-print '<td class="center" width="60">' . $langs->trans("Default") . "</td>\n";
-print '<td class="center" width="38">' . $langs->trans("ShortInfo") . '</td>';
-print '<td class="center" width="38">' . $langs->trans("Preview") . '</td>';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
+print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
+print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
+print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
 print "</tr>\n";
 
 clearstatcache();
 
 foreach ($dirmodels as $reldir) {
     foreach (array('', '/doc') as $valdir) {
-        $dir = dol_buildpath($reldir . "core/modules/bank" . $valdir);
+        $dir = dol_buildpath($reldir."core/modules/bank".$valdir);
 
         if (is_dir($dir)) {
             $handle = opendir($dir);
@@ -340,11 +340,11 @@ foreach ($dirmodels as $reldir) {
 
                 foreach ($filelist as $file) {
                     if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
-                        if (file_exists($dir . '/' . $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;
+                            require_once $dir.'/'.$file;
                             $module = new $classname($db);
 
                             $modulequalified = 1;
@@ -365,15 +365,15 @@ foreach ($dirmodels as $reldir) {
 
                                 // Active
                                 if (in_array($name, $def)) {
-                                    print '<td class="center">' . "\n";
-                                    print '<a href="' . $_SERVER["PHP_SELF"] . '?action=del&value=' . $name . '">';
+                                    print '<td class="center">'."\n";
+                                    print '<a 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 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 class="center">'."\n";
+                                    print '<a 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>";
                                 }
 
@@ -383,21 +383,21 @@ foreach ($dirmodels as $reldir) {
                                     print img_picto($langs->trans("Default"), 'on');
                                 }
                                 else {
-                                    print '<a 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 '<a 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"));
+                                $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("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><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("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);
@@ -409,7 +409,7 @@ foreach ($dirmodels as $reldir) {
                                 // 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>';
+                                    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');
@@ -433,7 +433,7 @@ print '<br><br>';
 print load_fiche_titre($langs->trans("BankColorizeMovement"), '', '');
 print '<table class="noborder centpercent">';
 print "<tr class=\"liste_titre\">\n";
-print '<td colspan="4">' . $langs->trans("Name") . '</td>';
+print '<td colspan="4">'.$langs->trans("Name").'</td>';
 print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
 print "</tr>\n";
 
@@ -442,28 +442,28 @@ print $langs->trans('BankColorizeMovementDesc');
 print "</td>";
 // Active
 if ($conf->global->BANK_COLORIZE_MOVEMENT) {
-    print '<td align="center">' . "\n";
-    print '<a href="' . $_SERVER["PHP_SELF"] . '?action=unsetbankcolorizemovement">';
+    print '<td align="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 align="center">' . "\n";
-    print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setbankcolorizemovement">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
+    print '<td align="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))
+if (!empty($conf->global->BANK_COLORIZE_MOVEMENT))
 {
-    $i=1;
+    $i = 1;
     while ($i <= 2)
     {
-        $key=$i;
-        $color='BANK_COLORIZE_MOVEMENT_COLOR'.$key;
+        $key = $i;
+        $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
 
         print '<tr class="oddeven">';
 
@@ -471,7 +471,7 @@ if(! empty($conf->global->BANK_COLORIZE_MOVEMENT))
         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 $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++;
@@ -491,9 +491,9 @@ print load_fiche_titre($langs->trans("Other"), '', '');
 
 print "<table class=\"noborder\" width=\"100%\">\n";
 print "<tr class=\"liste_titre\">\n";
-print '<td>' . $langs->trans("Name") . '</td>';
-print '<td>' . $langs->trans("Description") . '</td>';
-print '<td class="center" width="60">' . $langs->trans("Status") . "</td>\n";
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
 print "</tr>\n";
 
 print '<tr class="oddeven"><td width="100">';
@@ -503,16 +503,16 @@ 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 '<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 class="center">'."\n";
+    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
     print "</td>";
 }
 

+ 18 - 18
htdocs/admin/dav.php

@@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","other","agenda"));
+$langs->loadLangs(array("admin", "other", "agenda"));
 
 if (!$user->admin)
     accessforbidden();
@@ -37,7 +37,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
 
 
 
-$arrayofparameters=array(
+$arrayofparameters = array(
 	'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
     'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
     'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
@@ -60,14 +60,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 llxHeader('', $langs->trans("DAVSetup"), $wikihelp);
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
 
 
 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 
-$head=dav_admin_prepare_head();
+$head = dav_admin_prepare_head();
 
 dol_fiche_head($head, 'webdav', '', -1, 'action');
 
@@ -80,7 +80,7 @@ if ($action == 'edit')
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		if (isset($val['enabled']) && empty($val['enabled'])) continue;
 
@@ -100,7 +100,7 @@ if ($action == 'edit')
 		}
 		else
 		{
-			print '<input name="'.$key.'"  class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '">';
+			print '<input name="'.$key.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">';
 		}
 		print '</td></tr>';
 	}
@@ -119,7 +119,7 @@ else
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		print '<tr class="oddeven"><td>';
 		$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
@@ -166,22 +166,22 @@ print "<br>";
 
 
 // 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
+$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
 
 
 // Show message
-$message='';
-$url='<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
-$message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url);
-$message.='<br>';
-if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
+$message = '';
+$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
+$message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url);
+$message .= '<br>';
+if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
 {
-	$urlEntity = (! empty($conf->multicompany->enabled)?'?entity='.$conf->entity:'');
-	$url='<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
-	$message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url);
-	$message.='<br>';
+	$urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
+	$url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
+	$message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url);
+	$message .= '<br>';
 }
 print $message;
 

+ 71 - 71
htdocs/admin/defaultvalues.php

@@ -36,12 +36,12 @@ $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'error
 
 if (!$user->admin) accessforbidden();
 
-$id=GETPOST('rowid', 'int');
-$action=GETPOST('action', 'alpha');
+$id = GETPOST('rowid', 'int');
+$action = GETPOST('action', 'alpha');
 
-$mode = GETPOST('mode', 'aZ09')?GETPOST('mode', 'aZ09'):'createform';   // 'createform', 'filters', 'sortorder', 'focus'
+$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus'
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');
@@ -49,32 +49,32 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortfield) $sortfield='page,param';
-if (! $sortorder) $sortorder='ASC';
+if (!$sortfield) $sortfield = 'page,param';
+if (!$sortorder) $sortorder = 'ASC';
 
 $defaulturl = GETPOST('defaulturl');
 $defaultkey = GETPOST('defaultkey', 'alpha');
 $defaultvalue = GETPOST('defaultvalue');
 
-$defaulturl=preg_replace('/^\//', '', $defaulturl);
+$defaulturl = preg_replace('/^\//', '', $defaulturl);
 
 $urlpage = GETPOST('urlpage');
 $key = GETPOST('key');
 $value = GETPOST('value');
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('admindefaultvalues','globaladmin'));
+$hookmanager->initHooks(array('admindefaultvalues', 'globaladmin'));
 
 
 /*
  * Actions
  */
 
-if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
-if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
+if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
 
-$parameters=array('socid'=>$socid);
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
+$parameters = array('socid'=>$socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
@@ -82,11 +82,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
 // Purge search criteria
 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
 {
-    $defaulturl='';
-    $defaultkey='';
-    $defaultvalue='';
-    $toselect='';
-    $search_array_options=array();
+    $defaulturl = '';
+    $defaultkey = '';
+    $defaultvalue = '';
+    $toselect = '';
+    $search_array_options = array();
 }
 
 if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
@@ -97,7 +97,7 @@ if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
 
 if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify'))
 {
-	$error=0;
+	$error = 0;
 
 	if (($action == 'add' || (GETPOST('add') && $action != 'update')))
 	{
@@ -126,7 +126,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
 	    }
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 	    $db->begin();
 
@@ -137,7 +137,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
 	    if (GETPOST('actionmodify'))
 	    {
 		    $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
-		    $sql.= " WHERE rowid = ".$id;
+		    $sql .= " WHERE rowid = ".$id;
 	    }
 
 		$result = $db->query($sql);
@@ -145,16 +145,16 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
 		{
 		    $db->commit();
 			setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
-			$action="";
-			$defaulturl='';
-			$defaultkey='';
-			$defaultvalue='';
+			$action = "";
+			$defaulturl = '';
+			$defaultkey = '';
+			$defaultvalue = '';
 		}
 		else
 		{
 	        $db->rollback();
 		    setEventMessages($db->lasterror(), null, 'errors');
-			$action='';
+			$action = '';
 		}
 	}
 }
@@ -181,28 +181,28 @@ if ($action == 'delete')
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 $formadmin = new FormAdmin($db);
 
-$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
+$wikihelp = 'EN:Setup|FR:Paramétrage|ES:Configuración';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
-$param='&mode='.$mode;
+$param = '&mode='.$mode;
 
-$enabledisablehtml.= $langs->trans("EnableDefaultValues").' ';
+$enabledisablehtml .= $langs->trans("EnableDefaultValues").' ';
 if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
 {
     // Button off, click to enable
-    $enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
-    $enabledisablehtml.= img_picto($langs->trans("Disabled"), 'switch_off');
-    $enabledisablehtml.= '</a>';
+    $enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
+    $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
+    $enabledisablehtml .= '</a>';
 }
 else
 {
     // Button on, click to disable
-    $enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
-    $enabledisablehtml.= img_picto($langs->trans("Activated"), 'switch_on');
-    $enabledisablehtml.= '</a>';
+    $enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
+    $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
+    $enabledisablehtml .= '</a>';
 }
 
 print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup');
@@ -210,15 +210,15 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl
 print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n";
 print "<br>\n";
 
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
-if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
-if ($optioncss != '')  $param.='&optioncss='.$optioncss;
-if ($defaulturl)        $param.='&defaulturl='.urlencode($defaulturl);
-if ($defaultkey)        $param.='&defaultkey='.urlencode($defaultkey);
-if ($defaultvalue)      $param.='&defaultvalue='.urlencode($defaultvalue);
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
+if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
+if ($optioncss != '')  $param .= '&optioncss='.$optioncss;
+if ($defaulturl)        $param .= '&defaulturl='.urlencode($defaulturl);
+if ($defaultkey)        $param .= '&defaultkey='.urlencode($defaultkey);
+if ($defaultvalue)      $param .= '&defaultvalue='.urlencode($defaultvalue);
 
 
-print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">';
+print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug) ? '?debug=1' : '').'" method="POST">';
 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@@ -227,7 +227,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 print '<input type="hidden" name="page" value="'.$page.'">';
 
-$head=defaultvalues_prepare_head();
+$head = defaultvalues_prepare_head();
 
 dol_fiche_head($head, $mode, '', -1, '');
 
@@ -248,22 +248,22 @@ print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
 // Page
-$texthelp=$langs->trans("PageUrlForDefaultValues");
-if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
-else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
-$texthelp.='<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
-$texturl=$form->textwithpicto($langs->trans("Url"), $texthelp);
+$texthelp = $langs->trans("PageUrlForDefaultValues");
+if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
+else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
+$texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
+$texturl = $form->textwithpicto($langs->trans("Url"), $texthelp);
 print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
 // Field
-$texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField");
+$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
 if ($mode != 'sortorder')
 {
-    $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
+    $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
 }
 else
 {
-    $texthelp='field or alias.field';
-    $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
+    $texthelp = 'field or alias.field';
+    $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
 }
 print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
 // Value
@@ -271,24 +271,24 @@ if ($mode != 'focus' && $mode != 'mandatory')
 {
     if ($mode != 'sortorder')
     {
-        $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount')); // Must match list into GETPOST
+        $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
 		unset($substitutionarray['__USER_SIGNATURE__']);
-        $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
-        foreach($substitutionarray as $key => $val)
+        $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
+        foreach ($substitutionarray as $key => $val)
         {
-            $texthelp.=$key.' -> '.$val.'<br>';
+            $texthelp .= $key.' -> '.$val.'<br>';
         }
-        $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
+        $textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
     }
     else
     {
-        $texthelp='ASC or DESC';
-        $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp);
+        $texthelp = 'ASC or DESC';
+        $textvalue = $form->textwithpicto($langs->trans("SortOrder"), $texthelp);
     }
     print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
 }
 // Entity
-if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
+if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
 else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
 // Actions
 print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
@@ -315,10 +315,10 @@ if ($mode != 'focus' && $mode != 'mandatory')
     print '</td>';
 }
 // Limit to superadmin
-if (! empty($conf->multicompany->enabled) && !$user->entity)
+if (!empty($conf->multicompany->enabled) && !$user->entity)
 {
 	print '<td>';
-	print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">';	// We see environment, but to change it we must switch on other entity
+	print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
 	print '</td>';
 }
 else
@@ -328,8 +328,8 @@ else
 	print '</td>';
 }
 print '<td class="center">';
-$disabled='';
-if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled=' disabled="disabled"';
+$disabled = '';
+if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"';
 print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
 print "</td>\n";
 print '</tr>';
@@ -337,10 +337,10 @@ print '</tr>';
 
 // Show constants
 $sql = "SELECT rowid, entity, type, page, param, value";
-$sql.= " FROM ".MAIN_DB_PREFIX."default_values";
-$sql.= " WHERE type = '".$db->escape($mode)."'";
-$sql.= " AND entity IN (".$user->entity.",".$conf->entity.")";
-$sql.= $db->order($sortfield, $sortorder);
+$sql .= " FROM ".MAIN_DB_PREFIX."default_values";
+$sql .= " WHERE type = '".$db->escape($mode)."'";
+$sql .= " AND entity IN (".$user->entity.",".$conf->entity.")";
+$sql .= $db->order($sortfield, $sortorder);
 
 dol_syslog("translation::select from table", LOG_DEBUG);
 $result = $db->query($sql);
@@ -389,15 +389,15 @@ if ($result)
 		print '<td class="center">';
 		if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
 		{
-    		print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_edit().'</a>';
+    		print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
     		print ' &nbsp; ';
-    		print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_delete().'</a>';
+    		print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
 		}
 		else
 		{
 		    print '<input type="hidden" name="page" value="'.$page.'">';
 		    print '<input type="hidden" name="rowid" value="'.$id.'">';
-		    print '<div name="'.(! empty($obj->rowid)?$obj->rowid:'none').'"></div>';
+		    print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : 'none').'"></div>';
 		    print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
 		    print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
 		}

+ 32 - 32
htdocs/admin/delais.php

@@ -30,11 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 // Load translation files required by the page
 $langs->load("admin");
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 
-$modules=array(
+$modules = array(
 		'agenda' => array(
 				array(
 						'code' => 'MAIN_DELAY_ACTIONS_TODO',
@@ -137,11 +137,11 @@ $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->
 
 if ($action == 'update')
 {
-	foreach($modules as $module => $delays)
+	foreach ($modules as $module => $delays)
 	{
-		if (! empty($conf->$module->enabled))
+		if (!empty($conf->$module->enabled))
     	{
-    		foreach($delays as $delay)
+    		foreach ($delays as $delay)
     		{
     			if (GETPOST($delay['code']) != '')
     			{
@@ -155,11 +155,11 @@ if ($action == 'update')
 	dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
 
 	// For update value with percentage
-	$plus='';
-	if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
+	$plus = '';
+	if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
 	// Update values
-	for($i=0; $i<4; $i++) {
-    	if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
+	for ($i = 0; $i < 4; $i++) {
+    	if (isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
     }
 }
 
@@ -178,7 +178,7 @@ print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceD
 print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
 print "<br>\n";
 
-$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
+$countrynotdefined = '<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
 
 if ($action == 'edit')
 {
@@ -189,13 +189,13 @@ if ($action == 'edit')
     print '<table class="noborder centpercent">';
     print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
 
-    foreach($modules as $module => $delays)
+    foreach ($modules as $module => $delays)
     {
-    	if (! empty($conf->$module->enabled))
+    	if (!empty($conf->$module->enabled))
     	{
-    		foreach($delays as $delay)
+    		foreach ($delays as $delay)
     		{
-				$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
+				$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
     			print '<tr class="oddeven">';
     			print '<td width="20px">'.img_object('', $delay['img']).'</td>';
     			print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
@@ -214,7 +214,7 @@ if ($action == 'edit')
 
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
-	print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO));
+	print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
 	print '</td></tr>';
 
 	print '</table>';
@@ -228,13 +228,13 @@ else
 	print '<table class="noborder centpercent">';
     print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
 
-    foreach($modules as $module => $delays)
+    foreach ($modules as $module => $delays)
     {
-    	if (! empty($conf->$module->enabled))
+    	if (!empty($conf->$module->enabled))
     	{
-    		foreach($delays as $delay)
+    		foreach ($delays as $delay)
     		{
-				$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
+				$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
     			print '<tr class="oddeven">';
     			print '<td width="20px">'.img_object('', $delay['img']).'</td>';
     			print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
@@ -264,30 +264,30 @@ print '<br>';
 // Show logo for weather
 print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
 
-if($action == 'edit') {
+if ($action == 'edit') {
 	$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
 	$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
-	if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
+	if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
 	else $str_mode_enabled = $str_mode_percentage;
 	print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
 	print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
 
 	print '<br><br>';
 } else {
-	if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
+	if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
 	else print $langs->trans('MeteoPercentageModEnabled');
 	print '<br><br>';
 }
 
-$offset=0;
-$cursor=10; // By default
+$offset = 0;
+$cursor = 10; // By default
 //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
 //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
-$level0=$offset;           if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
-$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
-$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
-$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
-$text=''; $options='class="valignmiddle" height="60px"';
+$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0;
+$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1;
+$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2;
+$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3;
+$text = ''; $options = 'class="valignmiddle" height="60px"';
 
 
 if ($action == 'edit') {
@@ -361,7 +361,7 @@ if ($action == 'edit') {
 
 	<?php
 } else {
-	if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
+	if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
 		print '<div>';
 		print '<div class="inline-block" style="padding-right: 20px">';
 		print img_weather($text, 0, $options);
@@ -404,7 +404,7 @@ if ($action == 'edit') {
 
 print '</div>';
 
-if($action == 'edit') {
+if ($action == 'edit') {
 	print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
 	print '<br></form>';
 } else {

File diff suppressed because it is too large
+ 360 - 360
htdocs/admin/dict.php


+ 32 - 32
htdocs/admin/ldap_groups.php

@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","errors"));
+$langs->loadLangs(array("admin", "errors"));
 
 if (!$user->admin)
   accessforbidden();
@@ -48,25 +48,25 @@ $action = GETPOST('action', 'aZ09');
 
 if ($action == 'setvalue' && $user->admin)
 {
-	$error=0;
+	$error = 0;
 	$db->begin();
 
-	if (! dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
 
-	if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
 	//if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++;
-    if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++;
+    if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++;
 
 	// This one must be after the others
-    $valkey='';
-    $key=GETPOST("key");
-    if ($key) $valkey=$conf->global->$key;
-    if (! dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
+    $valkey = '';
+    $key = GETPOST("key");
+    if ($key) $valkey = $conf->global->$key;
+    if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
 
-    if (! $error)
+    if (!$error)
     {
     	$db->commit();
     	setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -85,14 +85,14 @@ if ($action == 'setvalue' && $user->admin)
  */
 
 llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 
 print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
 
 $head = ldap_prepare_head();
 
 // Test si fonction LDAP actives
-if (! function_exists("ldap_connect"))
+if (!function_exists("ldap_connect"))
 {
 	setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
 }
@@ -107,7 +107,7 @@ print '<br>';
 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 
-$form=new Form($db);
+$form = new Form($db);
 
 print '<table class="noborder centpercent">';
 
@@ -145,7 +145,7 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_GROUP_FIELD_FULLNAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldCommonNameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_FULLNAME)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_FULLNAME) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Name
@@ -161,14 +161,14 @@ print '</tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
 print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_GROUP_FIELD_DESCRIPTION.'">';
 print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_DESCRIPTION)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_DESCRIPTION) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // User group
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldGroupMembers").'</td><td>';
 print '<input size="25" type="text" name="fieldgroupmembers" value="'.$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS.'">';
 print '</td><td>'.$langs->trans("LDAPFieldGroupMembersExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Group id
@@ -194,11 +194,11 @@ print '</form>';
  */
 if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
 {
-	$butlabel=$langs->trans("LDAPTestSynchroGroup");
-	$testlabel='testgroup';
-	$key=$conf->global->LDAP_KEY_GROUPS;
-	$dn=$conf->global->LDAP_GROUP_DN;
-	$objectclass=$conf->global->LDAP_GROUP_OBJECT_CLASS;
+	$butlabel = $langs->trans("LDAPTestSynchroGroup");
+	$testlabel = 'testgroup';
+	$key = $conf->global->LDAP_KEY_GROUPS;
+	$dn = $conf->global->LDAP_GROUP_DN;
+	$objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS;
 
 	show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
 }
@@ -208,26 +208,26 @@ if (function_exists("ldap_connect"))
 	if ($_GET["action"] == 'testgroup')
 	{
 		// Creation objet
-		$object=new UserGroup($db);
+		$object = new UserGroup($db);
 		$object->initAsSpecimen();
 
 		// Test synchro
-		$ldap=new Ldap();
-		$result=$ldap->connect_bind();
+		$ldap = new Ldap();
+		$result = $ldap->connect_bind();
 
 		if ($result > 0)
 		{
-			$info=$object->_load_ldap_info();
-			$dn=$object->_load_ldap_dn($info);
+			$info = $object->_load_ldap_info();
+			$dn = $object->_load_ldap_dn($info);
 
 			// Get a gid number for objectclass PosixGroup
 			if (in_array('posixGroup', $info['objectclass'])) {
 				$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
 			}
 
-			$result1=$ldap->delete($dn);			// To be sure to delete existing records
-			$result2=$ldap->add($dn, $info, $user);	// Now the test
-			$result3=$ldap->delete($dn);			// Clean what we did
+			$result1 = $ldap->delete($dn); // To be sure to delete existing records
+			$result2 = $ldap->add($dn, $info, $user); // Now the test
+			$result3 = $ldap->delete($dn); // Clean what we did
 
 			if ($result2 > 0)
 			{

+ 30 - 30
htdocs/admin/ldap_members_types.php

@@ -48,23 +48,23 @@ $action = GETPOST('action', 'aZ09');
 
 if ($action == 'setvalue' && $user->admin)
 {
-	$error=0;
+	$error = 0;
 	$db->begin();
 
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
 
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
-	if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
+	if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++;
 
 	// This one must be after the others
-	$valkey='';
-	$key=GETPOST("key");
-	if ($key) $valkey=$conf->global->$key;
-	if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
+	$valkey = '';
+	$key = GETPOST("key");
+	if ($key) $valkey = $conf->global->$key;
+	if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -83,14 +83,14 @@ if ($action == 'setvalue' && $user->admin)
  */
 
 llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 
 print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
 
 $head = ldap_prepare_head();
 
 // Test si fonction LDAP actives
-if (! function_exists("ldap_connect"))
+if (!function_exists("ldap_connect"))
 {
 	setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
 }
@@ -105,7 +105,7 @@ print '<br>';
 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 
-$form=new Form($db);
+$form = new Form($db);
 
 print '<table class="noborder centpercent">';
 
@@ -143,21 +143,21 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME.'">';
 print '</td><td>'.$langs->trans("LDAPFieldCommonNameExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // Description
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
 print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION.'">';
 print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION) ? ' checked' : '')."></td>";
 print '</tr>';
 
 // User group
 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldGroupMembers").'</td><td>';
 print '<input size="25" type="text" name="fieldmembertypemembers" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS.'">';
 print '</td><td>'.$langs->trans("LDAPFieldGroupMembersExample").'</td>';
-print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)?' checked':'')."></td>";
+print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS) ? ' checked' : '')."></td>";
 print '</tr>';
 
 print '</table>';
@@ -176,11 +176,11 @@ print '</form>';
  */
 if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
 {
-	$butlabel=$langs->trans("LDAPTestSynchroMemberType");
-	$testlabel='testmembertype';
-	$key=$conf->global->LDAP_KEY_MEMBERS_TYPES;
-	$dn=$conf->global->LDAP_MEMBER_TYPE_DN;
-	$objectclass=$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS;
+	$butlabel = $langs->trans("LDAPTestSynchroMemberType");
+	$testlabel = 'testmembertype';
+	$key = $conf->global->LDAP_KEY_MEMBERS_TYPES;
+	$dn = $conf->global->LDAP_MEMBER_TYPE_DN;
+	$objectclass = $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS;
 
 	show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
 }
@@ -190,26 +190,26 @@ if (function_exists("ldap_connect"))
 	if ($_GET["action"] == 'testmembertype')
 	{
 		// Creation objet
-		$object=new AdherentType($db);
+		$object = new AdherentType($db);
 		$object->initAsSpecimen();
 
 		// Test synchro
-		$ldap=new Ldap();
-		$result=$ldap->connect_bind();
+		$ldap = new Ldap();
+		$result = $ldap->connect_bind();
 
 		if ($result > 0)
 		{
-			$info=$object->_load_ldap_info();
-			$dn=$object->_load_ldap_dn($info);
+			$info = $object->_load_ldap_info();
+			$dn = $object->_load_ldap_dn($info);
 
 			// Get a gid number for objectclass PosixGroup
 			if (in_array('posixGroup', $info['objectclass'])) {
 				$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPES');
 			}
 
-			$result1=$ldap->delete($dn);			// To be sure to delete existing records
-			$result2=$ldap->add($dn, $info, $user);	// Now the test
-			$result3=$ldap->delete($dn);			// Clean what we did
+			$result1 = $ldap->delete($dn); // To be sure to delete existing records
+			$result2 = $ldap->add($dn, $info, $user); // Now the test
+			$result3 = $ldap->delete($dn); // Clean what we did
 
 			if ($result2 > 0)
 			{

+ 7 - 7
htdocs/admin/loan.php

@@ -26,7 +26,7 @@ require '../main.inc.php';
 
 // Class
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'loan'));
@@ -38,7 +38,7 @@ if (!$user->admin)
 $action = GETPOST('action', 'alpha');
 
 // Other parameters LOAN_*
-$list = array (
+$list = array(
 		'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
 		'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
 		'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
@@ -60,7 +60,7 @@ if ($action == 'update')
         }
     }
 
-    if (! $error)
+    if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
     }
@@ -77,9 +77,9 @@ if ($action == 'update')
 llxHeader();
 
 $form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
+if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup');
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@@ -91,7 +91,7 @@ print '<input type="hidden" name="action" value="update">';
  */
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td colspan="3">' . $langs->trans('Options') . '</td>';
+print '<td colspan="3">'.$langs->trans('Options').'</td>';
 print "</tr>\n";
 
 foreach ($list as $key)
@@ -104,7 +104,7 @@ foreach ($list as $key)
 
 	// Value
 	print '<td>';
-	if (! empty($conf->accounting->enabled))
+	if (!empty($conf->accounting->enabled))
 	{
 		print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
 	}

+ 101 - 101
htdocs/admin/menus/edit.php

@@ -29,32 +29,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("other","admin"));
+$langs->loadLangs(array("other", "admin"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $dirstandard = array();
 $dirsmartphone = array();
-$dirmenus=array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
-foreach($dirmenus as $dirmenu)
+$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
+foreach ($dirmenus as $dirmenu)
 {
-    $dirstandard[]=$dirmenu.'standard';
-    $dirsmartphone[]=$dirmenu.'smartphone';
+    $dirstandard[] = $dirmenu.'standard';
+    $dirsmartphone[] = $dirmenu.'smartphone';
 }
 
-$action=GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'aZ09');
 
-$menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
-$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
-$menu_handler_top=preg_replace('/_backoffice.php/i', '', $menu_handler_top);
-$menu_handler_top=preg_replace('/_frontoffice.php/i', '', $menu_handler_top);
-$menu_handler_smartphone=preg_replace('/_backoffice.php/i', '', $menu_handler_smartphone);
-$menu_handler_smartphone=preg_replace('/_frontoffice.php/i', '', $menu_handler_smartphone);
+$menu_handler_top = $conf->global->MAIN_MENU_STANDARD;
+$menu_handler_smartphone = $conf->global->MAIN_MENU_SMARTPHONE;
+$menu_handler_top = preg_replace('/_backoffice.php/i', '', $menu_handler_top);
+$menu_handler_top = preg_replace('/_frontoffice.php/i', '', $menu_handler_top);
+$menu_handler_smartphone = preg_replace('/_backoffice.php/i', '', $menu_handler_smartphone);
+$menu_handler_smartphone = preg_replace('/_frontoffice.php/i', '', $menu_handler_smartphone);
 
-$menu_handler=$menu_handler_top;
+$menu_handler = $menu_handler_top;
 
-if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine");
-if (GETPOST("menu_handler"))    $menu_handler=GETPOST("menu_handler");
+if (GETPOST("handler_origine")) $menu_handler = GETPOST("handler_origine");
+if (GETPOST("menu_handler"))    $menu_handler = GETPOST("menu_handler");
 
 
 
@@ -64,53 +64,53 @@ if (GETPOST("menu_handler"))    $menu_handler=GETPOST("menu_handler");
 
 if ($action == 'update')
 {
-    if (! $_POST['cancel'])
+    if (!$_POST['cancel'])
     {
-        $leftmenu=''; $mainmenu='';
-        if (! empty($_POST['menuIdParent']) && ! is_numeric($_POST['menuIdParent']))
+        $leftmenu = ''; $mainmenu = '';
+        if (!empty($_POST['menuIdParent']) && !is_numeric($_POST['menuIdParent']))
         {
-            $tmp=explode('&', $_POST['menuIdParent']);
-            foreach($tmp as $s)
+            $tmp = explode('&', $_POST['menuIdParent']);
+            foreach ($tmp as $s)
             {
                 if (preg_match('/fk_mainmenu=/', $s))
                 {
-                    $mainmenu=preg_replace('/fk_mainmenu=/', '', $s);
+                    $mainmenu = preg_replace('/fk_mainmenu=/', '', $s);
                 }
                 if (preg_match('/fk_leftmenu=/', $s))
                 {
-                    $leftmenu=preg_replace('/fk_leftmenu=/', '', $s);
+                    $leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
                 }
             }
         }
 
         $menu = new Menubase($db);
-        $result=$menu->fetch(GETPOST('menuId', 'int'));
+        $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');
-            $menu->langs=GETPOST('langs', 'alpha');
-            $menu->position=GETPOST('position', 'int');
-            $menu->enabled=GETPOST('enabled', 'alpha');
-            $menu->perms=GETPOST('perms', 'alpha');
-            $menu->target=GETPOST('target', 'alpha');
-            $menu->user=GETPOST('user', 'alpha');
-            $menu->mainmenu=GETPOST('propertymainmenu', 'alpha');
+            $menu->titre = GETPOST('titre', 'alpha'); // deprecated
+            $menu->title = GETPOST('titre', 'alpha');
+            $menu->leftmenu = GETPOST('leftmenu', 'aZ09');
+            $menu->url = GETPOST('url', 'alpha');
+            $menu->langs = GETPOST('langs', 'alpha');
+            $menu->position = GETPOST('position', 'int');
+            $menu->enabled = GETPOST('enabled', 'alpha');
+            $menu->perms = GETPOST('perms', 'alpha');
+            $menu->target = GETPOST('target', 'alpha');
+            $menu->user = GETPOST('user', 'alpha');
+            $menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
             if (is_numeric(GETPOST('menuIdParent', 'alpha')))
             {
-            	$menu->fk_menu=GETPOST('menuIdParent', 'alpha');
+            	$menu->fk_menu = GETPOST('menuIdParent', 'alpha');
             }
             else
             {
-    	       	if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0;
-    	       	else $menu->fk_menu=-1;
-            	$menu->fk_mainmenu=$mainmenu;
-            	$menu->fk_leftmenu=$leftmenu;
+    	       	if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
+    	       	else $menu->fk_menu = -1;
+            	$menu->fk_mainmenu = $mainmenu;
+            	$menu->fk_leftmenu = $leftmenu;
             }
 
-            $result=$menu->update($user);
+            $result = $menu->update($user);
             if ($result > 0)
             {
 	            setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
@@ -144,91 +144,91 @@ if ($action == 'add')
         exit;
     }
 
-    $leftmenu=''; $mainmenu='';
-    if (GETPOST('menuId', 'alpha', 3) && ! is_numeric(GETPOST('menuId', 'alpha', 3)))
+    $leftmenu = ''; $mainmenu = '';
+    if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3)))
     {
-	    $tmp=explode('&', GETPOST('menuId', 'alpha', 3));
-	    foreach($tmp as $s)
+	    $tmp = explode('&', GETPOST('menuId', 'alpha', 3));
+	    foreach ($tmp as $s)
 	    {
 	    	if (preg_match('/fk_mainmenu=/', $s))
 	    	{
-				$mainmenu=preg_replace('/fk_mainmenu=/', '', $s);
+				$mainmenu = preg_replace('/fk_mainmenu=/', '', $s);
 	    	}
 	    	if (preg_match('/fk_leftmenu=/', $s))
 	    	{
-	    		$leftmenu=preg_replace('/fk_leftmenu=/', '', $s);
+	    		$leftmenu = preg_replace('/fk_leftmenu=/', '', $s);
 	    	}
 	    }
     }
 
     $langs->load("errors");
 
-    $error=0;
-    if (! $error && ! $_POST['menu_handler'])
+    $error = 0;
+    if (!$error && !$_POST['menu_handler'])
     {
 	    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors');
         $action = 'create';
         $error++;
     }
-    if (! $error && ! $_POST['type'])
+    if (!$error && !$_POST['type'])
     {
 	    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
         $action = 'create';
         $error++;
     }
-    if (! $error && ! $_POST['url'])
+    if (!$error && !$_POST['url'])
     {
     	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
         $action = 'create';
         $error++;
     }
-    if (! $error && ! $_POST['titre'])
+    if (!$error && !$_POST['titre'])
     {
     	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
         $action = 'create';
         $error++;
     }
-    if (! $error && $_POST['menuId'] && $_POST['type'] == 'top')
+    if (!$error && $_POST['menuId'] && $_POST['type'] == 'top')
     {
 	    setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
         $action = 'create';
         $error++;
     }
-    if (! $error && ! $_POST['menuId'] && $_POST['type'] == 'left')
+    if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left')
     {
 	    setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
         $action = 'create';
         $error++;
     }
 
-    if (! $error)
+    if (!$error)
     {
         $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');
-        $menu->position=GETPOST('position', 'int');
-        $menu->enabled=GETPOST('enabled', 'alpha');
-        $menu->perms=GETPOST('perms', 'alpha');
-        $menu->target=GETPOST('target', 'alpha');
-        $menu->user=GETPOST('user', 'alpha');
-        $menu->mainmenu=GETPOST('propertymainmenu', 'alpha');
+        $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');
+        $menu->position = GETPOST('position', 'int');
+        $menu->enabled = GETPOST('enabled', 'alpha');
+        $menu->perms = GETPOST('perms', 'alpha');
+        $menu->target = GETPOST('target', 'alpha');
+        $menu->user = GETPOST('user', 'alpha');
+        $menu->mainmenu = GETPOST('propertymainmenu', 'alpha');
         if (is_numeric(GETPOST('menuId', 'alpha', 3)))
         {
-        	$menu->fk_menu=GETPOST('menuId', 'alpha', 3);
+        	$menu->fk_menu = GETPOST('menuId', 'alpha', 3);
         }
         else
         {
-            if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0;
-            else $menu->fk_menu=-1;
-            $menu->fk_mainmenu=$mainmenu;
-            $menu->fk_leftmenu=$leftmenu;
+            if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0;
+            else $menu->fk_menu = -1;
+            $menu->fk_mainmenu = $mainmenu;
+            $menu->fk_leftmenu = $leftmenu;
         }
 
-        $result=$menu->create($user);
+        $result = $menu->create($user);
         if ($result > 0)
         {
             header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09'));
@@ -248,7 +248,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
     $this->db->begin();
 
     $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
-    $result=$db->query($sql);
+    $result = $db->query($sql);
 
     if ($result == 0)
     {
@@ -257,14 +257,14 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
         llxHeader();
 	    setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
         llxFooter();
-        exit ;
+        exit;
     }
     else
     {
         $this->db->rollback();
 
         $reload = 0;
-        $_GET["action"]='';
+        $_GET["action"] = '';
     }
 }
 
@@ -274,8 +274,8 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
  * View
  */
 
-$form=new Form($db);
-$formadmin=new FormAdmin($db);
+$form = new Form($db);
+$formadmin = new FormAdmin($db);
 
 llxHeader('', $langs->trans("Menu"));
 
@@ -320,7 +320,7 @@ if ($action == 'create')
     if (GETPOST('menuId', 'int'))
     {
         $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int');
-        $res  = $db->query($sql);
+        $res = $db->query($sql);
         if ($res)
         {
             while ($menu = $db->fetch_array($res))
@@ -337,7 +337,7 @@ if ($action == 'create')
     // Handler
     print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
     print '<td>';
-    $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler)?'':'_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone));
+    $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone));
     print '</td>';
     print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
 
@@ -361,15 +361,15 @@ if ($action == 'create')
     {
         print '<select name="type" class="flat" id="topleft">';
         print '<option value="">&nbsp;</option>';
-        print '<option value="top"'.($_POST["type"] && $_POST["type"]=='top'?' selected':'').'>'.$langs->trans('Top').'</option>';
-        print '<option value="left"'.($_POST["type"] && $_POST["type"]=='left'?' selected':'').'>'.$langs->trans('Left').'</option>';
+        print '<option value="top"'.($_POST["type"] && $_POST["type"] == 'top' ? ' selected' : '').'>'.$langs->trans('Top').'</option>';
+        print '<option value="left"'.($_POST["type"] && $_POST["type"] == 'left' ? ' selected' : '').'>'.$langs->trans('Left').'</option>';
         print '</select>';
     }
     print '</td><td>'.$langs->trans('DetailType').'</td></tr>';
 
     // Mainmenu code
     print '<tr><td class="fieldrequired">'.$langs->trans('MainMenuCode').'</td>';
-   	print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha')?GETPOST("propertymainmenu", 'alpha'):'').'"></td>';
+   	print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : '').'"></td>';
     print '<td>';
     print $langs->trans("Example").': mytopmenukey';
     print '</td></tr>';
@@ -382,7 +382,7 @@ if ($action == 'create')
     }
     else
     {
-        print '<td><input type="text" class="minwidth300" id="menuId" name="menuId" value="'.(GETPOST("menuId", 'int')?GETPOST("menuId", 'int'):'').'"></td>';
+        print '<td><input type="text" class="minwidth300" id="menuId" name="menuId" value="'.(GETPOST("menuId", 'int') ?GETPOST("menuId", 'int') : '').'"></td>';
     }
     print '<td>'.$langs->trans('DetailMenuIdParent');
     print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
@@ -398,19 +398,19 @@ if ($action == 'create')
     print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" class="minwidth300" name="langs" value="'.$parent_langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
 
     // Position
-    print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(isset($_POST["position"])?$_POST["position"]:100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
+    print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" class="width100" name="position" value="'.dol_escape_htmltag(isset($_POST["position"]) ? $_POST["position"] : 100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
 
     // Target
     print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
-    print '<option value=""'.($menu->target==""?' selected':'').'>&nbsp;</option>';
-    print '<option value="_blank"'.($menu->target=="_blank"?' selected':'').'>'.$langs->trans('_blank').'</option>';
+    print '<option value=""'.($menu->target == "" ? ' selected' : '').'>&nbsp;</option>';
+    print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
     print '</select></td></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
 
     // Enabled
-    print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled')?GETPOST("enabled", 'alpha'):'1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
+    print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.(GETPOSTISSET('enabled') ?GETPOST("enabled", 'alpha') : '1').'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
 
     // Perms
-    print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms')?GETPOST('perms', 'alpha'):'1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
+    print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.(GETPOSTISSET('perms') ?GETPOST('perms', 'alpha') : '1').'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
 
     print '</table>';
 
@@ -439,7 +439,7 @@ elseif ($action == 'edit')
     print '<table class="border centpercent">';
 
     $menu = new Menubase($db);
-    $result=$menu->fetch(GETPOST('menuId', 'int'));
+    $result = $menu->fetch(GETPOST('menuId', 'int'));
     //var_dump($menu);
 
     // Id
@@ -455,9 +455,9 @@ elseif ($action == 'edit')
 
     // User
     print '<tr><td class="nowrap fieldrequired">'.$langs->trans('MenuForUsers').'</td><td><select class="flat" name="user">';
-    print '<option value="2"'.($menu->user==2?' selected':'').'>'.$langs->trans("AllMenus").'</option>';
-    print '<option value="0"'.($menu->user==0?' selected':'').'>'.$langs->trans('Internal').'</option>';
-    print '<option value="1"'.($menu->user==1?' selected':'').'>'.$langs->trans('External').'</option>';
+    print '<option value="2"'.($menu->user == 2 ? ' selected' : '').'>'.$langs->trans("AllMenus").'</option>';
+    print '<option value="0"'.($menu->user == 0 ? ' selected' : '').'>'.$langs->trans('Internal').'</option>';
+    print '<option value="1"'.($menu->user == 1 ? ' selected' : '').'>'.$langs->trans('External').'</option>';
     print '</select></td><td>'.$langs->trans('DetailUser').'</td></tr>';
 
     // Type
@@ -473,7 +473,7 @@ elseif ($action == 'edit')
 	     }
 	     else
 	     {*/
-	    print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha')?GETPOST("propertymainmenu", 'alpha'):$menu->mainmenu).'"></td>';
+	    print '<td><input type="text" class="minwidth300" id="propertymainmenu" name="propertymainmenu" value="'.(GETPOST("propertymainmenu", 'alpha') ?GETPOST("propertymainmenu", 'alpha') : $menu->mainmenu).'"></td>';
 	    //}
 	    print '<td>';
 	    print $langs->trans("Example").': mytopmenukey';
@@ -483,9 +483,9 @@ elseif ($action == 'edit')
     // MenuId Parent
     print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent');
     print '</td>';
-    $valtouse=$menu->fk_menu;
-    if ($menu->fk_mainmenu) $valtouse='fk_mainmenu='.$menu->fk_mainmenu;
-    if ($menu->fk_leftmenu) $valtouse.='&fk_leftmenu='.$menu->fk_leftmenu;
+    $valtouse = $menu->fk_menu;
+    if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu;
+    if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu;
     print '<td><input type="text" name="menuIdParent" value="'.$valtouse.'" class="minwidth300"></td>';
     print '<td>'.$langs->trans('DetailMenuIdParent');
     print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def';
@@ -508,18 +508,18 @@ elseif ($action == 'edit')
 
     // Target
     print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
-    print '<option value=""'.($menu->target==""?' selected':'').'>&nbsp;</option>';
-    print '<option value="_blank"'.($menu->target=="_blank"?' selected':'').'>'.$langs->trans('_blank').'</option>';
+    print '<option value=""'.($menu->target == "" ? ' selected' : '').'>&nbsp;</option>';
+    print '<option value="_blank"'.($menu->target == "_blank" ? ' selected' : '').'>'.$langs->trans('_blank').'</option>';
     print '</select></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
 
     // Enabled
     print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" class="minwidth500" name="enabled" value="'.dol_escape_htmltag($menu->enabled).'"></td><td>'.$langs->trans('DetailEnabled');
-    if (! empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
+    if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')';
     print '</td></tr>';
 
     // Perms
     print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" class="minwidth500" name="perms" value="'.dol_escape_htmltag($menu->perms).'"></td><td>'.$langs->trans('DetailRight');
-    if (! empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
+    if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')';
     print '</td></tr>';
 
     print '</table>';

+ 12 - 12
htdocs/admin/multicurrency.php

@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
 $langs->loadLangs(array('admin', 'multicurrency'));
 
 // Access control
-if (! $user->admin) {
+if (!$user->admin) {
     accessforbidden();
 }
 
@@ -48,8 +48,8 @@ $action = GETPOST('action', 'alpha');
 
 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
 {
-	$code=$reg[1];
-	$value=GETPOST($code, 'alpha');
+	$code = $reg[1];
+	$value = GETPOST($code, 'alpha');
 	if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
 	{
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -62,7 +62,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
 
 if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
 {
-	$code=$reg[1];
+	$code = $reg[1];
 	if (dolibarr_del_const($db, $code, 0) > 0)
 	{
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -75,7 +75,7 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
 
 if ($action == 'add_currency')
 {
-	$error=0;
+	$error = 0;
 
 	$langs->loadCacheCurrencies('');
 
@@ -90,7 +90,7 @@ if ($action == 'add_currency')
 		setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
 		$error++;
 	}
-	if (! $error)
+	if (!$error)
 	{
 		if ($currency->create($user) > 0)
 		{
@@ -115,12 +115,12 @@ elseif ($action == 'update_currency')
 			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
 			$error++;
 		}
-		if (! $error)
+		if (!$error)
 		{
 			if ($currency->fetch($fk_multicurrency) > 0)
 			{
-				$result=$currency->updateRate($rate);
-				if ($result<0) {
+				$result = $currency->updateRate($rate);
+				if ($result < 0) {
 					setEventMessages(null, $currency->errors, 'errors');
 				}
 			}
@@ -171,14 +171,14 @@ if ($resql)
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 $page_name = "MultiCurrencySetup";
 
 llxHeader('', $langs->trans($page_name));
 
 // Subheader
-$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans($page_name), $linkback);
 
 // Configuration header
@@ -272,7 +272,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
 	print '<div class="div-table-responsive-no-min">';
 	print '<table class="noborder centpercent">';
 
-	$urlforapilayer='https://currencylayer.com';   //https://apilayer.net
+	$urlforapilayer = 'https://currencylayer.com'; //https://apilayer.net
 
 	print '<tr class="liste_titre">';
 	print '<td>'.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).'</td>'."\n";

+ 43 - 43
htdocs/admin/notification.php

@@ -47,45 +47,45 @@ if ($action == 'setvalue' && $user->admin)
 {
 	$db->begin();
 
-	$result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity);
+	$result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity);
     if ($result < 0) $error++;
 
-    if (! $error && is_array($_POST))
+    if (!$error && is_array($_POST))
     {
     	//var_dump($_POST);
-	    foreach($_POST as $key => $val)
+	    foreach ($_POST as $key => $val)
 	    {
-	    	if (! preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue;
+	    	if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue;
 
-	    	$newval='';
-	    	$newkey='';
+	    	$newval = '';
+	    	$newkey = '';
 
-	    	$shortkey=preg_replace('/_key$/', '', $key);
+	    	$shortkey = preg_replace('/_key$/', '', $key);
     		//print $shortkey.'<br>';
 
 	    	if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg))
 	    	{
 				dolibarr_del_const($db, 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity);
 
-				$newkey='NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount'));
-				$newval=GETPOST($shortkey.'_key');
+				$newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount'));
+				$newval = GETPOST($shortkey.'_key');
 				//print $newkey.' - '.$newval.'<br>';
 	    	}
 	    	elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg))
 	    	{
 		    	// Add a new entry
-	    		$newkey='NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount'));
-	    		$newval=GETPOST($shortkey.'_key');
+	    		$newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount'));
+	    		$newval = GETPOST($shortkey.'_key');
 	    	}
 
 	    	if ($newkey && $newval)
 	    	{
-				$result=dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity);
+				$result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity);
 	    	}
 	    }
     }
 
-  	if (! $error)
+  	if (!$error)
     {
     	$db->commit();
 
@@ -105,17 +105,17 @@ if ($action == 'setvalue' && $user->admin)
  *	View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 $notify = new Notify($db);
 
 llxHeader('', $langs->trans("NotificationSetup"));
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("NotificationSetup"), $linkback, 'title_setup');
 
 print $langs->trans("NotificationsDesc").'<br>';
 print $langs->trans("NotificationsDescUser").'<br>';
-if (! empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'<br>';
+if (!empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'<br>';
 print $langs->trans("NotificationsDescGlobal").'<br>';
 print '<br>';
 
@@ -133,7 +133,7 @@ print '<tr class="oddeven"><td>';
 print $langs->trans("NotificationEMailFrom").'</td>';
 print '<td>';
 print '<input size="32" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
-if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail"));
+if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail"));
 print '</td>';
 print '</tr>';
 print '</table>';
@@ -142,8 +142,8 @@ print '<br><br>';
 
 
 // Notification per contacts
-$title=$langs->trans("ListOfNotificationsPerUser");
-if (! empty($conf->societe->enabled)) $title=$langs->trans("ListOfNotificationsPerUserOrContact");
+$title = $langs->trans("ListOfNotificationsPerUser");
+if (!empty($conf->societe->enabled)) $title = $langs->trans("ListOfNotificationsPerUserOrContact");
 print load_fiche_titre($title, '', '');
 
 print '<table class="noborder centpercent">';
@@ -155,16 +155,16 @@ print '<td>'.$langs->trans("Label").'</td>';
 print "</tr>\n";
 
 // Load array of available notifications
-$notificationtrigger=new InterfaceNotification($db);
-$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
+$notificationtrigger = new InterfaceNotification($db);
+$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
 
 print '<tr class="oddeven">';
 print '<td>';
 
-$i=0;
-foreach($listofnotifiedevents as $notifiedevent)
+$i = 0;
+foreach ($listofnotifiedevents as $notifiedevent)
 {
-    $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
+    $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
     $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
 
     if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder');
@@ -185,7 +185,7 @@ print '</td></tr>';
 print '</table>';
 print '<div class="opacitymedium">';
 print '* '.$langs->trans("GoOntoUserCardToAddMore").'<br>';
-if (! empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>';
+if (!empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>';
 print '</div>';
 print '<br><br>';
 
@@ -203,12 +203,12 @@ print '<td>'.'</td>';
 print "</tr>\n";
 
 // Load array of available notifications
-$notificationtrigger=new InterfaceNotification($db);
-$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
+$notificationtrigger = new InterfaceNotification($db);
+$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
 
-foreach($listofnotifiedevents as $notifiedevent)
+foreach ($listofnotifiedevents as $notifiedevent)
 {
-    $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
+    $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
 
     $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
 	// Special cases
@@ -226,35 +226,35 @@ foreach($listofnotifiedevents as $notifiedevent)
     print '<td>'.$label.'</td>';
     print '<td>';
     // Notification with threshold
-    foreach($conf->global as $key => $val)
+    foreach ($conf->global as $key => $val)
     {
-		if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue;
+		if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue;
 
-	    $param='NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1];
-    	$value=GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key')?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha'):$conf->global->$param;
+	    $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1];
+    	$value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param;
 
-    	$s='<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key" value="'.dol_escape_htmltag($value).'">';		// Do not use type="email" here, we must be able to enter a list of email with , separator.
-	    $arrayemail=explode(',', $value);
-		$showwarning=0;
-		foreach($arrayemail as $keydet => $valuedet)
+    	$s = '<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key" value="'.dol_escape_htmltag($value).'">'; // Do not use type="email" here, we must be able to enter a list of email with , separator.
+	    $arrayemail = explode(',', $value);
+		$showwarning = 0;
+		foreach ($arrayemail as $keydet => $valuedet)
 		{
-			$valuedet=trim($valuedet);
-			if (! empty($valuedet) && ! isValidEmail($valuedet, 1)) $showwarning++;
+			$valuedet = trim($valuedet);
+			if (!empty($valuedet) && !isValidEmail($valuedet, 1)) $showwarning++;
 		}
-	    if ((! empty($conf->global->$param)) && $showwarning) $s.=' '.img_warning($langs->trans("ErrorBadEMail"));
+	    if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail"));
 	    print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2);
 		print '<br>';
     }
     // New entry input fields
-    $s='<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_new_key" value="">';		// Do not use type="email" here, we must be able to enter a list of email with , separator.
+    $s = '<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_new_key" value="">'; // Do not use type="email" here, we must be able to enter a list of email with , separator.
     print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2);
     print '</td>';
 
     print '<td>';
     // Notification with threshold
-    foreach($conf->global as $key => $val)
+    foreach ($conf->global as $key => $val)
     {
-		if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue;
+		if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue;
 
     	print $langs->trans("AmountHT").' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_amount" value="'.dol_escape_htmltag($reg[1]).'">';
 		print '<br>';

+ 11 - 11
htdocs/admin/oauth.php

@@ -29,8 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php';
 
 
 // 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
+$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
 
 // Load translation files required by the page
@@ -60,7 +60,7 @@ if ($action == 'update')
             $error++;
     }
 
-    if (! $error)
+    if (!$error)
     {
         setEventMessages($langs->trans("SetupSaved"), null);
     } else {
@@ -76,7 +76,7 @@ llxHeader();
 
 $form = new Form($db);
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@@ -92,29 +92,29 @@ print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
 
 print '<table class="noborder centpercent">';
 
-$i=0;
+$i = 0;
 
 // $list is defined into oauth.lib.php
 foreach ($list as $key)
 {
-    $supported=0;
-    if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1;
-    if (! $supported) continue;     // show only supported
+    $supported = 0;
+    if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1;
+    if (!$supported) continue; // show only supported
 
     $i++;
 
-    print '<tr class="liste_titre'.($i > 1 ?' liste_titre_add':'').'">';
+    print '<tr class="liste_titre'.($i > 1 ? ' liste_titre_add' : '').'">';
     // Api Name
     $label = $langs->trans($key[0]);
     print '<td>'.$label.'</td>';
     print '<td>';
-    if (! empty($key[3])) print $langs->trans($key[3]);
+    if (!empty($key[3])) print $langs->trans($key[3]);
     print '</td>';
     print '</tr>';
 
     if ($supported)
     {
-        $redirect_uri=$urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php';
+        $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php';
         print '<tr class="oddeven value">';
         print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
         print '<td><input style="width: 80%" type"text" name="uri'.$key[0].'" value="'.$redirect_uri.'">';

+ 54 - 54
htdocs/admin/oauthlogintokens.php

@@ -31,7 +31,7 @@ use OAuth\Common\Storage\DoliStorage;
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'printing', 'oauth'));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $mode = GETPOST('mode', 'alpha');
@@ -39,9 +39,9 @@ $value = GETPOST('value', 'alpha');
 $varname = GETPOST('varname', 'alpha');
 $driver = GETPOST('driver', 'alpha');
 
-if (! empty($driver)) $langs->load($driver);
+if (!empty($driver)) $langs->load($driver);
 
-if (!$mode) $mode='setup';
+if (!$mode) $mode = 'setup';
 
 
 /*
@@ -57,15 +57,15 @@ if (!$mode) $mode='setup';
 
 if ($action == 'setconst' && $user->admin)
 {
-    $error=0;
+    $error = 0;
     $db->begin();
     foreach ($_POST['setupdriver'] as $setupconst) {
         //print '<pre>'.print_r($setupconst, true).'</pre>';
-        $result=dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity);
-        if (! $result > 0) $error++;
+        $result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity);
+        if (!$result > 0) $error++;
     }
 
-    if (! $error)
+    if (!$error)
     {
         $db->commit();
         setEventMessages($langs->trans("SetupSaved"), null);
@@ -75,17 +75,17 @@ if ($action == 'setconst' && $user->admin)
         $db->rollback();
         dol_print_error($db);
     }
-    $action='';
+    $action = '';
 }
 
 if ($action == 'setvalue' && $user->admin)
 {
     $db->begin();
 
-    $result=dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
-    if (! $result > 0) $error++;
+    $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
+    if (!$result > 0) $error++;
 
-    if (! $error)
+    if (!$error)
     {
         $db->commit();
         setEventMessages($langs->trans("SetupSaved"), null);
@@ -104,15 +104,15 @@ if ($action == 'setvalue' && $user->admin)
  */
 
 // 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
+$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
 
 $form = new Form($db);
 
 llxHeader('', $langs->trans("PrintingSetup"));
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
 
 $head = oauthadmin_prepare_head();
@@ -124,52 +124,52 @@ if ($mode == 'setup' && $user->admin)
 {
     print $langs->trans("OAuthSetupForLogin")."<br><br>\n";
 
-    foreach($list as $key)
+    foreach ($list as $key)
     {
-        $supported=0;
-        if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1;
-        if (! $supported) continue;     // show only supported
+        $supported = 0;
+        if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1;
+        if (!$supported) continue; // show only supported
 
 
-        $OAUTH_SERVICENAME='Unknown';
+        $OAUTH_SERVICENAME = 'Unknown';
         if ($key[0] == 'OAUTH_GITHUB_NAME')
         {
-            $OAUTH_SERVICENAME='GitHub';
-            $urltorenew=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
-            $urltodelete=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
-            $urltocheckperms='https://github.com/settings/applications/';
+            $OAUTH_SERVICENAME = 'GitHub';
+            $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+            $urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+            $urltocheckperms = 'https://github.com/settings/applications/';
         }
         elseif ($key[0] == 'OAUTH_GOOGLE_NAME')
         {
-            $OAUTH_SERVICENAME='Google';
-            $urltorenew=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
-            $urltodelete=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
-            $urltocheckperms='https://security.google.com/settings/security/permissions';
+            $OAUTH_SERVICENAME = 'Google';
+            $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+            $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+            $urltocheckperms = 'https://security.google.com/settings/security/permissions';
         }
         elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME')
         {
-        	$OAUTH_SERVICENAME='StripeTest';
-        	$urltorenew=$urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
-        	$urltodelete='';
-        	$urltocheckperms='';
+        	$OAUTH_SERVICENAME = 'StripeTest';
+        	$urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+        	$urltodelete = '';
+        	$urltocheckperms = '';
         }
         elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME')
         {
-        	$OAUTH_SERVICENAME='StripeLive';
-        	$urltorenew=$urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
-        	$urltodelete='';
-        	$urltocheckperms='';
+        	$OAUTH_SERVICENAME = 'StripeLive';
+        	$urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+        	$urltodelete = '';
+        	$urltocheckperms = '';
         }
         else
 		{
-			$urltorenew='';
-			$urltodelete='';
-			$urltocheckperms='';
+			$urltorenew = '';
+			$urltodelete = '';
+			$urltocheckperms = '';
 		}
 
 
         // Show value of token
-        $tokenobj=null;
+        $tokenobj = null;
         // Token
         require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
         require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
@@ -179,14 +179,14 @@ if ($mode == 'setup' && $user->admin)
         {
             $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
         }
-        catch(Exception $e)
+        catch (Exception $e)
         {
             // Return an error if token not found
         }
 
         // Set other properties
-        $refreshtoken=false;
-        $expiredat='';
+        $refreshtoken = false;
+        $expiredat = '';
 
         $expire = false;
         // Is token expired or will token expire in the next 30 seconds
@@ -209,12 +209,12 @@ if ($mode == 'setup' && $user->admin)
                 }
                 else
                 {
-                    $expiredat=dol_print_date($endoflife, "dayhour");
+                    $expiredat = dol_print_date($endoflife, "dayhour");
                 }
             }
         }
 
-        $submit_enabled=0;
+        $submit_enabled = 0;
 
         print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&amp;driver='.$driver.'" autocomplete="off">';
         print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -230,7 +230,7 @@ if ($mode == 'setup' && $user->admin)
         print "</tr>\n";
 
         print '<tr class="oddeven">';
-        print '<td'.($key['required']?' class="required"':'').'>';
+        print '<td'.($key['required'] ? ' class="required"' : '').'>';
         //var_dump($key);
         print $langs->trans("OAuthIDSecret").'</td>';
         print '<td>';
@@ -241,7 +241,7 @@ if ($mode == 'setup' && $user->admin)
         print '</tr>'."\n";
 
         print '<tr class="oddeven">';
-        print '<td'.($key['required']?' class="required"':'').'>';
+        print '<td'.($key['required'] ? ' class="required"' : '').'>';
         //var_dump($key);
         print $langs->trans("IsTokenGenerated");
         print '</td>';
@@ -270,7 +270,7 @@ if ($mode == 'setup' && $user->admin)
         print '</tr>';
 
         print '<tr class="oddeven">';
-        print '<td'.($key['required']?' class="required"':'').'>';
+        print '<td'.($key['required'] ? ' class="required"' : '').'>';
         //var_dump($key);
         print $langs->trans("Token").'</td>';
         print '<td colspan="2">';
@@ -292,7 +292,7 @@ if ($mode == 'setup' && $user->admin)
         {
             // Token refresh
             print '<tr class="oddeven">';
-            print '<td'.($key['required']?' class="required"':'').'>';
+            print '<td'.($key['required'] ? ' class="required"' : '').'>';
             //var_dump($key);
             print $langs->trans("TOKEN_REFRESH").'</td>';
             print '<td colspan="2">';
@@ -302,7 +302,7 @@ if ($mode == 'setup' && $user->admin)
 
             // Token expired
             print '<tr class="oddeven">';
-            print '<td'.($key['required']?' class="required"':'').'>';
+            print '<td'.($key['required'] ? ' class="required"' : '').'>';
             //var_dump($key);
             print $langs->trans("TOKEN_EXPIRED").'</td>';
             print '<td colspan="2">';
@@ -312,7 +312,7 @@ if ($mode == 'setup' && $user->admin)
 
             // Token expired at
             print '<tr class="oddeven">';
-            print '<td'.($key['required']?' class="required"':'').'>';
+            print '<td'.($key['required'] ? ' class="required"' : '').'>';
             //var_dump($key);
             print $langs->trans("TOKEN_EXPIRE_AT").'</td>';
             print '<td colspan="2">';
@@ -323,7 +323,7 @@ if ($mode == 'setup' && $user->admin)
 
         print '</table>';
 
-        if (! empty($driver))
+        if (!empty($driver))
         {
             if ($submit_enabled) {
                 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>';
@@ -340,7 +340,7 @@ if ($mode == 'test' && $user->admin)
     print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
 
     print '<table class="noborder centpercent">';
-    if (! empty($driver))
+    if (!empty($driver))
     {
         require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
         $classname = 'printing_'.$driver;
@@ -348,7 +348,7 @@ if ($mode == 'test' && $user->admin)
         $printer = new $classname($db);
         //print '<pre>'.print_r($printer, true).'</pre>';
         if (count($printer->getlistAvailablePrinters())) {
-            if ($printer->listAvailablePrinters()==0) {
+            if ($printer->listAvailablePrinters() == 0) {
                 print $printer->resprint;
             } else {
                 setEventMessages($printer->error, $printer->errors, 'errors');
@@ -379,7 +379,7 @@ if ($mode == 'userconf' && $user->admin)
     print "</tr>\n";
     $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid';
     $resql = $db->query($sql);
-    while ($row=$db->fetch_array($resql)) {
+    while ($row = $db->fetch_array($resql)) {
         print '<tr class="oddeven">';
         print '<td>'.$row['login'].'</td>';
         print '<td>'.$row['module'].'</td>';

+ 36 - 36
htdocs/admin/pdf.php

@@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members'));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');
@@ -46,7 +46,7 @@ $cancel = GETPOST('cancel', 'alpha');
  */
 
 if ($cancel) {
-    $action='';
+    $action = '';
 }
 
 if ($action == 'update')
@@ -102,12 +102,12 @@ elseif ($action == 'disable_pdfsecurity')
  * View
  */
 
-$wikihelp='EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
+$wikihelp = 'EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
-$form=new Form($db);
-$formother=new FormOther($db);
-$formadmin=new FormAdmin($db);
+$form = new Form($db);
+$formother = new FormOther($db);
+$formadmin = new FormAdmin($db);
 
 $arraydetailsforpdffoot = array(
 	0 => $langs->transnoentitiesnoconv('NoDetails'),
@@ -137,8 +137,8 @@ print '<div class="div-table-responsive-no-min">';
 print '<table summary="more" class="noborder centpercent">';
 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
 
-$selected=$conf->global->MAIN_PDF_FORMAT;
-if (empty($selected)) $selected=dol_getDefaultFormat();
+$selected = $conf->global->MAIN_PDF_FORMAT;
+if (empty($selected)) $selected = dol_getDefaultFormat();
 
 // Show pdf format
 
@@ -147,16 +147,16 @@ print $formadmin->select_paper_format($selected, 'MAIN_PDF_FORMAT');
 print '</td></tr>';
 
 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_LEFT").'</td><td>';
-print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_LEFT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_LEFT)?10:$conf->global->MAIN_PDF_MARGIN_LEFT).'">';
+print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_LEFT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_LEFT) ? 10 : $conf->global->MAIN_PDF_MARGIN_LEFT).'">';
 print '</td></tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_RIGHT").'</td><td>';
-print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_RIGHT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_RIGHT)?10:$conf->global->MAIN_PDF_MARGIN_RIGHT).'">';
+print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_RIGHT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_RIGHT) ? 10 : $conf->global->MAIN_PDF_MARGIN_RIGHT).'">';
 print '</td></tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_TOP").'</td><td>';
-print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_TOP" value="'.(empty($conf->global->MAIN_PDF_MARGIN_TOP)?10:$conf->global->MAIN_PDF_MARGIN_TOP).'">';
+print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_TOP" value="'.(empty($conf->global->MAIN_PDF_MARGIN_TOP) ? 10 : $conf->global->MAIN_PDF_MARGIN_TOP).'">';
 print '</td></tr>';
 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").'</td><td>';
-print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_BOTTOM" value="'.(empty($conf->global->MAIN_PDF_MARGIN_BOTTOM)?10:$conf->global->MAIN_PDF_MARGIN_BOTTOM).'">';
+print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_BOTTOM" value="'.(empty($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? 10 : $conf->global->MAIN_PDF_MARGIN_BOTTOM).'">';
 print '</td></tr>';
 
 print '</table>';
@@ -175,16 +175,16 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width=
 // Hide VAT Intra on address
 
 print '<tr class="oddeven"><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td>';
-print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (! empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))?$conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS:0, 1);
+print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) ? $conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS : 0, 1);
 print '</td></tr>';
 
 // Show prof id in address into pdf
-for($i=1; $i<=6; $i++)
+for ($i = 1; $i <= 6; $i++)
 {
-	if (! $noCountryCode)
+	if (!$noCountryCode)
 	{
-		$pid=$langs->transcountry("ProfId".$i, $mysoc->country_code);
-		if ($pid == '-') $pid=false;
+		$pid = $langs->transcountry("ProfId".$i, $mysoc->country_code);
+		if ($pid == '-') $pid = false;
 	}
 	else
 	{
@@ -194,7 +194,7 @@ for($i=1; $i<=6; $i++)
 	{
 		print '<tr class="oddeven"><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid.'</td><td>';
 		$keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS';
-		print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant)?$conf->global->$keyforconstant:0, 1, $noCountryCode);
+		print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode);
 		print '</td></tr>';
 	}
 }
@@ -207,32 +207,32 @@ print '<br>';
 
 
 // Localtaxes
-$locales ='';
-$text='';
+$locales = '';
+$text = '';
 if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2))
 {
 	if ($mysoc->useLocalTax(1))
 	{
 		$locales = $langs->transcountry("LT1", $mysoc->country_code);
-		$text ='<tr class="oddeven"><td>' . $langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)) . '</td><td>';
-		$text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1);
+		$text = '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).'</td><td>';
+		$text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1);
 		$text .= '</td></tr>';
 	}
 
 	if ($mysoc->useLocalTax(2))
 	{
-		$locales.=($locales?' & ':'').$langs->transcountry("LT2", $mysoc->country_code);
+		$locales .= ($locales ? ' & ' : '').$langs->transcountry("LT2", $mysoc->country_code);
 
-		$text.= '<tr class="oddeven"><td>' . $langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)) . '</td><td>';
-		$text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1);
-		$text.= '</td></tr>';
+		$text .= '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).'</td><td>';
+		$text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1);
+		$text .= '</td></tr>';
 	}
 }
 
 $title = $langs->trans("PDFRulesForSalesTax");
 if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2))
 {
-	$title.=' - '.$langs->trans("PDFLocaltax", $locales);
+	$title .= ' - '.$langs->trans("PDFLocaltax", $locales);
 }
 
 print load_fiche_titre($title, '', '');
@@ -243,7 +243,7 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width=
 // Hide any information on Sale tax / VAT
 
 print '<tr class="oddeven"><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
-print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0, 1);
+print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT : 0, 1);
 print '</td></tr>';
 
 // Locataxes
@@ -263,31 +263,31 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width=
 //Desc
 
 print '<tr class="oddeven"><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
-print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC:0, 1);
+print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC : 0, 1);
 print '</td></tr>';
 
 //Ref
 
 print '<tr class="oddeven"><td>'.$langs->trans("HideRefOnPDF").'</td><td>';
-print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF:0, 1);
+print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF : 0, 1);
 print '</td></tr>';
 
 //Details
 
 print '<tr class="oddeven"><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
-print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0, 1);
+print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1);
 print '</td></tr>';
 
 //Invert sender and recipient
 
 print '<tr class="oddeven"><td>'.$langs->trans("SwapSenderAndRecipientOnPDF").'</td><td>';
-print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT))?$conf->global->MAIN_INVERT_SENDER_RECIPIENT:0, 1);
+print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1);
 print '</td></tr>';
 
 // Place customer adress to the ISO location
 
 print '<tr class="oddeven"><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>';
-print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (! empty($conf->global->MAIN_PDF_USE_ISO_LOCATION))?$conf->global->MAIN_PDF_USE_ISO_LOCATION:0, 1);
+print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1);
 print '</td></tr>';
 
 
@@ -317,9 +317,9 @@ print "</tr>\n";
 print '<tr class="oddeven">'."\n";
 print '<td>'.$langs->trans("LibraryToBuildPDF").'</td>'."\n";
 print '<td>';
-$i=0;
-$pdf=pdf_getInstance('A4');
-if (class_exists('FPDF') && ! class_exists('TCPDF'))
+$i = 0;
+$pdf = pdf_getInstance('A4');
+if (class_exists('FPDF') && !class_exists('TCPDF'))
 {
 	if ($i) print ' + ';
 	print 'FPDF';

+ 40 - 40
htdocs/admin/security.php

@@ -27,22 +27,22 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
 
-$action=GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'aZ09');
 
 // Load translation files required by the page
-$langs->loadLangs(array("users","admin","other"));
+$langs->loadLangs(array("users", "admin", "other"));
 
 if (!$user->admin) accessforbidden();
 
 // Allow/Disallow change to clear passwords once passwords are crypted
-$allow_disable_encryption=true;
+$allow_disable_encryption = true;
 
 /*
  * Actions
  */
 if ($action == 'setgeneraterule')
 {
-	if (! dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity))
+	if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity))
 	{
 		dol_print_error($db);
 	}
@@ -55,33 +55,33 @@ if ($action == 'setgeneraterule')
 
 if ($action == 'activate_encrypt')
 {
-    $error=0;
+    $error = 0;
 
 	$db->begin();
 
     dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity);
 
     $sql = "SELECT u.rowid, u.pass, u.pass_crypted";
-    $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
-    $sql.= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value
+    $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
+    $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value
 
-    $resql=$db->query($sql);
+    $resql = $db->query($sql);
     if ($resql)
     {
-        $numrows=$db->num_rows($resql);
-        $i=0;
+        $numrows = $db->num_rows($resql);
+        $i = 0;
         while ($i < $numrows)
         {
-            $obj=$db->fetch_object($resql);
+            $obj = $db->fetch_object($resql);
             if (dol_hash($obj->pass))
             {
                 $sql = "UPDATE ".MAIN_DB_PREFIX."user";
-                $sql.= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL";
-                $sql.= " WHERE rowid=".$obj->rowid;
+                $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL";
+                $sql .= " WHERE rowid=".$obj->rowid;
                 //print $sql;
 
                 $resql2 = $db->query($sql);
-                if (! $resql2)
+                if (!$resql2)
                 {
                     dol_print_error($db);
                     $error++;
@@ -96,7 +96,7 @@ if ($action == 'activate_encrypt')
 
 	//print $error." ".$sql;
     //exit;
-    if (! $error)
+    if (!$error)
 	{
 		$db->commit();
 		header("Location: security.php");
@@ -125,7 +125,7 @@ if ($action == 'activate_encryptdbpassconf')
 	$result = encodedecode_dbpassconf(1);
 	if ($result > 0)
 	{
-	    sleep(3);  // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
+	    sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
 
 	    // database value not required
 		//dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1");
@@ -142,7 +142,7 @@ elseif ($action == 'disable_encryptdbpassconf')
 	$result = encodedecode_dbpassconf(0);
 	if ($result > 0)
 	{
-	    sleep(3);  // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
+	    sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
 
 		// database value not required
 		//dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity);
@@ -196,7 +196,7 @@ if ($action == 'maj_pattern')
  */
 $form = new Form($db);
 
-$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
+$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
 llxHeader('', $langs->trans("Passwords"), $wikihelp);
 
 print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
@@ -205,7 +205,7 @@ print $langs->trans("GeneratedPasswordDesc")."<br>\n";
 print "<br>\n";
 
 
-$head=security_prepare_head();
+$head = security_prepare_head();
 
 dol_fiche_head($head, 'passwords', $langs->trans("Security"), -1);
 
@@ -220,11 +220,11 @@ print '<input type="hidden" name="consttype" value="yesno">';
 // Charge tableau des modules generation
 $dir = "../core/modules/security/generate";
 clearstatcache();
-$handle=opendir($dir);
-$i=1;
+$handle = opendir($dir);
+$i = 1;
 if (is_resource($handle))
 {
-    while (($file = readdir($handle))!==false)
+    while (($file = readdir($handle)) !== false)
     {
         if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg))
         {
@@ -233,7 +233,7 @@ if (is_resource($handle))
             require_once $dir.'/'.$file;
 
             $obj = new $classname($db, $conf, $langs, $user);
-            $arrayhandler[$obj->id]=$obj;
+            $arrayhandler[$obj->id] = $obj;
     		$i++;
         }
     }
@@ -251,7 +251,7 @@ print '</tr>';
 foreach ($arrayhandler as $key => $module)
 {
 	// Show modules according to features level
-    if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+    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())
@@ -265,9 +265,9 @@ foreach ($arrayhandler as $key => $module)
 
         // Show example of numbering module
         print '<td class="nowrap">';
-        $tmp=$module->getExample();
+        $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);
+        elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
         else print $tmp;
         print '</td>'."\n";
 
@@ -288,7 +288,7 @@ print '</form>';
 
 //if($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK == 1)
 // Patter for Password Perso
-if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){
+if ($conf->global->USER_PASSWORD_GENERATED == "Perso") {
 	$tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN);
 	print '<br>';
 	print '<table class="noborder centpercent">';
@@ -298,37 +298,37 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){
 
 
 	print '<tr class="oddeven">';
-	print '<td>' . $langs->trans("MinLength")."</td>";
+	print '<td>'.$langs->trans("MinLength")."</td>";
 	print '<td colspan="2"><input type="number" value="'.$tabConf[0].'" id="minlenght" min="1"></td>';
 	print '</tr>';
 
 
 	print '<tr class="oddeven">';
-	print '<td>' . $langs->trans("NbMajMin")."</td>";
+	print '<td>'.$langs->trans("NbMajMin")."</td>";
 	print '<td colspan="2"><input type="number" value="'.$tabConf[1].'" id="NbMajMin" min="0"></td>';
 	print '</tr>';
 
 
 	print '<tr class="oddeven">';
-	print '<td>' . $langs->trans("NbNumMin")."</td>";
+	print '<td>'.$langs->trans("NbNumMin")."</td>";
 	print '<td colspan="2"><input type="number" value="'.$tabConf[2].'" id="NbNumMin" min="0"></td>';
 	print '</tr>';
 
 
 	print '<tr class="oddeven">';
-	print '<td>' . $langs->trans("NbSpeMin")."</td>";
+	print '<td>'.$langs->trans("NbSpeMin")."</td>";
 	print '<td colspan="2"><input type="number" value="'.$tabConf[3].'" id="NbSpeMin" min="0"></td>';
 	print '</tr>';
 
 
 	print '<tr class="oddeven">';
-	print '<td>' . $langs->trans("NbIteConsecutive")."</td>";
+	print '<td>'.$langs->trans("NbIteConsecutive")."</td>";
 	print '<td colspan="2"><input type="number" value="'.$tabConf[4].'" id="NbIteConsecutive" min="0"></td>';
 	print '</tr>';
 
 
 	print '<tr class="oddeven">';
-	print '<td>' . $langs->trans("NoAmbiCaracAutoGeneration")."</td>";
+	print '<td>'.$langs->trans("NoAmbiCaracAutoGeneration")."</td>";
 	print '<td colspan="2"><input type="checkbox" id="NoAmbiCaracAutoGeneration" '.($tabConf[5] ? "checked" : "").' min="0"> <span id="textcheckbox">'.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'</span></td>';
 	print '</tr>';
 
@@ -398,7 +398,7 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){
 
 // Cryptage mot de passe
 print '<br>';
-print "<form method=\"post\" action=\"" . $_SERVER["PHP_SELF"] . "\">";
+print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print "<input type=\"hidden\" name=\"action\" value=\"encrypt\">";
 
@@ -413,12 +413,12 @@ print '</tr>';
 print '<tr class="oddeven">';
 print '<td colspan="3">'.$langs->trans("DoNotStoreClearPassword").'</td>';
 print '<td align="center" width="60">';
-if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
+if (!empty($conf->global->DATABASE_PWD_ENCRYPTED))
 {
 	print img_picto($langs->trans("Active"), 'tick');
 }
 print '</td>';
-if (! $conf->global->DATABASE_PWD_ENCRYPTED)
+if (!$conf->global->DATABASE_PWD_ENCRYPTED)
 {
 	print '<td align="center" width="100">';
 	print '<a href="security.php?action=activate_encrypt">'.$langs->trans("Activate").'</a>';
@@ -426,7 +426,7 @@ if (! $conf->global->DATABASE_PWD_ENCRYPTED)
 }
 
 // Database conf file encryption
-if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
+if (!empty($conf->global->DATABASE_PWD_ENCRYPTED))
 {
 	print '<td align="center" width="100">';
 	if ($allow_disable_encryption)
@@ -449,7 +449,7 @@ print '</tr>';
 print '<tr class="oddeven">';
 print '<td colspan="3">'.$langs->trans("MainDbPasswordFileConfEncrypted").'</td>';
 print '<td align="center" width="60">';
-if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
+if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
 {
 	print img_picto($langs->trans("Active"), 'tick');
 }
@@ -468,7 +468,7 @@ else
 	{
 		print '<a href="security.php?action=activate_encryptdbpassconf">'.$langs->trans("Activate").'</a>';
 	}
-	if (! empty($dolibarr_main_db_encrypted_pass))
+	if (!empty($dolibarr_main_db_encrypted_pass))
 	{
 		print '<a href="security.php?action=disable_encryptdbpassconf">'.$langs->trans("Disable").'</a>';
 	}
@@ -484,7 +484,7 @@ print '</tr>';
 print '<tr class="oddeven">';
 print '<td colspan="3">'.$langs->trans("DisableForgetPasswordLinkOnLogonPage").'</td>';
 print '<td align="center" width="60">';
-if(! empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
+if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
 {
 	print img_picto($langs->trans("Active"), 'tick');
 }

+ 28 - 28
htdocs/admin/security_file.php

@@ -31,19 +31,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array('users', 'admin', 'other'));
 
-if (! $user->admin)
+if (!$user->admin)
 	accessforbidden();
 
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 
-$upload_dir=$conf->admin->dir_temp;
+$upload_dir = $conf->admin->dir_temp;
 
 
 /*
  * Actions
  */
 
-if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
+if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC))
 {
     require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
@@ -52,15 +52,15 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
 
 if ($action == 'updateform')
 {
-	$antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'none');			// Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe
-	$antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'none');				// Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib"
-	$antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&"));	// Sanitize command
-	$antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&"));		// Sanitize params
-
-	$res3=dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity);
-	$res4=dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity);
-	$res5=dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity);
-	$res6=dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity);
+	$antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'none'); // Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe
+	$antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'none'); // Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib"
+	$antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command
+	$antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&")); // Sanitize params
+
+	$res3 = dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity);
+	$res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity);
+	$res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity);
+	$res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity);
 	if ($res3 && $res4 && $res5 && $res6) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
 }
 
@@ -70,8 +70,8 @@ if ($action == 'updateform')
 elseif ($action == 'delete')
 {
 	$langs->load("other");
-	$file = $conf->admin->dir_temp . '/' . GETPOST('urlfile', 'alpha');	// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
-	$ret=dol_delete_file($file);
+	$file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
+	$ret = dol_delete_file($file);
 	if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs');
 	else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors');
 	Header('Location: '.$_SERVER["PHP_SELF"]);
@@ -85,7 +85,7 @@ elseif ($action == 'delete')
 
 $form = new Form($db);
 
-$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
+$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
 llxHeader('', $langs->trans("Files"), $wikihelp);
 
 print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
@@ -98,13 +98,13 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="updateform">';
 
-$head=security_prepare_head();
+$head = security_prepare_head();
 
 dol_fiche_head($head, 'file', $langs->trans("Security"), -1);
 
 
 // Upload options
-$var=false;
+$var = false;
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
@@ -115,8 +115,8 @@ print '</tr>';
 
 print '<tr class="oddeven">';
 print '<td colspan="2">'.$langs->trans("MaxSizeForUploadedFiles").'.';
-$max=@ini_get('upload_max_filesize');
-if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit", $max*1024, $langs->trans("Kb")).'.';
+$max = @ini_get('upload_max_filesize');
+if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit", $max * 1024, $langs->trans("Kb")).'.';
 else print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.';
 print '</td>';
 print '<td class="nowrap">';
@@ -142,18 +142,18 @@ print $langs->trans("AntiVirusCommandExample");
 // Check command in inside safe_mode
 print '</td>';
 print '<td>';
-if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
+if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
 {
     $langs->load("errors");
-    $basedir=preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND));
-    $listdir=explode(';', ini_get('safe_mode_exec_dir'));
-    if (! in_array($basedir, $listdir))
+    $basedir = preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND));
+    $listdir = explode(';', ini_get('safe_mode_exec_dir'));
+    if (!in_array($basedir, $listdir))
     {
         print img_warning($langs->trans('WarningSafeModeOnCheckExecDir'));
         dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING);
     }
 }
-print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND):'').'">';
+print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND) : '').'">';
 print "</td>";
 print '</tr>';
 
@@ -164,7 +164,7 @@ print '<td colspan="2">'.$langs->trans("AntiVirusParam").'<br>';
 print $langs->trans("AntiVirusParamExample");
 print '</td>';
 print '<td>';
-print '<input type="text" name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" value="'.(! empty($conf->global->MAIN_ANTIVIRUS_PARAM)?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_PARAM):'').'">';
+print '<input type="text" name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_PARAM) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_PARAM) : '').'">';
 print "</td>";
 print '</tr>';
 
@@ -180,11 +180,11 @@ print '</form>';
 
 // Form to test upload
 print '<br>';
-$formfile=new FormFile($db);
+$formfile = new FormFile($db);
 $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestFileUploadForm"), 0, 0, 1, 50, '', '', 1, '', 0);
 
 // List of document
-$filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1);
+$filearray = dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1);
 $formfile->list_of_documents($filearray, null, 'admin_temp', '');
 
 // End of page

+ 35 - 35
htdocs/admin/sms.php

@@ -26,12 +26,12 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("companies","admin","products","sms","other","errors"));
+$langs->loadLangs(array("companies", "admin", "products", "sms", "other", "errors"));
 
 if (!$user->admin)
 accessforbidden();
 
-$substitutionarrayfortest=array(
+$substitutionarrayfortest = array(
 '__ID__' => 'TESTIdRecord',
 '__PHONEFROM__' => 'TESTPhoneFrom',
 '__PHONETO__' => 'TESTPhoneTo',
@@ -39,7 +39,7 @@ $substitutionarrayfortest=array(
 '__FIRSTNAME__' => 'TESTFirstname'
 );
 
-$action=GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'aZ09');
 
 
 /*
@@ -63,16 +63,16 @@ if ($action == 'update' && empty($_POST["cancel"]))
 /*
  * Send sms
  */
-if ($action == 'send' && ! $_POST['cancel'])
+if ($action == 'send' && !$_POST['cancel'])
 {
-	$error=0;
+	$error = 0;
 
-	$smsfrom='';
-	if (! empty($_POST["fromsms"])) $smsfrom=GETPOST("fromsms");
-	if (empty($smsfrom)) $smsfrom=GETPOST("fromname");
+	$smsfrom = '';
+	if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms");
+	if (empty($smsfrom)) $smsfrom = GETPOST("fromname");
 	$sendto     = GETPOST("sendto");
 	$body       = GETPOST('message');
-	$deliveryreceipt= GETPOST("deliveryreceipt");
+	$deliveryreceipt = GETPOST("deliveryreceipt");
     $deferred   = GETPOST('deferred');
     $priority   = GETPOST('priority');
     $class      = GETPOST('class');
@@ -82,40 +82,40 @@ if ($action == 'send' && ! $_POST['cancel'])
 	include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php';
 	$formsms = new FormSms($db);
 
-	if (! empty($formsms->error))
+	if (!empty($formsms->error))
 	{
 		setEventMessages($formsms->error, $formsms->errors, 'errors');
-	    $action='test';
+	    $action = 'test';
 	    $error++;
 	}
     if (empty($body))
     {
         setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors');
-        $action='test';
+        $action = 'test';
         $error++;
     }
-	if (empty($smsfrom) || ! str_replace('+', '', $smsfrom))
+	if (empty($smsfrom) || !str_replace('+', '', $smsfrom))
 	{
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors');
-        $action='test';
+        $action = 'test';
 		$error++;
 	}
-	if (empty($sendto) || ! str_replace('+', '', $sendto))
+	if (empty($sendto) || !str_replace('+', '', $sendto))
 	{
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors');
-        $action='test';
+        $action = 'test';
 		$error++;
 	}
-	if (! $error)
+	if (!$error)
 	{
 		// Make substitutions into message
         complete_substitutions_array($substitutionarrayfortest, $langs);
-	    $body=make_substitutions($body, $substitutionarrayfortest);
+	    $body = make_substitutions($body, $substitutionarrayfortest);
 
 		require_once DOL_DOCUMENT_ROOT.'/core/class/CSMSFile.class.php';
 
-		$smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class);  // This define OvhSms->login, pass, session and account
-		$result=$smsfile->sendfile(); // This send SMS
+		$smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account
+		$result = $smsfile->sendfile(); // This send SMS
 
 		if ($result)
 		{
@@ -128,7 +128,7 @@ if ($action == 'send' && ! $_POST['cancel'])
 			setEventMessages($smsfile->error, $smsfile->errors, 'errors');
 		}
 
-		$action='';
+		$action = '';
 	}
 }
 
@@ -138,11 +138,11 @@ if ($action == 'send' && ! $_POST['cancel'])
  * View
  */
 
-$linuxlike=1;
-if (preg_match('/^win/i', PHP_OS)) $linuxlike=0;
-if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0;
+$linuxlike = 1;
+if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0;
+if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0;
 
-$wikihelp='EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms';
+$wikihelp = 'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
 print load_fiche_titre($langs->trans("SmsSetup"), '', 'title_setup');
@@ -151,14 +151,14 @@ print '<span class="opacitymedium">'.$langs->trans("SmsDesc")."</span><br>\n";
 print "<br>\n";
 
 // List of sending methods
-$listofmethods=(is_array($conf->modules_parts['sms'])?$conf->modules_parts['sms']:array());
+$listofmethods = (is_array($conf->modules_parts['sms']) ? $conf->modules_parts['sms'] : array());
 asort($listofmethods);
 
 if ($action == 'edit')
 {
-	$form=new Form($db);
+	$form = new Form($db);
 
-	if (! count($listofmethods)) print '<div class="warning">'.$langs->trans("NoSmsEngine", '<a href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>').'</div>';
+	if (!count($listofmethods)) print '<div class="warning">'.$langs->trans("NoSmsEngine", '<a href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>').'</div>';
 
 	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -185,7 +185,7 @@ if ($action == 'edit')
 
 	// From
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).'</td>';
-	print '<td><input class="flat" name="MAIN_MAIL_SMS_FROM" size="32" value="' . $conf->global->MAIN_MAIL_SMS_FROM;
+	print '<td><input class="flat" name="MAIN_MAIL_SMS_FROM" size="32" value="'.$conf->global->MAIN_MAIL_SMS_FROM;
 	print '"></td></tr>';
 
 	// Autocopy to
@@ -197,7 +197,7 @@ if ($action == 'edit')
 	print '</table>';
 
 	print '<br><div class="center">';
-	print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"'.(!count($listofmethods)?' disabled':'').'>';
+	print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"'.(!count($listofmethods) ? ' disabled' : '').'>';
 	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
 	print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
 	print '</div>';
@@ -207,7 +207,7 @@ if ($action == 'edit')
 }
 else
 {
-	if (! count($listofmethods)) print '<div class="warning">'.$langs->trans("NoSmsEngine", '<a target="_blank" href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>').'</div>';
+	if (!count($listofmethods)) print '<div class="warning">'.$langs->trans("NoSmsEngine", '<a target="_blank" href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>').'</div>';
 
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
@@ -220,15 +220,15 @@ else
 
 	// Method
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>';
-	$text=$listofmethods[$conf->global->MAIN_SMS_SENDMODE];
-	if (empty($text)) $text=$langs->trans("Undefined").' '.img_warning();
+	$text = $listofmethods[$conf->global->MAIN_SMS_SENDMODE];
+	if (empty($text)) $text = $langs->trans("Undefined").' '.img_warning();
 	print $text;
 	print '</td></tr>';
 
 	// From
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).'</td>';
 	print '<td>'.$conf->global->MAIN_MAIL_SMS_FROM;
-	if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && ! isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone"));
+	if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && !isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone"));
 	print '</td></tr>';
 
 	// Autocopy to
@@ -260,7 +260,7 @@ else
 		print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
 	}*/
 
-	if (count($listofmethods) && ! empty($conf->global->MAIN_SMS_SENDMODE))
+	if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE))
 	{
 	    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
 	}

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

@@ -30,15 +30,15 @@ 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("install","other","admin"));
+$langs->loadLangs(array("install", "other", "admin"));
 
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 
-if (! $user->admin)
+if (!$user->admin)
 	accessforbidden();
 
 $sfurl = '';
-$version='0.0';
+$version = '0.0';
 
 
 
@@ -58,9 +58,9 @@ if ($action == 'getlastversion')
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
-$title=$langs->trans("InfoDolibarr");
+$title = $langs->trans("InfoDolibarr");
 
 llxHeader('', $title);
 
@@ -91,39 +91,39 @@ if (function_exists('curl_init'))
     {
         if ($sfurl)
         {
-            while (! empty($sfurl->channel[0]->item[$i]->title) && $i < 10000)
+            while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000)
             {
-                $title=$sfurl->channel[0]->item[$i]->title;
+                $title = $sfurl->channel[0]->item[$i]->title;
                 if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg))
                 {
-                    $newversion=$reg[1];
-                    $newversionarray=explode('.', $newversion);
-                    $versionarray=explode('.', $version);
+                    $newversion = $reg[1];
+                    $newversionarray = explode('.', $newversion);
+                    $versionarray = explode('.', $version);
                     //var_dump($newversionarray);var_dump($versionarray);
-                    if (versioncompare($newversionarray, $versionarray) > 0) $version=$newversion;
+                    if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion;
                 }
                 $i++;
             }
 
             // Show version
-            print $langs->trans("LastStableVersion").' : <b>'. (($version != '0.0')?$version:$langs->trans("Unknown")) .'</b>';
+            print $langs->trans("LastStableVersion").' : <b>'.(($version != '0.0') ? $version : $langs->trans("Unknown")).'</b>';
         }
         else
         {
-            print $langs->trans("LastStableVersion").' : <b>' .$langs->trans("UpdateServerOffline").'</b>';
+            print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("UpdateServerOffline").'</b>';
         }
     }
     else
     {
-        print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="butAction">' .$langs->trans("Check").'</a>';
+        print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="butAction">'.$langs->trans("Check").'</a>';
     }
 }
 
 // Now show link to the changelog
 print ' &nbsp; &nbsp; - &nbsp; &nbsp; ';
 
-$version=DOL_VERSION;
-if (preg_match('/[a-z]+/i', $version)) $version='develop';	// If version contains text, it is not an official tagged version, so we use the full change log.
+$version = DOL_VERSION;
+if (preg_match('/[a-z]+/i', $version)) $version = 'develop'; // If version contains text, it is not an official tagged version, so we use the full change log.
 
 print '<a href="https://raw.githubusercontent.com/Dolibarr/dolibarr/'.$version.'/ChangeLog" target="_blank">'.$langs->trans("SeeChangeLog").'</a>';
 print '</td></tr>'."\n";
@@ -155,8 +155,8 @@ print '<tr class="oddeven"><td>'.$langs->trans("Screen").'</td><td colspan="2">'
 print $_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
 print '</td></tr>'."\n";
 print '<tr class="oddeven"><td>'.$langs->trans("Session").'</td><td colspan="2">';
-$i=0;
-foreach($_SESSION as $key => $val)
+$i = 0;
+foreach ($_SESSION as $key => $val)
 {
 	if ($i > 0) print ', ';
 	if (is_array($val)) print $key.' => array(...)';
@@ -172,7 +172,7 @@ print '<br>';
 // Shmop
 if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
 {
-	$shmoparray=dol_listshmop();
+	$shmoparray = dol_listshmop();
 
     print '<div class="div-table-responsive-no-min">';
 	print '<table class="noborder centpercent">';
@@ -182,7 +182,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S
 	print '<td class="right">'.$langs->trans("Address").'</td>';
 	print '</tr>'."\n";
 
-	foreach($shmoparray as $key => $val)
+	foreach ($shmoparray as $key => $val)
 	{
 		print '<tr class="oddeven"><td>'.$key.'</td>';
 		print '<td>'.count($val).'</td>';
@@ -203,15 +203,15 @@ print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Localisat
 print '<tr class="oddeven"><td>'.$langs->trans("LanguageBrowserParameter", "HTTP_ACCEPT_LANGUAGE").'</td><td>'.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'</td></tr>'."\n";
 print '<tr class="oddeven"><td>'.$langs->trans("CurrentUserLanguage").'</td><td>'.$langs->getDefaultLang().'</td></tr>'."\n";
 // Thousands
-$thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
-if ($thousand == 'SeparatorThousand') $thousand=' ';	// ' ' does not work on trans method
-if ($thousand == 'None') $thousand='';
-print '<tr class="oddeven"><td>'.$langs->trans("CurrentValueSeparatorThousand").'</td><td>'.($thousand==' '?$langs->transnoentitiesnoconv("Space"):$thousand).'</td></tr>'."\n";
+$thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
+if ($thousand == 'SeparatorThousand') $thousand = ' '; // ' ' does not work on trans method
+if ($thousand == 'None') $thousand = '';
+print '<tr class="oddeven"><td>'.$langs->trans("CurrentValueSeparatorThousand").'</td><td>'.($thousand == ' ' ? $langs->transnoentitiesnoconv("Space") : $thousand).'</td></tr>'."\n";
 // Decimals
-$dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
+$dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
 print '<tr class="oddeven"><td>'.$langs->trans("CurrentValueSeparatorDecimal").'</td><td>'.$dec.'</td></tr>'."\n";
 // Show results of functions to see if everything works
-print '<tr class="oddeven"><td>&nbsp; => price2num(1233.56+1)</td><td>'.price2num(1233.56+1, '2').'</td></tr>'."\n";
+print '<tr class="oddeven"><td>&nbsp; => price2num(1233.56+1)</td><td>'.price2num(1233.56 + 1, '2').'</td></tr>'."\n";
 print '<tr class="oddeven"><td>&nbsp; => price2num('."'1".$thousand."234".$dec."56')</td><td>".price2num("1".$thousand."234".$dec."56", '2')."</td></tr>\n";
 if (($thousand != ',' && $thousand != '.') || ($thousand != ' '))
 {
@@ -220,21 +220,21 @@ if (($thousand != ',' && $thousand != '.') || ($thousand != ' '))
 }
 print '<tr class="oddeven"><td>&nbsp; => price(1234.56)</td><td>'.price(1234.56).'</td></tr>'."\n";
 // Timezone
-$txt =$langs->trans("OSTZ").' (variable system TZ): '.(! empty($_ENV["TZ"])?$_ENV["TZ"]:$langs->trans("NotDefined")).'<br>'."\n";
-$txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."<br>\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
-$txt.=$langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ)?$langs->trans("NotDefined"):$conf->global->MAIN_SERVER_TZ);
-print '<tr class="oddeven"><td>'.$langs->trans("CurrentTimeZone").'</td><td>';	// Timezone server PHP
-$a=getServerTimeZoneInt('now');
-$b=getServerTimeZoneInt('winter');
-$c=getServerTimeZoneInt('summer');
-$daylight=(is_numeric($c) && is_numeric($b))?round($c-$b):'unknown';
+$txt = $langs->trans("OSTZ").' (variable system TZ): '.(!empty($_ENV["TZ"]) ? $_ENV["TZ"] : $langs->trans("NotDefined")).'<br>'."\n";
+$txt .= $langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone") ?ini_get("date.timezone") : $langs->trans("NotDefined")).''."<br>\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
+$txt .= $langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ) ? $langs->trans("NotDefined") : $conf->global->MAIN_SERVER_TZ);
+print '<tr class="oddeven"><td>'.$langs->trans("CurrentTimeZone").'</td><td>'; // Timezone server PHP
+$a = getServerTimeZoneInt('now');
+$b = getServerTimeZoneInt('winter');
+$c = getServerTimeZoneInt('summer');
+$daylight = (is_numeric($c) && is_numeric($b)) ?round($c - $b) : 'unknown';
 //print $a." ".$b." ".$c." ".$daylight;
-$val=($a>=0?'+':'').$a;
-$val.=' ('.($a=='unknown'?'unknown':($a>=0?'+':'').($a*3600)).')';
-$val.=' &nbsp; &nbsp; &nbsp; '.getServerTimeZoneString();
-$val.=' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':($a==$c?yn($daylight):yn(0).($daylight?'  &nbsp; &nbsp; ('.$langs->trans('YesInSummer').')':'')));
+$val = ($a >= 0 ? '+' : '').$a;
+$val .= ' ('.($a == 'unknown' ? 'unknown' : ($a >= 0 ? '+' : '').($a * 3600)).')';
+$val .= ' &nbsp; &nbsp; &nbsp; '.getServerTimeZoneString();
+$val .= ' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': '.($daylight === 'unknown' ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '  &nbsp; &nbsp; ('.$langs->trans('YesInSummer').')' : '')));
 print $form->textwithtooltip($val, $txt, 2, 1, img_info(''));
-print '</td></tr>'."\n";	// value defined in http://fr3.php.net/manual/en/timezones.europe.php
+print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
 print '<tr class="oddeven"><td>&nbsp; => '.$langs->trans("CurrentHour").'</td><td>'.dol_print_date(dol_now(), 'dayhour', 'tzserver').'</td></tr>'."\n";
 print '<tr class="oddeven"><td>&nbsp; => dol_print_date(0,"dayhourtext")</td><td>'.dol_print_date(0, "dayhourtext").'</td>';
 print '<tr class="oddeven"><td>&nbsp; => dol_get_first_day(1970,1,false)</td><td>'.dol_get_first_day(1970, 1, false).' &nbsp; &nbsp; (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970, 1, false), 'dayhour').')</td>';
@@ -242,8 +242,8 @@ print '<tr class="oddeven"><td>&nbsp; => dol_get_first_day(1970,1,true)</td><td>
 // Database timezone
 if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
 {
-	print '<tr class="oddeven"><td>'.$langs->trans("MySQLTimeZone").' (database)</td><td>';	// Timezone server base
-	$sql="SHOW VARIABLES where variable_name = 'system_time_zone'";
+	print '<tr class="oddeven"><td>'.$langs->trans("MySQLTimeZone").' (database)</td><td>'; // Timezone server base
+	$sql = "SHOW VARIABLES where variable_name = 'system_time_zone'";
 	$resql = $db->query($sql);
 	if ($resql)
 	{
@@ -253,25 +253,25 @@ if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
 	print '</td></tr>'."\n";
 }
 // Client
-$tz=(int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst'];
-print '<tr class="oddeven"><td>'.$langs->trans("ClientTZ").'</td><td>'.($tz?($tz>=0?'+':'').$tz:'').' ('.($tz>=0?'+':'').($tz*60*60).')';
+$tz = (int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst'];
+print '<tr class="oddeven"><td>'.$langs->trans("ClientTZ").'</td><td>'.($tz ? ($tz >= 0 ? '+' : '').$tz : '').' ('.($tz >= 0 ? '+' : '').($tz * 60 * 60).')';
 print ' &nbsp; &nbsp; &nbsp; '.$_SESSION['dol_tz_string'];
 print ' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': ';
-if ($_SESSION['dol_dst']>0) print yn(1);
+if ($_SESSION['dol_dst'] > 0) print yn(1);
 else print yn(0);
-if (! empty($_SESSION['dol_dst_first'])) print ' &nbsp; &nbsp; ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']), 'dayhour', 'gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']), 'dayhour', 'gmt').')';
+if (!empty($_SESSION['dol_dst_first'])) print ' &nbsp; &nbsp; ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']), 'dayhour', 'gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']), 'dayhour', 'gmt').')';
 print '</td></tr>'."\n";
 print '</td></tr>'."\n";
 print '<tr class="oddeven"><td>&nbsp; => '.$langs->trans("ClientHour").'</td><td>'.dol_print_date(dol_now(), 'dayhour', 'tzuser').'</td></tr>'."\n";
 
-$filesystemencoding=ini_get("unicode.filesystem_encoding");	// Disponible avec PHP 6.0
+$filesystemencoding = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
 print '<tr class="oddeven"><td>'.$langs->trans("File encoding").' (php.ini unicode.filesystem_encoding)</td><td>'.$filesystemencoding.'</td></tr>'."\n";
 
-$tmp=ini_get("unicode.filesystem_encoding");						// Disponible avec PHP 6.0
-if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1';	// By default for windows
-if (empty($tmp)) $tmp='utf-8';										// By default for other
-if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING;
-print '<tr class="oddeven"><td>&nbsp; => '.$langs->trans("File encoding").'</td><td>'.$tmp.'</td></tr>'."\n";	// date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
+$tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
+if (empty($tmp) && !empty($_SERVER["WINDIR"])) $tmp = 'iso-8859-1'; // By default for windows
+if (empty($tmp)) $tmp = 'utf-8'; // By default for other
+if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
+print '<tr class="oddeven"><td>&nbsp; => '.$langs->trans("File encoding").'</td><td>'.$tmp.'</td></tr>'."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
 
 print '</table>';
 print '</div>';
@@ -280,7 +280,7 @@ print '<br>';
 
 
 // Parameters in conf.php file (when a parameter start with ?, it is shown only if defined)
-$configfileparameters=array(
+$configfileparameters = array(
 		'dolibarr_main_url_root' => $langs->trans("URLRoot"),
 		'?dolibarr_main_url_root_alt' => $langs->trans("URLRoot").' (alt)',
 		'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"),
@@ -346,9 +346,9 @@ print '<td>'.$langs->trans("Parameter").'</td>';
 print '<td>'.$langs->trans("Value").'</td>';
 print '</tr>'."\n";
 
-foreach($configfileparameters as $key => $value)
+foreach ($configfileparameters as $key => $value)
 {
-	$ignore=0;
+	$ignore = 0;
 
 	if (empty($ignore))
 	{
@@ -357,7 +357,7 @@ foreach($configfileparameters as $key => $value)
 		if (preg_match('/^\?/', $key) && empty(${$newkey}))
 		{
 		    if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled))
-                continue;    // We discard parameters starting with ?
+                continue; // We discard parameters starting with ?
 		}
 		if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue;
 
@@ -378,13 +378,13 @@ foreach($configfileparameters as $key => $value)
 			elseif ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/', ${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT');
 			elseif ($newkey == 'dolibarr_main_document_root_alt')
 			{
-				$tmparray=explode(',', ${$newkey});
-				$i=0;
-				foreach($tmparray as $value2)
+				$tmparray = explode(',', ${$newkey});
+				$i = 0;
+				foreach ($tmparray as $value2)
 				{
 					if ($i > 0) print ', ';
 					print $value2;
-					if (! is_readable($value2))
+					if (!is_readable($value2))
 					{
 						$langs->load("errors");
 						print ' '.img_warning($langs->trans("ErrorCantReadDir", $value2));
@@ -410,7 +410,7 @@ foreach($configfileparameters as $key => $value)
 			print "</td>";
 		}
 		print "</tr>\n";
-		$lastkeyshown=$newkey;
+		$lastkeyshown = $newkey;
 	}
 }
 print '</table>';
@@ -425,28 +425,28 @@ print '<table class="noborder">';
 print '<tr class="liste_titre">';
 print '<td class="titlefield">'.$langs->trans("Parameters").' '.$langs->trans("Database").'</td>';
 print '<td>'.$langs->trans("Value").'</td>';
-if (empty($conf->multicompany->enabled) || !$user->entity) print '<td class="center width="80px"">'.$langs->trans("Entity").'</td>';	// If superadmin or multicompany disabled
+if (empty($conf->multicompany->enabled) || !$user->entity) print '<td class="center width="80px"">'.$langs->trans("Entity").'</td>'; // If superadmin or multicompany disabled
 print "</tr>\n";
 
 $sql = "SELECT";
-$sql.= " rowid";
-$sql.= ", ".$db->decrypt('name')." as name";
-$sql.= ", ".$db->decrypt('value')." as value";
-$sql.= ", type";
-$sql.= ", note";
-$sql.= ", entity";
-$sql.= " FROM ".MAIN_DB_PREFIX."const";
+$sql .= " rowid";
+$sql .= ", ".$db->decrypt('name')." as name";
+$sql .= ", ".$db->decrypt('value')." as value";
+$sql .= ", type";
+$sql .= ", note";
+$sql .= ", entity";
+$sql .= " FROM ".MAIN_DB_PREFIX."const";
 if (empty($conf->multicompany->enabled))
 {
 	// If no multicompany mode, admins can see global and their constantes
-	$sql.= " WHERE entity IN (0,".$conf->entity.")";
+	$sql .= " WHERE entity IN (0,".$conf->entity.")";
 }
 else
 {
 	// If multicompany mode, superadmin (user->entity=0) can see everything, admin are limited to their entities.
-	if ($user->entity) $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
+	if ($user->entity) $sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
 }
-$sql.= " ORDER BY entity, name ASC";
+$sql .= " ORDER BY entity, name ASC";
 $resql = $db->query($sql);
 if ($resql)
 {
@@ -460,7 +460,7 @@ if ($resql)
 		print '<tr class="oddeven">';
 		print '<td class="tdoverflowmax300">'.$obj->name.'</td>'."\n";
 		print '<td class="tdoverflowmax300">'.dol_escape_htmltag($obj->value).'</td>'."\n";
-		if (empty($conf->multicompany->enabled) || !$user->entity) print '<td class="center" width="80px">'.$obj->entity.'</td>'."\n";	// If superadmin or multicompany disabled
+		if (empty($conf->multicompany->enabled) || !$user->entity) print '<td class="center" width="80px">'.$obj->entity.'</td>'."\n"; // If superadmin or multicompany disabled
 		print "</tr>\n";
 
 		$i++;

+ 11 - 11
htdocs/admin/system/index.php

@@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 // Load translation files required by the page
 $langs->loadLangs(array("admin", "user", "install"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 
 /*
@@ -49,7 +49,7 @@ print load_fiche_titre($langs->trans("SummarySystem"), '', 'title_setup');
 
 print '<table class="noborder centpercent">';
 print "<tr class=\"liste_titre\"><td colspan=\"2\">Dolibarr</td></tr>\n";
-$dolversion=version_dolibarr();
+$dolversion = version_dolibarr();
 print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>".$dolversion."</td></tr>\n";
 print '</table>';
 
@@ -57,7 +57,7 @@ print "<br>\n";
 
 print '<table class="noborder centpercent">';
 print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("OS")."</td></tr>\n";
-$osversion=version_os();
+$osversion = version_os();
 print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>".$osversion."</td></tr>\n";
 print '</table>';
 
@@ -66,7 +66,7 @@ print "<br>\n";
 // Serveur web
 print '<table class="noborder centpercent">';
 print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("WebServer")."</td></tr>\n";
-$apacheversion=version_webserver();
+$apacheversion = version_webserver();
 print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>".$apacheversion."</td></tr>\n";
 print '</table>';
 
@@ -75,7 +75,7 @@ print "<br>\n";
 // Php
 print '<table class="noborder centpercent">';
 print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("PHP")."</td></tr>\n";
-$phpversion=version_php();
+$phpversion = version_php();
 print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>".$phpversion."</td></tr>\n";
 print "<tr $bc[1]><td>".$langs->trans("PhpWebLink")."</td><td>".php_sapi_name()."</td></tr>\n";
 print '</table>';
@@ -85,15 +85,15 @@ print "<br>\n";
 // Database
 print '<table class="noborder centpercent">';
 print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Database")."</td></tr>\n";
-$dblabel=$db::LABEL;
-$dbversion=$db->getVersion();
-print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>" .$dblabel." ".$dbversion."</td></tr>\n";
+$dblabel = $db::LABEL;
+$dbversion = $db->getVersion();
+print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>".$dblabel." ".$dbversion."</td></tr>\n";
 print '</table>';
 // Add checks on database options
 if ($db->type == 'pgsql')
 {
 	// Check option standard_conforming_strings is on
-	$paramarray=$db->getServerParametersValues('standard_conforming_strings');
+	$paramarray = $db->getServerParametersValues('standard_conforming_strings');
     //	if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1)
     //	{
     //		$langs->load("errors");
@@ -104,8 +104,8 @@ print '<br>';
 // Browser
 print '<table class="noborder centpercent">';
 print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Browser")."</td></tr>\n";
-print "<tr $bc[0]><td width=\"280\">".$langs->trans("UserAgent")."</td><td>" .$_SERVER["HTTP_USER_AGENT"]."</td></tr>\n";
-print "<tr $bc[1]><td width=\"280\">".$langs->trans("Smartphone")."</td><td>".(($conf->browser->layout != 'phone')?$langs->trans("No"):$langs->trans("Yes"))."</td></tr>\n";
+print "<tr $bc[0]><td width=\"280\">".$langs->trans("UserAgent")."</td><td>".$_SERVER["HTTP_USER_AGENT"]."</td></tr>\n";
+print "<tr $bc[1]><td width=\"280\">".$langs->trans("Smartphone")."</td><td>".(($conf->browser->layout != 'phone') ? $langs->trans("No") : $langs->trans("Yes"))."</td></tr>\n";
 print '</table>';
 print '<br>';
 

+ 6 - 6
htdocs/admin/system/web.php

@@ -48,20 +48,20 @@ print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter")."</td><td>".$langs->trans("Value")."</td></tr>\n";
 print '<tr class="oddeven"><td>'.$langs->trans("Version")."</td><td>".$_SERVER["SERVER_SOFTWARE"]."</td></tr>\n";
-print '<tr class="oddeven"><td>'.$langs->trans("VirtualServerName")."</td><td>" . $_SERVER["SERVER_NAME"] . "</td></tr>\n";
+print '<tr class="oddeven"><td>'.$langs->trans("VirtualServerName")."</td><td>".$_SERVER["SERVER_NAME"]."</td></tr>\n";
 print '<tr class="oddeven"><td>'.$langs->trans("IP")."</td><td>".$_SERVER["SERVER_ADDR"]."</td></tr>\n";
-print '<tr><td>'.$langs->trans("Port")."</td><td>" . $_SERVER["SERVER_PORT"] . "</td></tr>\n";
+print '<tr><td>'.$langs->trans("Port")."</td><td>".$_SERVER["SERVER_PORT"]."</td></tr>\n";
 print '<tr><td>'.$langs->trans("DocumentRootServer")."</td><td>".$_SERVER["DOCUMENT_ROOT"]."</td></tr>\n";
-print '<tr><td>'.$langs->trans("DataRootServer")."</td><td>" . DOL_DATA_ROOT . "</td></tr>\n";
+print '<tr><td>'.$langs->trans("DataRootServer")."</td><td>".DOL_DATA_ROOT."</td></tr>\n";
 // Web user group by default
-$labeluser=dol_getwebuser('user');
-$labelgroup=dol_getwebuser('group');
+$labeluser = dol_getwebuser('user');
+$labelgroup = dol_getwebuser('group');
 if ($labeluser && $labelgroup)
 {
 	print '<tr><td>'.$langs->trans("WebUserGroup")." (env vars)</td><td>".$labeluser.'/'.$labelgroup."</td></tr>\n";
 }
 // Web user group real (detected by 'id' external command)
-$arrayout=array(); $varout=0;
+$arrayout = array(); $varout = 0;
 exec('id', $arrayout, $varout);
 if (empty($varout))	// Test command is ok. Work only on Linux OS.
 {

+ 37 - 37
htdocs/admin/ticket.php

@@ -74,7 +74,7 @@ if ($action == 'updateMask') {
 
     dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity);
 } elseif ($action == 'setvar') {
-    include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
+    include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
 
     $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
     if (!empty($notification_email)) {
@@ -177,7 +177,7 @@ $page_name = "TicketSetup";
 llxHeader('', $langs->trans($page_name), $help_url);
 
 // Subheader
-$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 
 print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
 
@@ -186,7 +186,7 @@ $head = ticketAdminPrepareHead();
 
 dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket");
 
-print '<span class="opacitymedium">'.$langs->trans("TicketSetupDictionaries") . '</span> : <a href="'.DOL_URL_ROOT.'/admin/dict.php">'.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'</a><br>';
+print '<span class="opacitymedium">'.$langs->trans("TicketSetupDictionaries").'</span> : <a href="'.DOL_URL_ROOT.'/admin/dict.php">'.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'</a><br>';
 
 dol_fiche_end();
 
@@ -199,17 +199,17 @@ print load_fiche_titre($langs->trans("TicketNumberingModules"));
 
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td width="100">' . $langs->trans("Name") . '</td>';
-print '<td>' . $langs->trans("Description") . '</td>';
-print '<td>' . $langs->trans("Example") . '</td>';
-print '<td align="center" width="60">' . $langs->trans("Activated") . '</td>';
-print '<td align="center" width="80">' . $langs->trans("ShortInfo") . '</td>';
+print '<td width="100">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
+print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
 print "</tr>\n";
 
 clearstatcache();
 
 foreach ($dirmodels as $reldir) {
-    $dir = dol_buildpath($reldir . "core/modules/ticket/");
+    $dir = dol_buildpath($reldir."core/modules/ticket/");
 
     if (is_dir($dir)) {
         $handle = opendir($dir);
@@ -219,7 +219,7 @@ foreach ($dirmodels as $reldir) {
                     $file = $reg[1];
                     $classname = substr($file, 4);
 
-                    include_once $dir . $file . '.php';
+                    include_once $dir.$file.'.php';
 
                     $module = new $file;
 
@@ -233,7 +233,7 @@ foreach ($dirmodels as $reldir) {
                     }
 
                     if ($module->isEnabled()) {
-                        print '<tr class="oddeven"><td>' . $module->name . "</td><td>\n";
+                        print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
                         print $module->info();
                         print '</td>';
 
@@ -241,20 +241,20 @@ foreach ($dirmodels as $reldir) {
                         print '<td class="nowrap">';
                         $tmp = $module->getExample();
                         if (preg_match('/^Error/', $tmp)) {
-                            print '<div class="error">' . $langs->trans($tmp) . '</div>';
+                            print '<div class="error">'.$langs->trans($tmp).'</div>';
                         } elseif ($tmp == 'NotConfigured') {
                             print $langs->trans($tmp);
                         } else {
                             print $tmp;
                         }
 
-                        print '</td>' . "\n";
+                        print '</td>'."\n";
 
                         print '<td align="center">';
-                        if ($conf->global->TICKET_ADDON == 'mod_' . $classname) {
+                        if ($conf->global->TICKET_ADDON == 'mod_'.$classname) {
                             print img_picto($langs->trans("Activated"), 'switch_on');
                         } else {
-                            print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=mod_' . $classname . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
+                            print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
                         }
                         print '</td>';
 
@@ -263,14 +263,14 @@ foreach ($dirmodels as $reldir) {
 
                         // Info
                         $htmltooltip = '';
-                        $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';
+                        $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
                         $nextval = $module->getNextValue($mysoc, $ticket);
                         if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
-                            $htmltooltip .= '' . $langs->trans("NextValue") . ': ';
+                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
                             if ($nextval) {
-                                $htmltooltip .= $nextval . '<br>';
+                                $htmltooltip .= $nextval.'<br>';
                             } else {
-                                $htmltooltip .= $langs->trans($module->error) . '<br>';
+                                $htmltooltip .= $langs->trans($module->error).'<br>';
                             }
                         }
 
@@ -290,8 +290,8 @@ foreach ($dirmodels as $reldir) {
 print '</table><br>';
 
 if (!$conf->use_javascript_ajax) {
-    print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" >';
-    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+    print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     print '<input type="hidden" name="action" value="setvarother">';
 }
 
@@ -299,7 +299,7 @@ print load_fiche_titre($langs->trans("TicketParams"));
 print '<table class="noborder centpercent">';
 
 print '<tr class="liste_titre">';
-print '<td>' . $langs->trans("Parameter") . '</td>';
+print '<td>'.$langs->trans("Parameter").'</td>';
 print '<td></td>';
 print '<td></td>';
 print "</tr>\n";
@@ -339,7 +339,7 @@ print '</tr>';
 // Also send to main email address
 if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
 {
-	print '<tr class="oddeven"><td>' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '</td>';
+	print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
 	print '<td class="left">';
 	if ($conf->use_javascript_ajax) {
 	    print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
@@ -377,7 +377,7 @@ print '</tr>';
 }*/
 
 // Auto assign ticket at user who created it
-print '<tr class="oddeven"><td>' . $langs->trans("TicketsAutoAssignTicket") . '</td>';
+print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoAssignTicket").'</td>';
 print '<td class="left">';
 if ($conf->use_javascript_ajax) {
     print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
@@ -402,17 +402,17 @@ print load_fiche_titre($langs->trans("Notification"));
 
 print '<table class="noborder centpercent">';
 
-print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" >';
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="setvar">';
 
 print '<tr class="liste_titre">';
-print '<td colspan="3">' . $langs->trans("Email") . '</td>';
+print '<td colspan="3">'.$langs->trans("Email").'</td>';
 print "</tr>\n";
 
 if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
     print '<tr>';
-    print '<td colspan="3"><div class="info">' . $langs->trans("TicketCkEditorEmailNotActivated") . '</div></td>';
+    print '<td colspan="3"><div class="info">'.$langs->trans("TicketCkEditorEmailNotActivated").'</div></td>';
     print "</tr>\n";
 }
 
@@ -435,18 +435,18 @@ print '</tr>';
 // @TODO Use module notification instead...
 
 // Email de réception des notifications
-print '<tr class="oddeven"><td>' . $langs->trans("TicketEmailNotificationTo") . '</td>';
+print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").'</td>';
 print '<td class="left">';
-print '<input type="text"   name="TICKET_NOTIFICATION_EMAIL_TO" value="' . (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : $conf->global->TICKET_NOTIFICATION_EMAIL_FROM) . '" size="20" ></td>';
+print '<input type="text"   name="TICKET_NOTIFICATION_EMAIL_TO" value="'.(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : $conf->global->TICKET_NOTIFICATION_EMAIL_FROM).'" size="20" ></td>';
 print '<td align="center">';
 print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
 print '</td>';
 print '</tr>';
 
 // Email d'envoi des notifications
-print '<tr class="oddeven"><td>' . $langs->trans("TicketEmailNotificationFrom") . '</td>';
+print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationFrom").'</td>';
 print '<td class="left">';
-print '<input type="text" name="TICKET_NOTIFICATION_EMAIL_FROM" value="' . $conf->global->TICKET_NOTIFICATION_EMAIL_FROM . '" size="20" ></td>';
+print '<input type="text" name="TICKET_NOTIFICATION_EMAIL_FROM" value="'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'" size="20" ></td>';
 print '<td align="center">';
 print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help');
 print '</td>';
@@ -454,9 +454,9 @@ print '</tr>';
 
 // Texte d'introduction
 $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
-print '<tr class="oddeven"><td>' . $langs->trans("TicketMessageMailIntroLabelAdmin") . '</label>';
+print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntroLabelAdmin").'</label>';
 print '</td><td>';
-require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
 $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
 $doleditor->Create();
 print '</td>';
@@ -466,9 +466,9 @@ print '</td></tr>';
 
 // Texte de signature
 $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText');
-print '<tr class="oddeven"><td>' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . '</label>';
+print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailSignatureLabelAdmin").'</label>';
 print '</td><td>';
-require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
 $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
 $doleditor->Create();
 print '</td>';
@@ -479,7 +479,7 @@ print '</td></tr>';
 print '</table>';
 
 print '<div class="center">';
-print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
+print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
 print '</div>';
 
 print '</form>';

+ 34 - 34
htdocs/admin/ticket_public.php

@@ -55,7 +55,7 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE')
 }
 
 if ($action == 'setvar') {
-    include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
+    include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
 
     $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml');
     if (!empty($topic_interface)) {
@@ -158,7 +158,7 @@ $page_name = "TicketSetup";
 llxHeader('', $langs->trans($page_name), $help_url);
 
 // Subheader
-$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 
 print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
 
@@ -167,7 +167,7 @@ $head = ticketAdminPrepareHead();
 
 dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket");
 
-print '<span class="opacitymedium">'.$langs->trans("TicketPublicAccess") . '</span> : <a href="' . dol_buildpath('/public/ticket/index.php', 1) . '" target="_blank" >' . dol_buildpath('/public/ticket/index.php', 2) . '</a>';
+print '<span class="opacitymedium">'.$langs->trans("TicketPublicAccess").'</span> : <a href="'.dol_buildpath('/public/ticket/index.php', 1).'" target="_blank" >'.dol_buildpath('/public/ticket/index.php', 2).'</a>';
 
 dol_fiche_end();
 
@@ -176,32 +176,32 @@ $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' ';
 if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 {
     // Button off, click to enable
-    $enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setTICKET_ENABLE_PUBLIC_INTERFACE&value=1'.$param.'">';
-    $enabledisablehtml.=img_picto($langs->trans("Disabled"), 'switch_off');
-    $enabledisablehtml.='</a>';
+    $enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setTICKET_ENABLE_PUBLIC_INTERFACE&value=1'.$param.'">';
+    $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
+    $enabledisablehtml .= '</a>';
 }
 else
 {
     // Button on, click to disable
-    $enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setTICKET_ENABLE_PUBLIC_INTERFACE&value=0'.$param.'">';
-    $enabledisablehtml.=img_picto($langs->trans("Activated"), 'switch_on');
-    $enabledisablehtml.='</a>';
+    $enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setTICKET_ENABLE_PUBLIC_INTERFACE&value=0'.$param.'">';
+    $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
+    $enabledisablehtml .= '</a>';
 }
 print $enabledisablehtml;
-print '<input type="hidden" id="TICKET_ENABLE_PUBLIC_INTERFACE" name="TICKET_ENABLE_PUBLIC_INTERFACE" value="'.(empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)?0:1).'">';
+print '<input type="hidden" id="TICKET_ENABLE_PUBLIC_INTERFACE" name="TICKET_ENABLE_PUBLIC_INTERFACE" value="'.(empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? 0 : 1).'">';
 
 print '<br><br>';
 
-if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
+if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 {
     if (empty($conf->use_javascript_ajax)) {
-        print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" >';
-        print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+        print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
+        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
         print '<input type="hidden" name="action" value="setvarother">';
     }
 
     print '<table class="noborder centpercent">';
-    print '<tr class="liste_titre"><td>' . $langs->trans("Parameters") . '</td>';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameters").'</td>';
     print '<td class="left">';
     print '</td>';
     print '<td class="center">';
@@ -209,7 +209,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
     print '</tr>';
 
     // Check if email exists
-    print '<tr class="oddeven"><td>' . $langs->trans("TicketsEmailMustExist") . '</td>';
+    print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailMustExist").'</td>';
     print '<td class="left">';
     if ($conf->use_javascript_ajax) {
         print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS');
@@ -242,7 +242,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
     }*/
 
     // Show logo for company
-    print '<tr class="oddeven"><td>' . $langs->trans("TicketsShowCompanyLogo") . '</td>';
+    print '<tr class="oddeven"><td>'.$langs->trans("TicketsShowCompanyLogo").'</td>';
     print '<td class="left">';
     if ($conf->use_javascript_ajax) {
     	print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO');
@@ -259,7 +259,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
     // Also send to main email address
     if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
     {
-    	print '<tr class="oddeven"><td>' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '</td>';
+    	print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
     	print '<td class="left">';
     	if ($conf->use_javascript_ajax) {
     	    print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
@@ -275,7 +275,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
     }
 
     if (!$conf->use_javascript_ajax) {
-        print '<tr class="impair"><td colspan="3" align="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '"></td>';
+        print '<tr class="impair"><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
         print '</tr>';
     }
 
@@ -290,25 +290,25 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 
     print '<table class="noborder centpercent">';
 
-    print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" >';
-    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+    print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     print '<input type="hidden" name="action" value="setvar">';
 
     print '<tr class="liste_titre">';
-    print '<td colspan="3">' . $langs->trans("Parameter") . '</td>';
+    print '<td colspan="3">'.$langs->trans("Parameter").'</td>';
     print "</tr>\n";
 
     if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
         print '<tr>';
-        print '<td colspan="3"><div class="info">' . $langs->trans("TicketCkEditorEmailNotActivated") . '</div></td>';
+        print '<td colspan="3"><div class="info">'.$langs->trans("TicketCkEditorEmailNotActivated").'</div></td>';
         print "</tr>\n";
     }
 
     // Interface topic
     $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC;
-    print '<tr><td>' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . '</label>';
+    print '<tr><td>'.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").'</label>';
     print '</td><td>';
-    print '<input type="text"   name="TICKET_PUBLIC_INTERFACE_TOPIC" value="' . $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC . '" size="40" ></td>';
+    print '<input type="text"   name="TICKET_PUBLIC_INTERFACE_TOPIC" value="'.$conf->global->TICKET_PUBLIC_INTERFACE_TOPIC.'" size="40" ></td>';
     print '</td>';
     print '<td align="center">';
     print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help');
@@ -316,9 +316,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 
     // Texte d'accueil homepage
     $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome');
-    print '<tr><td>' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . '</label>';
+    print '<tr><td>'.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").'</label>';
     print '</td><td>';
-    require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
     $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
     $doleditor->Create();
     print '</td>';
@@ -328,9 +328,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 
     // Texte d'aide à la saisie du message
     $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe');
-    print '<tr><td>' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . '</label>';
+    print '<tr><td>'.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").'</label>';
     print '</td><td>';
-    require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
     $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
     $doleditor->Create();
     print '</td>';
@@ -339,7 +339,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
     print '</td></tr>';
 
     // Activate email creation to user
-    print '<tr class="pair"><td>' . $langs->trans("TicketsDisableCustomerEmail") . '</td>';
+    print '<tr class="pair"><td>'.$langs->trans("TicketsDisableCustomerEmail").'</td>';
     print '<td class="left">';
     if ($conf->use_javascript_ajax) {
         print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS');
@@ -355,9 +355,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 
     // Texte de création d'un ticket
     $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody');
-    print '<tr><td>' . $langs->trans("TicketNewEmailBodyLabel") . '</label>';
+    print '<tr><td>'.$langs->trans("TicketNewEmailBodyLabel").'</label>';
     print '</td><td>';
-    require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
     $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
     $doleditor->Create();
     print '</td>';
@@ -367,9 +367,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 
     // Url public interface
     $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE;
-    print '<tr><td>' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . '</label>';
+    print '<tr><td>'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").'</label>';
     print '</td><td>';
-    print '<input type="text" name="TICKET_URL_PUBLIC_INTERFACE" value="' . $conf->global->TICKET_URL_PUBLIC_INTERFACE . '" size="40" ></td>';
+    print '<input type="text" name="TICKET_URL_PUBLIC_INTERFACE" value="'.$conf->global->TICKET_URL_PUBLIC_INTERFACE.'" size="40" ></td>';
     print '</td>';
     print '<td align="center">';
     print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
@@ -377,7 +377,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
 
     print '</table>';
 
-    print '<div class="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '"></div>';
+    print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
 
     print '</form>';
 }

+ 13 - 13
htdocs/admin/website_options.php

@@ -34,18 +34,18 @@ require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array('errors', 'admin', 'companies', 'website'));
 
-$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view';
-$confirm=GETPOST('confirm', 'alpha');
+$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view';
+$confirm = GETPOST('confirm', 'alpha');
 $backtopage = GETPOST('backtopage', 'alpha');
 
-$rowid=GETPOST('rowid', 'alpha');
+$rowid = GETPOST('rowid', 'alpha');
 
 if (!$user->admin) accessforbidden();
 
 $status = 1;
 
 // Load variable for pagination
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST('sortfield', 'alpha');
 $sortorder = GETPOST('sortorder', 'alpha');
 $page = GETPOST('page', 'int');
@@ -57,7 +57,7 @@ $pagenext = $page + 1;
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
 $hookmanager->initHooks(array('admin'));
 
-$arrayofparameters=array('WEBSITE_USE_WEBSITE_ACCOUNTS'=>array('css'=>'minwidth200'));
+$arrayofparameters = array('WEBSITE_USE_WEBSITE_ACCOUNTS'=>array('css'=>'minwidth200'));
 
 
 /*
@@ -72,16 +72,16 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  */
 
 $form = new Form($db);
-$formadmin=new FormAdmin($db);
+$formadmin = new FormAdmin($db);
 
 llxHeader('', $langs->trans("WebsiteSetup"));
 
-$titre=$langs->trans("WebsiteSetup");
-$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
+$titre = $langs->trans("WebsiteSetup");
+$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($titre, $linkback, 'title_setup');
 
 // Onglets
-$head=array();
+$head = array();
 $h = 0;
 
 $head[$h][0] = DOL_URL_ROOT."/admin/website.php";
@@ -106,11 +106,11 @@ if ($action == 'edit')
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		print '<tr class="oddeven"><td>';
 		print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
-		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
+		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>';
 	}
 
 	print '</table>';
@@ -127,11 +127,11 @@ else
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		print '<tr class="oddeven"><td>';
 		print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
-		print '</td><td>' . $conf->global->$key . '</td></tr>';
+		print '</td><td>'.$conf->global->$key.'</td></tr>';
 	}
 
 	print '</table>';

+ 23 - 23
htdocs/admin/workflow.php

@@ -28,9 +28,9 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals","receptions"));
+$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposals", "receptions"));
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 
@@ -41,7 +41,7 @@ $action = GETPOST('action', 'alpha');
 
 if (preg_match('/set(.*)/', $action, $reg))
 {
-    if (! dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0)
+    if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0)
     {
         dol_print_error($db);
     }
@@ -49,7 +49,7 @@ if (preg_match('/set(.*)/', $action, $reg))
 
 if (preg_match('/del(.*)/', $action, $reg))
 {
-    if (! dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0)
+    if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0)
     {
         dol_print_error($db);
     }
@@ -62,7 +62,7 @@ if (preg_match('/del(.*)/', $action, $reg))
 
 llxHeader('', $langs->trans("WorkflowSetup"), '');
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("WorkflowSetup"), $linkback, 'title_setup');
 
 print '<span class="opacitymedium">'.$langs->trans("WorkflowDesc").'</span><br>';
@@ -72,29 +72,29 @@ print "<br>";
 
 clearstatcache();
 
-$workflowcodes=array(
+$workflowcodes = array(
     // Automatic creation
     'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
 	'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
     'separator1'=>array('family'=>'separator', 'position'=>25),
 	// Automatic classification of proposal
-	'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal','warning'=>''),
-	'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal','warning'=>''),
+	'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal', 'warning'=>''),
+	'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal', 'warning'=>''),
 	// Automatic classification of order
 	'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
-	'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''),	// For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card.
+	'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order', 'warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card.
     'separator2'=>array('family'=>'separator', 'position'=>50),
 	// Automatic classification supplier proposal
-	'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal','warning'=>''),
+	'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal', 'warning'=>''),
 	// Automatic classification supplier order
-	'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order','warning'=>''),
+	'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order', 'warning'=>''),
 	//Automatic classification reception
 	'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>64, 'enabled'=>'! empty($conf->reception->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'bill'),
 );
 
-if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
+if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
 {
-	foreach($conf->modules_parts['workflow'] as $workflow)
+	foreach ($conf->modules_parts['workflow'] as $workflow)
 	{
 		$workflowcodes = array_merge($workflowcodes, $workflow);
 	}
@@ -103,16 +103,16 @@ if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['
 // Sort on position
 $workflowcodes = dol_sort_array($workflowcodes, 'position');
 
-$nbqualified=0;
-$oldfamily='';
+$nbqualified = 0;
+$oldfamily = '';
 
 print '<table class="noborder centpercent">'."\n";
 
-foreach($workflowcodes as $key => $params)
+foreach ($workflowcodes as $key => $params)
 {
-	$picto=$params['picto'];
-	$enabled=$params['enabled'];
-	$family=$params['family'];
+	$picto = $params['picto'];
+	$enabled = $params['enabled'];
+	$family = $params['family'];
 
 	if ($family == 'separator')
 	{
@@ -122,7 +122,7 @@ foreach($workflowcodes as $key => $params)
 		continue;
 	}
 
-	if (! verifCond($enabled)) continue;
+	if (!verifCond($enabled)) continue;
 
    	$nbqualified++;
 
@@ -156,20 +156,20 @@ foreach($workflowcodes as $key => $params)
 
    	print "<tr class=\"oddeven\">\n";
    	print "<td>".img_object('', $picto).$langs->trans('desc'.$key);
-   	if (! empty($params['warning']))
+   	if (!empty($params['warning']))
    	{
    		$langs->load("errors");
    		print ' '.img_warning($langs->transnoentitiesnoconv($params['warning']));
    	}
    	print "</td>\n";
    	print '<td align="center">';
-   	if (! empty($conf->use_javascript_ajax))
+   	if (!empty($conf->use_javascript_ajax))
    	{
    		print ajax_constantonoff($key);
    	}
    	else
    	{
-   		if (! empty($conf->global->$key))
+   		if (!empty($conf->global->$key))
    		{
    			print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=del'.$key.'">';
   			print img_picto($langs->trans("Activated"), 'switch_on');

+ 8 - 8
htdocs/asset/admin/setup.php

@@ -24,7 +24,7 @@
 
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
 
 global $langs, $user;
 
@@ -32,13 +32,13 @@ global $langs, $user;
 $langs->loadLangs(array("admin", "assets"));
 
 // Access control
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 // Parameters
 $action = GETPOST('action', 'alpha');
 $backtopage = GETPOST('backtopage', 'alpha');
 
-$arrayofparameters=array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500'));
+$arrayofparameters = array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500'));
 
 
 /*
@@ -54,7 +54,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 llxHeader('', $langs->trans("AssetsSetup"));
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup');
 
 
@@ -72,11 +72,11 @@ if ($action == 'edit')
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		print '<tr class="oddeven"><td>';
 		print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
-		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
+		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>';
 	}
 
 	print '</table>';
@@ -93,11 +93,11 @@ else
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		print '<tr class="oddeven"><td>';
 		print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
-		print '</td><td>' . $conf->global->$key . '</td></tr>';
+		print '</td><td>'.$conf->global->$key.'</td></tr>';
 	}
 
 	print '</table>';

+ 69 - 69
htdocs/asset/type.php

@@ -26,9 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
 require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
 
 // Load translation files required by the page
 $langs->load("assets");
@@ -40,25 +40,25 @@ $backtopage = GETPOST('backtopage', 'alpha');
 
 $type = GETPOST('type', 'alpha');
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');
 if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
-$offset = $limit * $page ;
+$offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortorder) {  $sortorder="DESC"; }
-if (! $sortfield) {  $sortfield="a.label"; }
+if (!$sortorder) {  $sortorder = "DESC"; }
+if (!$sortfield) {  $sortfield = "a.label"; }
 
-$label=GETPOST("label", "alpha");
-$accountancy_code_asset=GETPOST('accountancy_code_asset', 'string');
-$accountancy_code_depreciation_asset=GETPOST('accountancy_code_depreciation_asset', 'string');
-$accountancy_code_depreciation_expense=GETPOST('accountancy_code_depreciation_expense', 'string');
-$comment=GETPOST('comment', 'string');
+$label = GETPOST("label", "alpha");
+$accountancy_code_asset = GETPOST('accountancy_code_asset', 'string');
+$accountancy_code_depreciation_asset = GETPOST('accountancy_code_depreciation_asset', 'string');
+$accountancy_code_depreciation_expense = GETPOST('accountancy_code_depreciation_expense', 'string');
+$comment = GETPOST('comment', 'string');
 
 // Security check
-$result=restrictedArea($user, 'asset', $rowid, 'asset_type');
+$result = restrictedArea($user, 'asset', $rowid, 'asset_type');
 
 $object = new AssetType($db);
 
@@ -69,13 +69,13 @@ $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
 {
-	$type="";
-	$sall="";
+	$type = "";
+	$sall = "";
 }
 
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('assettypecard','globalcard'));
+$hookmanager->initHooks(array('assettypecard', 'globalcard'));
 
 
 /*
@@ -83,9 +83,9 @@ $hookmanager->initHooks(array('assettypecard','globalcard'));
  */
 
 if ($cancel) {
-	$action='';
+	$action = '';
 
-	if (! empty($backtopage))
+	if (!empty($backtopage))
 	{
 		header("Location: ".$backtopage);
 		exit;
@@ -94,11 +94,11 @@ if ($cancel) {
 
 if ($action == 'add' && $user->rights->asset->write)
 {
-	$object->label									= trim($label);
-	$object->accountancy_code_asset					= trim($accountancy_code_asset);
-	$object->accountancy_code_depreciation_asset	= trim($accountancy_code_depreciation_asset);
-	$object->accountancy_code_depreciation_expense	= trim($accountancy_code_depreciation_expense);
-	$object->note									= trim($comment);
+	$object->label = trim($label);
+	$object->accountancy_code_asset = trim($accountancy_code_asset);
+	$object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset);
+	$object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense);
+	$object->note = trim($comment);
 
 	// Fill array 'array_options' with data from add form
 	$ret = $extrafields->setOptionalsFromPost(null, $object);
@@ -121,9 +121,9 @@ if ($action == 'add' && $user->rights->asset->write)
 		}
 	}
 
-	if (! $error)
+	if (!$error)
 	{
-		$id=$object->create($user);
+		$id = $object->create($user);
 		if ($id > 0)
 		{
 			header("Location: ".$_SERVER["PHP_SELF"]);
@@ -147,19 +147,19 @@ if ($action == 'update' && $user->rights->asset->write)
 
 	$object->oldcopy = clone $object;
 
-	$object->label									= trim($label);
-	$object->accountancy_code_asset					= trim($accountancy_code_asset);
-	$object->accountancy_code_depreciation_asset	= trim($accountancy_code_depreciation_asset);
-	$object->accountancy_code_depreciation_expense	= trim($accountancy_code_depreciation_expense);
-	$object->note									= trim($comment);
+	$object->label = trim($label);
+	$object->accountancy_code_asset = trim($accountancy_code_asset);
+	$object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset);
+	$object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense);
+	$object->note = trim($comment);
 
 	// Fill array 'array_options' with data from add form
 	$ret = $extrafields->setOptionalsFromPost(null, $object);
 	if ($ret < 0) $error++;
 
-	$ret=$object->update($user);
+	$ret = $object->update($user);
 
-	if ($ret >= 0 && ! count($object->errors))
+	if ($ret >= 0 && !count($object->errors))
 	{
 		setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs');
 	}
@@ -175,7 +175,7 @@ if ($action == 'update' && $user->rights->asset->write)
 if ($action == 'confirm_delete' && $user->rights->asset->write)
 {
 	$object->fetch($rowid);
-	$res=$object->delete();
+	$res = $object->delete();
 
 	if ($res > 0)
 	{
@@ -186,7 +186,7 @@ if ($action == 'confirm_delete' && $user->rights->asset->write)
 	else
 	{
 		setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors');
-		$action='';
+		$action = '';
 	}
 }
 
@@ -195,20 +195,20 @@ if ($action == 'confirm_delete' && $user->rights->asset->write)
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
-$helpurl='';
+$helpurl = '';
 llxHeader('', $langs->trans("AssetsTypeSetup"), $helpurl);
 
 
 // List of asset type
-if (! $rowid && $action != 'create' && $action != 'edit')
+if (!$rowid && $action != 'create' && $action != 'edit')
 {
 	//dol_fiche_head('');
 
 	$sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note";
-	$sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d";
-	$sql.= " WHERE d.entity IN (".getEntity('asset_type').")";
+	$sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d";
+	$sql .= " WHERE d.entity IN (".getEntity('asset_type').")";
 
 	$result = $db->query($sql);
 	if ($result)
@@ -220,12 +220,12 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 
 		$param = '';
 
-        $newcardbutton='';
+        $newcardbutton = '';
         if ($user->rights->asset->configurer)
         {
-            $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/type.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAssetType').'</span>';
-            $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
-            $newcardbutton.= '</a>';
+            $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/type.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAssetType').'</span>';
+            $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
+            $newcardbutton .= '</a>';
         }
 
 		print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@@ -242,7 +242,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 		$moreforfilter = '';
 
 		print '<div class="div-table-responsive">';
-		print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
+		print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 		print '<tr class="liste_titre">';
 		print '<th>'.$langs->trans("Ref").'</th>';
@@ -271,7 +271,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 			print '<td>'.dol_escape_htmltag($objp->label).'</td>';
 
 			print '<td class="center">';
-			if (! empty($conf->accounting->enabled))
+			if (!empty($conf->accounting->enabled))
 			{
 				$accountingaccount = new AccountingAccount($db);
 				$accountingaccount->fetch('', $objp->accountancy_code_asset, 1);
@@ -283,7 +283,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 			print '</td>';
 
 			print '<td class="center">';
-			if (! empty($conf->accounting->enabled))
+			if (!empty($conf->accounting->enabled))
 			{
 				$accountingaccount2 = new AccountingAccount($db);
 				$accountingaccount2->fetch('', $objp->accountancy_code_depreciation_asset, 1);
@@ -295,7 +295,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 			print '</td>';
 
 			print '<td class="center">';
-			if (! empty($conf->accounting->enabled))
+			if (!empty($conf->accounting->enabled))
 			{
 				$accountingaccount3 = new AccountingAccount($db);
 				$accountingaccount3->fetch('', $objp->accountancy_code_depreciation_expense, 1);
@@ -333,7 +333,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
 if ($action == 'create')
 {
 	$object = new AssetType($db);
-	if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
+	if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
 
 	print load_fiche_titre($langs->trans("NewAssetType"));
 
@@ -348,7 +348,7 @@ if ($action == 'create')
 
 	print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>';
 
-	if (! empty($conf->accounting->enabled))
+	if (!empty($conf->accounting->enabled))
 	{
 		// Accountancy_code_asset
 		print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
@@ -390,8 +390,8 @@ if ($action == 'create')
 	print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
 
 	// Other attributes
-	$parameters=array();
-	$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action);    // Note that $action and $object may have been modified by hook
+	$parameters = array();
+	$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
 	print $hookmanager->resPrint;
 	if (empty($reshook))
 	{
@@ -438,11 +438,11 @@ if ($rowid > 0)
 
 		$linkback = '<a href="'.DOL_URL_ROOT.'/asset/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
-		$morehtmlref='<div class="refidno">';
+		$morehtmlref = '<div class="refidno">';
 		// Ref asset type
-		$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1);
-		$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1);
-		$morehtmlref.='</div>';
+		$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1);
+		$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1);
+		$morehtmlref .= '</div>';
 
 		dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
 
@@ -455,7 +455,7 @@ if ($rowid > 0)
 		print '<td class="nowrap">';
 		print $langs->trans("AccountancyCodeAsset");
 		print '</td><td>';
-		if (! empty($conf->accounting->enabled))
+		if (!empty($conf->accounting->enabled))
 		{
 			$accountingaccount = new AccountingAccount($db);
 			$accountingaccount->fetch('', $object->accountancy_code_asset, 1);
@@ -471,7 +471,7 @@ if ($rowid > 0)
 		print '<td class="nowrap">';
 		print $langs->trans("AccountancyCodeDepreciationAsset");
 		print '</td><td>';
-		if (! empty($conf->accounting->enabled))
+		if (!empty($conf->accounting->enabled))
 		{
 			$accountingaccount2 = new AccountingAccount($db);
 			$accountingaccount2->fetch('', $object->accountancy_code_depreciation_asset, 1);
@@ -487,7 +487,7 @@ if ($rowid > 0)
 		print '<td class="nowrap">';
 		print $langs->trans("AccountancyCodeDepreciationExpense");
 		print '</td><td>';
-		if (! empty($conf->accounting->enabled))
+		if (!empty($conf->accounting->enabled))
 		{
 			$accountingaccount3 = new AccountingAccount($db);
 			$accountingaccount3->fetch('', $object->accountancy_code_depreciation_expense, 1);
@@ -503,7 +503,7 @@ if ($rowid > 0)
 		print nl2br($object->note)."</td></tr>";
 
 		// Other attributes
-		include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
 
 		print '</table>';
 		print '</div>';
@@ -542,7 +542,7 @@ if ($rowid > 0)
 		$object = new AssetType($db);
 		$object->fetch($rowid);
 		$object->fetch_optionals();
-		if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
+		if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
 
 		$head = asset_type_prepare_head($object);
 
@@ -559,7 +559,7 @@ 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>';
 
-		if (! empty($conf->accounting->enabled))
+		if (!empty($conf->accounting->enabled))
 		{
 			// Accountancy_code_asset
 			print '<tr><td class="titlefield">'.$langs->trans("AccountancyCodeAsset").'</td>';
@@ -601,8 +601,8 @@ if ($rowid > 0)
 		print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
 
 		// Other attributes
-		$parameters=array();
-		$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action);    // Note that $action and $object may have been modified by hook
+		$parameters = array();
+		$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
 		print $hookmanager->resPrint;
 		if (empty($reshook))
 		{
@@ -615,17 +615,17 @@ if ($rowid > 0)
 		if (empty($reshook))
 		{
 			print '<br><br><table class="border centpercent">';
-			foreach($extrafields->attributes[$object->element]['label'] as $key=>$label)
+			foreach ($extrafields->attributes[$object->element]['label'] as $key=>$label)
 			{
-				if (isset($_POST["options_" . $key])) {
-					if (is_array($_POST["options_" . $key])) {
+				if (isset($_POST["options_".$key])) {
+					if (is_array($_POST["options_".$key])) {
 						// $_POST["options"] is an array but following code expects a comma separated string
-						$value = implode(",", $_POST["options_" . $key]);
+						$value = implode(",", $_POST["options_".$key]);
 					} else {
-						$value = $_POST["options_" . $key];
+						$value = $_POST["options_".$key];
 					}
 				} else {
-					$value = $adht->array_options["options_" . $key];
+					$value = $adht->array_options["options_".$key];
 				}
 				print '<tr><td width="30%">'.$label.'</td><td>';
 				print $extrafields->showInputField($key, $value);

+ 11 - 11
htdocs/bom/admin/setup.php

@@ -26,7 +26,7 @@
 // Load Dolibarr environment
 require '../../main.inc.php';
 // Libraries
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
 require_once '../lib/bom.lib.php';
 //require_once "../class/myclass.class.php";
 
@@ -34,15 +34,15 @@ require_once '../lib/bom.lib.php';
 $langs->loadLangs(array("admin", "mrp"));
 
 // Access control
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 // Parameters
 $action = GETPOST('action', 'alpha');
 $backtopage = GETPOST('backtopage', 'alpha');
 
-$arrayofparameters=array(
-	'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1),
-	'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1)
+$arrayofparameters = array(
+	'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
+	'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
 );
 
 
@@ -59,7 +59,7 @@ $page_name = "BomSetup";
 llxHeader('', $langs->trans($page_name));
 
 // Subheader
-$linkback = '<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
 
 print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom');
 
@@ -80,11 +80,11 @@ if ($action == 'edit')
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		print '<tr class="oddeven"><td>';
 		print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
-		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
+		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>';
 	}
 	print '</table>';
 
@@ -97,16 +97,16 @@ if ($action == 'edit')
 }
 else
 {
-	if (! empty($arrayofparameters))
+	if (!empty($arrayofparameters))
 	{
 		print '<table class="noborder centpercent">';
 		print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-		foreach($arrayofparameters as $key => $val)
+		foreach ($arrayofparameters as $key => $val)
 		{
 			print '<tr class="oddeven"><td>';
 			print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
-			print '</td><td>' . $conf->global->$key . '</td></tr>';
+			print '</td><td>'.$conf->global->$key.'</td></tr>';
 		}
 
 		print '</table>';

+ 15 - 15
htdocs/cashdesk/admin/cashdesk.php

@@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
 
 // If socid provided by ajax company selector
-if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id']))
+if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id']))
 {
 	$_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
 	$_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
@@ -49,7 +49,7 @@ if (GETPOST('action', 'alpha') == 'set')
 {
 	$db->begin();
 
-	if (GETPOST('socid', 'int') < 0) $_POST["socid"]='';
+	if (GETPOST('socid', 'int') < 0) $_POST["socid"] = '';
 
 	$res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
 	$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
@@ -62,9 +62,9 @@ if (GETPOST('action', 'alpha') == 'set')
 
 	dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
- 	if (! $error)
+ 	if (!$error)
     {
         $db->commit();
 	    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -80,12 +80,12 @@ if (GETPOST('action', 'alpha') == 'set')
  * View
  */
 
-$form=new Form($db);
-$formproduct=new FormProduct($db);
+$form = new Form($db);
+$formproduct = new FormProduct($db);
 
 llxHeader('', $langs->trans("CashDeskSetup"));
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("CashDeskSetup").' (SimplePOS)', $linkback, 'title_setup');
 print '<br>';
 
@@ -95,7 +95,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="set">';
 
-if (! empty($conf->service->enabled))
+if (!empty($conf->service->enabled))
 {
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre">';
@@ -123,7 +123,7 @@ print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdParty
 print '<td colspan="2">';
 print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0);
 print '</td></tr>';
-if (! empty($conf->banque->enabled))
+if (!empty($conf->banque->enabled))
 {
 	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
 	print '<td colspan="2">';
@@ -143,9 +143,9 @@ if (! empty($conf->banque->enabled))
 	print '</td></tr>';
 }
 
-if (! empty($conf->stock->enabled))
+if (!empty($conf->stock->enabled))
 {
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>';	// Force warehouse (this is not a default value)
+	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
 	print '<td colspan="2">';
 	if (empty($conf->productbatch->enabled)) {
 	    print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1);
@@ -160,12 +160,12 @@ if (! empty($conf->stock->enabled))
 	}
 	print '</td></tr>';
 
-	$disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK;
+	$disabled = $conf->global->CASHDESK_NO_DECREASE_STOCK;
 
 
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>';	// Force warehouse (this is not a default value)
+	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
 	print '<td colspan="2">';
-	if (! $disabled)
+	if (!$disabled)
 	{
 		print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled);
 		print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
@@ -178,7 +178,7 @@ if (! empty($conf->stock->enabled))
 }
 
 // Use Dolibarr Receipt Printer
-if (! empty($conf->receiptprinter->enabled))
+if (!empty($conf->receiptprinter->enabled))
 {
     print '<tr class="oddeven"><td>';
     print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';

+ 34 - 34
htdocs/categories/traduction.php

@@ -41,11 +41,11 @@ $action = GETPOST('action', 'alpha');
 $cancel = GETPOST('cancel', 'alpha');
 $type   = GETPOST('type', 'aZ09');
 
-if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type];	// For backward compatibility
+if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
 
 // Security check
-$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
-$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
+$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
+$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
 
 if ($id == "")
 {
@@ -74,7 +74,7 @@ if ($cancel == $langs->trans("Cancel"))
 // Validation de l'ajout
 if ($action == 'vadd' &&
 $cancel != $langs->trans("Cancel") &&
-($user->rights->categorie->creer ))
+($user->rights->categorie->creer))
 {
 	$object->fetch($id);
 	$current_lang = $langs->getDefaultLang();
@@ -92,7 +92,7 @@ $cancel != $langs->trans("Cancel") &&
     if (!$error) {
         if (empty($libelle)) {
             $error++;
-            $object->errors[] = $langs->trans('Language_' . $forcelangprod)  . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
+            $object->errors[] = $langs->trans('Language_'.$forcelangprod).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
         }
 
         if (!$error) {
@@ -129,15 +129,15 @@ $cancel != $langs->trans("Cancel") &&
 
 	foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet
 	{
-        $libelle = GETPOST('libelle-'. $key, 'alpha');
-        $desc = GETPOST('desc-' . $key);
+        $libelle = GETPOST('libelle-'.$key, 'alpha');
+        $desc = GETPOST('desc-'.$key);
 
         if (empty($libelle)) {
             $error++;
-            $object->errors[] = $langs->trans('Language_' . $key) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
+            $object->errors[] = $langs->trans('Language_'.$key).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
         }
 
-		if ( $key == $current_lang ) {
+		if ($key == $current_lang) {
 			$object->label       = $libelle;
 			$object->description = dol_htmlcleanlastbr($desc);
 		} else {
@@ -169,24 +169,24 @@ $result = $object->fetch($id, $ref);
 llxHeader("", "", $langs->trans("Translation"));
 
 $form = new Form($db);
-$formadmin=new FormAdmin($db);
+$formadmin = new FormAdmin($db);
 $formother = new FormOther($db);
 
-if ($type == Categorie::TYPE_PRODUCT)       $title=$langs->trans("ProductsCategoryShort");
-elseif ($type == Categorie::TYPE_SUPPLIER)  $title=$langs->trans("SuppliersCategoryShort");
-elseif ($type == Categorie::TYPE_CUSTOMER)  $title=$langs->trans("CustomersCategoryShort");
-elseif ($type == Categorie::TYPE_MEMBER)    $title=$langs->trans("MembersCategoryShort");
-elseif ($type == Categorie::TYPE_CONTACT)   $title=$langs->trans("ContactCategoriesShort");
-elseif ($type == Categorie::TYPE_ACCOUNT)   $title=$langs->trans("AccountsCategoriesShort");
-elseif ($type == Categorie::TYPE_PROJECT)   $title=$langs->trans("ProjectsCategoriesShort");
-elseif ($type == Categorie::TYPE_USER)      $title=$langs->trans("UsersCategoriesShort");
-else                                        $title=$langs->trans("Category");
+if ($type == Categorie::TYPE_PRODUCT)       $title = $langs->trans("ProductsCategoryShort");
+elseif ($type == Categorie::TYPE_SUPPLIER)  $title = $langs->trans("SuppliersCategoryShort");
+elseif ($type == Categorie::TYPE_CUSTOMER)  $title = $langs->trans("CustomersCategoryShort");
+elseif ($type == Categorie::TYPE_MEMBER)    $title = $langs->trans("MembersCategoryShort");
+elseif ($type == Categorie::TYPE_CONTACT)   $title = $langs->trans("ContactCategoriesShort");
+elseif ($type == Categorie::TYPE_ACCOUNT)   $title = $langs->trans("AccountsCategoriesShort");
+elseif ($type == Categorie::TYPE_PROJECT)   $title = $langs->trans("ProjectsCategoriesShort");
+elseif ($type == Categorie::TYPE_USER)      $title = $langs->trans("UsersCategoriesShort");
+else                                        $title = $langs->trans("Category");
 
 $head = categories_prepare_head($object, $type);
 
 // Calculate $cnt_trans
 $cnt_trans = 0;
-if (! empty($object->multilangs))
+if (!empty($object->multilangs))
 {
     foreach ($object->multilangs as $key => $value)
     {
@@ -199,15 +199,15 @@ dol_fiche_head($head, 'translation', $title, -1, 'category');
 $linkback = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>';
 
 $object->ref = $object->label;
-$morehtmlref='<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
+$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
 $ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
 foreach ($ways as $way)
 {
-    $morehtmlref.=$way."<br>\n";
+    $morehtmlref .= $way."<br>\n";
 }
-$morehtmlref.='</div>';
+$morehtmlref .= '</div>';
 
-dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
+dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
 
 print '<br>';
 
@@ -266,9 +266,9 @@ if ($action == 'edit')
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<input type="hidden" name="action" value="vedit">';
 	print '<input type="hidden" name="id" value="'.$object->id.'">';
-    print '<input type="hidden" name="type" value="' . $type . '">';
+    print '<input type="hidden" name="type" value="'.$type.'">';
 
-	if (! empty($object->multilangs))
+	if (!empty($object->multilangs))
 	{
 		foreach ($object->multilangs as $key => $value)
 		{
@@ -304,23 +304,23 @@ elseif ($action != 'add')
 {
     if ($cnt_trans) print '<div class="underbanner clearboth"></div>';
 
-    if (! empty($object->multilangs))
+    if (!empty($object->multilangs))
 	{
 		foreach ($object->multilangs as $key => $value)
 		{
-		    $s=picto_from_langcode($key);
+		    $s = picto_from_langcode($key);
 			print '<table class="border centpercent">';
-			print '<tr class="liste_titre"><td colspan="2">'.($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>';
+			print '<tr class="liste_titre"><td colspan="2">'.($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>';
 			print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
 			print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
-			if (! empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION))
+			if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION))
 			{
                 print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>';
 			}
 			print '</table>';
 		}
 	}
-	if (! $cnt_trans && $action != 'add') print '<div class="opacitymedium">'. $langs->trans('NoTranslation').'</div>';
+	if (!$cnt_trans && $action != 'add') print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
 }
 
 
@@ -338,14 +338,14 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<input type="hidden" name="action" value="vadd">';
 	print '<input type="hidden" name="id" value="'.$id.'">';
-    print '<input type="hidden" name="type" value="' . $type . '">';
+    print '<input type="hidden" name="type" value="'.$type.'">';
 
 	print '<table class="border centpercent">';
 	print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Translation').'</td><td>';
     print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs);
 	print '</td></tr>';
-	print '<tr><td class="fieldrequired">' . $langs->trans('Label') . '</td>';
-	print '<td><input name="libelle" size="40" value="' . GETPOST('libelle', 'alpha'). '"></td></tr>';
+	print '<tr><td class="fieldrequired">'.$langs->trans('Label').'</td>';
+	print '<td><input name="libelle" size="40" value="'.GETPOST('libelle', 'alpha').'"></td></tr>';
 	print '<tr><td>'.$langs->trans('Description').'</td><td>';
 	$doleditor = new DolEditor('desc', GETPOST('desc', 'none'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
 	$doleditor->Create();

File diff suppressed because it is too large
+ 337 - 337
htdocs/comm/action/index.php


+ 215 - 215
htdocs/comm/index.php

@@ -30,13 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
 require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
-if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
-if (! empty($conf->propal->enabled))  require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
-if (! empty($conf->supplier_proposal->enabled))  require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
-if (! empty($conf->commande->enabled))  require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
+if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+if (!empty($conf->propal->enabled))  require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+if (!empty($conf->supplier_proposal->enabled))  require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
+if (!empty($conf->commande->enabled))  require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
 
-if (! $user->rights->societe->lire) accessforbidden();
+if (!$user->rights->societe->lire) accessforbidden();
 
 $hookmanager = new HookManager($db);
 
@@ -46,19 +46,19 @@ $hookmanager->initHooks(array('commercialindex'));
 // Load translation files required by the page
 $langs->loadLangs(array("commercial", "propal"));
 
-$action=GETPOST('action', 'alpha');
-$bid=GETPOST('bid', 'int');
+$action = GETPOST('action', 'alpha');
+$bid = GETPOST('bid', 'int');
 
 // Securite acces client
-$socid=GETPOST('socid', 'int');
+$socid = GETPOST('socid', 'int');
 if (isset($user->socid) && $user->socid > 0)
 {
 	$action = '';
 	$socid = $user->socid;
 }
 
-$max=3;
-$now=dol_now();
+$max = 3;
+$now = dol_now();
 
 /*
  * Actions
@@ -71,11 +71,11 @@ $now=dol_now();
 
 $form = new Form($db);
 $formfile = new FormFile($db);
-$companystatic=new Societe($db);
-if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db);
-if (! empty($conf->supplier_proposal->enabled)) $supplierproposalstatic=new SupplierProposal($db);
-if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db);
-if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db);
+$companystatic = new Societe($db);
+if (!empty($conf->propal->enabled)) $propalstatic = new Propal($db);
+if (!empty($conf->supplier_proposal->enabled)) $supplierproposalstatic = new SupplierProposal($db);
+if (!empty($conf->commande->enabled)) $orderstatic = new Commande($db);
+if (!empty($conf->fournisseur->enabled)) $supplierorderstatic = new CommandeFournisseur($db);
 
 llxHeader("", $langs->trans("CommercialArea"));
 
@@ -83,37 +83,37 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial');
 
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
 {
     // Search proposal
-    if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
+    if (!empty($conf->propal->enabled) && $user->rights->propal->lire)
     {
-    	$listofsearchfields['search_proposal']=array('text'=>'Proposal');
+    	$listofsearchfields['search_proposal'] = array('text'=>'Proposal');
     }
     // Search customer order
-    if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
+    if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
     {
-    	$listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder');
+    	$listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder');
     }
     // Search supplier proposal
-    if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
+    if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
     {
-        $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort');
+        $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort');
     }
     // Search supplier order
-    if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
+    if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
     {
-    	$listofsearchfields['search_supplier_order']=array('text'=>'SupplierOrder');
+    	$listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder');
     }
     // Search intervention
-    if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
+    if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
     {
-    	$listofsearchfields['search_intervention']=array('text'=>'Intervention');
+    	$listofsearchfields['search_intervention'] = array('text'=>'Intervention');
     }
     // Search contract
-    if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
+    if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
     {
-        $listofsearchfields['search_contract']=array('text'=>'Contract');
+        $listofsearchfields['search_contract'] = array('text'=>'Contract');
     }
 
     if (count($listofsearchfields))
@@ -122,8 +122,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
     	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
         print '<div class="div-table-responsive-no-min">';
     	print '<table class="noborder nohover centpercent">';
-    	$i=0;
-    	foreach($listofsearchfields as $key => $value)
+    	$i = 0;
+    	foreach ($listofsearchfields as $key => $value)
     	{
     		if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
     		print '<tr '.$bc[false].'>';
@@ -143,22 +143,22 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
 /*
  * Draft proposals
  */
-if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
+if (!empty($conf->propal->enabled) && $user->rights->propal->lire)
 {
 	$langs->load("propal");
 
 	$sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
-    $sql.= ", s.code_client";
-	$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE p.fk_statut = 0";
-	$sql.= " AND p.fk_soc = s.rowid";
-	$sql.= " AND p.entity IN (".getEntity('propal').")";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid)	$sql.= " AND s.rowid = ".$socid;
-
-	$resql=$db->query($sql);
+    $sql .= ", s.code_client";
+	$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE p.fk_statut = 0";
+	$sql .= " AND p.fk_soc = s.rowid";
+	$sql .= " AND p.entity IN (".getEntity('propal').")";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid)	$sql .= " AND s.rowid = ".$socid;
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$total = 0;
@@ -172,27 +172,27 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 		if ($num > 0)
 		{
 			$i = 0;
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
 			{
 				$obj = $db->fetch_object($resql);
 
 				print '<tr class="oddeven"><td  class="nowrap">';
-				$propalstatic->id=$obj->rowid;
-				$propalstatic->ref=$obj->ref;
-                $propalstatic->ref_client=$obj->ref_client;
+				$propalstatic->id = $obj->rowid;
+				$propalstatic->ref = $obj->ref;
+                $propalstatic->ref_client = $obj->ref_client;
                 $propalstatic->total_ht = $obj->total_ht;
                 $propalstatic->total_tva = $obj->total_tva;
                 $propalstatic->total_ttc = $obj->total_ttc;
 				print $propalstatic->getNomUrl(1);
 				print '</td>';
 				print '<td class="nowrap">';
-				$companystatic->id=$obj->socid;
-				$companystatic->name=$obj->name;
-				$companystatic->client=$obj->client;
+				$companystatic->id = $obj->socid;
+				$companystatic->name = $obj->name;
+				$companystatic->client = $obj->client;
                 $companystatic->code_client = $obj->code_client;
                 $companystatic->code_fournisseur = $obj->code_fournisseur;
-				$companystatic->canvas=$obj->canvas;
+				$companystatic->canvas = $obj->canvas;
 				print $companystatic->getNomUrl(1, 'customer', 16);
 				print '</td>';
 				print '<td class="nowrap right">'.price($obj->total_ht).'</td></tr>';
@@ -203,7 +203,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
 			{
 				print '<tr class="liste_total"><td colspan="2" class="right">'.$langs->trans("Total").'</td><td class="right">'.price($total)."</td></tr>";
 			}
@@ -227,22 +227,22 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 /*
  * Draft supplier proposals
  */
-if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
+if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
 {
     $langs->load("supplier_proposal");
 
     $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
-    $sql.= ", s.code_client";
-    $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p";
-    $sql.= ", ".MAIN_DB_PREFIX."societe as s";
-    if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-    $sql.= " WHERE p.fk_statut = 0";
-    $sql.= " AND p.fk_soc = s.rowid";
-    $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")";
-    if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-    if ($socid)	$sql.= " AND s.rowid = ".$socid;
-
-    $resql=$db->query($sql);
+    $sql .= ", s.code_client";
+    $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p";
+    $sql .= ", ".MAIN_DB_PREFIX."societe as s";
+    if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+    $sql .= " WHERE p.fk_statut = 0";
+    $sql .= " AND p.fk_soc = s.rowid";
+    $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
+    if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+    if ($socid)	$sql .= " AND s.rowid = ".$socid;
+
+    $resql = $db->query($sql);
     if ($resql)
     {
         $total = 0;
@@ -251,31 +251,31 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos
         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">'.$num.'</span>':'').'</th></tr>';
+        print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
 
         if ($num > 0)
         {
             $i = 0;
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
             {
                 $obj = $db->fetch_object($resql);
 
                 print '<tr class="oddeven"><td  class="nowrap">';
-                $supplierproposalstatic->id=$obj->rowid;
-                $supplierproposalstatic->ref=$obj->ref;
+                $supplierproposalstatic->id = $obj->rowid;
+                $supplierproposalstatic->ref = $obj->ref;
                 $supplierproposalstatic->total_ht = $obj->total_ht;
                 $supplierproposalstatic->total_tva = $obj->total_tva;
                 $supplierproposalstatic->total_ttc = $obj->total_ttc;
                 print $supplierproposalstatic->getNomUrl(1);
                 print '</td>';
                 print '<td class="nowrap">';
-                $companystatic->id=$obj->socid;
-                $companystatic->name=$obj->name;
-                $companystatic->client=$obj->client;
+                $companystatic->id = $obj->socid;
+                $companystatic->name = $obj->name;
+                $companystatic->client = $obj->client;
                 $companystatic->code_client = $obj->code_client;
                 $companystatic->code_fournisseur = $obj->code_fournisseur;
-                $companystatic->canvas=$obj->canvas;
+                $companystatic->canvas = $obj->canvas;
                 print $companystatic->getNomUrl(1, 'supplier', 16);
                 print '</td>';
                 print '<td class="nowrap right">'.price($obj->total_ht).'</td></tr>';
@@ -286,7 +286,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
             {
                 print '<tr class="liste_total"><td class="right">'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
             }
@@ -309,20 +309,20 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos
 /*
  * Draft orders
  */
-if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
+if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
 {
 	$langs->load("orders");
 
 	$sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
-    $sql.= ", s.code_client";
-	$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE c.fk_soc = s.rowid";
-	$sql.= " AND c.fk_statut = 0";
-	$sql.= " AND c.entity IN (".getEntity('commande').")";
-	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 .= ", s.code_client";
+	$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE c.fk_soc = s.rowid";
+	$sql .= " AND c.fk_statut = 0";
+	$sql .= " AND c.entity IN (".getEntity('commande').")";
+	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;
 
 	$resql = $db->query($sql);
 	if ($resql)
@@ -333,34 +333,34 @@ 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">'.$num.'</span>':'').'</th></tr>';
+		print '<th colspan="3">'.$langs->trans("DraftOrders").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
 
 		if ($num > 0)
 		{
 			$i = 0;
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
 			{
 				$obj = $db->fetch_object($resql);
 				print '<tr class="oddeven"><td class="nowrap">';
-                $orderstatic->id=$obj->rowid;
-                $orderstatic->ref=$obj->ref;
-                $orderstatic->ref_client=$obj->ref_client;
+                $orderstatic->id = $obj->rowid;
+                $orderstatic->ref = $obj->ref;
+                $orderstatic->ref_client = $obj->ref_client;
                 $orderstatic->total_ht = $obj->total_ht;
                 $orderstatic->total_tva = $obj->total_tva;
                 $orderstatic->total_ttc = $obj->total_ttc;
                 print $orderstatic->getNomUrl(1);
                 print '</td>';
 				print '<td class="nowrap">';
-				$companystatic->id=$obj->socid;
-				$companystatic->name=$obj->name;
-				$companystatic->client=$obj->client;
+				$companystatic->id = $obj->socid;
+				$companystatic->name = $obj->name;
+				$companystatic->client = $obj->client;
                 $companystatic->code_client = $obj->code_client;
                 $companystatic->code_fournisseur = $obj->code_fournisseur;
-                $companystatic->canvas=$obj->canvas;
+                $companystatic->canvas = $obj->canvas;
 				print $companystatic->getNomUrl(1, 'customer', 16);
 				print '</td>';
-				if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
+				if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
 					print '<td class="nowrap right">'.price($obj->total_ht).'</td></tr>';
 				}
 				else {
@@ -373,7 +373,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
             {
                 print '<tr class="liste_total"><td class="right">'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
 			}
@@ -397,21 +397,21 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 /*
  * Draft suppliers orders
  */
-if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
+if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
 {
     $langs->load("orders");
 
     $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
-    $sql.= ", s.code_client";
-    $sql.= ", s.code_fournisseur";
-    $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
-    $sql.= ", ".MAIN_DB_PREFIX."societe as s";
-    if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-    $sql.= " WHERE cf.fk_soc = s.rowid";
-    $sql.= " AND cf.fk_statut = 0";
-    $sql.= " AND cf.entity IN (".getEntity('supplier_order').")";
-    if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-    if ($socid)	$sql.= " AND cf.fk_soc = ".$socid;
+    $sql .= ", s.code_client";
+    $sql .= ", s.code_fournisseur";
+    $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
+    $sql .= ", ".MAIN_DB_PREFIX."societe as s";
+    if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+    $sql .= " WHERE cf.fk_soc = s.rowid";
+    $sql .= " AND cf.fk_statut = 0";
+    $sql .= " AND cf.entity IN (".getEntity('supplier_order').")";
+    if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+    if ($socid)	$sql .= " AND cf.fk_soc = ".$socid;
 
     $resql = $db->query($sql);
     if ($resql)
@@ -422,34 +422,34 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande
         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">'.$num.'</span>':'').'</th></tr>';
+        print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
 
         if ($num > 0)
         {
             $i = 0;
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
             {
                 $obj = $db->fetch_object($resql);
                 print '<tr class="oddeven"><td class="nowrap">';
-                $supplierorderstatic->id=$obj->rowid;
-                $supplierorderstatic->ref=$obj->ref;
-                $supplierorderstatic->ref_supplier=$obj->ref_suppliert;
+                $supplierorderstatic->id = $obj->rowid;
+                $supplierorderstatic->ref = $obj->ref;
+                $supplierorderstatic->ref_supplier = $obj->ref_suppliert;
                 $supplierorderstatic->total_ht = $obj->total_ht;
                 $supplierorderstatic->total_tva = $obj->total_tva;
                 $supplierorderstatic->total_ttc = $obj->total_ttc;
                 print $supplierorderstatic->getNomUrl(1);
                 print '</td>';
                 print '<td class="nowrap">';
-                $companystatic->id=$obj->socid;
-                $companystatic->name=$obj->name;
-                $companystatic->client=$obj->client;
+                $companystatic->id = $obj->socid;
+                $companystatic->name = $obj->name;
+                $companystatic->client = $obj->client;
                 $companystatic->code_client = $obj->code_client;
                 $companystatic->code_fournisseur = $obj->code_fournisseur;
-                $companystatic->canvas=$obj->canvas;
+                $companystatic->canvas = $obj->canvas;
                 print $companystatic->getNomUrl(1, 'supplier', 16);
                 print '</td>';
-				if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
+				if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
 					print '<td class="nowrap right">'.price($obj->total_ht).'</td></tr>';
 				}
 				else {
@@ -462,7 +462,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
             {
                 print '<tr class="liste_total"><td class="right">'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
             }
@@ -484,24 +484,24 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
 
-$max=3;
+$max = 3;
 
 
 /*
  * Last modified customers or prospects
  */
-if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
+if (!empty($conf->societe->enabled) && $user->rights->societe->lire)
 {
 	$langs->load("boxes");
 
 	$sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas";
-    $sql.= ", s.code_client";
-	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE s.client IN (1, 2, 3)";
-	$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid)	$sql.= " AND s.rowid = $socid";
+    $sql .= ", s.code_client";
+	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE s.client IN (1, 2, 3)";
+	$sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid)	$sql .= " AND s.rowid = $socid";
 	$sql .= " ORDER BY s.tms DESC";
 	$sql .= $db->plimit($max, 0);
 
@@ -516,7 +516,7 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
 		print '<tr class="liste_titre">';
 		print '<th colspan="2">';
 		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects", $max);
-        elseif (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max);
+        elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max);
 		else print $langs->trans("BoxTitleLastModifiedCustomers", $max);
 		print '</th>';
 		print '<th class="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/societe/list.php?type=p,c">'.$langs->trans("FullList").'</a></th>';
@@ -526,12 +526,12 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
 			while ($i < $num)
 			{
 				$objp = $db->fetch_object($resql);
-				$companystatic->id=$objp->rowid;
-				$companystatic->name=$objp->name;
-				$companystatic->client=$objp->client;
+				$companystatic->id = $objp->rowid;
+				$companystatic->name = $objp->name;
+				$companystatic->client = $objp->client;
                 $companystatic->code_client = $objp->code_client;
                 $companystatic->code_fournisseur = $objp->code_fournisseur;
-                $companystatic->canvas=$objp->canvas;
+                $companystatic->canvas = $objp->canvas;
 				print '<tr class="oddeven">';
 				print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 48).'</td>';
 				print '<td class="right" nowrap>';
@@ -554,20 +554,20 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
 }
 
 // Last suppliers
-if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire)
+if (!empty($conf->fournisseur->enabled) && $user->rights->societe->lire)
 {
 	$langs->load("boxes");
 
 	$sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm";
-    $sql.= ", s.code_fournisseur";
-	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-	if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE s.fournisseur = 1";
-	$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
-	if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid)	$sql.= " AND s.rowid = ".$socid;
-	$sql.= " ORDER BY s.datec DESC";
-	$sql.= $db->plimit($max, 0);
+    $sql .= ", s.code_fournisseur";
+	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE s.fournisseur = 1";
+	$sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
+	if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid)	$sql .= " AND s.rowid = ".$socid;
+	$sql .= " ORDER BY s.datec DESC";
+	$sql .= $db->plimit($max, 0);
 
 	$result = $db->query($sql);
 	if ($result)
@@ -586,11 +586,11 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire)
 			while ($i < $num && $i < $max)
 			{
 				$objp = $db->fetch_object($result);
-				$companystatic->id=$objp->rowid;
-                $companystatic->name=$objp->name;
+				$companystatic->id = $objp->rowid;
+                $companystatic->name = $objp->name;
                 $companystatic->code_client = $objp->code_client;
                 $companystatic->code_fournisseur = $objp->code_fournisseur;
-                $companystatic->canvas=$objp->canvas;
+                $companystatic->canvas = $objp->canvas;
                 print '<tr class="oddeven">';
 				print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'supplier', 44).'</td>';
 				print '<td class="right">'.dol_print_date($db->jdate($objp->dm), 'day').'</td>';
@@ -630,26 +630,26 @@ if ($user->rights->agenda->myactions->read)
 /*
  * Last contracts
  */
-if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
+if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
 {
 	$langs->load("contracts");
 
 	$sql = "SELECT s.nom as name, s.rowid, s.canvas, ";
-    $sql.= ", s.code_client";
-	$sql.= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo";
-	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-	$sql.= ", ".MAIN_DB_PREFIX."contrat as c";
-	$sql.= ", ".MAIN_DB_PREFIX."product as p";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE c.fk_soc = s.rowid";
-	$sql.= " AND c.entity IN (".getEntity('contract').")";
-	$sql.= " AND c.fk_product = p.rowid";
-	if (! $user->rights->societe->client->voir && ! $socid)	$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid) $sql.= " AND s.rowid = ".$socid;
-	$sql.= " ORDER BY c.tms DESC";
-	$sql.= $db->plimit(5, 0);
-
-	$resql=$db->query($sql);
+    $sql .= ", s.code_client";
+	$sql .= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo";
+	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+	$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
+	$sql .= ", ".MAIN_DB_PREFIX."product as p";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE c.fk_soc = s.rowid";
+	$sql .= " AND c.entity IN (".getEntity('contract').")";
+	$sql .= " AND c.fk_product = p.rowid";
+	if (!$user->rights->societe->client->voir && !$socid)	$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid) $sql .= " AND s.rowid = ".$socid;
+	$sql .= " ORDER BY c.tms DESC";
+	$sql .= $db->plimit(5, 0);
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
@@ -661,18 +661,18 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO
 			print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("LastContracts", 5).'</th></tr>';
 			$i = 0;
 
-			$staticcontrat=new Contrat($db);
+			$staticcontrat = new Contrat($db);
 
 			while ($i < $num)
 			{
 				$obj = $db->fetch_object($resql);
 				print '<tr class="oddeven"><td><a href=\"../contrat/card.php?id=".$obj->contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."</a></td>';
 				print '<td>';
-                $companystatic->id=$objp->rowid;
-                $companystatic->name=$objp->name;
+                $companystatic->id = $objp->rowid;
+                $companystatic->name = $objp->name;
                 $companystatic->code_client = $objp->code_client;
                 $companystatic->code_fournisseur = $objp->code_fournisseur;
-                $companystatic->canvas=$objp->canvas;
+                $companystatic->canvas = $objp->canvas;
                 print $companystatic->getNomUrl(1, 'customer', 44);
 				print '</td>'."\n";
 				print "<td class=\"right\">".$staticcontrat->LibStatut($obj->statut, 3)."</td></tr>\n";
@@ -692,23 +692,23 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO
 /*
  * Opened proposals
  */
-if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
+if (!empty($conf->propal->enabled) && $user->rights->propal->lire)
 {
 	$langs->load("propal");
 
 	$sql = "SELECT s.nom as name, s.rowid, s.code_client";
-	$sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
-	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-	$sql.= ", ".MAIN_DB_PREFIX."propal as p";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE p.fk_soc = s.rowid";
-	$sql.= " AND p.entity IN (".getEntity('propal').")";
-	$sql.= " AND p.fk_statut = 1";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid) $sql.= " AND s.rowid = ".$socid;
-	$sql.= " ORDER BY p.rowid DESC";
-
-	$result=$db->query($sql);
+	$sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
+	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+	$sql .= ", ".MAIN_DB_PREFIX."propal as p";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE p.fk_soc = s.rowid";
+	$sql .= " AND p.entity IN (".getEntity('propal').")";
+	$sql .= " AND p.fk_statut = 1";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid) $sql .= " AND s.rowid = ".$socid;
+	$sql .= " ORDER BY p.rowid DESC";
+
+	$result = $db->query($sql);
 	if ($result)
 	{
 		$total = 0;
@@ -720,7 +720,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 			print '<table class="noborder centpercent">';
 			print '<tr class="liste_titre"><th colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></th></tr>';
 
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
 			{
 				$obj = $db->fetch_object($result);
@@ -730,9 +730,9 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 				// Ref
 				print '<td class="nowrap" width="140">';
 
-				$propalstatic->id=$obj->propalid;
-				$propalstatic->ref=$obj->ref;
-                $propalstatic->ref_client=$obj->ref_client;
+				$propalstatic->id = $obj->propalid;
+				$propalstatic->ref = $obj->ref;
+                $propalstatic->ref_client = $obj->ref_client;
                 $propalstatic->total_ht = $obj->total_ht;
                 $propalstatic->total_tva = $obj->total_tva;
                 $propalstatic->total_ttc = $obj->total_ttc;
@@ -745,26 +745,26 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 				if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
 				print '</td>';
 				print '<td width="16" align="center" class="nobordernopadding">';
-				$filename=dol_sanitizeFileName($obj->ref);
-				$filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
-				$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
+				$filename = dol_sanitizeFileName($obj->ref);
+				$filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+				$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
 				print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
 				print '</td></tr></table>';
 
 				print "</td>";
 
                 print '<td class="nowrap">';
-                $companystatic->id=$obj->rowid;
-                $companystatic->name=$obj->name;
-                $companystatic->client=$obj->client;
+                $companystatic->id = $obj->rowid;
+                $companystatic->name = $obj->name;
+                $companystatic->client = $obj->client;
                 $companystatic->code_client = $obj->code_client;
                 $companystatic->code_fournisseur = $obj->code_fournisseur;
-                $companystatic->canvas=$obj->canvas;
+                $companystatic->canvas = $obj->canvas;
                 print $companystatic->getNomUrl(1, 'customer', 44);
                 print '</td>';
 				print '<td class="right">';
 				print dol_print_date($db->jdate($obj->dp), 'day').'</td>'."\n";
-				if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
+				if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
 					print '<td class="right">'.price($obj->total_ht).'</td>';
 				}
 				else {
@@ -779,7 +779,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 			{
 				print '<tr class="liste_total"><td colspan="5" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td class=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
 			}
@@ -796,23 +796,23 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
 /*
  * Opened Order
  */
-if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
+if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
 {
 	$langs->load("orders");
 
 	$sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
-    $sql.= ", s.code_client";
-	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-	$sql.= ", ".MAIN_DB_PREFIX."commande as c";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE c.fk_soc = s.rowid";
-	$sql.= " AND c.entity IN (".getEntity('commande').")";
-	$sql.= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid) $sql.= " AND s.rowid = ".$socid;
-	$sql.= " ORDER BY c.rowid DESC";
-
-	$result=$db->query($sql);
+    $sql .= ", s.code_client";
+	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+	$sql .= ", ".MAIN_DB_PREFIX."commande as c";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE c.fk_soc = s.rowid";
+	$sql .= " AND c.entity IN (".getEntity('commande').")";
+	$sql .= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid) $sql .= " AND s.rowid = ".$socid;
+	$sql .= " ORDER BY c.rowid DESC";
+
+	$result = $db->query($sql);
 	if ($result)
 	{
 		$total = 0;
@@ -824,7 +824,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 			print '<table class="noborder centpercent">';
 			print '<tr class="liste_titre"><th class="liste_titre" colspan="5">'.$langs->trans("OrdersOpened").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1"><span class="badge">'.$num.'</span></th></tr>';
 
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
 			{
 				$obj = $db->fetch_object($result);
@@ -834,9 +834,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 				// Ref
 				print '<td class="nowrap" width="140">';
 
-				$orderstatic->id=$obj->commandeid;
-				$orderstatic->ref=$obj->ref;
-                $orderstatic->ref_client=$obj->ref_client;
+				$orderstatic->id = $obj->commandeid;
+				$orderstatic->ref = $obj->ref;
+                $orderstatic->ref_client = $obj->ref_client;
                 $orderstatic->total_ht = $obj->total_ht;
                 $orderstatic->total_tva = $obj->total_tva;
                 $orderstatic->total_ttc = $obj->total_ttc;
@@ -849,26 +849,26 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 				//if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
 				print '</td>';
 				print '<td width="16" align="center" class="nobordernopadding">';
-				$filename=dol_sanitizeFileName($obj->ref);
-				$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
-				$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
+				$filename = dol_sanitizeFileName($obj->ref);
+				$filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
+				$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
 				print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir);
 				print '</td></tr></table>';
 
 				print "</td>";
 
                 print '<td class="nowrap">';
-                $companystatic->id=$obj->rowid;
-                $companystatic->name=$obj->name;
-                $companystatic->client=$obj->client;
+                $companystatic->id = $obj->rowid;
+                $companystatic->name = $obj->name;
+                $companystatic->client = $obj->client;
                 $companystatic->code_client = $obj->code_client;
                 $companystatic->code_fournisseur = $obj->code_fournisseur;
-                $companystatic->canvas=$obj->canvas;
+                $companystatic->canvas = $obj->canvas;
                 print $companystatic->getNomUrl(1, 'customer', 44);
                 print '</td>';
 				print '<td class="right">';
 				print dol_print_date($db->jdate($obj->dp), 'day').'</td>'."\n";
-				if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
+				if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
 					print '<td class="right">'.price($obj->total_ht).'</td>';
 				}
 				else {
@@ -883,7 +883,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
 			{
 				print '<tr class="liste_total"><td colspan="5" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td class=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
 			}

+ 69 - 69
htdocs/comm/mailing/advtargetemailing.php

@@ -22,30 +22,30 @@
  *       \brief      Page to define emailing targets
  */
 
-if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1');
+if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1');
 
 require '../../main.inc.php';
 
-require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/emailing.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/advtargetemailing.class.php';
-require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/html.formadvtargetemailing.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/modules/mailings/advthirdparties.modules.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/advtargetemailing.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/html.formadvtargetemailing.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/advthirdparties.modules.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 
 // Load translation files required by the page
 $langs->loadLangs(array('mails', 'companies'));
-if (! empty($conf->categorie->enabled)) {
+if (!empty($conf->categorie->enabled)) {
 	$langs->load("categories");
 }
 
 // Security check
-if (! $user->rights->mailing->lire || $user->socid > 0)
+if (!$user->rights->mailing->lire || $user->socid > 0)
 	accessforbidden();
 
 // Load variable for pagination
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST('sortfield', 'alpha');
 $sortorder = GETPOST('sortorder', 'alpha');
 $page = GETPOST('page', 'int');
@@ -53,9 +53,9 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortorder)
+if (!$sortorder)
 	$sortorder = "ASC";
-if (! $sortfield)
+if (!$sortfield)
 	$sortfield = "email";
 
 $id = GETPOST('id', 'int');
@@ -72,7 +72,7 @@ if (GETPOST('button_removefilter_x', 'alpha')) {
 	$search_prenom = '';
 	$search_email = '';
 }
-$array_query = array ();
+$array_query = array();
 $object = new Mailing($db);
 $advTarget = new AdvanceTargetingMailing($db);
 
@@ -90,7 +90,7 @@ if ($result < 0)
 }
 else
 {
-	if (! empty($advTarget->id)) {
+	if (!empty($advTarget->id)) {
 		$array_query = json_decode($advTarget->filtervalue, true);
 	}
 }
@@ -101,12 +101,12 @@ else
  */
 
 if ($action == 'loadfilter') {
-	if (! empty($template_id)) {
+	if (!empty($template_id)) {
 		$result = $advTarget->fetch($template_id);
 		if ($result < 0) {
 			setEventMessages($advTarget->error, $advTarget->errors, 'errors');
 		} else {
-			if (! empty($advTarget->id)) {
+			if (!empty($advTarget->id)) {
 				$array_query = json_decode($advTarget->filtervalue, true);
 			}
 		}
@@ -116,7 +116,7 @@ if ($action == 'loadfilter') {
 if ($action == 'add') {
 	$user_contact_query = false;
 
-	$array_query = array ();
+	$array_query = array();
 
 	// Get extra fields
 
@@ -125,17 +125,17 @@ if ($action == 'add') {
 		if (preg_match("/^options_.*(?<!_cnct)$/", $key)) {
 			// Special case for start date come with 3 inputs day, month, year
 			if (preg_match("/st_dt/", $key)) {
-				$dtarr = array ();
+				$dtarr = array();
 				$dtarr = explode('_', $key);
-				if (! array_key_exists('options_' . $dtarr[1] . '_st_dt', $array_query)) {
-					$array_query['options_' . $dtarr[1] . '_st_dt'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_st_dtmonth', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtday', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtyear', 'int'));
+				if (!array_key_exists('options_'.$dtarr[1].'_st_dt', $array_query)) {
+					$array_query['options_'.$dtarr[1].'_st_dt'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_st_dtmonth', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtday', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtyear', 'int'));
 				}
 			} elseif (preg_match("/end_dt/", $key)) {
 				// Special case for end date come with 3 inputs day, month, year
-				$dtarr = array ();
+				$dtarr = array();
 				$dtarr = explode('_', $key);
-				if (! array_key_exists('options_' . $dtarr[1] . '_end_dt', $array_query)) {
-					$array_query['options_' . $dtarr[1] . '_end_dt'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_end_dtmonth', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtday', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtyear', 'int'));
+				if (!array_key_exists('options_'.$dtarr[1].'_end_dt', $array_query)) {
+					$array_query['options_'.$dtarr[1].'_end_dt'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_end_dtmonth', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtday', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtyear', 'int'));
 				}
 			} else {
 				$array_query[$key] = GETPOST($key);
@@ -145,17 +145,17 @@ if ($action == 'add') {
 			$user_contact_query = true;
 			// Special case for start date come with 3 inputs day, month, year
 			if (preg_match("/st_dt/", $key)) {
-				$dtarr = array ();
+				$dtarr = array();
 				$dtarr = explode('_', $key);
-				if (! array_key_exists('options_' . $dtarr[1] . '_st_dt' . '_cnct', $array_query)) {
-					$array_query['options_' . $dtarr[1] . '_st_dt' . '_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_st_dtmonth' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtday' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtyear' . '_cnct', 'int'));
+				if (!array_key_exists('options_'.$dtarr[1].'_st_dt'.'_cnct', $array_query)) {
+					$array_query['options_'.$dtarr[1].'_st_dt'.'_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_st_dtmonth'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtday'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtyear'.'_cnct', 'int'));
 				}
 			} elseif (preg_match("/end_dt/", $key)) {
 				// Special case for end date come with 3 inputs day, month, year
-				$dtarr = array ();
+				$dtarr = array();
 				$dtarr = explode('_', $key);
-				if (! array_key_exists('options_' . $dtarr[1] . '_end_dt' . '_cnct', $array_query)) {
-					$array_query['options_' . $dtarr[1] . '_end_dt' . '_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_end_dtmonth' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtday' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtyear' . '_cnct', 'int'));
+				if (!array_key_exists('options_'.$dtarr[1].'_end_dt'.'_cnct', $array_query)) {
+					$array_query['options_'.$dtarr[1].'_end_dt'.'_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_end_dtmonth'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtday'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtyear'.'_cnct', 'int'));
 				}
 			} else {
 				$array_query[$key] = GETPOST($key);
@@ -169,7 +169,7 @@ if ($action == 'add') {
 		if (preg_match("/^contact_/", $key)) {
 			$array_query[$key] = GETPOST($key);
 
-			$specials_date_key = array (
+			$specials_date_key = array(
 					'contact_update_st_dt',
 					'contact_update_end_dt',
 					'contact_create_st_dt',
@@ -178,15 +178,15 @@ if ($action == 'add') {
 			foreach ($specials_date_key as $date_key) {
 				if ($key == $date_key) {
 					$dt = GETPOST($date_key);
-					if (! empty($dt)) {
-						$array_query[$key] = dol_mktime(0, 0, 0, GETPOST($date_key . 'month', 'int'), GETPOST($date_key . 'day', 'int'), GETPOST($date_key . 'year', 'int'));
+					if (!empty($dt)) {
+						$array_query[$key] = dol_mktime(0, 0, 0, GETPOST($date_key.'month', 'int'), GETPOST($date_key.'day', 'int'), GETPOST($date_key.'year', 'int'));
 					} else {
 						$array_query[$key] = '';
 					}
 				}
 			}
 
-			if (! empty($array_query[$key])) {
+			if (!empty($array_query[$key])) {
 				$user_contact_query = true;
 			}
 		}
@@ -216,12 +216,12 @@ if ($action == 'add') {
 		}
 		// If use contact but no result use artefact to so not use socid into add_to_target
 		if (count($advTarget->contact_lines) == 0) {
-			$advTarget->contact_lines = array (
+			$advTarget->contact_lines = array(
 					0
 			);
 		}
 	} else {
-		$advTarget->contact_lines = array ();
+		$advTarget->contact_lines = array();
 	}
 
 	if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) {
@@ -234,11 +234,11 @@ if ($action == 'add') {
 
 	if ($result > 0) {
 		$query_temlate_id = '';
-		if (! empty($template_id)) {
-			$query_temlate_id = '&template_id=' . $template_id;
+		if (!empty($template_id)) {
+			$query_temlate_id = '&template_id='.$template_id;
 		}
 		setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
-		header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id . $query_temlate_id);
+		header("Location: ".$_SERVER['PHP_SELF']."?id=".$id.$query_temlate_id);
 		exit();
 	}
 	if ($result == 0) {
@@ -255,7 +255,7 @@ if ($action == 'clear') {
 	$obj = new $classname($db);
 	$obj->clear_target($id);
 
-	header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
+	header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
 	exit();
 }
 
@@ -265,28 +265,28 @@ if ($action == 'savefilter' || $action == 'createfilter') {
 
 	if ($action == 'createfilter' && empty($template_name)) {
 		setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('AdvTgtOrCreateNewFilter')), null, 'errors');
-		$error ++;
+		$error++;
 	}
 
 	if (empty($error)) {
-		$array_query = array ();
+		$array_query = array();
 
 		// Get extra fields
 		foreach ($_POST as $key => $value) {
 			if (preg_match("/^options_.*(?<!_cnct)$/", $key)) {
 				// Special case for start date come with 3 inputs day, month, year
 				if (preg_match("/st_dt/", $key)) {
-					$dtarr = array ();
+					$dtarr = array();
 					$dtarr = explode('_', $key);
-					if (! array_key_exists('options_' . $dtarr[1] . '_st_dt', $array_query)) {
-						$array_query['options_' . $dtarr[1] . '_st_dt'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_st_dtmonth', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtday', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtyear', 'int'));
+					if (!array_key_exists('options_'.$dtarr[1].'_st_dt', $array_query)) {
+						$array_query['options_'.$dtarr[1].'_st_dt'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_st_dtmonth', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtday', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtyear', 'int'));
 					}
 				} elseif (preg_match("/end_dt/", $key)) {
 					// Special case for end date come with 3 inputs day, month, year
-					$dtarr = array ();
+					$dtarr = array();
 					$dtarr = explode('_', $key);
-					if (! array_key_exists('options_' . $dtarr[1] . '_end_dt', $array_query)) {
-						$array_query['options_' . $dtarr[1] . '_end_dt'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_end_dtmonth', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtday', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtyear', 'int'));
+					if (!array_key_exists('options_'.$dtarr[1].'_end_dt', $array_query)) {
+						$array_query['options_'.$dtarr[1].'_end_dt'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_end_dtmonth', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtday', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtyear', 'int'));
 						// print $array_query['options_'.$dtarr[1].'_end_dt'];
 						// 01/02/1013=1361228400
 					}
@@ -297,17 +297,17 @@ if ($action == 'savefilter' || $action == 'createfilter') {
 			if (preg_match("/^options_.*_cnct/", $key)) {
 				// Special case for start date come with 3 inputs day, month, year
 				if (preg_match("/st_dt/", $key)) {
-					$dtarr = array ();
+					$dtarr = array();
 					$dtarr = explode('_', $key);
-					if (! array_key_exists('options_' . $dtarr[1] . '_st_dt' . '_cnct', $array_query)) {
-						$array_query['options_' . $dtarr[1] . '_st_dt' . '_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_st_dtmonth' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtday' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_st_dtyear' . '_cnct', 'int'));
+					if (!array_key_exists('options_'.$dtarr[1].'_st_dt'.'_cnct', $array_query)) {
+						$array_query['options_'.$dtarr[1].'_st_dt'.'_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_st_dtmonth'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtday'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_st_dtyear'.'_cnct', 'int'));
 					}
 				} elseif (preg_match("/end_dt/", $key)) {
 					// Special case for end date come with 3 inputs day, month, year
-					$dtarr = array ();
+					$dtarr = array();
 					$dtarr = explode('_', $key);
-					if (! array_key_exists('options_' . $dtarr[1] . '_end_dt' . '_cnct', $array_query)) {
-						$array_query['options_' . $dtarr[1] . '_end_dt' . '_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_' . $dtarr[1] . '_end_dtmonth' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtday' . '_cnct', 'int'), GETPOST('options_' . $dtarr[1] . '_end_dtyear' . '_cnct', 'int'));
+					if (!array_key_exists('options_'.$dtarr[1].'_end_dt'.'_cnct', $array_query)) {
+						$array_query['options_'.$dtarr[1].'_end_dt'.'_cnct'] = dol_mktime(0, 0, 0, GETPOST('options_'.$dtarr[1].'_end_dtmonth'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtday'.'_cnct', 'int'), GETPOST('options_'.$dtarr[1].'_end_dtyear'.'_cnct', 'int'));
 						// print $array_query['cnct_options_'.$dtarr[1].'_end_dt'];
 						// 01/02/1013=1361228400
 					}
@@ -323,7 +323,7 @@ if ($action == 'savefilter' || $action == 'createfilter') {
 			if (preg_match("/^contact_/", $key)) {
 				$array_query[$key] = GETPOST($key);
 
-				$specials_date_key = array (
+				$specials_date_key = array(
 						'contact_update_st_dt',
 						'contact_update_end_dt',
 						'contact_create_st_dt',
@@ -332,8 +332,8 @@ if ($action == 'savefilter' || $action == 'createfilter') {
 				foreach ($specials_date_key as $date_key) {
 					if ($key == $date_key) {
 						$dt = GETPOST($date_key);
-						if (! empty($dt)) {
-							$array_query[$key] = dol_mktime(0, 0, 0, GETPOST($date_key . 'month', 'int'), GETPOST($date_key . 'day', 'int'), GETPOST($date_key . 'year', 'int'));
+						if (!empty($dt)) {
+							$array_query[$key] = dol_mktime(0, 0, 0, GETPOST($date_key.'month', 'int'), GETPOST($date_key.'day', 'int'), GETPOST($date_key.'year', 'int'));
 						} else {
 							$array_query[$key] = '';
 						}
@@ -368,21 +368,21 @@ if ($action == 'deletefilter') {
 	if ($result < 0) {
 		setEventMessages($advTarget->error, $advTarget->errors, 'errors');
 	}
-	header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
+	header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
 	exit();
 }
 
 if ($action == 'delete') {
 	// Ici, rowid indique le destinataire et id le mailing
-	$sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing_cibles WHERE rowid=" . $rowid;
+	$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid;
 	$resql = $db->query($sql);
 	if ($resql) {
-		if (! empty($id)) {
+		if (!empty($id)) {
 			$classname = "MailingTargets";
 			$obj = new $classname($db);
 			$obj->update_nb($id);
 
-			header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
+			header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
 			exit();
 		} else {
 			header("Location: liste.php");
@@ -421,30 +421,30 @@ if ($object->fetch($id) >= 0) {
 
 	print '<table class="border centpercent">';
 
-	$linkback = '<a href="' . DOL_URL_ROOT . '/comm/mailing/liste.php">' . $langs->trans("BackToList") . '</a>';
+	$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/liste.php">'.$langs->trans("BackToList").'</a>';
 
-	print '<tr><td width="25%">' . $langs->trans("Ref") . '</td>';
+	print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
 	print '<td colspan="3">';
 	print $form->showrefnav($object, 'id', $linkback);
 	print '</td></tr>';
 
-	print '<tr><td width="25%">' . $langs->trans("MailTitle") . '</td><td colspan="3">' . $object->titre . '</td></tr>';
+	print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>';
 
-	print '<tr><td width="25%">' . $langs->trans("MailFrom") . '</td><td colspan="3">' . dol_print_email($object->email_from, 0, 0, 0, 0, 1) . '</td></tr>';
+	print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';
 
 	// Errors to
-	print '<tr><td width="25%">' . $langs->trans("MailErrorsTo") . '</td><td colspan="3">' . dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
+	print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
 	print '</td></tr>';
 
 	// Status
-	print '<tr><td width="25%">' . $langs->trans("Status") . '</td><td colspan="3">' . $object->getLibStatut(4) . '</td></tr>';
+	print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
 
 	// Nb of distinct emails
 	print '<tr><td width="25%">';
 	print $langs->trans("TotalNbOfDistinctRecipients");
 	print '</td><td colspan="3">';
 	$nbemail = ($object->nbemail ? $object->nbemail : '0');
-	if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) {
+	if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) {
 		$text = $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
 		print $form->textwithpicto($nbemail, $text, 1, 'warning');
 	} else {
@@ -458,7 +458,7 @@ if ($object->fetch($id) >= 0) {
 
 	// Show email selectors
 	if ($object->statut == 0 && $user->rights->mailing->creer) {
-		include DOL_DOCUMENT_ROOT . '/core/tpl/advtarget.tpl.php';
+		include DOL_DOCUMENT_ROOT.'/core/tpl/advtarget.tpl.php';
 	}
 }
 

+ 88 - 88
htdocs/comm/mailing/cibles.php

@@ -36,11 +36,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 $langs->load("mails");
 
 // Security check
-if (! $user->rights->mailing->lire || $user->socid > 0) accessforbidden();
+if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden();
 
 
 // Load variable for pagination
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST('sortfield', 'alpha');
 $sortorder = GETPOST('sortorder', 'alpha');
 $page = GETPOST('page', 'int');
@@ -48,23 +48,23 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortfield) $sortfield="email";
-if (! $sortorder) $sortorder="ASC";
-
-$id=GETPOST('id', 'int');
-$rowid=GETPOST('rowid', 'int');
-$action=GETPOST('action', 'aZ09');
-$search_lastname=GETPOST("search_lastname", 'alphanohtml');
-$search_firstname=GETPOST("search_firstname", 'alphanohtml');
-$search_email=GETPOST("search_email", 'alphanohtml');
-$search_other=GETPOST("search_other", 'alphanohtml');
-$search_dest_status=GETPOST('search_dest_status', 'alphanohtml');
+if (!$sortfield) $sortfield = "email";
+if (!$sortorder) $sortorder = "ASC";
+
+$id = GETPOST('id', 'int');
+$rowid = GETPOST('rowid', 'int');
+$action = GETPOST('action', 'aZ09');
+$search_lastname = GETPOST("search_lastname", 'alphanohtml');
+$search_firstname = GETPOST("search_firstname", 'alphanohtml');
+$search_email = GETPOST("search_email", 'alphanohtml');
+$search_other = GETPOST("search_other", 'alphanohtml');
+$search_dest_status = GETPOST('search_dest_status', 'alphanohtml');
 
 // Search modules dirs
 $modulesdir = dolGetModulesDirs('/mailings');
 
 $object = new Mailing($db);
-$result=$object->fetch($id);
+$result = $object->fetch($id);
 
 
 /*
@@ -73,8 +73,8 @@ $result=$object->fetch($id);
 
 if ($action == 'add')
 {
-	$module=GETPOST("module", 'alpha');
-	$result=-1;
+	$module = GETPOST("module", 'alpha');
+	$result = -1;
 
 	foreach ($modulesdir as $dir)
 	{
@@ -93,7 +93,7 @@ if ($action == 'add')
 			// Add targets into database
 			$obj = new $classname($db);
 			dol_syslog("Call add_to_target on class ".$classname);
-			$result=$obj->add_to_target($id);
+			$result = $obj->add_to_target($id);
 		}
 	}
 	if ($result > 0)
@@ -109,7 +109,7 @@ if ($action == 'add')
 	}
 	if ($result < 0)
 	{
-		setEventMessages($langs->trans("Error").($obj->error?' '.$obj->error:''), null, 'errors');
+		setEventMessages($langs->trans("Error").($obj->error ? ' '.$obj->error : ''), null, 'errors');
 	}
 }
 
@@ -128,7 +128,7 @@ if (GETPOST('exportcsv', 'int'))
 {
 	$completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv';
 	header('Content-Type: text/csv');
-	header('Content-Disposition: attachment;filename=' . $completefilename);
+	header('Content-Disposition: attachment;filename='.$completefilename);
 
 	// List of selected targets
 	$sql  = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,";
@@ -137,7 +137,7 @@ if (GETPOST('exportcsv', 'int'))
 	$sql .= " WHERE mc.fk_mailing=".$object->id;
 	$sql .= $db->order($sortfield, $sortorder);
 
-	$resql=$db->query($sql);
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
@@ -145,17 +145,17 @@ if (GETPOST('exportcsv', 'int'))
 
 		while ($obj = $db->fetch_object($resql))
 		{
-			print $obj->rowid . $sep;
-			print $obj->lastname . $sep;
-			print $obj->firstname . $sep;
-			print $obj->email . $sep;
-			print $obj->other . $sep;
-			print $obj->date_envoi . $sep;
-			print $obj->tms . $sep;
-			print $obj->source_url . $sep;
-			print $obj->source_id . $sep;
-			print $obj->source_type . $sep;
-			print $obj->error_text . $sep;
+			print $obj->rowid.$sep;
+			print $obj->lastname.$sep;
+			print $obj->firstname.$sep;
+			print $obj->email.$sep;
+			print $obj->other.$sep;
+			print $obj->date_envoi.$sep;
+			print $obj->tms.$sep;
+			print $obj->source_url.$sep;
+			print $obj->source_id.$sep;
+			print $obj->source_type.$sep;
+			print $obj->error_text.$sep;
 			print "\n";
 		}
 
@@ -171,11 +171,11 @@ if (GETPOST('exportcsv', 'int'))
 if ($action == 'delete')
 {
 	// Ici, rowid indique le destinataire et id le mailing
-	$sql="DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid;
-	$resql=$db->query($sql);
+	$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid;
+	$resql = $db->query($sql);
 	if ($resql)
 	{
-		if (! empty($id))
+		if (!empty($id))
 		{
 			$obj = new MailingTargets($db);
 			$obj->update_nb($id);
@@ -195,13 +195,13 @@ if ($action == 'delete')
 }
 
 // Purge search criteria
-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
+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_firstname='';
-	$search_email='';
-	$search_other='';
-	$search_dest_status='';
+	$search_lastname = '';
+	$search_firstname = '';
+	$search_email = '';
+	$search_other = '';
+	$search_dest_status = '';
 }
 
 
@@ -223,16 +223,16 @@ if ($object->fetch($id) >= 0)
 
 	$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
 
-	$morehtmlright='';
+	$morehtmlright = '';
 	$nbtry = $nbok = 0;
 	if ($object->statut == 2 || $object->statut == 3)
 	{
 		$nbtry = $object->countNbOfTargets('alreadysent');
 		$nbko  = $object->countNbOfTargets('alreadysentko');
 
-		$morehtmlright.=' ('.$nbtry.'/'.$object->nbemail;
-		if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error");
-		$morehtmlright.=') &nbsp; ';
+		$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
+		if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
+		$morehtmlright .= ') &nbsp; ';
 	}
 
 	dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
@@ -254,22 +254,22 @@ if ($object->fetch($id) >= 0)
 	print '<tr><td>';
 	print $langs->trans("TotalNbOfDistinctRecipients");
 	print '</td><td colspan="3">';
-	$nbemail = ($object->nbemail?$object->nbemail:0);
+	$nbemail = ($object->nbemail ? $object->nbemail : 0);
 	if (is_numeric($nbemail))
 	{
-		$text='';
-		if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
+		$text = '';
+		if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
 		{
 			if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
 			{
-				$text.=$langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
+				$text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
 			}
 			else
 			{
-				$text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed');
+				$text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
 			}
 		}
-		if (empty($nbemail)) $nbemail.=' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
+		if (empty($nbemail)) $nbemail .= ' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
 		if ($text)
 		{
 			print $form->textwithpicto($nbemail, $text, 1, 'warning');
@@ -290,12 +290,12 @@ if ($object->fetch($id) >= 0)
 	print '<br>';
 
 
-	$allowaddtarget=($object->statut == 0);
+	$allowaddtarget = ($object->statut == 0);
 
 	// Show email selectors
 	if ($allowaddtarget && $user->rights->mailing->creer)
 	{
-		print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1):''), 'generic');
+		print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic');
 
 		//print '<table class="noborder centpercent">';
 		print '<div class="tagtable centpercent liste_titre_bydiv borderbottom" id="tablelines">';
@@ -317,22 +317,22 @@ if ($object->fetch($id) >= 0)
 
 		foreach ($modulesdir as $dir)
 		{
-		    $modulenames=array();
+		    $modulenames = array();
 
 		    // Load modules attributes in arrays (name, numero, orders) from dir directory
 		    //print $dir."\n<br>";
 		    dol_syslog("Scan directory ".$dir." for modules");
-		    $handle=@opendir($dir);
+		    $handle = @opendir($dir);
 			if (is_resource($handle))
 			{
-				while (($file = readdir($handle))!==false)
+				while (($file = readdir($handle)) !== false)
 				{
 					if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 					{
 						if (preg_match("/(.*)\.modules\.php$/i", $file, $reg))
 						{
 							if ($reg[1] == 'example') continue;
-							$modulenames[]=$reg[1];
+							$modulenames[] = $reg[1];
 						}
 					}
 				}
@@ -345,7 +345,7 @@ if ($object->fetch($id) >= 0)
 			$var = true;
 
 			// Loop on each submodule
-			foreach($modulenames as $modulename)
+			foreach ($modulenames as $modulename)
 			{
 				// Loading Class
 				$file = $dir.$modulename.".modules.php";
@@ -355,12 +355,12 @@ if ($object->fetch($id) >= 0)
 				$obj = new $classname($db);
 
 				// Check dependencies
-				$qualified=(isset($obj->enabled)?$obj->enabled:1);
+				$qualified = (isset($obj->enabled) ? $obj->enabled : 1);
 				foreach ($obj->require_module as $key)
 				{
-					if (! $conf->$key->enabled || (! $user->admin && $obj->require_admin))
+					if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin))
 					{
-						$qualified=0;
+						$qualified = 0;
 						//print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
 						break;
 					}
@@ -369,7 +369,7 @@ if ($object->fetch($id) >= 0)
 				// Si le module mailing est qualifie
 				if ($qualified)
 				{
-					$var = ! $var;
+					$var = !$var;
 
 					if ($allowaddtarget)
 					{
@@ -382,16 +382,16 @@ if ($object->fetch($id) >= 0)
 					}
 
 					print '<div class="tagtd">';
-					if (empty($obj->picto)) $obj->picto='generic';
+					if (empty($obj->picto)) $obj->picto = 'generic';
 					print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle pictomodule"');
 					print ' ';
 					print $obj->getDesc();
 					print '</div>';
 
 					try {
-						$nbofrecipient=$obj->getNbOfRecipients('');
+						$nbofrecipient = $obj->getNbOfRecipients('');
 					}
-					catch(Exception $e)
+					catch (Exception $e)
 					{
 						dol_syslog($e->getMessage(), LOG_ERR);
 					}
@@ -411,9 +411,9 @@ if ($object->fetch($id) >= 0)
 					if ($allowaddtarget)
 					{
     					try {
-    						$filter=$obj->formFilter();
+    						$filter = $obj->formFilter();
     					}
-    					catch(Exception $e)
+    					catch (Exception $e)
     					{
     						dol_syslog($e->getMessage(), LOG_ERR);
     					}
@@ -451,11 +451,11 @@ if ($object->fetch($id) >= 0)
 	$sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
 	$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
 	$sql .= " WHERE mc.fk_mailing=".$object->id;
-	if ($search_lastname)  $sql.= natural_search("mc.lastname", $search_lastname);
-	if ($search_firstname) $sql.= natural_search("mc.firstname", $search_firstname);
-	if ($search_email)     $sql.= natural_search("mc.email", $search_email);
-	if ($search_other)     $sql.= natural_search("mc.other", $search_other);
-	if ($search_dest_status != '' && $search_dest_status >= -1) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." ";
+	if ($search_lastname)  $sql .= natural_search("mc.lastname", $search_lastname);
+	if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname);
+	if ($search_email)     $sql .= natural_search("mc.email", $search_email);
+	if ($search_other)     $sql .= natural_search("mc.other", $search_other);
+	if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." ";
 	$sql .= $db->order($sortfield, $sortorder);
 
 	// Count total nb of records
@@ -472,20 +472,20 @@ if ($object->fetch($id) >= 0)
 	}
 
 	//$nbtotalofrecords=$object->nbemail;     // nbemail is a denormalized field storing nb of targets
-	$sql .= $db->plimit($limit+1, $offset);
+	$sql .= $db->plimit($limit + 1, $offset);
 
-	$resql=$db->query($sql);
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
 
 		$param = "&id=".$object->id;
 		//if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
-		if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
-		if ($search_lastname)  $param.= "&search_lastname=".urlencode($search_lastname);
-		if ($search_firstname) $param.= "&search_firstname=".urlencode($search_firstname);
-		if ($search_email)     $param.= "&search_email=".urlencode($search_email);
-		if ($search_other)     $param.= "&search_other=".urlencode($search_other);
+		if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
+		if ($search_lastname)  $param .= "&search_lastname=".urlencode($search_lastname);
+		if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname);
+		if ($search_email)     $param .= "&search_email=".urlencode($search_email);
+		if ($search_other)     $param .= "&search_other=".urlencode($search_other);
 
 		print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -494,11 +494,11 @@ if ($object->fetch($id) >= 0)
         print '<input type="hidden" name="page" value="'.$page.'">';
 		print '<input type="hidden" name="id" value="'.$object->id.'">';
 
-		$morehtmlcenter='';
+		$morehtmlcenter = '';
 		if ($allowaddtarget) {
-			$morehtmlcenter='<span class="opacitymedium">'.$langs->trans("ToClearAllRecipientsClickHere").'</span> <a href="'.$_SERVER["PHP_SELF"].'?clearlist=1&id='.$object->id.'" class="button reposition">'.$langs->trans("TargetsReset").'</a>';
+			$morehtmlcenter = '<span class="opacitymedium">'.$langs->trans("ToClearAllRecipientsClickHere").'</span> <a href="'.$_SERVER["PHP_SELF"].'?clearlist=1&id='.$object->id.'" class="button reposition">'.$langs->trans("TargetsReset").'</a>';
 		}
-		$morehtmlcenter.=' <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?exportcsv=1&id='.$object->id.'">'.$langs->trans("Download").'</a>';
+		$morehtmlcenter .= ' <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?exportcsv=1&id='.$object->id.'">'.$langs->trans("Download").'</a>';
 
 		print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
 
@@ -555,12 +555,12 @@ if ($object->fetch($id) >= 0)
 		print '</td>';
 		// Action column
 		print '<td class="liste_titre maxwidthsearch">';
-		$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
+		$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
 		print $searchpicto;
 		print '</td>';
 		print '</tr>';
 
-		if ($page) $param.= "&page=".urlencode($page);
+		if ($page) $param .= "&page=".urlencode($page);
 
 		print '<tr class="liste_titre">';
 		print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder);
@@ -584,10 +584,10 @@ if ($object->fetch($id) >= 0)
 			include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
 			include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
 			include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
-			$objectstaticmember=new Adherent($db);
-			$objectstaticuser=new User($db);
-			$objectstaticcompany=new Societe($db);
-			$objectstaticcontact=new Contact($db);
+			$objectstaticmember = new Adherent($db);
+			$objectstaticuser = new User($db);
+			$objectstaticcompany = new Societe($db);
+			$objectstaticcontact = new Contact($db);
 
 			while ($i < min($num, $limit))
 			{
@@ -601,7 +601,7 @@ if ($object->fetch($id) >= 0)
 				print '<td align="center">';
                 if (empty($obj->source_id) || empty($obj->source_type))
                 {
-                    print empty($obj->source_url)?'':$obj->source_url; // For backward compatibility
+                    print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
                 }
                 else
                 {

+ 20 - 20
htdocs/comm/mailing/index.php

@@ -25,7 +25,7 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 
 $hookmanager = new HookManager($db);
@@ -38,14 +38,14 @@ $langs->loadLangs(array('commercial', 'orders'));
 
 
 // Security check
-$result=restrictedArea($user, 'mailing');
+$result = restrictedArea($user, 'mailing');
 
 
 /*
  *	View
  */
 
-$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
+$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
 llxHeader('', 'EMailing', $help_url);
 
 print load_fiche_titre($langs->trans("MailingArea"));
@@ -77,18 +77,18 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistics").'</td></tr>';
 
-$dir=DOL_DOCUMENT_ROOT."/core/modules/mailings";
-$handle=opendir($dir);
+$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
+$handle = opendir($dir);
 
 if (is_resource($handle))
 {
-    while (($file = readdir($handle))!==false)
+    while (($file = readdir($handle)) !== false)
     {
         if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
         {
             if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg))
             {
-                $modulename=$reg[1];
+                $modulename = $reg[1];
        			if ($modulename == 'example') continue;
 
                 // Loading Class
@@ -97,12 +97,12 @@ if (is_resource($handle))
                 require_once $file;
                 $mailmodule = new $classname($db);
 
-                $qualified=1;
+                $qualified = 1;
                 foreach ($mailmodule->require_module as $key)
                 {
-                    if (! $conf->$key->enabled || (! $user->admin && $mailmodule->require_admin))
+                    if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin))
                     {
-                        $qualified=0;
+                        $qualified = 0;
                         //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif";
                         break;
                     }
@@ -115,13 +115,13 @@ if (is_resource($handle))
                     {
                         print '<tr class="oddeven">';
 
-                        $result=$db->query($sql);
+                        $result = $db->query($sql);
                         if ($result) {
                             $num = $db->num_rows($result);
 
                             $i = 0;
 
-                            while ($i < $num )
+                            while ($i < $num)
                             {
                                 $obj = $db->fetch_object($result);
                                 print '<td>'.img_object('', $mailmodule->picto).' '.$obj->label.'</td><td class="right">'.$obj->nb.'<td>';
@@ -154,12 +154,12 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 /*
  * List of last emailings
  */
-$limit=10;
+$limit = 10;
 $sql  = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat";
-$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m";
-$sql.= " ORDER BY m.date_creat DESC";
-$sql.= " LIMIT ".$limit;
-$result=$db->query($sql);
+$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
+$sql .= " ORDER BY m.date_creat DESC";
+$sql .= " LIMIT ".$limit;
+$result = $db->query($sql);
 if ($result) {
     print '<div class="div-table-responsive-no-min">';
     print '<table class="noborder centpercent">';
@@ -174,10 +174,10 @@ if ($result) {
     {
         $i = 0;
 
-        while ($i < $num )
+        while ($i < $num)
 	    {
 	        $obj = $db->fetch_object($result);
-			$mailstatic=new Mailing($db);
+			$mailstatic = new Mailing($db);
 			$mailstatic->id = $obj->rowid;
 			$mailstatic->ref = $obj->rowid;
 
@@ -185,7 +185,7 @@ if ($result) {
 	        print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
 	        print '<td>'.dol_trunc($obj->titre, 38).'</td>';
 	        print '<td align="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
-	        print '<td align="center">'.($obj->nbemail?$obj->nbemail:"0").'</td>';
+	        print '<td align="center">'.($obj->nbemail ? $obj->nbemail : "0").'</td>';
 	        print '<td class="right">'.$mailstatic->LibStatut($obj->statut, 5).'</td>';
             print '</tr>';
 	        $i++;

+ 16 - 16
htdocs/comm/multiprix.php

@@ -60,13 +60,13 @@ if ($_POST["action"] == 'setpricelevel')
 
 llxHeader();
 
-$userstatic=new User($db);
+$userstatic = new User($db);
 
 if ($_socid > 0)
 {
 	// On recupere les donnees societes par l'objet
 	$objsoc = new Societe($db);
-	$objsoc->id=$_socid;
+	$objsoc->id = $_socid;
 	$objsoc->fetch($_socid, $to);
 
 	if ($errmesg)
@@ -81,9 +81,9 @@ if ($_socid > 0)
 
 	$head = societe_prepare_head($objsoc);
 
-	$tabchoice='';
-	if ($objsoc->client == 1) $tabchoice='customer';
-	if ($objsoc->client == 2) $tabchoice='prospect';
+	$tabchoice = '';
+	if ($objsoc->client == 1) $tabchoice = 'customer';
+	if ($objsoc->client == 2) $tabchoice = 'prospect';
 
 	print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -99,14 +99,14 @@ if ($_socid > 0)
 	print '<tr><td>';
 	print $langs->trans("NewValue").'</td><td>';
 	print '<select name="price_level" class="flat">';
-	for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
+	for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
 	{
-		print '<option value="'.$i.'"' ;
-		if($i == $objsoc->price_level)
+		print '<option value="'.$i.'"';
+		if ($i == $objsoc->price_level)
 		print 'selected';
 		print '>'.$i;
-		$keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$i;
-		if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
+		$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
+		if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
 		print '</option>';
 	}
 	print '</select>';
@@ -129,11 +129,11 @@ if ($_socid > 0)
 	 */
 	$sql  = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login";
 	$sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u";
-	$sql .= " WHERE rc.fk_soc =". $objsoc->id;
+	$sql .= " WHERE rc.fk_soc =".$objsoc->id;
 	$sql .= " AND u.rowid = rc.fk_user_author";
 	$sql .= " ORDER BY rc.datec DESC";
 
-	$resql=$db->query($sql);
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		print '<table class="noborder centpercent">';
@@ -143,18 +143,18 @@ if ($_socid > 0)
 		print '<td>'.$langs->trans("PriceLevel").'</td>';
 		print '<td class="right">'.$langs->trans("User").'</td>';
 		print '</tr>';
-		$i = 0 ;
+		$i = 0;
 		$num = $db->num_rows($resql);
 
-		while ($i < $num )
+		while ($i < $num)
 		{
 			$obj = $db->fetch_object($resql);
 
 			print '<tr class="oddeven">';
 			print '<td>'.dol_print_date($db->jdate($obj->dc), "dayhour").'</td>';
 			print '<td>'.$obj->price_level.' </td>';
-			$userstatic->id=$obj->uid;
-			$userstatic->lastname=$obj->login;
+			$userstatic->id = $obj->uid;
+			$userstatic->lastname = $obj->login;
 			print '<td class="right">'.$userstatic->getNomUrl(1).'</td>';
 			print '</tr>';
 			$i++;

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

@@ -26,7 +26,7 @@
 
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
 
 $hookmanager = new HookManager($db);
 
@@ -37,8 +37,8 @@ $hookmanager->initHooks(array('proposalindex'));
 $langs->loadLangs(array('propal', 'companies'));
 
 // Security check
-$socid=GETPOST('socid', 'int');
-if (isset($user->socid) && $user->socid  > 0)
+$socid = GETPOST('socid', 'int');
+if (isset($user->socid) && $user->socid > 0)
 {
 	$action = '';
 	$socid = $user->socid;
@@ -49,12 +49,12 @@ $result = restrictedArea($user, 'propal');
 /*
  * View
  */
-$now=dol_now();
-$propalstatic=new Propal($db);
-$companystatic=new Societe($db);
+$now = dol_now();
+$propalstatic = new Propal($db);
+$companystatic = new Societe($db);
 $form = new Form($db);
 $formfile = new FormFile($db);
-$help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
+$help_url = "EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
 
 llxHeader("", $langs->trans("ProspectionArea"), $help_url);
 
@@ -65,7 +65,7 @@ print load_fiche_titre($langs->trans("ProspectionArea"), '', 'commercial');
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
 
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
 {
     print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
     print '<div class="div-table-responsive-no-min">';
@@ -83,25 +83,25 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
  */
 
 $sql = "SELECT count(p.rowid), p.fk_statut";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-$sql.= ", ".MAIN_DB_PREFIX."propal as p";
-if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE p.fk_soc = s.rowid";
-$sql.= " AND p.entity IN (".getEntity('propal').")";
-if ($user->socid) $sql.=' AND p.fk_soc = '.$user->socid;
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " AND p.fk_statut IN (0,1,2,3,4)";
-$sql.= " GROUP BY p.fk_statut";
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+$sql .= ", ".MAIN_DB_PREFIX."propal as p";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE p.fk_soc = s.rowid";
+$sql .= " AND p.entity IN (".getEntity('propal').")";
+if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid;
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " AND p.fk_statut IN (0,1,2,3,4)";
+$sql .= " GROUP BY p.fk_statut";
 $resql = $db->query($sql);
 if ($resql)
 {
     $num = $db->num_rows($resql);
     $i = 0;
 
-    $total=0;
-    $totalinprocess=0;
-    $dataseries=array();
-    $vals=array();
+    $total = 0;
+    $totalinprocess = 0;
+    $dataseries = array();
+    $vals = array();
     // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
     while ($i < $num)
     {
@@ -110,10 +110,10 @@ if ($resql)
         {
             //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
             {
-                $vals[$row[1]]=$row[0];
-                $totalinprocess+=$row[0];
+                $vals[$row[1]] = $row[0];
+                $totalinprocess += $row[0];
             }
-            $total+=$row[0];
+            $total += $row[0];
         }
         $i++;
     }
@@ -122,15 +122,15 @@ if ($resql)
     print '<div class="div-table-responsive-no-min">';
     print '<table class="noborder nohover centpercent">';
     print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'</td></tr>'."\n";
-    $listofstatus=array(0,1,2,3,4);
+    $listofstatus = array(0, 1, 2, 3, 4);
     foreach ($listofstatus as $status)
     {
-    	$dataseries[]=array($propalstatic->LibStatut($status, 1), (isset($vals[$status])?(int) $vals[$status]:0));
-        if (! $conf->use_javascript_ajax)
+    	$dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
+        if (!$conf->use_javascript_ajax)
         {
             print '<tr class="oddeven">';
             print '<td>'.$propalstatic->LibStatut($status, 0).'</td>';
-            print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status])?$vals[$status]:0).'</a></td>';
+            print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
             print "</tr>\n";
         }
     }
@@ -146,7 +146,7 @@ if ($resql)
         $dolgraph->SetType(array('pie'));
         $dolgraph->setWidth('100%');
         $dolgraph->draw('idgraphthirdparties');
-        print $dolgraph->show($total?0:1);
+        print $dolgraph->show($total ? 0 : 1);
 
         print '</td></tr>';
     }
@@ -164,19 +164,19 @@ else
 /*
  * Draft proposals
  */
-if (! empty($conf->propal->enabled))
+if (!empty($conf->propal->enabled))
 {
 	$sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
-	$sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE c.fk_soc = s.rowid";
-	$sql.= " AND c.entity IN (".getEntity('propal').")";
-	$sql.= " AND c.fk_statut = 0";
-	if ($socid) $sql.= " AND c.fk_soc = ".$socid;
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-
-	$resql=$db->query($sql);
+	$sql .= " FROM ".MAIN_DB_PREFIX."propal as c";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE c.fk_soc = s.rowid";
+	$sql .= " AND c.entity IN (".getEntity('propal').")";
+	$sql .= " AND c.fk_statut = 0";
+	if ($socid) $sql .= " AND c.fk_soc = ".$socid;
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
@@ -189,20 +189,20 @@ if (! empty($conf->propal->enabled))
 			print '<td colspan="2">'.$langs->trans("DraftPropals").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=0"><span class="badge">'.$num.'</span></a></td></tr>';
 
 			$i = 0;
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
 			{
 				$obj = $db->fetch_object($resql);
 				print '<tr class="oddeven">';
 
-				$propalstatic->id=$obj->rowid;
-				$propalstatic->ref=$obj->ref;
+				$propalstatic->id = $obj->rowid;
+				$propalstatic->ref = $obj->ref;
 				print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
 
-				$companystatic->id=$obj->socid;
-				$companystatic->name=$obj->socname;
-				$companystatic->client=$obj->client;
-				$companystatic->canvas=$obj->canvas;
+				$companystatic->id = $obj->socid;
+				$companystatic->name = $obj->socname;
+				$companystatic->client = $obj->client;
+				$companystatic->canvas = $obj->canvas;
 				print '<td>'.$companystatic->getNomUrl(1, 'customer', 24).'</td>';
 
 				print '</tr>';
@@ -212,7 +212,7 @@ if (! empty($conf->propal->enabled))
 			{
 				print '<tr class="liste_total"><td colspan="2" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
 			{
 				print '<tr class="liste_total"><td class="right">'.$langs->trans("Total").'</td><td class="right">'.price($total)."</td></tr>";
 			}
@@ -227,26 +227,26 @@ if (! empty($conf->propal->enabled))
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
 
-$max=5;
+$max = 5;
 
 /*
  * Last modified proposals
  */
 
 $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
-$sql.= " date_cloture as datec";
-$sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
-$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE c.fk_soc = s.rowid";
-$sql.= " AND c.entity IN (".getEntity('propal').")";
+$sql .= " date_cloture as datec";
+$sql .= " FROM ".MAIN_DB_PREFIX."propal as c";
+$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE c.fk_soc = s.rowid";
+$sql .= " AND c.entity IN (".getEntity('propal').")";
 //$sql.= " AND c.fk_statut > 2";
 if ($socid) $sql .= " AND c.fk_soc = ".$socid;
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " ORDER BY c.tms DESC";
-$sql.= $db->plimit($max, 0);
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " ORDER BY c.tms DESC";
+$sql .= $db->plimit($max, 0);
 
-$resql=$db->query($sql);
+$resql = $db->query($sql);
 if ($resql)
 {
 	print '<div class="div-table-responsive-no-min">';
@@ -265,8 +265,8 @@ if ($resql)
 			print '<tr class="oddeven">';
 			print '<td width="20%" class="nowrap">';
 
-			$propalstatic->id=$obj->rowid;
-			$propalstatic->ref=$obj->ref;
+			$propalstatic->id = $obj->rowid;
+			$propalstatic->ref = $obj->ref;
 
 			print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 			print '<td width="96" class="nobordernopadding nowrap">';
@@ -278,18 +278,18 @@ if ($resql)
 			print '</td>';
 
 			print '<td width="16" class="nobordernopadding right">';
-			$filename=dol_sanitizeFileName($obj->ref);
-			$filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
-			$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
+			$filename = dol_sanitizeFileName($obj->ref);
+			$filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+			$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
 			print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
 			print '</td></tr></table>';
 
 			print '</td>';
 
-			$companystatic->id=$obj->socid;
-			$companystatic->name=$obj->socname;
-			$companystatic->client=$obj->client;
-			$companystatic->canvas=$obj->canvas;
+			$companystatic->id = $obj->socid;
+			$companystatic->name = $obj->socname;
+			$companystatic->client = $obj->client;
+			$companystatic->canvas = $obj->canvas;
 			print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
 
 			print '<td>'.dol_print_date($db->jdate($obj->datec), 'day').'</td>';
@@ -307,25 +307,25 @@ else dol_print_error($db);
 /*
  * Opened proposals
  */
-if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
+if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
 {
 	$langs->load("propal");
 
-	$now=dol_now();
+	$now = dol_now();
 
 	$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client";
-	$sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
-	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-	$sql.= ", ".MAIN_DB_PREFIX."propal as p";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE p.fk_soc = s.rowid";
-	$sql.= " AND p.entity IN (".getEntity('propal').")";
-	$sql.= " AND p.fk_statut = 1";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid) $sql.= " AND s.rowid = ".$socid;
-	$sql.= " ORDER BY p.rowid DESC";
-
-	$result=$db->query($sql);
+	$sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
+	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+	$sql .= ", ".MAIN_DB_PREFIX."propal as p";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE p.fk_soc = s.rowid";
+	$sql .= " AND p.entity IN (".getEntity('propal').")";
+	$sql .= " AND p.fk_statut = 1";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid) $sql .= " AND s.rowid = ".$socid;
+	$sql .= " ORDER BY p.rowid DESC";
+
+	$result = $db->query($sql);
 	if ($result)
 	{
 		$total = 0;
@@ -337,7 +337,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
 			print '<table class="noborder centpercent">';
 			print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>';
 
-			$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+			$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
 			while ($i < $nbofloop)
 			{
 				$obj = $db->fetch_object($result);
@@ -347,8 +347,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
 				// Ref
 				print '<td class="nowrap" width="140">';
 
-				$propalstatic->id=$obj->propalid;
-				$propalstatic->ref=$obj->ref;
+				$propalstatic->id = $obj->propalid;
+				$propalstatic->ref = $obj->ref;
 
 				print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 				print '<td class="nobordernopadding nowrap">';
@@ -358,18 +358,18 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
 				if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
 				print '</td>';
 				print '<td width="16" align="center" class="nobordernopadding">';
-				$filename=dol_sanitizeFileName($obj->ref);
-				$filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
-				$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
+				$filename = dol_sanitizeFileName($obj->ref);
+				$filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+				$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
 				print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
 				print '</td></tr></table>';
 
 				print "</td>";
 
-				$companystatic->id=$obj->socid;
-				$companystatic->name=$obj->socname;
-				$companystatic->client=$obj->client;
-				$companystatic->canvas=$obj->canvas;
+				$companystatic->id = $obj->socid;
+				$companystatic->name = $obj->socname;
+				$companystatic->client = $obj->client;
+				$companystatic->canvas = $obj->canvas;
 				print '<td class="left">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>'."\n";
 
 				print '<td class="right">';
@@ -384,7 +384,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
 			{
 				print '<tr class="liste_total"><td colspan="5" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
 			}
-			elseif ($total>0)
+			elseif ($total > 0)
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
 			}

+ 63 - 63
htdocs/comm/prospect/index.php

@@ -41,7 +41,7 @@ if ($user->socid > 0)
  *	View
  */
 
-$companystatic=new Societe($db);
+$companystatic = new Societe($db);
 
 llxHeader();
 
@@ -52,9 +52,9 @@ print load_fiche_titre($langs->trans("ProspectionArea"));
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
 
-if (! empty($conf->propal->enabled))
+if (!empty($conf->propal->enabled))
 {
-	$var=false;
+	$var = false;
 	print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/card.php">';
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<table class="noborder nohover centpercent">';
@@ -72,22 +72,22 @@ if (! empty($conf->propal->enabled))
  */
 
 $sql = "SELECT count(*) as cc, st.libelle, st.id";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE s.fk_stcomm = st.id";
-$sql.= " AND s.client IN (2, 3)";
-$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " GROUP BY st.id";
-$sql.= " ORDER BY st.id";
-
-$resql=$db->query($sql);
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE s.fk_stcomm = st.id";
+$sql .= " AND s.client IN (2, 3)";
+$sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " GROUP BY st.id";
+$sql .= " ORDER BY st.id";
+
+$resql = $db->query($sql);
 if ($resql)
 {
 	$num = $db->num_rows($resql);
 	$i = 0;
-	if ($num > 0 )
+	if ($num > 0)
 	{
 		print '<table class="noborder centpercent">';
 		print '<tr class="liste_titre">';
@@ -111,21 +111,21 @@ if ($resql)
 /*
  * Liste des propal brouillons
  */
-if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
+if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
 {
 	$sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname";
-	$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE p.fk_statut = 0";
-	$sql.= " AND p.fk_soc = s.rowid";
-	$sql.= " AND p.entity IN (".getEntity('propal').")";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-
-	$resql=$db->query($sql);
+	$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE p.fk_statut = 0";
+	$sql .= " AND p.fk_soc = s.rowid";
+	$sql .= " AND p.entity IN (".getEntity('propal').")";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
-		$total=0;
+		$total = 0;
 		$num = $db->num_rows($resql);
 		$i = 0;
 		if ($num > 0)
@@ -146,7 +146,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
 				$i++;
 				$total += $obj->price;
 			}
-			if ($total>0) {
+			if ($total > 0) {
 				print '<tr class="liste_total"><td>'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td></tr>";
 			}
 			print "</table><br>";
@@ -163,29 +163,29 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 /*
  * Actions commerciales a faire
  */
-if (! empty($conf->agenda->enabled)) show_array_actions_to_do(10);
+if (!empty($conf->agenda->enabled)) show_array_actions_to_do(10);
 
 /*
  * Dernieres propales ouvertes
  */
-if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
+if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
 {
 	$sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,";
-	$sql.= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid";
-	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-	$sql.= ", ".MAIN_DB_PREFIX."propal as p";
-	$sql.= ", ".MAIN_DB_PREFIX."c_propalst as c";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE p.fk_soc = s.rowid";
-	$sql.= " AND p.fk_statut = c.id";
-	$sql.= " AND p.fk_statut = 1";
-	$sql.= " AND p.entity IN (".getEntity('propal').")";
-	if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	if ($socid) $sql.= " AND s.rowid = ".$socid;
-	$sql.= " ORDER BY p.rowid DESC";
-	$sql.= $db->plimit(5, 0);
-
-	$resql=$db->query($sql);
+	$sql .= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid";
+	$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+	$sql .= ", ".MAIN_DB_PREFIX."propal as p";
+	$sql .= ", ".MAIN_DB_PREFIX."c_propalst as c";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE p.fk_soc = s.rowid";
+	$sql .= " AND p.fk_statut = c.id";
+	$sql .= " AND p.fk_statut = 1";
+	$sql .= " AND p.entity IN (".getEntity('propal').")";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	if ($socid) $sql .= " AND s.rowid = ".$socid;
+	$sql .= " ORDER BY p.rowid DESC";
+	$sql .= $db->plimit(5, 0);
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$total = 0;
@@ -205,10 +205,10 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
 				print img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'</a></td>';
 
 				print "<td>";
-                $companystatic->id=$obj->socid;
-                $companystatic->name=$obj->name;
-                $companystatic->client=$obj->client;
-                $companystatic->canvas=$obj->canvas;
+                $companystatic->id = $obj->socid;
+                $companystatic->name = $obj->name;
+                $companystatic->client = $obj->client;
+                $companystatic->canvas = $obj->canvas;
                 print $companystatic->getNomUrl(1, '', 44);
 				print "</td>\n";
 				print "<td align=\"right\">";
@@ -217,7 +217,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
 				$i++;
 				$total += $obj->price;
 			}
-			if ($total>0)
+			if ($total > 0)
 			{
 				print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td class=\"right\">".price($total)."</td></tr>";
 			}
@@ -235,20 +235,20 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
  *
  */
 $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE s.fk_stcomm = 1";
-$sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " ORDER BY s.tms ASC";
-$sql.= $db->plimit(15, 0);
-
-$resql=$db->query($sql);
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE s.fk_stcomm = 1";
+$sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " ORDER BY s.tms ASC";
+$sql .= $db->plimit(15, 0);
+
+$resql = $db->query($sql);
 if ($resql)
 {
 	$num = $db->num_rows($resql);
 	$i = 0;
-	if ($num > 0 )
+	if ($num > 0)
 	{
 		print '<table class="noborder centpercent">';
 		print '<tr class="liste_titre"><td>'.$langs->trans("ProspectToContact").'</td></tr>';
@@ -258,10 +258,10 @@ if ($resql)
 			$obj = $db->fetch_object($resql);
 
 			print '<tr class="oddeven"><td width="12%">';
-            $companystatic->id=$obj->socid;
-            $companystatic->name=$obj->name;
-            $companystatic->client=$obj->client;
-            $companystatic->canvas=$obj->canvas;
+            $companystatic->id = $obj->socid;
+            $companystatic->name = $obj->name;
+            $companystatic->client = $obj->client;
+            $companystatic->canvas = $obj->canvas;
             print $companystatic->getNomUrl(1, 'prospect', 44);
 			print '</td></tr>';
 			$i++;

+ 35 - 35
htdocs/comm/remise.php

@@ -29,9 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array('companies', 'orders', 'bills'));
 
-$id=GETPOST("id", 'int');
+$id = GETPOST("id", 'int');
 
-$socid = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int');
+$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
 // Security check
 if ($user->socid > 0)
 {
@@ -45,7 +45,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
  * Actions
  */
 
-if (GETPOST('cancel', 'alpha') && ! empty($backtopage))
+if (GETPOST('cancel', 'alpha') && !empty($backtopage))
 {
      header("Location: ".$backtopage);
      exit;
@@ -58,15 +58,15 @@ if (GETPOST('action', 'aZ09') == 'setremise')
 
 	$discount_type = GETPOST('discount_type', 'int');
 
-	if(! empty($discount_type)) {
-		$result=$object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user);
+	if (!empty($discount_type)) {
+		$result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user);
 	} else {
-		$result=$object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user);
+		$result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user);
 	}
 
 	if ($result > 0)
 	{
-	    if (! empty($backtopage))
+	    if (!empty($backtopage))
 	    {
     		header("Location: ".$backtopage);
     		exit;
@@ -88,7 +88,7 @@ if (GETPOST('action', 'aZ09') == 'setremise')
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader();
 
@@ -116,13 +116,13 @@ if ($socid > 0)
 
 	dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), -1, 'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom');
+    dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
 
     print '<div class="fichecenter">';
 
     print '<div class="underbanner clearboth"></div>';
 
-    if (! $isCustomer && ! $isSupplier) {
+    if (!$isCustomer && !$isSupplier) {
     	print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
 
     	dol_fiche_end();
@@ -176,7 +176,7 @@ if ($socid > 0)
 			print '<input type="radio" name="discount_type" id="discount_type_0" checked value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
 		}
 		if ($isSupplier) {
-		    print ' <input type="radio" name="discount_type" id="discount_type_1"'.($isCustomer?'':' checked').' value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
+		    print ' <input type="radio" name="discount_type" id="discount_type_1"'.($isCustomer ? '' : ' checked').' value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
 		}
 		print '</td></tr>';
 	}
@@ -197,7 +197,7 @@ if ($socid > 0)
 
 	print '<div class="center">';
 	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
-    if (! empty($backtopage))
+    if (!empty($backtopage))
     {
         print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
 	    print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
@@ -208,8 +208,8 @@ if ($socid > 0)
 
 	print '<br>';
 
-	if($isCustomer) {
-		if($isSupplier) {
+	if ($isCustomer) {
+		if ($isSupplier) {
 			print '<div class="fichecenter">';
 			print '<div class="fichehalfleft">';
 			print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
@@ -218,15 +218,15 @@ if ($socid > 0)
 		/*
 		 * List log of all customer percent discounts
 		 */
-		$sql  = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
-		$sql.= " u.login, u.rowid as user_id";
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u";
-		$sql.= " WHERE rc.fk_soc = " . $object->id;
-		$sql.= " AND rc.entity = " . $conf->entity;
-		$sql.= " AND u.rowid = rc.fk_user_author";
-		$sql.= " ORDER BY rc.datec DESC";
-
-		$resql=$db->query($sql);
+		$sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
+		$sql .= " u.login, u.rowid as user_id";
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u";
+		$sql .= " WHERE rc.fk_soc = ".$object->id;
+		$sql .= " AND rc.entity = ".$conf->entity;
+		$sql .= " AND u.rowid = rc.fk_user_author";
+		$sql .= " ORDER BY rc.datec DESC";
+
+		$resql = $db->query($sql);
 		if ($resql)
 		{
 			print '<table class="noborder centpercent">';
@@ -266,8 +266,8 @@ if ($socid > 0)
 		}
 	}
 
-	if($isSupplier) {
-		if($isCustomer) {
+	if ($isSupplier) {
+		if ($isCustomer) {
 			print '</div>'; // class="fichehalfleft"
 			print '<div class="fichehalfright">';
 			print '<div class="ficheaddleft">';
@@ -277,15 +277,15 @@ if ($socid > 0)
 		/*
 		 * List log of all supplier percent discounts
 		 */
-		$sql  = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
-		$sql.= " u.login, u.rowid as user_id";
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u";
-		$sql.= " WHERE rc.fk_soc = " . $object->id;
-		$sql.= " AND rc.entity = " . $conf->entity;
-		$sql.= " AND u.rowid = rc.fk_user_author";
-		$sql.= " ORDER BY rc.datec DESC";
-
-		$resql=$db->query($sql);
+		$sql = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
+		$sql .= " u.login, u.rowid as user_id";
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u";
+		$sql .= " WHERE rc.fk_soc = ".$object->id;
+		$sql .= " AND rc.entity = ".$conf->entity;
+		$sql .= " AND u.rowid = rc.fk_user_author";
+		$sql .= " ORDER BY rc.datec DESC";
+
+		$resql = $db->query($sql);
 		if ($resql)
 		{
 			print '<table class="noborder centpercent">';
@@ -324,7 +324,7 @@ if ($socid > 0)
 			dol_print_error($db);
 		}
 
-		if($isCustomer) {
+		if ($isCustomer) {
 			print '</div>'; // class="ficheaddleft"
 			print '</div>'; // class="fichehalfright"
 			print '</div>'; // class="fichecenter"

File diff suppressed because it is too large
+ 277 - 277
htdocs/comm/remx.php


+ 117 - 117
htdocs/commande/index.php

@@ -27,9 +27,9 @@
 
 require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
 require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
-require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
 
 if (!$user->rights->commande->lire) accessforbidden();
 
@@ -42,7 +42,7 @@ $hookmanager->initHooks(array('ordersindex'));
 $langs->loadLangs(array('orders', 'bills'));
 
 // Security check
-$socid=GETPOST('socid', 'int');
+$socid = GETPOST('socid', 'int');
 if ($user->socid > 0)
 {
 	$action = '';
@@ -55,11 +55,11 @@ if ($user->socid > 0)
  * View
  */
 
-$commandestatic=new Commande($db);
-$companystatic=new Societe($db);
+$commandestatic = new Commande($db);
+$companystatic = new Societe($db);
 $form = new Form($db);
 $formfile = new FormFile($db);
-$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
+$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
 
 llxHeader("", $langs->trans("Orders"), $help_url);
 
@@ -69,10 +69,10 @@ print load_fiche_titre($langs->trans("OrdersArea"), '', 'commercial');
 
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
 {
     // Search customer orders
-    $var=false;
+    $var = false;
     print '<form method="post" action="'.DOL_URL_ROOT.'/commande/list.php">';
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     print '<div class="div-table-responsive-no-min">';
@@ -89,14 +89,14 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
  */
 
 $sql = "SELECT count(c.rowid), c.fk_statut";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-$sql.= ", ".MAIN_DB_PREFIX."commande as c";
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE c.fk_soc = s.rowid";
-$sql.= " AND c.entity IN (".getEntity('societe').")";
-if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid;
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " GROUP BY c.fk_statut";
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+$sql .= ", ".MAIN_DB_PREFIX."commande as c";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE c.fk_soc = s.rowid";
+$sql .= " AND c.entity IN (".getEntity('societe').")";
+if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid;
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " GROUP BY c.fk_statut";
 
 $resql = $db->query($sql);
 if ($resql)
@@ -104,10 +104,10 @@ if ($resql)
     $num = $db->num_rows($resql);
     $i = 0;
 
-    $total=0;
-    $totalinprocess=0;
-    $dataseries=array();
-    $vals=array();
+    $total = 0;
+    $totalinprocess = 0;
+    $dataseries = array();
+    $vals = array();
     // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not)
     while ($i < $num)
     {
@@ -145,7 +145,7 @@ if ($resql)
         $dolgraph->SetType(array('pie'));
         $dolgraph->setWidth('100%');
         $dolgraph->draw('idgraphstatus');
-        print $dolgraph->show($total?0:1);
+        print $dolgraph->show($total ? 0 : 1);
 
         print '</td></tr>';
     }
@@ -155,7 +155,7 @@ if ($resql)
 	    {
         	print '<tr class="oddeven">';
             print '<td>'.$commandestatic->LibStatut($status, $bool, 0).'</td>';
-            print '<td class="right"><a href="list.php?viewstatut='.$status.'">'.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' ';
+            print '<td class="right"><a href="list.php?viewstatut='.$status.'">'.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' ';
             print $commandestatic->LibStatut($status, $bool, 3);
             print '</a>';
             print '</td>';
@@ -175,22 +175,22 @@ else
 /*
  * Draft orders
  */
-if (! empty($conf->commande->enabled))
+if (!empty($conf->commande->enabled))
 {
 	$sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
-    $sql.= ", s.client";
-    $sql.= ", s.code_client";
-    $sql.= ", s.canvas";
-	$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE c.fk_soc = s.rowid";
-	$sql.= " AND c.entity IN (".getEntity('commande').")";
-	$sql.= " AND c.fk_statut = 0";
-	if ($socid) $sql.= " AND c.fk_soc = ".$socid;
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-
-	$resql=$db->query($sql);
+    $sql .= ", s.client";
+    $sql .= ", s.code_client";
+    $sql .= ", s.canvas";
+	$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE c.fk_soc = s.rowid";
+	$sql .= " AND c.entity IN (".getEntity('commande').")";
+	$sql .= " AND c.fk_statut = 0";
+	if ($socid) $sql .= " AND c.fk_soc = ".$socid;
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
         print '<div class="div-table-responsive-no-min">';
@@ -207,14 +207,14 @@ if (! empty($conf->commande->enabled))
 			{
 				$obj = $db->fetch_object($resql);
 
-                $commandestatic->id=$obj->rowid;
-                $commandestatic->ref=$obj->ref;
+                $commandestatic->id = $obj->rowid;
+                $commandestatic->ref = $obj->ref;
 
-				$companystatic->id=$obj->socid;
-				$companystatic->name=$obj->name;
-				$companystatic->client=$obj->client;
-				$companystatic->code_client=$obj->code_client;
-				$companystatic->canvas=$obj->canvas;
+				$companystatic->id = $obj->socid;
+				$companystatic->name = $obj->name;
+				$companystatic->client = $obj->client;
+				$companystatic->code_client = $obj->code_client;
+				$companystatic->canvas = $obj->canvas;
 
 				print '<tr class="oddeven">';
 				print '<td class="nowrap">';
@@ -238,29 +238,29 @@ if (! empty($conf->commande->enabled))
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
 
-$max=5;
+$max = 5;
 
 /*
  * Last modified orders
  */
 
 $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,";
-$sql.= " s.nom as name, s.rowid as socid";
-$sql.= ", s.client";
-$sql.= ", s.code_client";
-$sql.= ", s.canvas";
-$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
-$sql.= " ".MAIN_DB_PREFIX."societe as s";
-if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE c.fk_soc = s.rowid";
-$sql.= " AND c.entity IN (".getEntity('commande').")";
+$sql .= " s.nom as name, s.rowid as socid";
+$sql .= ", s.client";
+$sql .= ", s.code_client";
+$sql .= ", s.canvas";
+$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
+$sql .= " ".MAIN_DB_PREFIX."societe as s";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE c.fk_soc = s.rowid";
+$sql .= " AND c.entity IN (".getEntity('commande').")";
 //$sql.= " AND c.fk_statut > 2";
 if ($socid) $sql .= " AND c.fk_soc = ".$socid;
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " ORDER BY c.tms DESC";
-$sql.= $db->plimit($max, 0);
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " ORDER BY c.tms DESC";
+$sql .= $db->plimit($max, 0);
 
-$resql=$db->query($sql);
+$resql = $db->query($sql);
 if ($resql)
 {
     print '<div class="div-table-responsive-no-min">';
@@ -280,14 +280,14 @@ if ($resql)
 			print '<tr class="oddeven">';
 			print '<td width="20%" class="nowrap">';
 
-			$commandestatic->id=$obj->rowid;
-			$commandestatic->ref=$obj->ref;
+			$commandestatic->id = $obj->rowid;
+			$commandestatic->ref = $obj->ref;
 
-			$companystatic->id=$obj->socid;
-			$companystatic->name=$obj->name;
-			$companystatic->client=$obj->client;
-			$companystatic->code_client=$obj->code_client;
-			$companystatic->canvas=$obj->canvas;
+			$companystatic->id = $obj->socid;
+			$companystatic->name = $obj->name;
+			$companystatic->client = $obj->client;
+			$companystatic->code_client = $obj->code_client;
+			$companystatic->canvas = $obj->canvas;
 
 			print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 			print '<td width="96" class="nobordernopadding nowrap">';
@@ -299,9 +299,9 @@ if ($resql)
 			print '</td>';
 
 			print '<td width="16" class="nobordernopadding hideonsmartphone right">';
-			$filename=dol_sanitizeFileName($obj->ref);
-			$filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
-			$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
+			$filename = dol_sanitizeFileName($obj->ref);
+			$filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+			$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
 			print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
 			print '</td></tr></table>';
 
@@ -324,23 +324,23 @@ else dol_print_error($db);
 /*
  * Orders to process
  */
-if (! empty($conf->commande->enabled))
+if (!empty($conf->commande->enabled))
 {
 	$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
-    $sql.= ", s.client";
-    $sql.= ", s.code_client";
-    $sql.= ", s.canvas";
-	$sql.=" FROM ".MAIN_DB_PREFIX."commande as c";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE c.fk_soc = s.rowid";
-	$sql.= " AND c.entity IN (".getEntity('commande').")";
-	$sql.= " AND c.fk_statut = 1";
-	if ($socid) $sql.= " AND c.fk_soc = ".$socid;
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	$sql.= " ORDER BY c.rowid DESC";
-
-	$resql=$db->query($sql);
+    $sql .= ", s.client";
+    $sql .= ", s.code_client";
+    $sql .= ", s.canvas";
+	$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE c.fk_soc = s.rowid";
+	$sql .= " AND c.entity IN (".getEntity('commande').")";
+	$sql .= " AND c.fk_statut = 1";
+	if ($socid) $sql .= " AND c.fk_soc = ".$socid;
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	$sql .= " ORDER BY c.rowid DESC";
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
@@ -359,14 +359,14 @@ if (! empty($conf->commande->enabled))
 				print '<tr class="oddeven">';
 				print '<td class="nowrap" width="20%">';
 
-				$commandestatic->id=$obj->rowid;
-				$commandestatic->ref=$obj->ref;
+				$commandestatic->id = $obj->rowid;
+				$commandestatic->ref = $obj->ref;
 
-				$companystatic->id=$obj->socid;
-				$companystatic->name=$obj->name;
-				$companystatic->client=$obj->client;
-				$companystatic->code_client=$obj->code_client;
-				$companystatic->canvas=$obj->canvas;
+				$companystatic->id = $obj->socid;
+				$companystatic->name = $obj->name;
+				$companystatic->client = $obj->client;
+				$companystatic->code_client = $obj->code_client;
+				$companystatic->canvas = $obj->canvas;
 
 				print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 				print '<td width="96" class="nobordernopadding nowrap">';
@@ -378,9 +378,9 @@ if (! empty($conf->commande->enabled))
 				print '</td>';
 
 				print '<td width="16" class="nobordernopadding hideonsmartphone right">';
-				$filename=dol_sanitizeFileName($obj->ref);
-				$filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
-				$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
+				$filename = dol_sanitizeFileName($obj->ref);
+				$filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+				$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
 				print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
 				print '</td></tr></table>';
 
@@ -405,23 +405,23 @@ if (! empty($conf->commande->enabled))
 /*
  * Orders thar are in a shipping process
  */
-if (! empty($conf->commande->enabled))
+if (!empty($conf->commande->enabled))
 {
 	$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
-    $sql.= ", s.client";
-    $sql.= ", s.code_client";
-    $sql.= ", s.canvas";
-	$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE c.fk_soc = s.rowid";
-	$sql.= " AND c.entity IN (".getEntity('commande').")";
-	$sql.= " AND c.fk_statut = 2 ";
-	if ($socid) $sql.= " AND c.fk_soc = ".$socid;
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	$sql.= " ORDER BY c.rowid DESC";
-
-	$resql=$db->query($sql);
+    $sql .= ", s.client";
+    $sql .= ", s.code_client";
+    $sql .= ", s.canvas";
+	$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE c.fk_soc = s.rowid";
+	$sql .= " AND c.entity IN (".getEntity('commande').")";
+	$sql .= " AND c.fk_statut = 2 ";
+	if ($socid) $sql .= " AND c.fk_soc = ".$socid;
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	$sql .= " ORDER BY c.rowid DESC";
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
@@ -441,14 +441,14 @@ if (! empty($conf->commande->enabled))
 				print '<tr class="oddeven">';
 				print '<td width="20%" class="nowrap">';
 
-				$commandestatic->id=$obj->rowid;
-				$commandestatic->ref=$obj->ref;
+				$commandestatic->id = $obj->rowid;
+				$commandestatic->ref = $obj->ref;
 
-				$companystatic->id=$obj->socid;
-				$companystatic->name=$obj->name;
-				$companystatic->client=$obj->client;
-				$companystatic->code_client=$obj->code_client;
-				$companystatic->canvas=$obj->canvas;
+				$companystatic->id = $obj->socid;
+				$companystatic->name = $obj->name;
+				$companystatic->client = $obj->client;
+				$companystatic->code_client = $obj->code_client;
+				$companystatic->canvas = $obj->canvas;
 
 				print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 				print '<td width="96" class="nobordernopadding nowrap">';
@@ -460,9 +460,9 @@ if (! empty($conf->commande->enabled))
 				print '</td>';
 
 				print '<td width="16" class="nobordernopadding hideonsmartphone right">';
-				$filename=dol_sanitizeFileName($obj->ref);
-				$filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
-				$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
+				$filename = dol_sanitizeFileName($obj->ref);
+				$filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
+				$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
 				print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
 				print '</td></tr></table>';
 

+ 16 - 16
htdocs/compta/bank/account_statement_document.php

@@ -26,13 +26,13 @@
  * 	\brief      Page de gestion des documents attaches a un compte bancaire
  */
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php";
-require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
-require_once DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php";
-require_once DOL_DOCUMENT_ROOT . "/core/class/html.formfile.class.php";
-require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
+require_once DOL_DOCUMENT_ROOT."/core/lib/bank.lib.php";
+require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
+require_once DOL_DOCUMENT_ROOT."/core/lib/images.lib.php";
+require_once DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php";
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
 
-global $conf,$db,$langs;
+global $conf, $db, $langs;
 // Load translation files required by the page
 $langs->loadLangs(array('banks', 'companies', 'other'));
 
@@ -70,7 +70,7 @@ if (!$sortfield)
 	$sortfield = "name";
 
 $object = new Account($db);
-if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref);
+if ($id > 0 || !empty($ref)) $object->fetch($id, $ref);
 
 $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', '');
 
@@ -82,10 +82,10 @@ $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', '');
 if (!empty($num))
 {
 	$object->fetch_thirdparty();
-	$upload_dir = $conf->bank->dir_output . "/".$id."/statement/" . dol_sanitizeFileName($num);
+	$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num);
 }
 $backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$num;
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
+include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
 
 
 /*
@@ -100,7 +100,7 @@ $form = new Form($db);
 
 if ($id > 0 || !empty($ref)) {
 	if ($object->fetch($id, $ref)) {
-		$upload_dir = $conf->bank->dir_output . "/".$id."/statement/" . dol_sanitizeFileName($num);
+		$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num);
 
 		// Onglets
 		$head = account_statement_prepare_head($object, $num);
@@ -111,13 +111,13 @@ if ($id > 0 || !empty($ref)) {
 		$filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
 		$totalsize = 0;
 		foreach ($filearray as $key => $file) {
-			$totalsize+=$file['size'];
+			$totalsize += $file['size'];
 		}
 
 		$morehtmlref = '';
 
 
-		$title=$langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
+		$title = $langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
 		print load_fiche_titre($title, '', 'title_bank.png');
 
 
@@ -125,8 +125,8 @@ if ($id > 0 || !empty($ref)) {
 		print '<div class="underbanner clearboth"></div>';
 
 		print '<table class="border tableforfield centpercent">';
-		print '<tr><td class="titlefield">' . $langs->trans("NbOfAttachedFiles") . '</td><td colspan="3">' . count($filearray) . '</td></tr>';
-		print '<tr><td>' . $langs->trans("TotalSizeOfAttachedFiles") . '</td><td colspan="3">' .dol_print_size($totalsize, 1, 1).'</td></tr>';
+		print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
+		print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
 		print "</table>\n";
 
 		print '</div>';
@@ -137,10 +137,10 @@ if ($id > 0 || !empty($ref)) {
 		$modulepart = 'bank';
 		$permission = $user->rights->banque->modifier;
 		$permtoedit = $user->rights->banque->modifier;
-		$param = '&id=' . $object->id.'&num='.$num;
+		$param = '&id='.$object->id.'&num='.$num;
 		$uri = '&num='.$num;
 		$relativepathwithnofile = $id."/statement/".$num."/";
-		include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
+		include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
 	}
 	else {
 		dol_print_error($db);

+ 117 - 117
htdocs/compta/bank/card.php

@@ -29,28 +29,28 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
-if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
-if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
+if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("banks","bills","categories","companies","compta"));
+$langs->loadLangs(array("banks", "bills", "categories", "companies", "compta"));
 
 $action = GETPOST('action', 'aZ09');
 $cancel = GETPOST('cancel', 'alpha');
 
 // Security check
-$id = GETPOST("id", 'int') ? GETPOST("id", 'int'): GETPOST('ref', 'alpha');
+$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
 $fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid';
 
-$result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
+$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
 
 $object = new Account($db);
 $extrafields = new ExtraFields($db);
@@ -59,17 +59,17 @@ $extrafields = new ExtraFields($db);
 $extrafields->fetch_name_optionals_label($object->table_element);
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('bankcard','globalcard'));
+$hookmanager->initHooks(array('bankcard', 'globalcard'));
 
 /*
  * Actions
  */
 
-if ($cancel) $action='';
+if ($cancel) $action = '';
 
 if ($action == 'add')
 {
-	$error=0;
+	$error = 0;
 
 	$db->begin();
 
@@ -92,10 +92,10 @@ if ($action == 'add')
 	$object->iban            = trim($_POST["iban"]);
 	$object->domiciliation   = trim(GETPOST("domiciliation", "nohtml"));
 
-	$object->proprio 	     = trim(GETPOST("proprio", 'alphanohtml'));
+	$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
 	$object->owner_address   = trim(GETPOST("owner_address", 'nohtml'));
 
-	$account_number 		 = GETPOST('account_number', 'alphanohtml');
+	$account_number = GETPOST('account_number', 'alphanohtml');
 	if (empty($account_number) || $account_number == '-1')
 	{
 		$object->account_number = '';
@@ -124,26 +124,26 @@ if ($action == 'add')
 	if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
 	{
 		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
-		$action='create';       // Force chargement page en mode creation
+		$action = 'create'; // Force chargement page en mode creation
 		$error++;
 	}
 	if (empty($object->ref))
 	{
 		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
-		$action='create';       // Force chargement page en mode creation
+		$action = 'create'; // Force chargement page en mode creation
 		$error++;
 	}
 	if (empty($object->label))
 	{
 		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
-		$action='create';       // Force chargement page en mode creation
+		$action = 'create'; // Force chargement page en mode creation
 		$error++;
 	}
 
 	// Fill array 'array_options' with data from add form
 	$ret = $extrafields->setOptionalsFromPost(null, $object);
 
-	if (! $error)
+	if (!$error)
 	{
 		$id = $object->create($user);
 		if ($id > 0)
@@ -152,19 +152,19 @@ if ($action == 'add')
 			$categories = GETPOST('categories', 'array');
 			$object->setCategories($categories);
 
-			$_GET["id"]=$id;            // Force chargement page en mode visu
+			$_GET["id"] = $id; // Force chargement page en mode visu
 
-			$action='';
+			$action = '';
 		}
 		else {
 			$error++;
 			setEventMessages($object->error, $object->errors, 'errors');
 
-			$action='create';   // Force chargement page en mode creation
+			$action = 'create'; // Force chargement page en mode creation
 		}
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 	}
@@ -176,7 +176,7 @@ if ($action == 'add')
 
 if ($action == 'update')
 {
-	$error=0;
+	$error = 0;
 
 	// Update account
 	$object = new Account($db);
@@ -198,10 +198,10 @@ if ($action == 'update')
 	$object->iban            = trim($_POST["iban"]);
 	$object->domiciliation   = trim(GETPOST("domiciliation", "nohtml"));
 
-	$object->proprio 	     = trim(GETPOST("proprio", 'alphanohtml'));
+	$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
 	$object->owner_address   = trim(GETPOST("owner_address", 'nohtml'));
 
-	$account_number 		 = GETPOST('account_number', 'alpha');
+	$account_number = GETPOST('account_number', 'alpha');
 	if (empty($account_number) || $account_number == '-1')
 	{
 		$object->account_number = '';
@@ -225,31 +225,31 @@ if ($action == 'update')
 	if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
 	{
 		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
-		$action='edit';       // Force chargement page en mode creation
+		$action = 'edit'; // Force chargement page en mode creation
 		$error++;
 	}
 	if (empty($object->ref))
 	{
 		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
-		$action='edit';       // Force chargement page en mode creation
+		$action = 'edit'; // Force chargement page en mode creation
 		$error++;
 	}
 	if (empty($object->label))
 	{
 		setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
-		$action='edit';       // Force chargement page en mode creation
+		$action = 'edit'; // Force chargement page en mode creation
 		$error++;
 	}
 
 	$db->begin();
 
-	if (! $error)
+	if (!$error)
 	{
 		// Fill array 'array_options' with data from add form
 		$ret = $extrafields->setOptionalsFromPost(null, $object);
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$result = $object->update($user);
 		if ($result >= 0)
@@ -258,17 +258,17 @@ if ($action == 'update')
 			$categories = GETPOST('categories', 'array');
 			$object->setCategories($categories);
 
-			$_GET["id"]=$_POST["id"];   // Force chargement page en mode visu
+			$_GET["id"] = $_POST["id"]; // Force chargement page en mode visu
 		}
 		else
 		{
 			$error++;
 			setEventMessages($object->error, $object->errors, 'errors');
-			$action='edit';     // Force chargement page edition
+			$action = 'edit'; // Force chargement page edition
 		}
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 	}
@@ -294,7 +294,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
 	else
 	{
 		setEventMessages($object->error, $object->errors, 'errors');
-		$action='';
+		$action = '';
 	}
 }
 
@@ -306,11 +306,11 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
 $form = new Form($db);
 $formbank = new FormBank($db);
 $formcompany = new FormCompany($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
+if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
 
-$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
+$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
 
-$title = $langs->trans("FinancialAccount") . " - " . $langs->trans("Card");
+$title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card");
 $helpurl = "";
 llxHeader("", $title, $helpurl);
 
@@ -319,7 +319,7 @@ llxHeader("", $title, $helpurl);
 
 if ($action == 'create')
 {
-	$object=new Account($db);
+	$object = new Account($db);
 
 	print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png');
 
@@ -350,7 +350,7 @@ if ($action == 'create')
 
 	// Ref
 	print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
-	print '<td><input size="8" type="text" class="flat" name="ref" value="'.dol_escape_htmltag(GETPOST("ref")?GETPOST("ref", 'alpha'):$object->ref).'" maxlength="12" autofocus></td></tr>';
+	print '<td><input size="8" type="text" class="flat" name="ref" value="'.dol_escape_htmltag(GETPOST("ref") ?GETPOST("ref", 'alpha') : $object->ref).'" maxlength="12" autofocus></td></tr>';
 
 	// Label
 	print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
@@ -359,15 +359,15 @@ if ($action == 'create')
 	// Type
 	print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
 	print '<td>';
-	$formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]: Account::TYPE_CURRENT, "type");
+	$formbank->selectTypeOfBankAccount(isset($_POST["type"]) ? $_POST["type"] : Account::TYPE_CURRENT, "type");
 	print '</td></tr>';
 
 	// Currency
 	print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
 	print '<td>';
-	$selectedcode=$object->currency_code;
-	if (! $selectedcode) $selectedcode=$conf->currency;
-	print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code');
+	$selectedcode = $object->currency_code;
+	if (!$selectedcode) $selectedcode = $conf->currency;
+	print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code');
 	//print $langs->trans("Currency".$conf->currency);
 	//print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
 	print '</td></tr>';
@@ -375,17 +375,17 @@ if ($action == 'create')
 	// Status
 	print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
 	print '<td>';
-	print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int')!=''?GETPOST("clos", 'int'):$object->clos));
+	print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int') != '' ?GETPOST("clos", 'int') : $object->clos));
 	print '</td></tr>';
 
 	// Country
-	$selectedcode='';
+	$selectedcode = '';
 	if (isset($_POST["account_country_id"]))
 	{
-		$selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$object->country_code;
+		$selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code;
 	}
-	elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code;
-	$object->country_code = getCountry($selectedcode, 2);	// Force country code on account to have following field on bank fields matching country rules
+	elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code;
+	$object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
 
 	print '<tr><td class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
 	print '<td>';
@@ -397,7 +397,7 @@ if ($action == 'create')
 	print '<tr><td>'.$langs->trans('State').'</td><td>';
 	if ($selectedcode)
 	{
-		$formcompany->select_departement(isset($_POST["account_state_id"])?$_POST["account_state_id"]:'', $selectedcode, 'account_state_id');
+		$formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id');
 	}
 	else
 	{
@@ -420,7 +420,7 @@ if ($action == 'create')
 		$cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT);
 		if (is_array($cats))
 		{
-			foreach($cats as $cat) {
+			foreach ($cats as $cat) {
 				$arrayselected[] = $cat->id;
 			}
 		}
@@ -433,13 +433,13 @@ if ($action == 'create')
 	print '<td>';
 	// Editor wysiwyg
 	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-	$doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%');
+	$doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%');
 	$doleditor->Create();
 	print '</td></tr>';
 
 	// Other attributes
-	$parameters=array();
-	$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
+	$parameters = array();
+	$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 	print $hookmanager->resPrint;
 	if (empty($reshook))
 	{
@@ -454,7 +454,7 @@ if ($action == 'create')
 
 	// Sold
 	print '<tr><td class="titlefieldcreate">'.$langs->trans("InitialBankBalance").'</td>';
-	print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde")?GETPOST("solde"):price2num($object->solde)).'"></td></tr>';
+	print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde") ?GETPOST("solde") : price2num($object->solde)).'"></td></tr>';
 
 	print '<tr><td>'.$langs->trans("Date").'</td>';
 	print '<td>';
@@ -462,10 +462,10 @@ if ($action == 'create')
 	print '</td></tr>';
 
 	print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
-	print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed")?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
+	print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed") ?GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
 
 	print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
-	print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired")?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
+	print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired") ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
 
 	print '</table>';
 	print '<br>';
@@ -476,7 +476,7 @@ if ($action == 'create')
 
 		// If bank account
 		print '<tr><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
-		print '<td><input size="30" type="text" class="flat" name="bank" value="'.(GETPOST('bank')?GETPOST('bank', 'alpha'):$object->bank).'"></td>';
+		print '<td><input size="30" type="text" class="flat" name="bank" value="'.(GETPOST('bank') ?GETPOST('bank', 'alpha') : $object->bank).'"></td>';
 		print '</tr>';
 
 		// Show fields of bank account
@@ -500,32 +500,32 @@ if ($action == 'create')
 			}
 
 			print '<td>'.$langs->trans($val).'</td>';
-			print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.(GETPOST($name)?GETPOST($name, 'alpha'):$content).'"></td>';
+			print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.(GETPOST($name) ?GETPOST($name, 'alpha') : $content).'"></td>';
 			print '</tr>';
 		}
 		$ibankey = FormBank::getIBANLabel($object);
-		$bickey="BICNumber";
-		if ($object->getCountryCode() == 'IN') $bickey="SWIFT";
+		$bickey = "BICNumber";
+		if ($object->getCountryCode() == 'IN') $bickey = "SWIFT";
 
 		// IBAN
 		print '<tr><td>'.$langs->trans($ibankey).'</td>';
-		print '<td><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOST('iban')?GETPOST('iban', 'alpha'):$object->iban).'"></td></tr>';
+		print '<td><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOST('iban') ?GETPOST('iban', 'alpha') : $object->iban).'"></td></tr>';
 
 		print '<tr><td>'.$langs->trans($bickey).'</td>';
-		print '<td><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOST('bic')?GETPOST('bic', 'alpha'):$object->bic).'"></td></tr>';
+		print '<td><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOST('bic') ?GETPOST('bic', 'alpha') : $object->bic).'"></td></tr>';
 
 		print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
 		print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";
-		print (GETPOST('domiciliation')?GETPOST('domiciliation'):$object->domiciliation);
+		print (GETPOST('domiciliation') ?GETPOST('domiciliation') : $object->domiciliation);
 		print "</textarea></td></tr>";
 
 		print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
-		print '<td><input size="30" type="text" class="flat" name="proprio" value="'.(GETPOST('proprio')?GETPOST('proprio', 'alpha'):$object->proprio).'">';
+		print '<td><input size="30" type="text" class="flat" name="proprio" value="'.(GETPOST('proprio') ?GETPOST('proprio', 'alpha') : $object->proprio).'">';
 		print '</td></tr>';
 
 		print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
 		print "<textarea class=\"flat\" name=\"owner_address\" rows=\"2\" cols=\"40\">";
-		print (GETPOST('owner_address')?GETPOST('owner_address', 'alpha'):$object->owner_address);
+		print (GETPOST('owner_address') ?GETPOST('owner_address', 'alpha') : $object->owner_address);
 		print "</textarea></td></tr>";
 
 		print '</table>';
@@ -534,10 +534,10 @@ if ($action == 'create')
 
 	print '<table class="border centpercent">';
 	// Accountancy code
-	$fieldrequired='';
-	if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
+	$fieldrequired = '';
+	if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired = 'fieldrequired ';
 
-	if (! empty($conf->accounting->enabled))
+	if (!empty($conf->accounting->enabled))
 	{
 		print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
 		print '<td>';
@@ -547,11 +547,11 @@ if ($action == 'create')
 	else
 	{
 		print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
-		print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number', 'alpha'):$object->account_number).'"></td></tr>';
+		print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number") ?GETPOST('account_number', 'alpha') : $object->account_number).'"></td></tr>';
 	}
 
 	// Accountancy journal
-	if (! empty($conf->accounting->enabled))
+	if (!empty($conf->accounting->enabled))
 	{
 		print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
 		print '<td>';
@@ -564,9 +564,9 @@ if ($action == 'create')
 	dol_fiche_end();
 
 	print '<div class="center">';
-	print '<input type="submit" class="button" value="' . $langs->trans("CreateAccount") . '">';
+	print '<input type="submit" class="button" value="'.$langs->trans("CreateAccount").'">';
 	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-	print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
+	print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
 	print '</div>';
 
 	print '</form>';
@@ -588,11 +588,11 @@ else
 		if ($_GET["ref"])
 		{
 			$object->fetch(0, $_GET["ref"]);
-			$_GET["id"]=$object->id;
+			$_GET["id"] = $object->id;
 		}
 
 		// Show tabs
-		$head=bank_prepare_head($object);
+		$head = bank_prepare_head($object);
 		dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account');
 
 		$formconfirm = '';
@@ -608,7 +608,7 @@ else
 
 		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
-		$morehtmlref='';
+		$morehtmlref = '';
 		dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
 
 
@@ -625,18 +625,18 @@ else
 		// Currency
 		print '<tr><td>'.$langs->trans("Currency").'</td>';
 		print '<td>';
-		$selectedcode=$object->currency_code;
-		if (! $selectedcode) $selectedcode=$conf->currency;
+		$selectedcode = $object->currency_code;
+		if (!$selectedcode) $selectedcode = $conf->currency;
 		print $langs->trans("Currency".$selectedcode);
 		print '</td></tr>';
 
 		// Conciliate
 		print '<tr><td>'.$langs->trans("Conciliable").'</td>';
 		print '<td>';
-		$conciliate=$object->canBeConciliated();
+		$conciliate = $object->canBeConciliated();
 		if ($conciliate == -2) print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("CashAccount").')</span>';
 		elseif ($conciliate == -3) print $langs->trans("No").' <span class="opacitymedium">('.$langs->trans("Closed").')</span>';
-		else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' <span class="opacitymedium">('.$langs->trans("ConciliationDisabled").')</span>'));
+		else print ($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' <span class="opacitymedium">('.$langs->trans("ConciliationDisabled").')</span>'));
 		print '</td></tr>';
 
 		print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
@@ -648,7 +648,7 @@ else
 		// Accountancy code
 		print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
 		print '<td>';
-		if (! empty($conf->accounting->enabled)) {
+		if (!empty($conf->accounting->enabled)) {
 			$accountingaccount = new AccountingAccount($db);
 			$accountingaccount->fetch('', $object->account_number, 1);
 
@@ -659,7 +659,7 @@ else
 		print '</td></tr>';
 
 		// Accountancy journal
-		if (! empty($conf->accounting->enabled))
+		if (!empty($conf->accounting->enabled))
 		{
 			print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
 			print '<td>';
@@ -675,7 +675,7 @@ else
 
 		// Other attributes
 		$cols = 2;
-		include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
 
 		print '</table>';
 
@@ -725,13 +725,13 @@ else
 			}
 
 			$ibankey = FormBank::getIBANLabel($object);
-			$bickey="BICNumber";
-			if ($object->getCountryCode() == 'IN') $bickey="SWIFT";
+			$bickey = "BICNumber";
+			if ($object->getCountryCode() == 'IN') $bickey = "SWIFT";
 
 			print '<tr><td>'.$langs->trans($ibankey).'</td>';
 			print '<td>'.$object->iban.'&nbsp;';
-			if (! empty($object->iban)) {
-				if (! checkIbanForAccount($object)) {
+			if (!empty($object->iban)) {
+				if (!checkIbanForAccount($object)) {
 					print img_picto($langs->trans("IbanNotValid"), 'warning');
 				} else {
 					print img_picto($langs->trans("IbanValid"), 'info');
@@ -741,8 +741,8 @@ else
 
 			print '<tr><td>'.$langs->trans($bickey).'</td>';
 			print '<td>'.$object->bic.'&nbsp;';
-			if (! empty($object->bic)) {
-				if (! checkSwiftForAccount($object)) {
+			if (!empty($object->bic)) {
+				if (!checkSwiftForAccount($object)) {
 					print img_picto($langs->trans("SwiftNotValid"), 'warning');
 				} else {
 					print img_picto($langs->trans("SwiftValid"), 'info');
@@ -783,7 +783,7 @@ else
 			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a>';
 		}
 
-		$canbedeleted=$object->can_be_deleted();   // Renvoi vrai si compte sans mouvements
+		$canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements
 		if ($user->rights->banque->configurer && $canbedeleted)
 		{
 			print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
@@ -837,16 +837,16 @@ else
 
 		// Ref
 		print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
-		print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.dol_escape_htmltag(isset($_POST["ref"])?GETPOST("ref"):$object->ref).'"></td></tr>';
+		print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.dol_escape_htmltag(isset($_POST["ref"]) ?GETPOST("ref") : $object->ref).'"></td></tr>';
 
 		// Label
 		print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
-		print '<td><input type="text" class="flat minwidth300" name="label" value="'.dol_escape_htmltag(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
+		print '<td><input type="text" class="flat minwidth300" name="label" value="'.dol_escape_htmltag(isset($_POST["label"]) ?GETPOST("label") : $object->label).'"></td></tr>';
 
 		// Type
 		print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
 		print '<td class="maxwidth200onsmartphone">';
-		$formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type), "type");
+		$formbank->selectTypeOfBankAccount((isset($_POST["type"]) ? $_POST["type"] : $object->type), "type");
 		print '</td></tr>';
 
 		// Currency
@@ -854,9 +854,9 @@ else
 		print '<input type="hidden" value="'.$object->currency_code.'">';
 		print '</td>';
 		print '<td class="maxwidth200onsmartphone">';
-		$selectedcode=$object->currency_code;
-		if (! $selectedcode) $selectedcode=$conf->currency;
-		print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code');
+		$selectedcode = $object->currency_code;
+		if (!$selectedcode) $selectedcode = $conf->currency;
+		print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code');
 		//print $langs->trans("Currency".$conf->currency);
 		//print '<input type="hidden" name="account_currency_code" value="'.$conf->currency.'">';
 		print '</td></tr>';
@@ -864,15 +864,15 @@ else
 		// Status
 		print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
 		print '<td class="maxwidth200onsmartphone">';
-		print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
+		print $form->selectarray("clos", $object->status, (isset($_POST["clos"]) ? $_POST["clos"] : $object->clos));
 		print '</td></tr>';
 
 		// Country
-		$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
-		$selectedcode=$object->country_code;
-		if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"];
-		elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code;
-		$object->country_code = getCountry($selectedcode, 2);	// Force country code on account to have following field on bank fields matching country rules
+		$object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
+		$selectedcode = $object->country_code;
+		if (isset($_POST["account_country_id"])) $selectedcode = $_POST["account_country_id"];
+		elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code;
+		$object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
 
 		print '<tr><td class="fieldrequired">'.$langs->trans("Country").'</td>';
 		print '<td class="maxwidth200onsmartphone">';
@@ -884,7 +884,7 @@ else
 		print '<tr><td>'.$langs->trans('State').'</td><td class="maxwidth200onsmartphone">';
 		if ($selectedcode)
 		{
-			print $formcompany->select_state(isset($_POST["account_state_id"])?$_POST["account_state_id"]:$object->state_id, $selectedcode, 'account_state_id');
+			print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id');
 		}
 		else
 		{
@@ -895,22 +895,22 @@ else
 		// Conciliable
 		print '<tr><td>'.$langs->trans("Conciliable").'</td>';
 		print '<td>';
-		$conciliate=$object->canBeConciliated();
+		$conciliate = $object->canBeConciliated();
 		if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
 		elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
-		else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
+		else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0) ? '' : ' checked="checked"').'"> '.$langs->trans("DisableConciliation");
 		print '</td></tr>';
 
 		// Balance
 		print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
-		print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"])?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
+		print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"]) ?GETPOST("account_min_allowed") : $object->min_allowed).'"></td></tr>';
 
 		print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
-		print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"])?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
+		print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"]) ?GETPOST("account_min_desired") : $object->min_desired).'"></td></tr>';
 
 		// Web
 		print '<tr><td>'.$langs->trans("Web").'</td>';
-		print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
+		print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"]) ?GETPOST("url") : $object->url).'">';
 		print '</td></tr>';
 
 		// Tags-Categories
@@ -935,13 +935,13 @@ else
 		print '<td>';
 		// Editor wysiwyg
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-		$doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%');
+		$doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%');
 		$doleditor->Create();
 		print '</td></tr>';
 
 		// Other attributes
-		$parameters=array();
-		$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
+		$parameters = array();
+		$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 		print $hookmanager->resPrint;
 		if (empty($reshook))
 		{
@@ -973,7 +973,7 @@ else
 		print '</td></tr>';
 
 		// Accountancy journal
-		if (! empty($conf->accounting->enabled))
+		if (!empty($conf->accounting->enabled))
 		{
 			print '<tr><td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>';
 			print '<td>';
@@ -1022,8 +1022,8 @@ else
 			}
 
 			$ibankey = FormBank::getIBANLabel($object);
-			$bickey="BICNumber";
-			if ($object->getCountryCode() == 'IN') $bickey="SWIFT";
+			$bickey = "BICNumber";
+			if ($object->getCountryCode() == 'IN') $bickey = "SWIFT";
 
 			// IBAN
 			print '<tr><td>'.$langs->trans($ibankey).'</td>';

File diff suppressed because it is too large
+ 305 - 305
htdocs/compta/index.php


+ 86 - 86
htdocs/compta/sociales/payments.php

@@ -37,15 +37,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 $langs->loadLangs(array('compta', 'bills'));
 
 // Security check
-if ($user->socid) $socid=$user->socid;
+if ($user->socid) $socid = $user->socid;
 $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|');
 
-$mode=GETPOST("mode", 'alpha');
-$year=GETPOST("year", 'int');
-$filtre=GETPOST("filtre", 'alpha');
-if (! $year && $mode != 'sconly') { $year=date("Y", time()); }
+$mode = GETPOST("mode", 'alpha');
+$year = GETPOST("year", 'int');
+$filtre = GETPOST("filtre", 'alpha');
+if (!$year && $mode != 'sconly') { $year = date("Y", time()); }
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');
@@ -53,8 +53,8 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortfield) $sortfield="pc.datep";
-if (! $sortorder) $sortorder="DESC";
+if (!$sortfield) $sortfield = "pc.datep";
+if (!$sortorder) $sortorder = "DESC";
 
 
 /*
@@ -62,21 +62,21 @@ if (! $sortorder) $sortorder="DESC";
  */
 
 $tva_static = new Tva($db);
-$socialcontrib=new ChargeSociales($db);
-$payment_sc_static=new PaymentSocialContribution($db);
+$socialcontrib = new ChargeSociales($db);
+$payment_sc_static = new PaymentSocialContribution($db);
 $sal_static = new PaymentSalary($db);
 
 llxHeader('', $langs->trans("SpecialExpensesArea"));
 
-$title=$langs->trans("SpecialExpensesArea");
-if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments");
+$title = $langs->trans("SpecialExpensesArea");
+if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments");
 
-$param='';
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
-if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
-if ($mode == 'sconly') $param='&mode=sconly';
-if ($sortfield) $param.='&sortfield='.$sortfield;
-if ($sortorder) $param.='&sortorder='.$sortorder;
+$param = '';
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
+if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
+if ($mode == 'sconly') $param = '&mode=sconly';
+if ($sortfield) $param .= '&sortfield='.$sortfield;
+if ($sortorder) $param .= '&sortorder='.$sortorder;
 
 
 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@@ -90,7 +90,7 @@ print '<input type="hidden" name="mode" value="'.$mode.'">';
 
 if ($mode != 'sconly')
 {
-    $center=($year?'<a href="list.php?year='.($year-1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="list.php?year='.($year+1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>":"");
+    $center = ($year ? '<a href="list.php?year='.($year - 1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="list.php?year='.($year + 1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>" : "");
     print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1);
 }
 else
@@ -98,7 +98,7 @@ else
     print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit);
 }
 
-if ($year) $param.='&year='.$year;
+if ($year) $param .= '&year='.$year;
 
 if ($mode != 'sconly')
 {
@@ -106,12 +106,12 @@ if ($mode != 'sconly')
 	print "<br>";
 }
 
-if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
+if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 {
 	// Social contributions only
 	if ($mode != 'sconly')
 	{
-		print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
+		print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
 	}
 
 	print '<table class="noborder centpercent">';
@@ -127,15 +127,15 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 	print "</tr>\n";
 
 	$sql = "SELECT c.id, c.libelle as type_label,";
-	$sql.= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,";
-	$sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,";
-	$sql.= " pct.code as payment_code";
-	$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
-	$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,";
-	$sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc";
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
-	$sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid";
-	$sql.= " AND cs.entity = ".$conf->entity;
+	$sql .= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,";
+	$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,";
+	$sql .= " pct.code as payment_code";
+	$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
+	$sql .= " ".MAIN_DB_PREFIX."chargesociales as cs,";
+	$sql .= " ".MAIN_DB_PREFIX."paiementcharge as pc";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
+	$sql .= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid";
+	$sql .= " AND cs.entity = ".$conf->entity;
 	if ($year > 0)
 	{
 		$sql .= " AND (";
@@ -145,12 +145,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 		$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
 		$sql .= ")";
 	}
-	if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
+	if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
 	//$sql.= $db->plimit($limit+1,$offset);
 	//print $sql;
 
 	dol_syslog("compta/sociales/payments.php: select payment", LOG_DEBUG);
-	$resql=$db->query($sql);
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
@@ -163,8 +163,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 		{
 			$obj = $db->fetch_object($resql);
 
-			$payment_sc_static->id=$obj->pid;
-			$payment_sc_static->ref=$obj->pid;
+			$payment_sc_static->id = $obj->pid;
+			$payment_sc_static->ref = $obj->pid;
 
 			print '<tr class="oddeven">';
 			// Ref payment
@@ -177,16 +177,16 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
     	    print $obj->num_payment.'</td>';
 			// Label
 			print '<td>';
-			$socialcontrib->id=$obj->rowid;
-			$socialcontrib->ref=$obj->rowid;
-			$socialcontrib->label=$obj->label;
+			$socialcontrib->id = $obj->rowid;
+			$socialcontrib->ref = $obj->rowid;
+			$socialcontrib->label = $obj->label;
 			print $socialcontrib->getNomUrl(1, '20');
 			print '</td>';
 			// Type
 			print '<td><a href="../sociales/list.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->type_label.'</a></td>';
 			// Date
-			$date=$obj->periode;
-			if (empty($date)) $date=$obj->date_ech;
+			$date = $obj->periode;
+			if (empty($date)) $date = $obj->date_ech;
 			print '<td>'.dol_print_date($date, 'day').'</td>';
 			// Expected to pay
 			print '<td class="right">'.price($obj->total).'</td>';
@@ -202,7 +202,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 			$i++;
 		}
 	    print '<tr class="liste_total"><td colspan="3" class="liste_total">'.$langs->trans("Total").'</td>';
-	    print '<td class="liste_total right"></td>';     // A total here has no sense
+	    print '<td class="liste_total right"></td>'; // A total here has no sense
 	    print '<td align="center" class="liste_total">&nbsp;</td>';
 	    print '<td align="center" class="liste_total">&nbsp;</td>';
 	    print '<td align="center" class="liste_total">&nbsp;</td>';
@@ -217,33 +217,33 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 }
 
 // VAT
-if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
+if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 {
-	if (! $mode || $mode != 'sconly')
+	if (!$mode || $mode != 'sconly')
 	{
 		print "<br>";
 
 		$tva = new Tva($db);
 
-		print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
+		print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
 
 		$sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm";
-		$sql.= " FROM ".MAIN_DB_PREFIX."tva as pv";
-		$sql.= " WHERE pv.entity = ".$conf->entity;
+		$sql .= " FROM ".MAIN_DB_PREFIX."tva as pv";
+		$sql .= " WHERE pv.entity = ".$conf->entity;
 		if ($year > 0)
 		{
 			// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
 			// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
-			$sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
+			$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
 		}
-		if (preg_match('/^pv\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
+		if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
 
 		$result = $db->query($sql);
 		if ($result)
 		{
 		    $num = $db->num_rows($result);
 		    $i = 0;
-		    $total = 0 ;
+		    $total = 0;
 		    print '<table class="noborder centpercent">';
 		    print '<tr class="liste_titre">';
 			print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder);
@@ -268,8 +268,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 		        print '<td class="right">'.price($obj->amount)."</td>";
 
 		        // Ref payment
-				$tva_static->id=$obj->rowid;
-				$tva_static->ref=$obj->rowid;
+				$tva_static->id = $obj->rowid;
+				$tva_static->ref = $obj->rowid;
 		        print '<td class="left">'.$tva_static->getNomUrl(1)."</td>\n";
 
 		        print '<td align="center">'.dol_print_date($db->jdate($obj->dm), 'day')."</td>\n";
@@ -296,55 +296,55 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
 }
 
 // Localtax
-if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
+if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
 {
-	$j=1;
-	$numlt=3;
+	$j = 1;
+	$numlt = 3;
 }
-elseif($mysoc->localtax1_assuj=="1")
+elseif ($mysoc->localtax1_assuj == "1")
 {
-	$j=1;
-	$numlt=2;
+	$j = 1;
+	$numlt = 2;
 }
-elseif($mysoc->localtax2_assuj=="1")
+elseif ($mysoc->localtax2_assuj == "1")
 {
-	$j=2;
-	$numlt=3;
+	$j = 2;
+	$numlt = 3;
 }
 else
 {
-	$j=0;
-	$numlt=0;
+	$j = 0;
+	$numlt = 0;
 }
 
-while($j<$numlt)
+while ($j < $numlt)
 {
-	if (! $mode || $mode != 'sconly')
+	if (!$mode || $mode != 'sconly')
 	{
 		print "<br>";
 
 		$tva = new Tva($db);
 
-		print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"), $mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
+		print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
 
 
 		$sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
-		$sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv";
-		$sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ;
+		$sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv";
+		$sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j;
 		if ($year > 0)
 		{
 			// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
 			// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
-			$sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
+			$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
 		}
-		if (preg_match('/^pv/', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
+		if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
 
 		$result = $db->query($sql);
 		if ($result)
 		{
 			$num = $db->num_rows($result);
 			$i = 0;
-			$total = 0 ;
+			$total = 0;
 			print '<table class="noborder centpercent">';
 			print '<tr class="liste_titre">';
 			print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder);
@@ -369,8 +369,8 @@ while($j<$numlt)
 				print '<td class="right">'.price($obj->amount)."</td>";
 
 				// Ref payment
-				$tva_static->id=$obj->rowid;
-				$tva_static->ref=$obj->rowid;
+				$tva_static->id = $obj->rowid;
+				$tva_static->ref = $obj->rowid;
 				print '<td class="left">'.$tva_static->getNomUrl(1)."</td>\n";
 
 				print '<td align="center">'.dol_print_date($db->jdate($obj->dp), 'day')."</td>\n";
@@ -399,33 +399,33 @@ while($j<$numlt)
 
 
 // Payment Salary
-if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
+if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
 {
-    if (! $mode || $mode != 'sconly')
+    if (!$mode || $mode != 'sconly')
     {
         $sal = new PaymentSalary($db);
 
         print "<br>";
 
-        print load_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
+        print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
 
         $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary";
-        $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
-        $sql.= " WHERE s.entity IN (".getEntity('user').")";
-        $sql.= " AND u.rowid = s.fk_user";
+        $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
+        $sql .= " WHERE s.entity IN (".getEntity('user').")";
+        $sql .= " AND u.rowid = s.fk_user";
         if ($year > 0)
         {
-            $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
-            $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')";
+            $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
+            $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')";
         }
-        if (preg_match('/^s\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
+        if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
 
         $result = $db->query($sql);
         if ($result)
         {
             $num = $db->num_rows($result);
             $i = 0;
-            $total = 0 ;
+            $total = 0;
             print '<table class="noborder centpercent">';
             print '<tr class="liste_titre">';
             print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder);
@@ -448,11 +448,11 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
 
                 print "<td>".$obj->label."</td>\n";
 
-                print '<td class="right">'.($obj->salary?price($obj->salary):'')."</td>";
+                print '<td class="right">'.($obj->salary ?price($obj->salary) : '')."</td>";
 
                 // Ref payment
-                $sal_static->id=$obj->rowid;
-                $sal_static->ref=$obj->rowid;
+                $sal_static->id = $obj->rowid;
+                $sal_static->ref = $obj->rowid;
                 print '<td class="left">'.$sal_static->getNomUrl(1)."</td>\n";
 
                 print '<td align="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
@@ -462,7 +462,7 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
                 $i++;
             }
             print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
-            print '<td class="right"></td>';      // A total here has no sense
+            print '<td class="right"></td>'; // A total here has no sense
             print '<td align="center">&nbsp;</td>';
             print '<td align="center">&nbsp;</td>';
             print '<td class="right">'.price($total)."</td>";

File diff suppressed because it is too large
+ 200 - 200
htdocs/contact/card.php


+ 29 - 29
htdocs/core/lib/bank.lib.php

@@ -38,42 +38,42 @@ function bank_prepare_head(Account $object)
     $h = 0;
     $head = array();
 
-    $head[$h][0] = DOL_URL_ROOT . '/compta/bank/card.php?id=' . $object->id;
+    $head[$h][0] = DOL_URL_ROOT.'/compta/bank/card.php?id='.$object->id;
     $head[$h][1] = $langs->trans("Card");
     $head[$h][2] = 'bankname';
     $h++;
 
-    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/bankentries_list.php?id=" . $object->id;
+    $head[$h][0] = DOL_URL_ROOT."/compta/bank/bankentries_list.php?id=".$object->id;
     $head[$h][1] = $langs->trans("BankTransactions");
     $head[$h][2] = 'journal';
     $h++;
 
     //    if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
     //    {
-    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id;
+    $head[$h][0] = DOL_URL_ROOT."/compta/bank/treso.php?account=".$object->id;
     $head[$h][1] = $langs->trans("PlannedTransactions");
     $head[$h][2] = 'cash';
     $h++;
     //    }
 
-    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id;
+    $head[$h][0] = DOL_URL_ROOT."/compta/bank/annuel.php?account=".$object->id;
     $head[$h][1] = $langs->trans("IOMonthlyReporting");
     $head[$h][2] = 'annual';
     $h++;
 
-    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/graph.php?account=" . $object->id;
+    $head[$h][0] = DOL_URL_ROOT."/compta/bank/graph.php?account=".$object->id;
     $head[$h][1] = $langs->trans("Graph");
     $head[$h][2] = 'graph';
     $h++;
 
     if ($object->courant != Account::TYPE_CASH)
     {
-    	$nbReceipts=0;
+    	$nbReceipts = 0;
 
     	// List of all standing receipts
     	$sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb";
-    	$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-    	$sql.= " WHERE b.fk_account = ".$object->id;
+    	$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+    	$sql .= " WHERE b.fk_account = ".$object->id;
 
     	$resql = $db->query($sql);
     	if ($resql)
@@ -85,7 +85,7 @@ function bank_prepare_head(Account $object)
 
     	$head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id;
 	    $head[$h][1] = $langs->trans("AccountStatements");
-	    if (($nbReceipts) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbReceipts).'</span>';
+	    if (($nbReceipts) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbReceipts).'</span>';
 	    $head[$h][2] = 'statement';
 	    $h++;
 	}
@@ -93,12 +93,12 @@ function bank_prepare_head(Account $object)
     // Attached files
     require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-    $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
+    $upload_dir = $conf->bank->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 . "/compta/bank/document.php?account=" . $object->id;
+    $nbLinks = Link::count($db, $object->element, $object->id);
+    $head[$h][0] = DOL_URL_ROOT."/compta/bank/document.php?account=".$object->id;
     $head[$h][1] = $langs->trans("Documents");
-    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
+    if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
     $head[$h][2] = 'document';
     $h++;
 
@@ -129,12 +129,12 @@ function bank_admin_prepare_head($object)
 	$h = 0;
 	$head = array();
 
-	$head[$h][0] = DOL_URL_ROOT . '/admin/bank.php';
+	$head[$h][0] = DOL_URL_ROOT.'/admin/bank.php';
 	$head[$h][1] = $langs->trans("Miscellaneous");
 	$head[$h][2] = 'general';
 	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT . '/admin/chequereceipts.php';
+    $head[$h][0] = DOL_URL_ROOT.'/admin/chequereceipts.php';
     $head[$h][1] = $langs->trans("CheckReceiptShort");
     $head[$h][2] = 'checkreceipts';
     $h++;
@@ -167,11 +167,11 @@ function bank_admin_prepare_head($object)
  */
 function account_statement_prepare_head($object, $num)
 {
-	global $langs, $conf, $user,$db;
+	global $langs, $conf, $user, $db;
 	$h = 0;
 	$head = array();
 
-	$head[$h][0] = DOL_URL_ROOT . '/compta/bank/releve.php?account=' . $object->id.'&num='.$num;
+	$head[$h][0] = DOL_URL_ROOT.'/compta/bank/releve.php?account='.$object->id.'&num='.$num;
 	$head[$h][1] = $langs->trans("AccountStatements");
 	$head[$h][2] = 'statement';
 	$h++;
@@ -179,13 +179,13 @@ function account_statement_prepare_head($object, $num)
 	// Attached files
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-	$upload_dir = $conf->bank->dir_output . "/" . $object->id.'/'.dol_sanitizeFileName($num);
+	$upload_dir = $conf->bank->dir_output."/".$object->id.'/'.dol_sanitizeFileName($num);
 	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
-	$nbLinks=Link::count($db, $object->element, $object->id);
+	$nbLinks = Link::count($db, $object->element, $object->id);
 
-	$head[$h][0] = DOL_URL_ROOT . "/compta/bank/account_statement_document.php?account=" . $object->id."&num=".$num;
+	$head[$h][0] = DOL_URL_ROOT."/compta/bank/account_statement_document.php?account=".$object->id."&num=".$num;
 	$head[$h][1] = $langs->trans("Documents");
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
 	$head[$h][2] = 'document';
 	$h++;
 
@@ -223,12 +223,12 @@ function various_payment_prepare_head($object)
 
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-	$upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
+	$upload_dir = $conf->bank->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);
+    $nbLinks = Link::count($db, $object->element, $object->id);
 	$head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/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>';
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
 	$head[$h][2] = 'documents';
 	$h++;
 
@@ -293,12 +293,12 @@ function checkBanForAccount($account)
     if (empty($account->cle))
         $account->cle = $account->cle_rib;
 
-    dol_syslog("bank.lib::checkBanForAccount account->code_banque=" . $account->code_banque . " account->code_guichet=" . $account->code_guichet . " account->number=" . $account->number . " account->cle=" . $account->cle . " account->iban=" . $account->iban . " country_code=" . $country_code, LOG_DEBUG);
+    dol_syslog("bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG);
 
     if ($country_code == 'FR') { // France rules
         $coef = array(62, 34, 3);
         // Concatenation des differents codes.
-        $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet) . trim($account->number) . trim($account->cle));
+        $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle));
         // On remplace les eventuelles lettres par des chiffres.
         //$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678");	//Ne marche pas
         $rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz", "12345678912345678923456789");
@@ -322,7 +322,7 @@ function checkBanForAccount($account)
 
     if ($country_code == 'ES') { // Spanish rules
         $CCC = strtolower(trim($account->number));
-        $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet));
+        $rib = strtolower(trim($account->code_banque).trim($account->code_guichet));
         $cle_rib = strtolower(checkES($rib, $CCC));
         if ($cle_rib == strtolower($account->cle)) {
             return true;
@@ -364,7 +364,7 @@ function checkES($IentOfi, $InumCta)
         return $keycontrol;
     }
 
-    $ccc = $IentOfi . $InumCta;
+    $ccc = $IentOfi.$InumCta;
     $numbers = "1234567890";
 
     $i = 0;
@@ -396,7 +396,7 @@ function checkES($IentOfi, $InumCta)
     $sum = 0;
 
     for ($i = 0; $i < 11; $i++) {
-        $sum += $values[$i] * (int) substr($InumCta, $i, 1);//int to cast result of substr to a number
+        $sum += $values[$i] * (int) substr($InumCta, $i, 1); //int to cast result of substr to a number
     }
 
     $key = 11 - $sum % 11;

File diff suppressed because it is too large
+ 227 - 227
htdocs/core/lib/company.lib.php


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

@@ -33,39 +33,39 @@
  */
 function show_skin($fuser, $edit = 0)
 {
-    global $conf,$langs,$db;
+    global $conf, $langs, $db;
     global $bc;
 
-	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 
     $formother = new FormOther($db);
 
-    $dirskins=array('/includes/ckeditor/ckeditor/skins');
-    if (! empty($conf->modules_parts['theme']))		// Using this feature slow down application
+    $dirskins = array('/includes/ckeditor/ckeditor/skins');
+    if (!empty($conf->modules_parts['theme']))		// Using this feature slow down application
     {
-    	foreach($conf->modules_parts['theme'] as $reldir)
+    	foreach ($conf->modules_parts['theme'] as $reldir)
     	{
-	    	$dirskins=array_merge($dirskins, (array) ($reldir.'theme'));
+	    	$dirskins = array_merge($dirskins, (array) ($reldir.'theme'));
     	}
     }
-    $dirskins=array_unique($dirskins);
+    $dirskins = array_unique($dirskins);
 	// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
 
-    $selected_theme='';
-    if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme='moono-lisa';
-    else $selected_theme=$conf->global->FCKEDITOR_SKIN;
+    $selected_theme = '';
+    if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme = 'moono-lisa';
+    else $selected_theme = $conf->global->FCKEDITOR_SKIN;
 
-    $colspan=2;
+    $colspan = 2;
 
-    $thumbsbyrow=6;
+    $thumbsbyrow = 6;
     print '<table class="noborder centpercent">';
 
-    $var=false;
+    $var = false;
 
     // Title
    	print '<tr class="liste_titre"><th width="35%">'.$langs->trans("DefaultSkin").'</th>';
    	print '<th class="right">';
-   	$url='http://ckeditor.com/addons/skins/all';
+   	$url = 'http://ckeditor.com/addons/skins/all';
    	/*print '<a href="'.$url.'" target="_blank">';
    	print $langs->trans('DownloadMoreSkins');
    	print '</a>';*/
@@ -74,7 +74,7 @@ function show_skin($fuser, $edit = 0)
 	print '<tr class="oddeven">';
    	print '<td>'.$langs->trans("ThemeDir").'</td>';
    	print '<td>';
-   	foreach($dirskins as $dirskin)
+   	foreach ($dirskins as $dirskin)
    	{
    		echo '"'.$dirskin.'" ';
    	}
@@ -86,22 +86,22 @@ function show_skin($fuser, $edit = 0)
 
     print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
 
-    $i=0;
-    foreach($dirskins as $dir)
+    $i = 0;
+    foreach ($dirskins as $dir)
     {
     	//print $dirroot.$dir;exit;
-    	$dirskin=dol_buildpath($dir, 0);	// This include loop on $conf->file->dol_document_root
-    	$urltheme=dol_buildpath($dir, 1);
+    	$dirskin = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
+    	$urltheme = dol_buildpath($dir, 1);
 
     	if (is_dir($dirskin))
     	{
-    		$handle=opendir($dirskin);
+    		$handle = opendir($dirskin);
     		if (is_resource($handle))
     		{
-    			while (($subdir = readdir($handle))!==false)
+    			while (($subdir = readdir($handle)) !== false)
     			{
     				if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.'
-    						&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i', $subdir))
+    						&& substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir))
     				{
     					// Disable not stable themes (dir ends with _exp or _dev)
     					if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
@@ -110,11 +110,11 @@ function show_skin($fuser, $edit = 0)
     					print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
     					if ($subdir == $selected_theme)
     					{
-    						print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
+    						print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
     					}
     					else
     					{
-    						print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
+    						print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
     					}
 						print '</div>';
 

File diff suppressed because it is too large
+ 248 - 248
htdocs/core/lib/pdf.lib.php


File diff suppressed because it is too large
+ 213 - 213
htdocs/core/lib/project.lib.php


+ 92 - 92
htdocs/core/lib/usergroups.lib.php

@@ -37,10 +37,10 @@ function user_prepare_head($object)
 
 	$langs->load("users");
 
-	$canreadperms=true;
-	if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
+	$canreadperms = true;
+	if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
 	{
-		$canreadperms=($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms));
+		$canreadperms = ($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms));
 	}
 
 	$h = 0;
@@ -51,8 +51,8 @@ function user_prepare_head($object)
 	$head[$h][2] = 'user';
 	$h++;
 
-	if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
-		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
+	if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE))
+		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
 	{
 		$langs->load("ldap");
 		$head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id;
@@ -64,7 +64,7 @@ function user_prepare_head($object)
 	if ($canreadperms)
 	{
 		$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id;
-		$head[$h][1] = $langs->trans("Rights"). '<span class="badge marginleftonlyshort">'.($object->nb_rights).'</span>';
+		$head[$h][1] = $langs->trans("Rights").'<span class="badge marginleftonlyshort">'.($object->nb_rights).'</span>';
 		$head[$h][2] = 'rights';
 		$h++;
 	}
@@ -74,23 +74,23 @@ function user_prepare_head($object)
 	$head[$h][2] = 'guisetup';
 	$h++;
 
-	if (! empty($conf->agenda->enabled))
+	if (!empty($conf->agenda->enabled))
 	{
-		if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
-		$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
+		if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
+		$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
 
-		$i=1;
+		$i = 1;
 		$nbagenda = 0;
 		while ($i <= $MAXAGENDA)
 		{
-			$key=$i;
-			$name='AGENDA_EXT_NAME_'.$object->id.'_'.$key;
-			$src='AGENDA_EXT_SRC_'.$object->id.'_'.$key;
-			$offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
-			$color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
+			$key = $i;
+			$name = 'AGENDA_EXT_NAME_'.$object->id.'_'.$key;
+			$src = 'AGENDA_EXT_SRC_'.$object->id.'_'.$key;
+			$offsettz = 'AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
+			$color = 'AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
 			$i++;
 
-			if (! empty($object->conf->$name)) $nbagenda++;
+			if (!empty($object->conf->$name)) $nbagenda++;
 		}
 
 		$head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
@@ -99,7 +99,7 @@ function user_prepare_head($object)
 		$h++;
 	}
 
-	if (! empty($conf->clicktodial->enabled))
+	if (!empty($conf->clicktodial->enabled))
 	{
 		$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id;
 		$head[$h][1] = $langs->trans("ClickToDial");
@@ -108,13 +108,13 @@ function user_prepare_head($object)
 	}
 
 	// Notifications
-	if ($user->socid == 0 && ! empty($conf->notification->enabled))
+	if ($user->socid == 0 && !empty($conf->notification->enabled))
 	{
 		$nbNote = 0;
 		$sql = "SELECT COUNT(n.rowid) as nb";
-		$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n";
-		$sql.= " WHERE fk_user = ".$object->id;
-		$resql=$db->query($sql);
+		$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
+		$sql .= " WHERE fk_user = ".$object->id;
+		$resql = $db->query($sql);
 		if ($resql)
 		{
 			$num = $db->num_rows($resql);
@@ -122,7 +122,7 @@ function user_prepare_head($object)
 			while ($i < $num)
 			{
 				$obj = $db->fetch_object($resql);
-				$nbNote=$obj->nb;
+				$nbNote = $obj->nb;
 				$i++;
 			}
 		}
@@ -132,7 +132,7 @@ function user_prepare_head($object)
 
 		$head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id;
 		$head[$h][1] = $langs->trans("Notifications");
-		if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
+		if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
 		$head[$h][2] = 'notify';
 		$h++;
 	}
@@ -143,10 +143,10 @@ function user_prepare_head($object)
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'user');
 
-	if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
-		|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))
-		|| (! empty($conf->expensereport->enabled) && ! empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall))
-		|| (! empty($conf->holiday->enabled) && ! empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->read_all))
+	if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
+		|| (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))
+		|| (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall))
+		|| (!empty($conf->holiday->enabled) && !empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->read_all))
 		)
 	{
 		// Bank
@@ -161,22 +161,22 @@ function user_prepare_head($object)
 	{
 		// Notes
 		$nbNote = 0;
-		if(!empty($object->note)) $nbNote++;
+		if (!empty($object->note)) $nbNote++;
 		$head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
 		$head[$h][1] = $langs->trans("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>';
 		$head[$h][2] = 'note';
 		$h++;
 
 		// Attached files
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 		require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-		$upload_dir = $conf->user->dir_output . "/" . $object->id;
+		$upload_dir = $conf->user->dir_output."/".$object->id;
 		$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
-		$nbLinks=Link::count($db, $object->element, $object->id);
+		$nbLinks = Link::count($db, $object->element, $object->id);
 		$head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$object->id;
 		$head[$h][1] = $langs->trans("Documents");
-		if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
+		if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
 		$head[$h][2] = 'document';
 		$h++;
 
@@ -201,10 +201,10 @@ function group_prepare_head($object)
 {
 	global $langs, $conf, $user;
 
-	$canreadperms=true;
-	if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
+	$canreadperms = true;
+	if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
 	{
-		$canreadperms=($user->admin || $user->rights->user->group_advance->readperms);
+		$canreadperms = ($user->admin || $user->rights->user->group_advance->readperms);
 	}
 
 	$h = 0;
@@ -215,8 +215,8 @@ function group_prepare_head($object)
 	$head[$h][2] = 'group';
 	$h++;
 
-	if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
-		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
+	if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE))
+		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
 	{
 		$langs->load("ldap");
 		$head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id;
@@ -228,7 +228,7 @@ function group_prepare_head($object)
 	if ($canreadperms)
 	{
 		$head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$object->id;
-		$head[$h][1] = $langs->trans("GroupRights"). '<span class="badge marginleftonlyshort">'.($object->nb_rights).'</span>';
+		$head[$h][1] = $langs->trans("GroupRights").'<span class="badge marginleftonlyshort">'.($object->nb_rights).'</span>';
 		$head[$h][2] = 'rights';
 		$h++;
 	}
@@ -254,7 +254,7 @@ function user_admin_prepare_head()
 	global $langs, $conf, $user;
 
 	$langs->load("users");
-	$h=0;
+	$h = 0;
 
 	$head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
 	$head[$h][1] = $langs->trans("Parameters");
@@ -297,39 +297,39 @@ function user_admin_prepare_head()
  */
 function showSkins($fuser, $edit = 0, $foruserprofile = false)
 {
-	global $conf,$langs,$db,$form;
+	global $conf, $langs, $db, $form;
 
-	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 
 	$formother = new FormOther($db);
 
-	$dirthemes=array('/theme');
-	if (! empty($conf->modules_parts['theme']))		// Using this feature slow down application
+	$dirthemes = array('/theme');
+	if (!empty($conf->modules_parts['theme']))		// Using this feature slow down application
 	{
-		foreach($conf->modules_parts['theme'] as $reldir)
+		foreach ($conf->modules_parts['theme'] as $reldir)
 		{
-			$dirthemes=array_merge($dirthemes, (array) ($reldir.'theme'));
+			$dirthemes = array_merge($dirthemes, (array) ($reldir.'theme'));
 		}
 	}
-	$dirthemes=array_unique($dirthemes);
+	$dirthemes = array_unique($dirthemes);
 	// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
 
-	$selected_theme='';
-	if (empty($foruserprofile)) $selected_theme=$conf->global->MAIN_THEME;
-	else $selected_theme=((is_object($fuser) && ! empty($fuser->conf->MAIN_THEME))?$fuser->conf->MAIN_THEME:'');
+	$selected_theme = '';
+	if (empty($foruserprofile)) $selected_theme = $conf->global->MAIN_THEME;
+	else $selected_theme = ((is_object($fuser) && !empty($fuser->conf->MAIN_THEME)) ? $fuser->conf->MAIN_THEME : '');
 
-	$hoverdisabled='';
-	if (empty($foruserprofile)) $hoverdisabled=(isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
-	else $hoverdisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0'):'');
+	$hoverdisabled = '';
+	if (empty($foruserprofile)) $hoverdisabled = (isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
+	else $hoverdisabled = (is_object($fuser) ? (empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0') : '');
 
-	$checkeddisabled='';
-	if (empty($foruserprofile)) $checkeddisabled=(isset($conf->global->THEME_ELDY_USE_CHECKED) && $conf->global->THEME_ELDY_USE_CHECKED == '0');
-	else $checkeddisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_CHECKED) || $fuser->conf->THEME_ELDY_USE_CHECKED == '0'):'');
+	$checkeddisabled = '';
+	if (empty($foruserprofile)) $checkeddisabled = (isset($conf->global->THEME_ELDY_USE_CHECKED) && $conf->global->THEME_ELDY_USE_CHECKED == '0');
+	else $checkeddisabled = (is_object($fuser) ? (empty($fuser->conf->THEME_ELDY_USE_CHECKED) || $fuser->conf->THEME_ELDY_USE_CHECKED == '0') : '');
 
-	$colspan=2;
-	if ($foruserprofile) $colspan=4;
+	$colspan = 2;
+	if ($foruserprofile) $colspan = 4;
 
-	$thumbsbyrow=6;
+	$thumbsbyrow = 6;
 	print '<table class="noborder centpercent">';
 
 	// Title
@@ -342,14 +342,14 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 		print '<tr>';
 		print '<td>'.$langs->trans("DefaultSkin").'</td>';
 		print '<td>'.$conf->global->MAIN_THEME.'</td>';
-		print '<td class="nowrap left" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
+		print '<td class="nowrap left" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit ? '' : ' disabled').' type="checkbox" '.($selected_theme ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>';
 		print '<td>&nbsp;</td>';
 		print '</tr>';
 	}
 	else
 	{
 		$dirthemestring = '';
-		foreach($dirthemes as $dirtheme)
+		foreach ($dirthemes as $dirtheme)
 		{
 			$dirthemestring .= '"'.$dirtheme.'" ';
 		}
@@ -358,7 +358,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 		print $form->textwithpicto($langs->trans("DefaultSkin"), $langs->trans("ThemeDir").' : '.$dirthemestring);
 		print '</th>';
 		print '<th class="right">';
-		$url='https://www.dolistore.com/4-skins';
+		$url = 'https://www.dolistore.com/4-skins';
 		print '<a href="'.$url.'" target="_blank">';
 		print $langs->trans('DownloadMoreSkins');
 		print '</a>';
@@ -369,43 +369,43 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 
 	print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
 
-	$i=0;
-	foreach($dirthemes as $dir)
+	$i = 0;
+	foreach ($dirthemes as $dir)
 	{
 		//print $dirroot.$dir;exit;
-		$dirtheme=dol_buildpath($dir, 0);	// This include loop on $conf->file->dol_document_root
-		$urltheme=dol_buildpath($dir, 1);
+		$dirtheme = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
+		$urltheme = dol_buildpath($dir, 1);
 
 		if (is_dir($dirtheme))
 		{
-			$handle=opendir($dirtheme);
+			$handle = opendir($dirtheme);
 			if (is_resource($handle))
 			{
-				while (($subdir = readdir($handle))!==false)
+				while (($subdir = readdir($handle)) !== false)
 				{
 					if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
-							&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i', $subdir))
+							&& substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir))
 					{
 						// Disable not stable themes (dir ends with _exp or _dev)
 						if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
 						if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue;
 
 						print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
-						$file=$dirtheme."/".$subdir."/thumb.png";
-						$url=$urltheme."/".$subdir."/thumb.png";
-						if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
-						print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST('optioncss', 'alpha', 1)?'&optioncss='.GETPOST('optioncss', 'alpha', 1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
-						if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
-						else $title=$langs->trans("ShowPreview");
+						$file = $dirtheme."/".$subdir."/thumb.png";
+						$url = $urltheme."/".$subdir."/thumb.png";
+						if (!file_exists($file)) $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
+						print '<a href="'.$_SERVER["PHP_SELF"].($edit ? '?action=edit&theme=' : '?theme=').$subdir.(GETPOST('optioncss', 'alpha', 1) ? '&optioncss='.GETPOST('optioncss', 'alpha', 1) : '').($fuser ? '&id='.$fuser->id : '').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
+						if ($subdir == $conf->global->MAIN_THEME) $title = $langs->trans("ThemeCurrentlyActive");
+						else $title = $langs->trans("ShowPreview");
 						print '<img class="img-skinthumb shadow" src="'.$url.'" alt="'.$title.'" title="'.$title.'" style="border: none; margin-bottom: 5px;">';
 						print '</a><br>';
 						if ($subdir == $selected_theme)
 						{
-							print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
+							print '<input '.($edit ? '' : 'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
 						}
 						else
 						{
-							print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
+							print '<input '.($edit ? '' : 'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
 						}
 						print '</div>';
 
@@ -487,10 +487,10 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 	}
 	else
 	{
-		$default=$langs->trans('No');
+		$default = $langs->trans('No');
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 		if ($edit)
 		{
 			print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
@@ -534,7 +534,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 	{
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("BackgroundColor").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 		//var_dump($conf->global->THEME_ELDY_BACKBODY);
 		if ($edit)
 		{
@@ -659,7 +659,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("TextTitleColor").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 		if ($edit)
 		{
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB, array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', 'formcolor', 1).' ';
@@ -686,7 +686,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 		if ($edit)
 		{
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1, array()), ''), 'THEME_ELDY_BACKTITLE1', 'formcolor', 1).' ';
@@ -713,7 +713,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("BackgroundTableTitleTextColor").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 		if ($edit)
 		{
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLE, array()), ''), 'THEME_ELDY_TEXTTITLE', 'formcolor', 1).' ';
@@ -816,7 +816,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("LinkColor").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 		if ($edit)
 		{
 			print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''), 'THEME_ELDY_TEXTLINK', 'formcolor', 1).' ';
@@ -904,18 +904,18 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("HighlightLinesChecked").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 		//print '<input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
 		//print ' &nbsp; ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
 		if ($edit)
 		{
-			if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color='e6edf0';
+			if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color = 'e6edf0';
 			else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED, array()), '');
 			print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', 'formcolor', 1).' ';
 		}
 		else
 		{
-			if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color='e6edf0';
+			if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color = 'e6edf0';
 			else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED, array()), '');
 			if ($color)
 			{
@@ -935,10 +935,10 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 	if ($foruserprofile)
 	{
 	    //$default=yn($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER);
-	    $default=$langs->trans('No');
+	    $default = $langs->trans('No');
 	    print '<tr class="oddeven">';
 	    print '<td>'.$langs->trans("MAIN_OPTIMIZEFORTEXTBROWSER").'</td>';
-	    print '<td colspan="'.($colspan-1).'">';
+	    print '<td colspan="'.($colspan - 1).'">';
    	    if ($edit)
    	    {
    	        print $form->selectyesno('MAIN_OPTIMIZEFORTEXTBROWSER', $fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER, 1);
@@ -988,10 +988,10 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 	if ($foruserprofile)
 	{
 		//$default=yn($conf->global->MAIN_OPTIMIZEFORCOLORBLIND);
-		$default=$langs->trans('No');
+		$default = $langs->trans('No');
 		print '<tr class="oddeven">';
 		print '<td>'.$langs->trans("MAIN_OPTIMIZEFORCOLORBLIND").'</td>';
-		print '<td colspan="'.($colspan-1).'">';
+		print '<td colspan="'.($colspan - 1).'">';
 
 		$colorBlindOptions = array(
 			0 => $langs->trans('No'),
@@ -1007,10 +1007,10 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 		}
 		else
 		{
-			if (!empty($fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND) && isset($colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND])){
+			if (!empty($fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND) && isset($colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND])) {
 				print $colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND];
 			}
-			else{
+			else {
 				print yn(0);
 			}
 		}

+ 97 - 97
htdocs/core/lib/website2.lib.php

@@ -38,11 +38,11 @@ function dolSaveMasterFile($filemaster)
 	dol_delete_file($filemaster);
 
 	$mastercontent = '<?php'."\n";
-	$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
-	$mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
-	$mastercontent.= '?>'."\n";
+	$mastercontent .= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
+	$mastercontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
+	$mastercontent .= '?>'."\n";
 	$result = file_put_contents($filemaster, $mastercontent);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
 
 		return $result;
@@ -64,17 +64,17 @@ function dolSavePageAlias($filealias, $object, $objectpage)
 	dol_syslog("dolSavePageAlias We regenerate the alias page filealias=".$filealias);
 
 	$aliascontent = '<?php'."\n";
-	$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
-	$aliascontent.= 'global $dolibarr_main_data_root;'."\n";
-	$aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
-	$aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
-	$aliascontent.= '?>'."\n";
+	$aliascontent .= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
+	$aliascontent .= 'global $dolibarr_main_data_root;'."\n";
+	$aliascontent .= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
+	$aliascontent .= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
+	$aliascontent .= '?>'."\n";
 	$result = file_put_contents($filealias, $aliascontent);
-	if (! empty($conf->global->MAIN_UMASK)) {
+	if (!empty($conf->global->MAIN_UMASK)) {
 		@chmod($filealias, octdec($conf->global->MAIN_UMASK));
 	}
 
-	return ($result?true:false);
+	return ($result ?true:false);
 }
 
 
@@ -96,54 +96,54 @@ function dolSavePageContent($filetpl, $object, $objectpage)
 	dol_delete_file($filetpl);
 
 	$shortlangcode = '';
-	if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang);		// en_US or en-US -> en
-
-	$tplcontent ='';
-	$tplcontent.= "<?php // BEGIN PHP\n";
-	$tplcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
-	$tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
-	$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
-	$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
-	$tplcontent.= "ob_start();\n";
-	$tplcontent.= "// END PHP ?>\n";
-	if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
+	if ($objectpage->lang) $shortlangcode = preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
+
+	$tplcontent = '';
+	$tplcontent .= "<?php // BEGIN PHP\n";
+	$tplcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
+	$tplcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
+	$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
+	$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
+	$tplcontent .= "ob_start();\n";
+	$tplcontent .= "// END PHP ?>\n";
+	if (!empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
 	{
-		$tplcontent.= "<!DOCTYPE html>\n";
+		$tplcontent .= "<!DOCTYPE html>\n";
 	}
-	$tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
-	$tplcontent.= '<head>'."\n";
-	$tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
-	$tplcontent.= '<meta charset="utf-8">'."\n";
-	$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
-	$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
-	$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
-	$tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
-	$tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
-	$tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
-	$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
-	$tplcontent.= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
-	$tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
-	$tplcontent.= '<!-- Include link to CSS file -->'."\n";
-	$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
-	$tplcontent.= '<!-- Include HTML header from common file -->'."\n";
-	$tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
-	$tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
-	$tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
-	$tplcontent.= '</head>'."\n";
-
-	$tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
-	$tplcontent.= '<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n";
-	$tplcontent.= $objectpage->content."\n";
-	$tplcontent.= '</body>'."\n";
-	$tplcontent.= '</html>'."\n";
-
-	$tplcontent.= '<?php // BEGIN PHP'."\n";
-	$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.');'."\n";
-	$tplcontent.= "// END PHP ?>"."\n";
+	$tplcontent .= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"' : '').'>'."\n";
+	$tplcontent .= '<head>'."\n";
+	$tplcontent .= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
+	$tplcontent .= '<meta charset="utf-8">'."\n";
+	$tplcontent .= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
+	$tplcontent .= '<meta name="robots" content="index, follow" />'."\n";
+	$tplcontent .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
+	$tplcontent .= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
+	$tplcontent .= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
+	$tplcontent .= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
+	$tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
+	$tplcontent .= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
+	$tplcontent .= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
+	$tplcontent .= '<!-- Include link to CSS file -->'."\n";
+	$tplcontent .= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
+	$tplcontent .= '<!-- Include HTML header from common file -->'."\n";
+	$tplcontent .= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
+	$tplcontent .= '<!-- Include HTML header from page header block -->'."\n";
+	$tplcontent .= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
+	$tplcontent .= '</head>'."\n";
+
+	$tplcontent .= '<!-- File generated by Dolibarr website module editor -->'."\n";
+	$tplcontent .= '<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n";
+	$tplcontent .= $objectpage->content."\n";
+	$tplcontent .= '</body>'."\n";
+	$tplcontent .= '</html>'."\n";
+
+	$tplcontent .= '<?php // BEGIN PHP'."\n";
+	$tplcontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.');'."\n";
+	$tplcontent .= "// END PHP ?>"."\n";
 
 	//var_dump($filetpl);exit;
 	$result = file_put_contents($filetpl, $tplcontent);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
 
 		return $result;
@@ -163,33 +163,33 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
 {
 	global $conf;
 
-	$result1=false;
-	$result2=false;
+	$result1 = false;
+	$result2 = false;
 
 	dol_mkdir($pathofwebsite);
 
 	dol_delete_file($fileindex);
 	$indexcontent = '<?php'."\n";
-	$indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
-	$indexcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
-	$indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
-	$indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
-	$indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
-	$indexcontent.= "	require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
-	$indexcontent.= '	redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
-	$indexcontent.= "}\n";
-	$indexcontent.= "include_once './".basename($filetpl)."'\n";
-	$indexcontent.= '// END PHP ?>'."\n";
+	$indexcontent .= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
+	$indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
+	$indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
+	$indexcontent .= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
+	$indexcontent .= "	require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
+	$indexcontent .= "	require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
+	$indexcontent .= '	redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
+	$indexcontent .= "}\n";
+	$indexcontent .= "include_once './".basename($filetpl)."'\n";
+	$indexcontent .= '// END PHP ?>'."\n";
 	$result1 = file_put_contents($fileindex, $indexcontent);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
 
 		dol_delete_file($filewrapper);
 
-		$wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
+		$wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
 
 		$result2 = file_put_contents($filewrapper, $wrappercontent);
-		if (! empty($conf->global->MAIN_UMASK))
+		if (!empty($conf->global->MAIN_UMASK))
 			@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
 
 			return ($result1 && $result2);
@@ -211,7 +211,7 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
 
 	dol_mkdir($pathofwebsite);
 	$result = file_put_contents($filehtmlheader, $htmlheadercontent);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
 
 	return $result;
@@ -232,7 +232,7 @@ function dolSaveCssFile($filecss, $csscontent)
 
 	dol_mkdir($pathofwebsite);
 	$result = file_put_contents($filecss, $csscontent);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($filecss, octdec($conf->global->MAIN_UMASK));
 
 	return $result;
@@ -253,7 +253,7 @@ function dolSaveJsFile($filejs, $jscontent)
 
 	dol_mkdir($pathofwebsite);
 	$result = file_put_contents($filejs, $jscontent);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($filejs, octdec($conf->global->MAIN_UMASK));
 
 	return $result;
@@ -274,7 +274,7 @@ function dolSaveRobotFile($filerobot, $robotcontent)
 
 	dol_mkdir($pathofwebsite);
 	$result = file_put_contents($filerobot, $robotcontent);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
 
 	return $result;
@@ -295,7 +295,7 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess)
 
 	dol_mkdir($pathofwebsite);
 	$result = file_put_contents($filehtaccess, $htaccess);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
 
 	return $result;
@@ -316,7 +316,7 @@ function dolSaveManifestJson($file, $content)
 
 	dol_mkdir($pathofwebsite);
 	$result = file_put_contents($file, $content);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($file, octdec($conf->global->MAIN_UMASK));
 
 	return $result;
@@ -337,7 +337,7 @@ function dolSaveReadme($file, $content)
 
 	dol_mkdir($pathofwebsite);
 	$result = file_put_contents($file, $content);
-	if (! empty($conf->global->MAIN_UMASK))
+	if (!empty($conf->global->MAIN_UMASK))
 		@chmod($file, octdec($conf->global->MAIN_UMASK));
 
 		return $result;
@@ -352,29 +352,29 @@ function dolSaveReadme($file, $content)
  */
 function showWebsiteTemplates(Website $website)
 {
-	global $conf,$langs,$db,$form;
+	global $conf, $langs, $db, $form;
 	global $bc;
 
-	$dirthemes=array('/doctemplates/websites');
-	if (! empty($conf->modules_parts['websitetemplates']))		// Using this feature slow down application
+	$dirthemes = array('/doctemplates/websites');
+	if (!empty($conf->modules_parts['websitetemplates']))		// Using this feature slow down application
 	{
-		foreach($conf->modules_parts['websitetemplates'] as $reldir)
+		foreach ($conf->modules_parts['websitetemplates'] as $reldir)
 		{
-			$dirthemes=array_merge($dirthemes, (array) ($reldir.'doctemplates/websites'));
+			$dirthemes = array_merge($dirthemes, (array) ($reldir.'doctemplates/websites'));
 		}
 	}
-	$dirthemes=array_unique($dirthemes);
+	$dirthemes = array_unique($dirthemes);
 	// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
 
-	$colspan=2;
+	$colspan = 2;
 
-	$thumbsbyrow=6;
+	$thumbsbyrow = 6;
 	print '<table class="noborder centpercent">';
 
 	// Title
 	print '<tr class="liste_titre"><th class="titlefield"></th>';
 	print '<th class="right">';
-	$url='https://www.dolistore.com/43-web-site-templates';
+	$url = 'https://www.dolistore.com/43-web-site-templates';
 	print '<a href="'.$url.'" target="_blank">';
 	print $langs->trans('DownloadMoreSkins');
 	print '</a>';
@@ -383,7 +383,7 @@ function showWebsiteTemplates(Website $website)
 	print '<tr>';
 	print '<td>'.$langs->trans("ThemeDir").'</td>';
 	print '<td>';
-	foreach($dirthemes as $dirtheme)
+	foreach ($dirthemes as $dirtheme)
 	{
 		echo '"'.$dirtheme.'" ';
 	}
@@ -394,17 +394,17 @@ function showWebsiteTemplates(Website $website)
 
 	print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
 
-	$i=0;
-	foreach($dirthemes as $dir)
+	$i = 0;
+	foreach ($dirthemes as $dir)
 	{
 		//print $dirroot.$dir;exit;
-		$dirtheme=DOL_DATA_ROOT.$dir;	// This include loop on $conf->file->dol_document_root
+		$dirtheme = DOL_DATA_ROOT.$dir; // This include loop on $conf->file->dol_document_root
 		if (is_dir($dirtheme))
 		{
-			$handle=opendir($dirtheme);
+			$handle = opendir($dirtheme);
 			if (is_resource($handle))
 			{
-				while (($subdir = readdir($handle))!==false)
+				while (($subdir = readdir($handle)) !== false)
 				{
 					if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
 						&& substr($subdir, 0, 3) <> 'CVS' && preg_match('/\.zip$/i', $subdir))
@@ -418,9 +418,9 @@ function showWebsiteTemplates(Website $website)
 						print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
 
 						$file = $dirtheme."/".$subdirwithoutzip.".jpg";
-						$url=DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
+						$url = DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
 
-						if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
+						if (!file_exists($file)) $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
 
 						$originalfile = basename($file);
 						$entity = $conf->entity;
@@ -428,10 +428,10 @@ function showWebsiteTemplates(Website $website)
 						$cache = '';
 						$title = $file;
 
-						$ret='';
-						$urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile, 1, '&entity='.$entity);
-						if (! empty($urladvanced)) $ret.='<a class="'.$urladvanced['css'].'" target="'.$urladvanced['target'].'" mime="'.$urladvanced['mime'].'" href="'.$urladvanced['url'].'">';
-						else $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
+						$ret = '';
+						$urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 1, '&entity='.$entity);
+						if (!empty($urladvanced)) $ret .= '<a class="'.$urladvanced['css'].'" target="'.$urladvanced['target'].'" mime="'.$urladvanced['mime'].'" href="'.$urladvanced['url'].'">';
+						else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
 						print $ret;
 						print '<img class="img-skinthumb shadow" src="'.$url.'" border="0" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
 						print '</a>';

File diff suppressed because it is too large
+ 191 - 191
htdocs/core/menus/standard/eldy.lib.php


File diff suppressed because it is too large
+ 249 - 249
htdocs/core/modules/facture/doc/pdf_crabe.modules.php


+ 193 - 193
htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php

@@ -135,57 +135,57 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 		// Dimension page
 		$this->type = 'pdf';
-		$formatarray=pdf_getFormat();
+		$formatarray = pdf_getFormat();
 		$this->page_largeur = $formatarray['width'];
 		$this->page_hauteur = $formatarray['height'];
-		$this->format = array($this->page_largeur,$this->page_hauteur);
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+		$this->format = array($this->page_largeur, $this->page_hauteur);
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
 
-		$this->option_logo = 1;                    // Affiche logo
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
-		$this->option_modereg = 1;                 // Affiche mode reglement
-		$this->option_condreg = 1;                 // Affiche conditions reglement
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
+		$this->option_logo = 1; // Affiche logo
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
+		$this->option_modereg = 1; // Affiche mode reglement
+		$this->option_condreg = 1; // Affiche conditions reglement
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
+		$this->option_multilang = 1; // Dispo en plusieurs langues
 
-		$this->franchise=!$mysoc->tva_assuj;
+		$this->franchise = !$mysoc->tva_assuj;
 
         // Define column position
-		$this->posxdesc=$this->marge_gauche+1;
-		$this->posxtva=112;
-		$this->posxup=126;
-		$this->posxqty=145;
-		$this->posxunit=162;
-		$this->posxdiscount=162;
-		$this->postotalht=174;
-
-		if($conf->global->PRODUCT_USE_UNITS) {
-			$this->posxtva=99;
-			$this->posxup=114;
-			$this->posxqty=130;
-			$this->posxunit=147;
+		$this->posxdesc = $this->marge_gauche + 1;
+		$this->posxtva = 112;
+		$this->posxup = 126;
+		$this->posxqty = 145;
+		$this->posxunit = 162;
+		$this->posxdiscount = 162;
+		$this->postotalht = 174;
+
+		if ($conf->global->PRODUCT_USE_UNITS) {
+			$this->posxtva = 99;
+			$this->posxup = 114;
+			$this->posxqty = 130;
+			$this->posxunit = 147;
 		}
 		//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
-			$this->posxpicture-=20;
-			$this->posxtva-=20;
-			$this->posxup-=20;
-			$this->posxqty-=20;
-			$this->posxunit-=20;
-			$this->posxdiscount-=20;
-			$this->postotalht-=20;
+			$this->posxpicture -= 20;
+			$this->posxtva -= 20;
+			$this->posxup -= 20;
+			$this->posxqty -= 20;
+			$this->posxunit -= 20;
+			$this->posxdiscount -= 20;
+			$this->postotalht -= 20;
 		}
 
-		$this->tva=array();
-        $this->localtax1=array();
-        $this->localtax2=array();
-		$this->atleastoneratenotnull=0;
-		$this->atleastonediscount=0;
+		$this->tva = array();
+        $this->localtax1 = array();
+        $this->localtax2 = array();
+		$this->atleastoneratenotnull = 0;
+		$this->atleastonediscount = 0;
     }
 
 
@@ -204,17 +204,17 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
     public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
     {
         // phpcs:enable
-		global $user,$langs,$conf,$mysoc,$hookmanager,$nblines;
+		global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
 
 		// Get source company
-		if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
-		if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc;	// If fetch_thirdparty fails, object has no socid (specimen)
-		$this->emetteur=$object->thirdparty;
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2);    // By default, if was not defined
+		if (!is_object($object->thirdparty)) $object->fetch_thirdparty();
+		if (!is_object($object->thirdparty)) $object->thirdparty = $mysoc; // If fetch_thirdparty fails, object has no socid (specimen)
+		$this->emetteur = $object->thirdparty;
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
 
-		if (! is_object($outputlangs)) $outputlangs=$langs;
+		if (!is_object($outputlangs)) $outputlangs = $langs;
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
 
 		// Load translation files required by the page
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products"));
@@ -233,22 +233,22 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 			if ($object->specimen)
 			{
 				$dir = $conf->fournisseur->facture->dir_output;
-				$file = $dir . "/SPECIMEN.pdf";
+				$file = $dir."/SPECIMEN.pdf";
 			}
 			else
 			{
 				$objectref = dol_sanitizeFileName($object->ref);
 				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
                 $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$objectref;
-				$file = $dir . "/" . $objectref . ".pdf";
-				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
+				$file = $dir."/".$objectref.".pdf";
+				if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
 			}
 
-			if (! file_exists($dir))
+			if (!file_exists($dir))
 			{
 				if (dol_mkdir($dir) < 0)
 				{
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
 					return 0;
 				}
 			}
@@ -287,14 +287,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
                 }
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
                 // Set path to the background PDF File
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
                 {
                 	$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
                     $tplidx = $pdf->importPage(1);
                 }
 
 				$pdf->Open();
-				$pagenb=0;
+				$pagenb = 0;
 				$pdf->SetDrawColor(128, 128, 128);
 
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -302,12 +302,12 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
 
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
 
 				// Set $this->atleastonediscount if you have at least one discount
-                for ($i = 0 ; $i < $nblines ; $i++)
+                for ($i = 0; $i < $nblines; $i++)
                 {
                     if ($object->lines[$i]->remise_percent)
                     {
@@ -317,26 +317,26 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				if (empty($this->atleastonediscount))
 				{
 				    $delta = ($this->postotalht - $this->posxdiscount);
-				    $this->posxpicture+=$delta;
-				    $this->posxtva+=$delta;
-				    $this->posxup+=$delta;
-				    $this->posxqty+=$delta;
-				    $this->posxunit+=$delta;
-				    $this->posxdiscount+=$delta;
+				    $this->posxpicture += $delta;
+				    $this->posxtva += $delta;
+				    $this->posxup += $delta;
+				    $this->posxqty += $delta;
+				    $this->posxunit += $delta;
+				    $this->posxdiscount += $delta;
 				    // post of fields after are not modified, stay at same position
 				}
 
                 // New page
 				$pdf->AddPage();
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
 				$pagenb++;
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
 				$pdf->SetFont('', '', $default_font_size - 1);
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
 				$pdf->SetTextColor(0, 0, 0);
 
-				$tab_top = 90+$top_shift;
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
+				$tab_top = 90 + $top_shift;
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
 
 				// Incoterm
 				if ($conf->incoterm->enabled)
@@ -540,10 +540,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 						$this->_pagefoot($pdf, $object, $outputlangs, 1);
 						$pagenb++;
 						$pdf->setPage($pagenb);
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
 					}
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
 					{
 						if ($pagenb == 1)
 						{
@@ -556,7 +556,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 						$this->_pagefoot($pdf, $object, $outputlangs, 1);
 						// New page
 						$pdf->AddPage();
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
 						$pagenb++;
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
 					}
@@ -566,24 +566,24 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				if ($pagenb == 1)
 				{
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
 				}
 				else
 				{
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
 				}
 
 				// Display total area
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+				$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
 
-				$amount_credit_notes_included=0;
-				$amount_deposits_included=0;
+				$amount_credit_notes_included = 0;
+				$amount_deposits_included = 0;
 
 				// Display Payments area
 				if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->SUPPLIER_INVOICE_NO_PAYMENT_DETAILS))
 				{
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter);
+					$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter);
 				}
 
 				// Pagefoot
@@ -596,31 +596,31 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 				// Add pdfgeneration hook
 				$hookmanager->initHooks(array('pdfgeneration'));
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
 				global $action;
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
+				$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;
 				}
 
-				if (! empty($conf->global->MAIN_UMASK))
+				if (!empty($conf->global->MAIN_UMASK))
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
 
 				$this->result = array('fullpath'=>$file);
 
-				return 1;   // No error
+				return 1; // No error
 			}
 			else
 			{
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
 				return 0;
 			}
 		}
 		else
 		{
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
 			return 0;
 		}
     }
@@ -686,46 +686,46 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$index++;
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-				$tvacompl='';
+				$tvacompl = '';
 
 				if (preg_match('/\*/', $tvakey))
 				{
-					$tvakey=str_replace('*', '', $tvakey);
+					$tvakey = str_replace('*', '', $tvakey);
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 				}
 
 				$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
-				$totalvat.=vatrate($tvakey, 1).$tvacompl;
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 			}
 		}
-		if (! $this->atleastoneratenotnull) // If no vat at all
+		if (!$this->atleastoneratenotnull) // If no vat at all
 		{
 			$index++;
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva, 0, $outputlangs), 0, 'R', 1);
 
 			// Total LocalTax1
-			if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
+			if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0)
 			{
 				$index++;
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1, 0, $outputlangs), 0, 'R', 1);
 			}
 
 			// Total LocalTax2
-			if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
+			if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0)
 			{
 				$index++;
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2, 0, $outputlangs), 0, 'R', 1);
 			}
@@ -743,15 +743,15 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					$index++;
 					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-					$tvacompl='';
+					$tvacompl = '';
 					if (preg_match('/\*/', $tvakey))
 					{
-						$tvakey=str_replace('*', '', $tvakey);
+						$tvakey = str_replace('*', '', $tvakey);
 						$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 					}
 					$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-					$totalvat.= vatrate(abs($tvakey), 1).$tvacompl;
-					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+					$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+					$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
 					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 					$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -762,7 +762,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 			//{
 			//Local tax 2
-			foreach($this->localtax2 as $tvakey => $tvaval) {
+			foreach ($this->localtax2 as $tvakey => $tvaval) {
 				if ($tvakey != 0)    // On affiche pas taux 0
 				{
 					//$this->atleastoneratenotnull++;
@@ -770,15 +770,15 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					$index++;
 					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-					$tvacompl='';
+					$tvacompl = '';
 					if (preg_match('/\*/', $tvakey))
 					{
-						$tvakey=str_replace('*', '', $tvakey);
+						$tvakey = str_replace('*', '', $tvakey);
 						$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 					}
 					$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-					$totalvat.= vatrate(abs($tvakey), 1).$tvacompl;
-					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+					$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+					$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
 					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 					$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -792,24 +792,24 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFillColor(224, 224, 224);
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
 
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 		$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
 
 		$pdf->SetTextColor(0, 0, 0);
-		$creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);	// Warning, this also include excess received
-		$depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+		$creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
+		$depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
-		if (! empty($object->paye)) $resteapayer=0;
+		if (!empty($object->paye)) $resteapayer = 0;
 
 		if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
 		{
 			// Already paid + Deposits
 			$index++;
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
 
@@ -819,7 +819,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
 				$index++;
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 				$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
 			}
@@ -873,8 +873,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		global $conf;
 
 		// Force to disable hidetop and hidebottom
-		$hidebottom=0;
-		if ($hidetop) $hidetop=-1;
+		$hidebottom = 0;
+		if ($hidetop) $hidetop = -1;
 
 		$currency = !empty($currency) ? $currency : $conf->currency;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -886,52 +886,52 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		if (empty($hidetop))
 		{
 			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
 
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
 		}
 
 		$pdf->SetDrawColor(128, 128, 128);
 		$pdf->SetFont('', '', $default_font_size - 1);
 
 		// Output Rect
-		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect takes a length in 3rd parameter and 4th parameter
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
 
 		if (empty($hidetop))
 		{
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line takes a position y in 2nd parameter and 4th parameter
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
 
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
 			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
 		}
 
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
         {
-    		$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
+    		$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
 			if (empty($hidetop))
 			{
-    			$pdf->SetXY($this->posxtva-3, $tab_top+1);
-    			$pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+    			$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
+    			$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
 			}
         }
 
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
 		if (empty($hidetop))
 		{
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
-			$pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
 		}
 
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
 		if (empty($hidetop))
 		{
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
-			$pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
+			$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
 		}
 
-		if (! empty($conf->global->PRODUCT_USE_UNITS))
+		if (!empty($conf->global->PRODUCT_USE_UNITS))
 		{
 			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
 			if (empty($hidetop)) {
@@ -943,18 +943,18 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 		if ($this->atleastonediscount)
 		{
-			$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+			$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
 			if (empty($hidetop))
 			{
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
 			}
 		}
 
 		$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
 		if (empty($hidetop))
 		{
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
 			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
 		}
 	}
@@ -975,8 +975,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
         // phpcs:enable
 		global $conf;
 
-		$sign=1;
-		if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
+		$sign = 1;
+		if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
 
 		$tab3_posx = 120;
 		$tab3_top = $posy + 8;
@@ -993,21 +993,21 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
 		$pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
 
-		$pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
+		$pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
 
 		$pdf->SetFont('', '', $default_font_size - 4);
 		$pdf->SetXY($tab3_posx, $tab3_top);
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
-		$pdf->SetXY($tab3_posx+21, $tab3_top);
+		$pdf->SetXY($tab3_posx + 21, $tab3_top);
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
-		$pdf->SetXY($tab3_posx+40, $tab3_top);
+		$pdf->SetXY($tab3_posx + 40, $tab3_top);
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
-		$pdf->SetXY($tab3_posx+58, $tab3_top);
+		$pdf->SetXY($tab3_posx + 58, $tab3_top);
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
 
-		$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
+		$pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
 
-		$y=0;
+		$y = 0;
 
 		$pdf->SetFont('', '', $default_font_size - 4);
 
@@ -1016,39 +1016,39 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 		// Loop on each payment
 		$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
-		$sql.= " cp.code";
-		$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
-		$sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id;
-		$sql.= " ORDER BY p.datep";
-		$resql=$this->db->query($sql);
+		$sql .= " cp.code";
+		$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
+		$sql .= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id;
+		$sql .= " ORDER BY p.datep";
+		$resql = $this->db->query($sql);
 		if ($resql)
 		{
 		    $num = $this->db->num_rows($resql);
-			$i=0;
+			$i = 0;
 			while ($i < $num) {
-			    $y+=3;
+			    $y += 3;
 				$row = $this->db->fetch_object($resql);
 
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
 				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
 				$pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0);
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
-				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
+				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
 
 				$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
 				$pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
 
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
 
 				$i++;
 			}
 		}
 		else
 		{
-			$this->error=$this->db->lasterror();
+			$this->error = $this->db->lasterror();
 			return -1;
 		}
 	}
@@ -1078,8 +1078,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-		$posy=$this->marge_haute;
-		$posx=$this->page_largeur-$this->marge_droite-100;
+		$posy = $this->marge_haute;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
 
@@ -1103,7 +1103,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		}
 		else
 		{*/
-			$text=$this->emetteur->name;
+			$text = $this->emetteur->name;
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
 		//}
 
@@ -1111,43 +1111,43 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$pdf->SetXY($posx, $posy);
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
-		$posy+=1;
+		$posy += 1;
 
 		if ($object->ref_supplier)
 		{
-    		$posy+=4;
+    		$posy += 4;
 			$pdf->SetFont('', 'B', $default_font_size);
     		$pdf->SetXY($posx, $posy);
 			$pdf->SetTextColor(0, 0, 60);
-    		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R');
-			$posy+=1;
+    		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : ".$object->ref_supplier, '', 'R');
+			$posy += 1;
 		}
 
 		$pdf->SetFont('', '', $default_font_size - 1);
 
-		if (! empty($conf->global->PDF_SHOW_PROJECT))
+		if (!empty($conf->global->PDF_SHOW_PROJECT))
 		{
 			$object->fetch_projet();
-			if (! empty($object->project->ref))
+			if (!empty($object->project->ref))
 			{
-        		$posy+=4;
+        		$posy += 4;
 				$pdf->SetXY($posx, $posy);
         		$langs->load("projects");
 				$pdf->SetTextColor(0, 0, 60);
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
 			}
 		}
 
 		if ($object->date)
 		{
-			$posy+=4;
+			$posy += 4;
 			$pdf->SetXY($posx, $posy);
 			$pdf->SetTextColor(0, 0, 60);
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
 		}
 		else
 		{
-			$posy+=4;
+			$posy += 4;
 			$pdf->SetXY($posx, $posy);
 			$pdf->SetTextColor(255, 0, 0);
 			$pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
@@ -1155,13 +1155,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 		if ($object->thirdparty->code_fournisseur)
 		{
-			$posy+=4;
+			$posy += 4;
 			$pdf->SetXY($posx, $posy);
 			$pdf->SetTextColor(0, 0, 60);
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
 		}
 
-		$posy+=1;
+		$posy += 1;
 		$pdf->SetTextColor(0, 0, 60);
 
 		$top_shift = 0;
@@ -1176,27 +1176,27 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		if ($showaddress)
 		{
 			// Sender properties
-		    $carac_emetteur='';
+		    $carac_emetteur = '';
 		    // Add internal contact of proposal if defined
-		    $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
 		    if (count($arrayidcontact) > 0)
 		    {
 		        $object->fetch_user($arrayidcontact[0]);
-		        $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+		        $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
 		    }
 
 		    $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
 
 			// Show sender
-			$posy=42+$top_shift;
-			$posx=$this->marge_gauche;
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
-			$hautcadre=40;
+			$posy = 42 + $top_shift;
+			$posx = $this->marge_gauche;
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+			$hautcadre = 40;
 
 			// Show sender frame
 			$pdf->SetTextColor(0, 0, 0);
 			$pdf->SetFont('', '', $default_font_size - 2);
-			$pdf->SetXY($posx, $posy-5);
+			$pdf->SetXY($posx, $posy - 5);
 			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
 			$pdf->SetXY($posx, $posy);
 			$pdf->SetFillColor(230, 230, 230);
@@ -1204,25 +1204,25 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 			$pdf->SetTextColor(0, 0, 60);
 
 			// Show sender name
-			$pdf->SetXY($posx+2, $posy+3);
+			$pdf->SetXY($posx + 2, $posy + 3);
 			$pdf->SetFont('', 'B', $default_font_size);
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
-			$posy=$pdf->getY();
+			$posy = $pdf->getY();
 
 			// Show sender information
-			$pdf->SetXY($posx+2, $posy);
+			$pdf->SetXY($posx + 2, $posy);
 			$pdf->SetFont('', '', $default_font_size - 1);
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
 
 
 
 			// If BILLING contact defined on invoice, we use it
-			$usecontact=false;
-			$arrayidcontact=$object->getIdContact('internal', 'BILLING');
+			$usecontact = false;
+			$arrayidcontact = $object->getIdContact('internal', 'BILLING');
 			if (count($arrayidcontact) > 0)
 			{
-				$usecontact=true;
-				$result=$object->fetch_contact($arrayidcontact[0]);
+				$usecontact = true;
+				$result = $object->fetch_contact($arrayidcontact[0]);
 			}
 
 			//Recipient name
@@ -1233,26 +1233,26 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$thirdparty = $mysoc;
 			}
 
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
 
-			$carac_client=pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact))?$object->contact:null), $usecontact, 'target', $object);
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object);
 
 			// Show recipient
-			$widthrecbox=100;
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
-			$posy=42+$top_shift;
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+			$widthrecbox = 100;
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+			$posy = 42 + $top_shift;
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
 
 			// Show recipient frame
 			$pdf->SetTextColor(0, 0, 0);
 			$pdf->SetFont('', '', $default_font_size - 2);
-			$pdf->SetXY($posx+2, $posy-5);
+			$pdf->SetXY($posx + 2, $posy - 5);
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
 
 			// Show recipient name
-			$pdf->SetXY($posx+2, $posy+3);
+			$pdf->SetXY($posx + 2, $posy + 3);
 			$pdf->SetFont('', 'B', $default_font_size);
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
 
@@ -1260,7 +1260,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 			// Show recipient information
 			$pdf->SetFont('', '', $default_font_size - 1);
-			$pdf->SetXY($posx+2, $posy);
+			$pdf->SetXY($posx + 2, $posy);
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
 		}
 
@@ -1280,7 +1280,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
     protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
     {
         global $conf;
-        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+        $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
         return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
     }
 }

+ 194 - 194
htdocs/core/tpl/advtarget.tpl.php

@@ -49,213 +49,213 @@ print '<script type="text/javascript" language="javascript">
 
 print load_fiche_titre($langs->trans("AdvTgtTitle"));
 
-print '<div class="tabBar">' . "\n";
-print '<form name="find_customer" id="find_customer" action="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '"  method="POST">' . "\n";
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">' . "\n";
-print '<input type="hidden" name="action" value="">' . "\n";
-print '<table class="border centpercent">' . "\n";
+print '<div class="tabBar">'."\n";
+print '<form name="find_customer" id="find_customer" action="'.$_SERVER['PHP_SELF'].'?id='.$id.'"  method="POST">'."\n";
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
+print '<input type="hidden" name="action" value="">'."\n";
+print '<table class="border centpercent">'."\n";
 
-print '<tr>' . "\n";
-print '<td colspan="3" class="right">' . "\n";
+print '<tr>'."\n";
+print '<td colspan="3" class="right">'."\n";
 
-print '<input type="button" name="addcontact" id="addcontact" value="' . $langs->trans('AdvTgtAddContact') . '" class="butAction"/>' . "\n";
+print '<input type="button" name="addcontact" id="addcontact" value="'.$langs->trans('AdvTgtAddContact').'" class="butAction"/>'."\n";
 
-print '</td>' . "\n";
-print '</tr>' . "\n";
+print '</td>'."\n";
+print '</tr>'."\n";
 
-print '<tr><td>' . $langs->trans('AdvTgtNameTemplate') . '</td><td>';
-if (! empty($template_id)) {
+print '<tr><td>'.$langs->trans('AdvTgtNameTemplate').'</td><td>';
+if (!empty($template_id)) {
 	$default_template = $template_id;
 } else {
 	$default_template = $advTarget->id;
 }
 print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element);
-print '<input type="button" name="loadfilter" id="loadfilter" value="' . $langs->trans('AdvTgtLoadFilter') . '" class="butAction"/>';
-print '<input type="button" name="deletefilter" id="deletefilter" value="' . $langs->trans('AdvTgtDeleteFilter') . '" class="butAction"/>';
-print '<input type="button" name="savefilter" id="savefilter" value="' . $langs->trans('AdvTgtSaveFilter') . '" class="butAction"/>';
+print '<input type="button" name="loadfilter" id="loadfilter" value="'.$langs->trans('AdvTgtLoadFilter').'" class="butAction"/>';
+print '<input type="button" name="deletefilter" id="deletefilter" value="'.$langs->trans('AdvTgtDeleteFilter').'" class="butAction"/>';
+print '<input type="button" name="savefilter" id="savefilter" value="'.$langs->trans('AdvTgtSaveFilter').'" class="butAction"/>';
 print $langs->trans('AdvTgtOrCreateNewFilter');
 print '<input type="text" name="template_name" id="template_name" value=""/>';
-print '<input type="button" name="createfilter" id="createfilter" value="' . $langs->trans('AdvTgtCreateFilter') . '" class="butAction"/>';
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '<input type="button" name="createfilter" id="createfilter" value="'.$langs->trans('AdvTgtCreateFilter').'" class="butAction"/>';
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
-print '<tr><td>' . $langs->trans('AdvTgtTypeOfIncude') . '</td><td>';
+print '<tr><td>'.$langs->trans('AdvTgtTypeOfIncude').'</td><td>';
 print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']);
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Customer name
-print '<tr><td>' . $langs->trans('ThirdPartyName');
-if (! empty($array_query['cust_name'])) {
+print '<tr><td>'.$langs->trans('ThirdPartyName');
+if (!empty($array_query['cust_name'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td><input type="text" name="cust_name" value="' . $array_query['cust_name'] . '"/></td><td>' . "\n";
+print '</td><td><input type="text" name="cust_name" value="'.$array_query['cust_name'].'"/></td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Code Client
-print '<tr><td>' . $langs->trans('CustomerCode');
-if (! empty($array_query['cust_code'])) {
+print '<tr><td>'.$langs->trans('CustomerCode');
+if (!empty($array_query['cust_code'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td><input type="text" name="cust_code" value="' . $array_query['cust_code'] . '"/></td><td>' . "\n";
+print '</td><td><input type="text" name="cust_code" value="'.$array_query['cust_code'].'"/></td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Address Client
-print '<tr><td>' . $langs->trans('Address');
-if (! empty($array_query['cust_adress'])) {
+print '<tr><td>'.$langs->trans('Address');
+if (!empty($array_query['cust_adress'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td><input type="text" name="cust_adress" value="' . $array_query['cust_adress'] . '"/></td><td>' . "\n";
+print '</td><td><input type="text" name="cust_adress" value="'.$array_query['cust_adress'].'"/></td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Zip Client
-print '<tr><td>' . $langs->trans('Zip');
-if (! empty($array_query['cust_zip'])) {
+print '<tr><td>'.$langs->trans('Zip');
+if (!empty($array_query['cust_zip'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td><input type="text" name="cust_zip" value="' . $array_query['cust_zip'] . '"/></td><td>' . "\n";
+print '</td><td><input type="text" name="cust_zip" value="'.$array_query['cust_zip'].'"/></td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // City Client
-print '<tr><td>' . $langs->trans('Town');
-if (! empty($array_query['cust_city'])) {
+print '<tr><td>'.$langs->trans('Town');
+if (!empty($array_query['cust_city'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td><input type="text" name="cust_city" value="' . $array_query['cust_city'] . '"/></td><td>' . "\n";
+print '</td><td><input type="text" name="cust_city" value="'.$array_query['cust_city'].'"/></td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Customer Country
-print '<tr><td>' . $langs->trans("Country");
+print '<tr><td>'.$langs->trans("Country");
 if (count($array_query['cust_country']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // State Customer
-print '<tr><td>' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty');
+print '<tr><td>'.$langs->trans('Status').' '.$langs->trans('ThirdParty');
 if (count($array_query['cust_status']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
 print '</td><td>';
 print $formadvtargetemaling->advMultiselectarray(
-    'cust_status', array (
+    'cust_status', array(
 		'0' => $langs->trans('ActivityCeased'),
 		'1' => $langs->trans('InActivity')
     ),
     $array_query['cust_status']
 );
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Mother Company
-print '<tr><td>' . $langs->trans("Maison mère");
-if (! empty($array_query['cust_mothercompany'])) {
+print '<tr><td>'.$langs->trans("Maison mère");
+if (!empty($array_query['cust_mothercompany'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
-print '<input type="text" name="cust_mothercompany" value="' . $array_query['cust_mothercompany'] . '"/>';
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
+print '<input type="text" name="cust_mothercompany" value="'.$array_query['cust_mothercompany'].'"/>';
+print '</td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Prospect/Customer
 $selected = $array_query['cust_typecust'];
-print '<tr><td>' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty');
+print '<tr><td>'.$langs->trans('ProspectCustomer').' '.$langs->trans('ThirdParty');
 if (count($array_query['cust_typecust']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
 print '</td><td>';
-$options_array = array (
+$options_array = array(
 	2 => $langs->trans('Prospect'),
 	3 => $langs->trans('ProspectCustomer'),
 	1 => $langs->trans('Customer'),
 	0 => $langs->trans('NorProspectNorCustomer')
 );
 print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Prospection status
-print '<tr><td>' . $langs->trans('ProspectLevel');
+print '<tr><td>'.$langs->trans('ProspectLevel');
 if (count($array_query['cust_prospect_status']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
 print '</td><td>';
 print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Prospection comm status
-print '<tr><td>' . $langs->trans('StatusProsp');
+print '<tr><td>'.$langs->trans('StatusProsp');
 if (count($array_query['cust_comm_status']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
 print '</td><td>';
 print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Customer Type
-print '<tr><td>' . $langs->trans("ThirdPartyType");
+print '<tr><td>'.$langs->trans("ThirdPartyType");
 if (count($array_query['cust_typeent']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Staff number
-print '<td>' . $langs->trans("Staff");
+print '<td>'.$langs->trans("Staff");
 if (count($array_query['cust_effectif_id']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
 print '</td><td>';
 print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Sales manager
-print '<tr><td>' . $langs->trans("SalesRepresentatives");
+print '<tr><td>'.$langs->trans("SalesRepresentatives");
 if (count($array_query['cust_saleman']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Customer Default Langauge
-if (! empty($conf->global->MAIN_MULTILANGS)) {
-	print '<tr><td>' . $langs->trans("DefaultLang");
+if (!empty($conf->global->MAIN_MULTILANGS)) {
+	print '<tr><td>'.$langs->trans("DefaultLang");
 	if (count($array_query['cust_language']) > 0) {
 		print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 	}
-	print '</td><td>' . "\n";
+	print '</td><td>'."\n";
 	print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']);
-	print '</td><td>' . "\n";
-	print '</td></tr>' . "\n";
+	print '</td><td>'."\n";
+	print '</td></tr>'."\n";
 }
 
-if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
+if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
 	// Customer Categories
-	print '<tr><td>' . $langs->trans("CustomersCategoryShort");
+	print '<tr><td>'.$langs->trans("CustomersCategoryShort");
 	if (count($array_query['cust_categ']) > 0) {
 		print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 	}
-	print '</td><td>' . "\n";
+	print '</td><td>'."\n";
 	print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']);
-	print '</td><td>' . "\n";
-	print '</td></tr>' . "\n";
+	print '</td><td>'."\n";
+	print '</td></tr>'."\n";
 }
 
 // Standard Extrafield feature
@@ -267,59 +267,59 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
 	$extrafields->fetch_name_optionals_label($elementtype);
 	foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
 		if ($key != 'ts_nameextra' && $key != 'ts_payeur') {
-			print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
-			if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) {
+			print '<tr><td>'.$extrafields->attributes[$elementtype]['label'][$key];
+			if (!empty($array_query['options_'.$key]) || (is_array($array_query['options_'.$key]) && count($array_query['options_'.$key]) > 0)) {
 				print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 			}
 			print '</td><td>';
 			if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
-				print '<input type="text" name="options_' . $key . '"/></td><td>' . "\n";
+				print '<input type="text" name="options_'.$key.'"/></td><td>'."\n";
 				print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
 			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
-				print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options' . $key . '_min"/>';
-				print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options' . $key . '_max"/>';
-				print '</td><td>' . "\n";
+				print $langs->trans("AdvTgtMinVal").'<input type="text" name="options'.$key.'_min"/>';
+				print $langs->trans("AdvTgtMaxVal").'<input type="text" name="options'.$key.'_max"/>';
+				print '</td><td>'."\n";
 				print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
 			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
 				print '<table class="nobordernopadding"><tr>';
-				print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
-				print $form->selectDate('', 'options_' . $key . '_st_dt');
-				print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
-				print $form->selectDate('', 'options_' . $key . '_end_dt');
+				print '<td>'.$langs->trans("AdvTgtStartDt").'</td><td>';
+				print $form->selectDate('', 'options_'.$key.'_st_dt');
+				print '</td><td>'.$langs->trans("AdvTgtEndDt").'</td><td>';
+				print $form->selectDate('', 'options_'.$key.'_end_dt');
 				print '</td></tr></table>';
 
-				print '</td><td>' . "\n";
+				print '</td><td>'."\n";
 				print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
 			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
                 print $form->selectarray(
-                    'options_' . $key,
-                    array (
+                    'options_'.$key,
+                    array(
 						'' => '',
 						'1' => $langs->trans('Yes'),
 						'0' => $langs->trans('No')
                     ),
-                    $array_query['options_' . $key]
+                    $array_query['options_'.$key]
                 );
-				print '</td><td>' . "\n";
+				print '</td><td>'."\n";
 			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
-				print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key]);
-				print '</td><td>' . "\n";
+				print $formadvtargetemaling->advMultiselectarray('options_'.$key, $extrafields->attributes[$key]['param']['options'], $array_query['options_'.$key]);
+				print '</td><td>'."\n";
 			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
-				print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key]);
-				print '</td><td>' . "\n";
+				print $formadvtargetemaling->advMultiselectarraySelllist('options_'.$key, $extrafields->attributes[$key]['param']['options'], $array_query['options_'.$key]);
+				print '</td><td>'."\n";
 			} else {
 				print '<table class="nobordernopadding"><tr>';
 				print '<td></td><td>';
-				if (is_array($array_query['options_' . $key])) {
-					print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key]));
+				if (is_array($array_query['options_'.$key])) {
+					print $extrafields->showInputField($key, implode(',', $array_query['options_'.$key]));
 				} else {
-					print $extrafields->showInputField($key, $array_query['options_' . $key]);
+					print $extrafields->showInputField($key, $array_query['options_'.$key]);
 				}
 				print '</td></tr></table>';
 
-				print '</td><td>' . "\n";
+				print '</td><td>'."\n";
 			}
-			print '</td></tr>' . "\n";
+			print '</td></tr>'."\n";
 		}
 	}
 } else {
@@ -327,12 +327,12 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
 	$action_search = 'query';
 
 	// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-	include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
+	include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
 	$hookmanager = new HookManager($db);
-	$hookmanager->initHooks(array ('thirdpartycard'));
+	$hookmanager->initHooks(array('thirdpartycard'));
 
-	$parameters=array();
-	if (! empty($advTarget->id)) {
+	$parameters = array();
+	if (!empty($advTarget->id)) {
 		$parameters = array('array_query' => $advTarget->filtervalue);
 	}
 	// Other attributes
@@ -341,25 +341,25 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
 }
 
 // State Contact
-print '<tr><td>' . $langs->trans('Status') . ' ' . $langs->trans('Contact');
+print '<tr><td>'.$langs->trans('Status').' '.$langs->trans('Contact');
 if (count($array_query['contact_status']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
 print '</td><td>';
 print $formadvtargetemaling->advMultiselectarray(
     'contact_status',
-    array (
+    array(
 		'0' => $langs->trans('ActivityCeased'),
 		'1' => $langs->trans('InActivity')
     ),
     $array_query['contact_status']
 );
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Civility
-print '<tr><td width="15%">' . $langs->trans("UserTitle");
+print '<tr><td width="15%">'.$langs->trans("UserTitle");
 if (count($array_query['contact_civility']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
@@ -368,170 +368,170 @@ print $formadvtargetemaling->multiselectCivility('contact_civility', $array_quer
 print '</td></tr>';
 
 // contact name
-print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname');
-if (! empty($array_query['contact_lastname'])) {
+print '<tr><td>'.$langs->trans('Contact').' '.$langs->trans('Lastname');
+if (!empty($array_query['contact_lastname'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td><input type="text" name="contact_lastname" value="' . $array_query['contact_lastname'] . '"/></td><td>' . "\n";
+print '</td><td><input type="text" name="contact_lastname" value="'.$array_query['contact_lastname'].'"/></td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
-print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname');
-if (! empty($array_query['contact_firstname'])) {
+print '</td></tr>'."\n";
+print '<tr><td>'.$langs->trans('Contact').' '.$langs->trans('Firstname');
+if (!empty($array_query['contact_firstname'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td><input type="text" name="contact_firstname" value="' . $array_query['contact_firstname'] . '"/></td><td>' . "\n";
+print '</td><td><input type="text" name="contact_firstname" value="'.$array_query['contact_firstname'].'"/></td><td>'."\n";
 print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-print '</td></tr>' . "\n";
+print '</td></tr>'."\n";
 
 // Contact Country
-print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("Country");
+print '<tr><td>'.$langs->trans('Contact').' '.$langs->trans("Country");
 if (count($array_query['contact_country']) > 0) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']);
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Never send mass mailing
-print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email");
-if (! empty($array_query['contact_no_email'])) {
+print '<tr><td>'.$langs->trans('Contact').' '.$langs->trans("No_Email");
+if (!empty($array_query['contact_no_email'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print $form->selectarray(
     'contact_no_email',
-    array (
+    array(
 		'' => '',
 		'1' => $langs->trans('Yes'),
 		'0' => $langs->trans('No')
     ),
     $array_query['contact_no_email']
 );
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Contact Date Create
-print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation");
-if (! empty($array_query['contact_create_st_dt'])) {
+print '<tr><td>'.$langs->trans('Contact').' '.$langs->trans("DateCreation");
+if (!empty($array_query['contact_create_st_dt'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print '<table class="nobordernopadding"><tr>';
-print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
+print '<td>'.$langs->trans("AdvTgtStartDt").'</td><td>';
 print $form->selectDate($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1);
-print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
+print '</td><td>'.$langs->trans("AdvTgtEndDt").'</td><td>';
 print $form->selectDate($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1);
 print '</td></tr></table>';
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
 // Contact update Create
-print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification");
-if (! empty($array_query['contact_update_st_dt'])) {
+print '<tr><td>'.$langs->trans('Contact').' '.$langs->trans("DateLastModification");
+if (!empty($array_query['contact_update_st_dt'])) {
 	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 }
-print '</td><td>' . "\n";
+print '</td><td>'."\n";
 print '<table class="nobordernopadding"><tr>';
-print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
+print '<td>'.$langs->trans("AdvTgtStartDt").'</td><td>';
 print $form->selectDate($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1);
-print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
+print '</td><td>'.$langs->trans("AdvTgtEndDt").'</td><td>';
 print $form->selectDate($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1);
 print '</td></tr></table>';
-print '</td><td>' . "\n";
-print '</td></tr>' . "\n";
+print '</td><td>'."\n";
+print '</td></tr>'."\n";
 
-if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
+if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
 	// Customer Categories
-	print '<tr><td>' . $langs->trans("ContactCategoriesShort");
+	print '<tr><td>'.$langs->trans("ContactCategoriesShort");
 	if (count($array_query['contact_categ']) > 0) {
 		print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 	}
-	print '</td><td>' . "\n";
+	print '</td><td>'."\n";
 	print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']);
-	print '</td><td>' . "\n";
-	print '</td></tr>' . "\n";
+	print '</td><td>'."\n";
+	print '</td></tr>'."\n";
 }
 
 // Standard Extrafield feature
 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
-	$elementype=Contact::$table_element;
+	$elementype = Contact::$table_element;
 	// fetch optionals attributes and labels
 	dol_include_once('/core/class/extrafields.class.php');
 	$extrafields = new ExtraFields($db);
 	$extrafields->fetch_name_optionals_label($elementype);
-    foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) {
-        if($value == 'radio')$value = 'select';
+    foreach ($extrafields->attributes[$elementtype]['type'] as $key=>&$value) {
+        if ($value == 'radio')$value = 'select';
     }
 
     foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
-		print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
-		if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) {
+		print '<tr><td>'.$extrafields->attributes[$elementtype]['label'][$key];
+		if ($array_query['options_'.$key.'_cnct'] != '' || (is_array($array_query['options_'.$key.'_cnct']) && count($array_query['options_'.$key.'_cnct']) > 0)) {
 			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 		}
 		print '</td><td>';
 		if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
-			print '<input type="text" name="options_' . $key . '_cnct"/></td><td>' . "\n";
+			print '<input type="text" name="options_'.$key.'_cnct"/></td><td>'."\n";
 			print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
 		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
-			print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options_' . $key . '_min_cnct"/>';
-			print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options_' . $key . '_max_cnct"/>';
-			print '</td><td>' . "\n";
+			print $langs->trans("AdvTgtMinVal").'<input type="text" name="options_'.$key.'_min_cnct"/>';
+			print $langs->trans("AdvTgtMaxVal").'<input type="text" name="options_'.$key.'_max_cnct"/>';
+			print '</td><td>'."\n";
 			print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
 		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
 			print '<table class="nobordernopadding"><tr>';
-			print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
-			print $form->selectDate('', 'options_' . $key . '_st_dt' . '_cnct');
-			print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
-			print $form->selectDate('', 'options_' . $key . '_end_dt' . '_cnct');
+			print '<td>'.$langs->trans("AdvTgtStartDt").'</td><td>';
+			print $form->selectDate('', 'options_'.$key.'_st_dt'.'_cnct');
+			print '</td><td>'.$langs->trans("AdvTgtEndDt").'</td><td>';
+			print $form->selectDate('', 'options_'.$key.'_end_dt'.'_cnct');
 			print '</td></tr></table>';
-			print '</td><td>' . "\n";
+			print '</td><td>'."\n";
 			print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
 		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
             print $form->selectarray(
-                'options_' . $key . '_cnct',
-                array (
+                'options_'.$key.'_cnct',
+                array(
 					'' => '',
 					'1' => $langs->trans('Yes'),
 					'0' => $langs->trans('No')
                 ),
-                $array_query['options_' . $key . '_cnct']
+                $array_query['options_'.$key.'_cnct']
             );
-			print '</td><td>' . "\n";
+			print '</td><td>'."\n";
 		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
-			print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key . '_cnct']);
-			print '</td><td>' . "\n";
+			print $formadvtargetemaling->advMultiselectarray('options_'.$key.'_cnct', $extrafields->attributes[$key]['param']['options'], $array_query['options_'.$key.'_cnct']);
+			print '</td><td>'."\n";
 		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
-			print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key . '_cnct']);
-			print '</td><td>' . "\n";
+			print $formadvtargetemaling->advMultiselectarraySelllist('options_'.$key.'_cnct', $extrafields->attributes[$key]['param']['options'], $array_query['options_'.$key.'_cnct']);
+			print '</td><td>'."\n";
 		} else {
 			print '<table class="nobordernopadding"><tr>';
 			print '<td></td><td>';
-			if (is_array($array_query['options_' . $key . '_cnct'])) {
-				print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct');
+			if (is_array($array_query['options_'.$key.'_cnct'])) {
+				print $extrafields->showInputField($key, implode(',', $array_query['options_'.$key.'_cnct']), '', '_cnct');
 			} else {
-				print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct');
+				print $extrafields->showInputField($key, $array_query['options_'.$key.'_cnct'], '', '_cnct');
 			}
 			print '</td></tr></table>';
-			print '</td><td>' . "\n";
+			print '</td><td>'."\n";
 		}
-		print '</td></tr>' . "\n";
+		print '</td></tr>'."\n";
 	}
 }
-print '<tr>' . "\n";
-print '<td colspan="3" class="right">' . "\n";
-print '<input type="button" name="addcontact" id="addcontact" value="' . $langs->trans('AdvTgtAddContact') . '" class="butAction"/>' . "\n";
-print '</td>' . "\n";
-print '</tr>' . "\n";
-print '</table>' . "\n";
-print '</form>' . "\n";
-print '</div>' . "\n";
-print '<form action="' . $_SERVER['PHP_SELF'] . '?action=clear&id=' . $object->id . '" method="POST">';
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+print '<tr>'."\n";
+print '<td colspan="3" class="right">'."\n";
+print '<input type="button" name="addcontact" id="addcontact" value="'.$langs->trans('AdvTgtAddContact').'" class="butAction"/>'."\n";
+print '</td>'."\n";
+print '</tr>'."\n";
+print '</table>'."\n";
+print '</form>'."\n";
+print '</div>'."\n";
+print '<form action="'.$_SERVER['PHP_SELF'].'?action=clear&id='.$object->id.'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print load_fiche_titre($langs->trans("ToClearAllRecipientsClickHere"));
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td class="liste_titre right"><input type="submit" class="button" value="' . $langs->trans("TargetsReset") . '"></td>';
+print '<td class="liste_titre right"><input type="submit" class="button" value="'.$langs->trans("TargetsReset").'"></td>';
 print '</tr>';
 print '</table>';
 print '</form>';

+ 4 - 4
htdocs/core/tpl/document_actions_post_headers.tpl.php

@@ -29,7 +29,7 @@
 // $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
 
 // Protection to avoid direct call of template
-if (empty($langs) || ! is_object($langs))
+if (empty($langs) || !is_object($langs))
 {
 	print "Error, template page can't be called as URL";
 	exit;
@@ -57,9 +57,9 @@ if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket
 
 if ($action == 'delete')
 {
-	$langs->load("companies");	// Need for string DeleteFile+ConfirmDeleteFiles
+	$langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
     print $form->formconfirm(
-			$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int') . (empty($param)?'':$param),
+			$_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param),
 			$langs->trans('DeleteFile'),
 			$langs->trans('ConfirmDeleteFile'),
 			'confirm_deletefile',
@@ -128,7 +128,7 @@ $formfile->list_of_documents(
     $modulepart,
     $param,
     0,
-    $relativepathwithnofile,		// relative path with no file. For example "0/1"
+    $relativepathwithnofile, // relative path with no file. For example "0/1"
     $permission,
     0,
     '',

+ 12 - 12
htdocs/datapolicy/admin/setup.php

@@ -23,7 +23,7 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
 require_once '../lib/datapolicy.lib.php';
 
 // Translations
@@ -33,13 +33,13 @@ $langs->load('members');
 $langs->load('datapolicy@datapolicy');
 
 // Access control
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 // Parameters
 $action = GETPOST('action', 'alpha');
 $backtopage = GETPOST('backtopage', 'alpha');
 
-$arrayofparameters=array(
+$arrayofparameters = array(
     'DATAPOLICY_TIERS_CLIENT'=>array('css'=>'minwidth200'),
     'DATAPOLICY_TIERS_PROSPECT'=>array('css'=>'minwidth200'),
     'DATAPOLICY_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200'),
@@ -78,7 +78,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 // }
 
 
-$arrayofparameters=array(
+$arrayofparameters = array(
     'ThirdParty' => array(
         'DATAPOLICY_TIERS_CLIENT'=>array('css'=>'minwidth200'),
         'DATAPOLICY_TIERS_PROSPECT'=>array('css'=>'minwidth200'),
@@ -120,7 +120,7 @@ $page_name = "datapolicySetup";
 llxHeader('', $langs->trans($page_name));
 
 // Subheader
-$linkback = '<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
 
 print load_fiche_titre($langs->trans($page_name), $linkback, 'object_generic');
 
@@ -141,17 +141,17 @@ if ($action == 'edit')
     print '<table class="noborder centpercent">';
     print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-    foreach($arrayofparameters as $title => $tab)
+    foreach ($arrayofparameters as $title => $tab)
     {
         print '<tr class="liste_titre"><td class="titlefield" colspan="2">'.$langs->trans($title).'</td></tr>';
-        foreach($tab as $key => $val)
+        foreach ($tab as $key => $val)
         {
             print '<tr class="oddeven"><td>';
             print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
             print '</td><td>';
-            print '<select name="'.$key.'"  class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'">';
+            print '<select name="'.$key.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'">';
             foreach ($valTab as $key1 => $val1) {
-                print '<option value="'.$key1.'" ' . ($conf->global->$key == $key1 ? 'selected="selected"' : '') . '>';
+                print '<option value="'.$key1.'" '.($conf->global->$key == $key1 ? 'selected="selected"' : '').'>';
                 print $val1;
                 print '</option>';
             }
@@ -172,14 +172,14 @@ if ($action == 'edit')
     print '<table class="noborder centpercent">';
     print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-    foreach($arrayofparameters as $title => $tab)
+    foreach ($arrayofparameters as $title => $tab)
     {
         print '<tr class="liste_titre"><td class="titlefield" colspan="2">'.$langs->trans($title).'</td></tr>';
-        foreach($tab as $key => $val)
+        foreach ($tab as $key => $val)
         {
             print '<tr class="oddeven"><td>';
             print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
-            print '</td><td>' . ($conf->global->$key == '' ? $langs->trans('None') : $valTab[$conf->global->$key]) . '</td></tr>';
+            print '</td><td>'.($conf->global->$key == '' ? $langs->trans('None') : $valTab[$conf->global->$key]).'</td></tr>';
         }
     }
 

+ 43 - 43
htdocs/expensereport/index.php

@@ -29,8 +29,8 @@
  */
 
 require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
-require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
 
 $hookmanager = new HookManager($db);
 
@@ -42,7 +42,7 @@ $langs->loadLangs(array('companies', 'users', 'trips'));
 
 // Security check
 $socid = GETPOST('socid', 'int');
-if ($user->socid) $socid=$user->socid;
+if ($user->socid) $socid = $user->socid;
 $result = restrictedArea($user, 'expensereport', '', '');
 
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -52,41 +52,41 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $conf->liste_limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortorder) $sortorder="DESC";
-if (! $sortfield) $sortfield="d.date_create";
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "d.date_create";
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 
 
 /*
  * View
  */
 
-$tripandexpense_static=new ExpenseReport($db);
+$tripandexpense_static = new ExpenseReport($db);
 
 $childids = $user->getAllChildIds();
-$childids[]=$user->id;
+$childids[] = $user->id;
 
 //$help_url='EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones';
-$help_url='';
+$help_url = '';
 llxHeader('', $langs->trans("ListOfFees"), $help_url);
 
 
-$label=$somme=$nb=array();
+$label = $somme = $nb = array();
 
-$totalnb=$totalsum=0;
+$totalnb = $totalsum = 0;
 $sql = "SELECT tf.code, tf.label, count(de.rowid) as nb, sum(de.total_ht) as km";
-$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."expensereport_det as de, ".MAIN_DB_PREFIX."c_type_fees as tf";
-$sql.= " WHERE de.fk_expensereport = d.rowid AND d.entity IN (".getEntity('expensereport').") AND de.fk_c_type_fees = tf.id";
+$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."expensereport_det as de, ".MAIN_DB_PREFIX."c_type_fees as tf";
+$sql .= " WHERE de.fk_expensereport = d.rowid AND d.entity IN (".getEntity('expensereport').") AND de.fk_c_type_fees = tf.id";
 // RESTRICT RIGHTS
 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
     && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)))
 {
     $childids = $user->getAllChildIds();
-    $childids[]=$user->id;
-    $sql.= " AND d.fk_user_author IN (".join(',', $childids).")\n";
+    $childids[] = $user->id;
+    $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n";
 }
 
-$sql.= " GROUP BY tf.code, tf.label";
+$sql .= " GROUP BY tf.code, tf.label";
 
 $result = $db->query($sql);
 if ($result)
@@ -121,10 +121,10 @@ print '<tr class="liste_titre">';
 print '<th colspan="4">'.$langs->trans("Statistics").'</th>';
 print "</tr>\n";
 
-$listoftype=$tripandexpense_static->listOfTypes();
+$listoftype = $tripandexpense_static->listOfTypes();
 foreach ($listoftype as $code => $label)
 {
-    $dataseries[]=array($label, (isset($somme[$code])?(int) $somme[$code]:0));
+    $dataseries[] = array($label, (isset($somme[$code]) ? (int) $somme[$code] : 0));
 }
 
 if ($conf->use_javascript_ajax)
@@ -135,13 +135,13 @@ if ($conf->use_javascript_ajax)
     $dolgraph = new DolGraph();
     $dolgraph->SetData($dataseries);
     $dolgraph->setHeight(350);
-    $dolgraph->combine = empty($conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT)?0.05:$conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT;
+    $dolgraph->combine = empty($conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT) ? 0.05 : $conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT;
     $dolgraph->setShowLegend(1);
     $dolgraph->setShowPercent(1);
     $dolgraph->SetType(array('pie'));
     $dolgraph->setWidth('100%');
     $dolgraph->draw('idgraphstatus');
-    print $dolgraph->show($totalnb?0:1);
+    print $dolgraph->show($totalnb ? 0 : 1);
 
     print '</td></tr>';
 }
@@ -160,33 +160,33 @@ print '</div>';
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
 
-$max=10;
+$max = 10;
 
 $langs->load("boxes");
 
 $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut, u.photo, u.email, u.admin";
-$sql.= ", d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as fk_status";
-$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u";
-if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE u.rowid = d.fk_user_author";
+$sql .= ", d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as fk_status";
+$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u";
+if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE u.rowid = d.fk_user_author";
 // RESTRICT RIGHTS
 if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
     && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)))
 {
     $childids = $user->getAllChildIds();
-    $childids[]=$user->id;
-    $sql.= " AND d.fk_user_author IN (".join(',', $childids).")\n";
+    $childids[] = $user->id;
+    $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n";
 }
-$sql.= ' AND d.entity IN ('.getEntity('expensereport').')';
-if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-if ($socid) $sql.= " AND d.fk_user_author = ".$socid;
-$sql.= $db->order($sortfield, $sortorder);
-$sql.= $db->plimit($max, 0);
+$sql .= ' AND d.entity IN ('.getEntity('expensereport').')';
+if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+if ($socid) $sql .= " AND d.fk_user_author = ".$socid;
+$sql .= $db->order($sortfield, $sortorder);
+$sql .= $db->plimit($max, 0);
 
 $result = $db->query($sql);
 if ($result)
 {
-    $var=false;
+    $var = false;
     $num = $db->num_rows($result);
 
     $i = 0;
@@ -204,21 +204,21 @@ if ($result)
     {
         $total_ttc = $totalam = $total = 0;
 
-        $expensereportstatic=new ExpenseReport($db);
-        $userstatic=new User($db);
+        $expensereportstatic = new ExpenseReport($db);
+        $userstatic = new User($db);
         while ($i < $num && $i < $max)
         {
             $obj = $db->fetch_object($result);
-            $expensereportstatic->id=$obj->rowid;
-            $expensereportstatic->ref=$obj->ref;
-            $userstatic->id=$obj->uid;
+            $expensereportstatic->id = $obj->rowid;
+            $expensereportstatic->ref = $obj->ref;
+            $userstatic->id = $obj->uid;
             $userstatic->admin = $obj->admin;
             $userstatic->email = $obj->email;
-            $userstatic->lastname=$obj->lastname;
-            $userstatic->firstname=$obj->firstname;
-            $userstatic->login=$obj->login;
-            $userstatic->statut=$obj->statut;
-            $userstatic->photo=$obj->photo;
+            $userstatic->lastname = $obj->lastname;
+            $userstatic->firstname = $obj->firstname;
+            $userstatic->login = $obj->login;
+            $userstatic->statut = $obj->statut;
+            $userstatic->photo = $obj->photo;
             print '<tr class="oddeven">';
             print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
             print '<td>'.$userstatic->getNomUrl(-1).'</td>';

+ 251 - 251
htdocs/exports/export.php

@@ -127,153 +127,153 @@ $entitytolang = array(
     'bomline'      => 'BOMLine'
 );
 
-$array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array();
-$array_filtervalue=isset($_SESSION["export_filtered_fields"])?$_SESSION["export_filtered_fields"]:array();
-$datatoexport=GETPOST("datatoexport", "aZ09");
-$action=GETPOST('action', 'alpha');
-$confirm=GETPOST('confirm', 'alpha');
-$step=GETPOST("step", "int")?GETPOST("step", "int"):1;
-$export_name=GETPOST("export_name", "alphanohtml");
-$hexa=GETPOST("hexa", "alpha");
-$exportmodelid=GETPOST("exportmodelid", "int");
-$field=GETPOST("field", "alpa");
-
-$objexport=new Export($db);
+$array_selected = isset($_SESSION["export_selected_fields"]) ? $_SESSION["export_selected_fields"] : array();
+$array_filtervalue = isset($_SESSION["export_filtered_fields"]) ? $_SESSION["export_filtered_fields"] : array();
+$datatoexport = GETPOST("datatoexport", "aZ09");
+$action = GETPOST('action', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
+$step = GETPOST("step", "int") ?GETPOST("step", "int") : 1;
+$export_name = GETPOST("export_name", "alphanohtml");
+$hexa = GETPOST("hexa", "alpha");
+$exportmodelid = GETPOST("exportmodelid", "int");
+$field = GETPOST("field", "alpa");
+
+$objexport = new Export($db);
 $objexport->load_arrays($user, $datatoexport);
 
-$objmodelexport=new ModeleExports($db);
+$objmodelexport = new ModeleExports($db);
 $form = new Form($db);
 $htmlother = new FormOther($db);
 $formfile = new FormFile($db);
-$sqlusedforexport='';
+$sqlusedforexport = '';
 
 $upload_dir = $conf->export->dir_temp.'/'.$user->id;
 
 //$usefilters=($conf->global->MAIN_FEATURES_LEVEL > 1);
-$usefilters=1;
+$usefilters = 1;
 
 
 /*
  * Actions
  */
 
-if ($action=='selectfield')     // Selection of field at step 2
+if ($action == 'selectfield')     // Selection of field at step 2
 {
-	$fieldsarray=$objexport->array_export_fields[0];
-	$fieldsentitiesarray=$objexport->array_export_entities[0];
-    $fieldsdependenciesarray=$objexport->array_export_dependencies[0];
+	$fieldsarray = $objexport->array_export_fields[0];
+	$fieldsentitiesarray = $objexport->array_export_entities[0];
+    $fieldsdependenciesarray = $objexport->array_export_dependencies[0];
 
-    if ($field=='all')
+    if ($field == 'all')
     {
-		foreach($fieldsarray as $key=>$val)
+		foreach ($fieldsarray as $key=>$val)
 		{
-			if (! empty($array_selected[$key])) continue;		// If already selected, check next
-			$array_selected[$key]=count($array_selected)+1;
+			if (!empty($array_selected[$key])) continue; // If already selected, check next
+			$array_selected[$key] = count($array_selected) + 1;
 		    //print_r($array_selected);
-		    $_SESSION["export_selected_fields"]=$array_selected;
+		    $_SESSION["export_selected_fields"] = $array_selected;
 		}
     }
     else
     {
-        $warnings=array();
+        $warnings = array();
 
-        $array_selected[$field]=count($array_selected)+1;    // We tag the key $field as "selected"
+        $array_selected[$field] = count($array_selected) + 1; // We tag the key $field as "selected"
         // We check if there is a dependency to activate
         /*var_dump($field);
         var_dump($fieldsentitiesarray[$field]);
         var_dump($fieldsdependenciesarray);*/
-        $listofdependencies=array();
-        if (! empty($fieldsentitiesarray[$field]) && ! empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]]))
+        $listofdependencies = array();
+        if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]]))
         {
             // We found a dependency on the type of field
-            $tmp=$fieldsdependenciesarray[$fieldsentitiesarray[$field]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid'))
-            if (is_array($tmp)) $listofdependencies=$tmp;
-            else $listofdependencies=array($tmp);
+            $tmp = $fieldsdependenciesarray[$fieldsentitiesarray[$field]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid'))
+            if (is_array($tmp)) $listofdependencies = $tmp;
+            else $listofdependencies = array($tmp);
         }
-        elseif (! empty($field) && ! empty($fieldsdependenciesarray[$field]))
+        elseif (!empty($field) && !empty($fieldsdependenciesarray[$field]))
         {
             // We found a dependency on a dedicated field
-            $tmp=$fieldsdependenciesarray[$field]; // $fieldsdependenciesarray=array('fd.fieldx'=>'fd.rowid') or array('fd.fieldx'=>array('fd.rowid','ab.rowid'))
-            if (is_array($tmp)) $listofdependencies=$tmp;
-            else $listofdependencies=array($tmp);
+            $tmp = $fieldsdependenciesarray[$field]; // $fieldsdependenciesarray=array('fd.fieldx'=>'fd.rowid') or array('fd.fieldx'=>array('fd.rowid','ab.rowid'))
+            if (is_array($tmp)) $listofdependencies = $tmp;
+            else $listofdependencies = array($tmp);
         }
 
         if (count($listofdependencies))
         {
-            foreach($listofdependencies as $fieldid)
+            foreach ($listofdependencies as $fieldid)
             {
                 if (empty($array_selected[$fieldid]))
                 {
-                    $array_selected[$fieldid]=count($array_selected)+1;    // We tag the key $fieldid as "selected"
-                    $warnings[]=$langs->trans("ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid]));
+                    $array_selected[$fieldid] = count($array_selected) + 1; // We tag the key $fieldid as "selected"
+                    $warnings[] = $langs->trans("ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid]));
                 }
             }
         }
 	    //print_r($array_selected);
-	    $_SESSION["export_selected_fields"]=$array_selected;
+	    $_SESSION["export_selected_fields"] = $array_selected;
 
 	    setEventMessages($warnings, null, 'warnings');
     }
 }
-if ($action=='unselectfield')
+if ($action == 'unselectfield')
 {
-    if ($_GET["field"]=='all')
+    if ($_GET["field"] == 'all')
     {
-		$array_selected=array();
-		$_SESSION["export_selected_fields"]=$array_selected;
+		$array_selected = array();
+		$_SESSION["export_selected_fields"] = $array_selected;
     }
     else
     {
 	    unset($array_selected[$_GET["field"]]);
 	    // Renumber fields of array_selected (from 1 to nb_elements)
 	    asort($array_selected);
-	    $i=0;
-	    $array_selected_save=$array_selected;
-	    foreach($array_selected as $code=>$value)
+	    $i = 0;
+	    $array_selected_save = $array_selected;
+	    foreach ($array_selected as $code=>$value)
 	    {
 	        $i++;
-	        $array_selected[$code]=$i;
+	        $array_selected[$code] = $i;
 	        //print "x $code x $i y<br>";
 	    }
-	    $_SESSION["export_selected_fields"]=$array_selected;
+	    $_SESSION["export_selected_fields"] = $array_selected;
     }
 }
 
-if ($action=='downfield' || $action=='upfield')
+if ($action == 'downfield' || $action == 'upfield')
 {
-    $pos=$array_selected[$_GET["field"]];
-    if ($action=='downfield') $newpos=$pos+1;
-    if ($action=='upfield') $newpos=$pos-1;
+    $pos = $array_selected[$_GET["field"]];
+    if ($action == 'downfield') $newpos = $pos + 1;
+    if ($action == 'upfield') $newpos = $pos - 1;
     // Recherche code avec qui switcher
-    $newcode="";
-    foreach($array_selected as $code=>$value)
+    $newcode = "";
+    foreach ($array_selected as $code=>$value)
     {
         if ($value == $newpos)
         {
-            $newcode=$code;
+            $newcode = $code;
             break;
         }
     }
     //print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)");
     if ($newcode)   // Si newcode trouve (protection contre resoumission de page)
     {
-        $array_selected[$_GET["field"]]=$newpos;
-        $array_selected[$newcode]=$pos;
-        $_SESSION["export_selected_fields"]=$array_selected;
+        $array_selected[$_GET["field"]] = $newpos;
+        $array_selected[$newcode] = $pos;
+        $_SESSION["export_selected_fields"] = $array_selected;
     }
 }
 
 if ($step == 1 || $action == 'cleanselect')
 {
-    $_SESSION["export_selected_fields"]=array();
-    $_SESSION["export_filtered_fields"]=array();
-    $array_selected=array();
-    $array_filtervalue=array();
+    $_SESSION["export_selected_fields"] = array();
+    $_SESSION["export_filtered_fields"] = array();
+    $array_selected = array();
+    $array_filtervalue = array();
 }
 
 if ($action == 'builddoc')
 {
-    $max_execution_time_for_export = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME)?300:$conf->global->EXPORT_MAX_EXECUTION_TIME);    // 5mn if not defined
+    $max_execution_time_for_export = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined
     $max_time = @ini_get("max_execution_time");
     if ($max_time && $max_time < $max_execution_time_for_export)
     {
@@ -281,25 +281,25 @@ if ($action == 'builddoc')
     }
 
     // Build export file
-	$result=$objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue);
+	$result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue);
 	if ($result < 0)
 	{
 		setEventMessages($objexport->error, $objexport->errors, 'errors');
-		$sqlusedforexport=$objexport->sqlusedforexport;
+		$sqlusedforexport = $objexport->sqlusedforexport;
 	}
 	else
 	{
 		setEventMessages($langs->trans("FileSuccessfullyBuilt"), null, 'mesgs');
-	    $sqlusedforexport=$objexport->sqlusedforexport;
+	    $sqlusedforexport = $objexport->sqlusedforexport;
     }
 }
 
 // Delete file
 if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes')
 {
-	$file = $upload_dir . "/" . GETPOST('file');	// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
+	$file = $upload_dir."/".GETPOST('file'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
 
-	$ret=dol_delete_file($file);
+	$ret = dol_delete_file($file);
 	if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
 	else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
 	header('Location: '.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport);
@@ -311,7 +311,7 @@ if ($action == 'deleteprof')
 	if ($_GET["id"])
 	{
 		$objexport->fetch($_GET["id"]);
-		$result=$objexport->delete($user);
+		$result = $objexport->delete($user);
 	}
 }
 
@@ -323,20 +323,20 @@ if ($action == 'add_export_model')
 		asort($array_selected);
 
 		// Set save string
-		$hexa='';
-		foreach($array_selected as $key=>$val)
+		$hexa = '';
+		foreach ($array_selected as $key=>$val)
 		{
-			if ($hexa) $hexa.=',';
-			$hexa.=$key;
+			if ($hexa) $hexa .= ',';
+			$hexa .= $key;
 		}
 
-		$hexafiltervalue='';
-		if (! empty($array_filtervalue) && is_array($array_filtervalue))
+		$hexafiltervalue = '';
+		if (!empty($array_filtervalue) && is_array($array_filtervalue))
 		{
-			foreach($array_filtervalue as $key=>$val)
+			foreach ($array_filtervalue as $key=>$val)
 			{
-				if ($hexafiltervalue) $hexafiltervalue.=',';
-				$hexafiltervalue.=$key.'='.$val;
+				if ($hexafiltervalue) $hexafiltervalue .= ',';
+				$hexafiltervalue .= $key.'='.$val;
 			}
 		}
 
@@ -368,33 +368,33 @@ if ($action == 'add_export_model')
 // Reload a predefined export model
 if ($step == 2 && $action == 'select_model')
 {
-    $_SESSION["export_selected_fields"]=array();
-    $_SESSION["export_filtered_fields"]=array();
+    $_SESSION["export_selected_fields"] = array();
+    $_SESSION["export_filtered_fields"] = array();
 
-    $array_selected=array();
-    $array_filtervalue=array();
+    $array_selected = array();
+    $array_filtervalue = array();
 
     $result = $objexport->fetch($exportmodelid);
     if ($result > 0)
     {
-		$fieldsarray=explode(',', $objexport->hexa);
-		$i=1;
-		foreach($fieldsarray as $val)
+		$fieldsarray = explode(',', $objexport->hexa);
+		$i = 1;
+		foreach ($fieldsarray as $val)
 		{
-			$array_selected[$val]=$i;
+			$array_selected[$val] = $i;
 			$i++;
 		}
-		$_SESSION["export_selected_fields"]=$array_selected;
+		$_SESSION["export_selected_fields"] = $array_selected;
 
-		$fieldsarrayvalue=explode(',', $objexport->hexafiltervalue);
-		$i=1;
-		foreach($fieldsarrayvalue as $val)
+		$fieldsarrayvalue = explode(',', $objexport->hexafiltervalue);
+		$i = 1;
+		foreach ($fieldsarrayvalue as $val)
 		{
-			$tmp=explode('=', $val);
-			$array_filtervalue[$tmp[0]]=$tmp[1];
+			$tmp = explode('=', $val);
+			$array_filtervalue[$tmp[0]] = $tmp[1];
 			$i++;
 		}
-		$_SESSION["export_filtered_fields"]=$array_filtervalue;
+		$_SESSION["export_filtered_fields"] = $array_filtervalue;
     }
 }
 
@@ -404,22 +404,22 @@ if ($step == 4 && $action == 'submitFormField')
 	// on boucle sur les champs selectionne pour recuperer la valeur
 	if (is_array($objexport->array_export_TypeFields[0]))
 	{
-		$_SESSION["export_filtered_fields"]=array();
-		foreach($objexport->array_export_TypeFields[0] as $code => $type)	// $code: s.fieldname $value: Text|Boolean|List:ccc
+		$_SESSION["export_filtered_fields"] = array();
+		foreach ($objexport->array_export_TypeFields[0] as $code => $type)	// $code: s.fieldname $value: Text|Boolean|List:ccc
 		{
-			$newcode=(string) preg_replace('/\./', '_', $code);
+			$newcode = (string) preg_replace('/\./', '_', $code);
 			//print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n<br>";
-			$filterqualified=1;
-			if (! isset($_POST[$newcode]) || $_POST[$newcode] == '') $filterqualified=0;
-			elseif (preg_match('/^List/', $type) && (is_numeric($_POST[$newcode]) && $_POST[$newcode] <= 0)) $filterqualified=0;
+			$filterqualified = 1;
+			if (!isset($_POST[$newcode]) || $_POST[$newcode] == '') $filterqualified = 0;
+			elseif (preg_match('/^List/', $type) && (is_numeric($_POST[$newcode]) && $_POST[$newcode] <= 0)) $filterqualified = 0;
 			if ($filterqualified)
 			{
 				//print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n";
 				$objexport->array_export_FilterValue[0][$code] = $_POST[$newcode];
 			}
 		}
-		$array_filtervalue=(! empty($objexport->array_export_FilterValue[0])?$objexport->array_export_FilterValue[0]:'');
-		$_SESSION["export_filtered_fields"]=$array_filtervalue;
+		$array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : '');
+		$_SESSION["export_filtered_fields"] = $array_filtervalue;
 	}
 }
 
@@ -428,7 +428,7 @@ if ($step == 4 && $action == 'submitFormField')
  * View
  */
 
-if ($step == 1 || ! $datatoexport)
+if ($step == 1 || !$datatoexport)
 {
     llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones');
 
@@ -436,7 +436,7 @@ if ($step == 1 || ! $datatoexport)
 
     $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=1';
     $head[$h][1] = $langs->trans("Step")." 1";
-    $hselected=$h;
+    $hselected = $h;
     $h++;
 
     dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -1);
@@ -445,7 +445,7 @@ if ($step == 1 || ! $datatoexport)
     print '<div class="opacitymedium">'.$langs->trans("SelectExportDataSet").'</div><br>';
 
     // Affiche les modules d'exports
-    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
+    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
     print '<table class="noborder centpercent">';
     print '<tr class="liste_titre">';
     print '<td>'.$langs->trans("Module").'</td>';
@@ -462,8 +462,8 @@ if ($step == 1 || ! $datatoexport)
 	        //print img_object($objexport->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
             print $objexport->array_export_module[$key]->getName();
             print '</td><td>';
-			$icon=preg_replace('/:.*$/', '', $objexport->array_export_icon[$key]);
-			$label=$objexport->array_export_label[$key];
+			$icon = preg_replace('/:.*$/', '', $objexport->array_export_icon[$key]);
+			$label = $objexport->array_export_label[$key];
             //print $value.'-'.$icon.'-'.$label."<br>";
 			print img_object($objexport->array_export_module[$key]->getName(), $icon).' ';
             print $label;
@@ -501,7 +501,7 @@ if ($step == 2 && $datatoexport)
 
     $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport;
     $head[$h][1] = $langs->trans("Step")." 2";
-    $hselected=$h;
+    $hselected = $h;
     $h++;
 
     dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2);
@@ -521,8 +521,8 @@ if ($step == 2 && $datatoexport)
     // Lot de donnees a exporter
     print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
     print '<td>';
-	$icon=preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
-    $label=$objexport->array_export_label[0];
+	$icon = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
+    $label = $objexport->array_export_label[0];
     //print $value.'-'.$icon.'-'.$label."<br>";
     print img_object($objexport->array_export_module[0]->getName(), $icon).' ';
     print $label;
@@ -543,7 +543,7 @@ if ($step == 2 && $datatoexport)
     print '<input type="hidden" name="datatoexport" value="'.$datatoexport.'">';
     print '<div class="valignmiddle marginbottomonly">';
     print '<span class="opacitymedium">'.$langs->trans("SelectExportFields").'</span> ';
-    if(empty($conf->global->EXPORTS_SHARE_MODELS))$htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1, $user->id);
+    if (empty($conf->global->EXPORTS_SHARE_MODELS))$htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1, $user->id);
 	else $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1);
     print ' ';
     print '<input type="submit" class="button" value="'.$langs->trans("Select").'">';
@@ -551,7 +551,7 @@ if ($step == 2 && $datatoexport)
     print '</form>';
 
 
-    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
+    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
     print '<table class="noborder centpercent">';
     print '<tr class="liste_titre">';
 	print '<td>'.$langs->trans("Entities").'</td>';
@@ -565,9 +565,9 @@ if ($step == 2 && $datatoexport)
     print '</tr>';
 
     // Champs exportables
-    $fieldsarray=$objexport->array_export_fields[0];
+    $fieldsarray = $objexport->array_export_fields[0];
     // Select request if all fields are selected
-    $sqlmaxforexport=$objexport->build_sql(0, array(), array());
+    $sqlmaxforexport = $objexport->build_sql(0, array(), array());
 
 	//    $this->array_export_module[0]=$module;
 	//    $this->array_export_code[0]=$module->export_code[$r];
@@ -579,48 +579,48 @@ if ($step == 2 && $datatoexport)
 
     $i = 0;
 
-    foreach($fieldsarray as $code=>$label)
+    foreach ($fieldsarray as $code=>$label)
     {
         print '<tr class="oddeven">';
 
         $i++;
 
-        $entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]);
-        $entityicon=strtolower(! empty($entitytoicon[$entity])?$entitytoicon[$entity]:$entity);
-        $entitylang=(! empty($entitytolang[$entity])?$entitytolang[$entity]:$entity);
+        $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
+        $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
+        $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
 
         print '<td class="nowrap">';
         // If value of entityicon=entitylang='icon:Label'
         //print $code.'-'.$label.'-'.$entity;
 
-        $tmparray=explode(':', $entityicon);
-        if (count($tmparray) >=2)
+        $tmparray = explode(':', $entityicon);
+        if (count($tmparray) >= 2)
         {
-            $entityicon=$tmparray[0];
-            $entitylang=$tmparray[1];
+            $entityicon = $tmparray[0];
+            $entitylang = $tmparray[1];
         }
         print img_object('', $entityicon).' '.$langs->trans($entitylang);
         print '</td>';
 
-        $text=(empty($objexport->array_export_special[0][$code])?'':'<i>').$langs->trans($label).(empty($objexport->array_export_special[0][$code])?'':'</i>');
+        $text = (empty($objexport->array_export_special[0][$code]) ? '' : '<i>').$langs->trans($label).(empty($objexport->array_export_special[0][$code]) ? '' : '</i>');
 
-        $tablename=getablenamefromfield($code, $sqlmaxforexport);
-        $htmltext ='<b>'.$langs->trans("Name").":</b> ".$text.'<br>';
-        if (! empty($objexport->array_export_special[0][$code]))
+        $tablename = getablenamefromfield($code, $sqlmaxforexport);
+        $htmltext = '<b>'.$langs->trans("Name").":</b> ".$text.'<br>';
+        if (!empty($objexport->array_export_special[0][$code]))
         {
-            $htmltext.='<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
+            $htmltext .= '<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
         }
         else
         {
-            $htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
+            $htmltext .= '<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
         }
-   		if (! empty($objexport->array_export_examplevalues[0][$code]))
+   		if (!empty($objexport->array_export_examplevalues[0][$code]))
 		{
-		    $htmltext.='<b>'.$langs->trans("SourceExample").':</b> '.$objexport->array_export_examplevalues[0][$code].'<br>';
+		    $htmltext .= '<b>'.$langs->trans("SourceExample").':</b> '.$objexport->array_export_examplevalues[0][$code].'<br>';
 		}
-    	if (! empty($objexport->array_export_TypeFields[0][$code]))
+    	if (!empty($objexport->array_export_TypeFields[0][$code]))
 		{
-		    $htmltext.='<b>'.$langs->trans("Type").':</b> '.$objexport->array_export_TypeFields[0][$code].'<br>';
+		    $htmltext .= '<b>'.$langs->trans("Type").':</b> '.$objexport->array_export_TypeFields[0][$code].'<br>';
 		}
 
 		if (isset($array_selected[$code]) && $array_selected[$code])
@@ -700,7 +700,7 @@ if ($step == 3 && $datatoexport)
 
 	$head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport;
 	$head[$h][1] = $langs->trans("Step")." 3";
-	$hselected=$h;
+	$hselected = $h;
 	$h++;
 
 	dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2);
@@ -719,8 +719,8 @@ if ($step == 3 && $datatoexport)
 	// Lot de donnees a exporter
 	print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
 	print '<td>';
-	$icon=preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
-	$label=$objexport->array_export_label[0];
+	$icon = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
+	$label = $objexport->array_export_label[0];
 	//print $value.'-'.$icon.'-'.$label."<br>";
 	print img_object($objexport->array_export_module[0]->getName(), $icon).' ';
 	print $label;
@@ -728,11 +728,11 @@ if ($step == 3 && $datatoexport)
 
 	// Nbre champs exportes
 	print '<tr><td>'.$langs->trans("ExportedFields").'</td>';
-	$list='';
-	foreach($array_selected as $code=>$value)
+	$list = '';
+	foreach ($array_selected as $code=>$value)
 	{
-		$list.=(! empty($list)?', ':'');
-		$list.=(isset($objexport->array_export_fields[0][$code])?$langs->trans($objexport->array_export_fields[0][$code]):'');
+		$list .= (!empty($list) ? ', ' : '');
+		$list .= (isset($objexport->array_export_fields[0][$code]) ? $langs->trans($objexport->array_export_fields[0][$code]) : '');
 	}
 	print '<td>'.$list.'</td></tr>';
 
@@ -749,7 +749,7 @@ if ($step == 3 && $datatoexport)
 	print '<form action="'.$_SERVER["PHP_SELF"].'?step=4&action=submitFormField&datatoexport='.$datatoexport.'" name="FilterField" method="post">';
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 
-	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
+	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
 
     print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre">';
@@ -761,58 +761,58 @@ if ($step == 3 && $datatoexport)
 	print '</tr>';
 
 	// Champs exportables
-	$fieldsarray=$objexport->array_export_fields[0];
+	$fieldsarray = $objexport->array_export_fields[0];
 	// Champs filtrable
-	$Typefieldsarray=$objexport->array_export_TypeFields[0];
+	$Typefieldsarray = $objexport->array_export_TypeFields[0];
 	// valeur des filtres
-	$ValueFiltersarray=(! empty($objexport->array_export_FilterValue[0])?$objexport->array_export_FilterValue[0]:'');
+	$ValueFiltersarray = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : '');
 	// Select request if all fields are selected
-	$sqlmaxforexport=$objexport->build_sql(0, array(), array());
+	$sqlmaxforexport = $objexport->build_sql(0, array(), array());
 
 	$i = 0;
 	// on boucle sur les champs
-	foreach($fieldsarray as $code => $label)
+	foreach ($fieldsarray as $code => $label)
 	{
 		print '<tr class="oddeven">';
 
 		$i++;
-		$entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]);
-		$entityicon=strtolower(! empty($entitytoicon[$entity])?$entitytoicon[$entity]:$entity);
-		$entitylang=(! empty($entitytolang[$entity])?$entitytolang[$entity]:$entity);
+		$entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
+		$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
+		$entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
 
 		print '<td class="nowrap">';
 		// If value of entityicon=entitylang='icon:Label'
-		$tmparray=explode(':', $entityicon);
-		if (count($tmparray) >=2)
+		$tmparray = explode(':', $entityicon);
+		if (count($tmparray) >= 2)
 		{
-			$entityicon=$tmparray[0];
-			$entitylang=$tmparray[1];
+			$entityicon = $tmparray[0];
+			$entitylang = $tmparray[1];
 		}
 		print img_object('', $entityicon).' '.$langs->trans($entitylang);
 		print '</td>';
 
 		// Field name
-		$labelName=(! empty($fieldsarray[$code])?$fieldsarray[$code]:'');
-		$ValueFilter=(! empty($array_filtervalue[$code])?$array_filtervalue[$code]:'');
-		$text=(empty($objexport->array_export_special[0][$code])?'':'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code])?'':'</i>');
+		$labelName = (!empty($fieldsarray[$code]) ? $fieldsarray[$code] : '');
+		$ValueFilter = (!empty($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
+		$text = (empty($objexport->array_export_special[0][$code]) ? '' : '<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ? '' : '</i>');
 
-		$tablename=getablenamefromfield($code, $sqlmaxforexport);
-		$htmltext ='<b>'.$langs->trans("Name").':</b> '.$text.'<br>';
-        if (! empty($objexport->array_export_special[0][$code]))
+		$tablename = getablenamefromfield($code, $sqlmaxforexport);
+		$htmltext = '<b>'.$langs->trans("Name").':</b> '.$text.'<br>';
+        if (!empty($objexport->array_export_special[0][$code]))
 		{
-		    $htmltext.='<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
+		    $htmltext .= '<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
 		}
 		else
 		{
-		    $htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
+		    $htmltext .= '<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
 		}
-		if (! empty($objexport->array_export_examplevalues[0][$code]))
+		if (!empty($objexport->array_export_examplevalues[0][$code]))
 		{
-		    $htmltext.=$langs->trans("SourceExample").': <b>'.$objexport->array_export_examplevalues[0][$code].'</b><br>';
+		    $htmltext .= $langs->trans("SourceExample").': <b>'.$objexport->array_export_examplevalues[0][$code].'</b><br>';
 		}
-		if (! empty($objexport->array_export_TypeFields[0][$code]))
+		if (!empty($objexport->array_export_TypeFields[0][$code]))
 		{
-		    $htmltext.=$langs->trans("Type").': <b>'.$objexport->array_export_TypeFields[0][$code].'</b><br>';
+		    $htmltext .= $langs->trans("Type").': <b>'.$objexport->array_export_TypeFields[0][$code].'</b><br>';
 		}
 
 		print '<td>';
@@ -821,12 +821,12 @@ if ($step == 3 && $datatoexport)
 
 		// Filter value
 		print '<td>';
-		if (! empty($Typefieldsarray[$code]))	// Example: Text, List:c_country:label:rowid, Number, Boolean
+		if (!empty($Typefieldsarray[$code]))	// Example: Text, List:c_country:label:rowid, Number, Boolean
 		{
-			$szInfoFiltre=$objexport->genDocFilter($Typefieldsarray[$code]);
+			$szInfoFiltre = $objexport->genDocFilter($Typefieldsarray[$code]);
 			if ($szInfoFiltre)	// Is there an info help for this filter ?
 			{
-				$tmp=$objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
+				$tmp = $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
 				print $form->textwithpicto($tmp, $szInfoFiltre);
 			}
 			else
@@ -866,7 +866,7 @@ if ($step == 4 && $datatoexport)
 
     llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones');
 
-    $stepoffset=0;
+    $stepoffset = 0;
     $h = 0;
 
     $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=1';
@@ -887,8 +887,8 @@ if ($step == 4 && $datatoexport)
     }
 
     $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=4&datatoexport='.$datatoexport;
-    $head[$h][1] = $langs->trans("Step")." ".(3+$stepoffset);
-    $hselected=$h;
+    $head[$h][1] = $langs->trans("Step")." ".(3 + $stepoffset);
+    $hselected = $h;
     $h++;
 
     dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2);
@@ -907,18 +907,18 @@ if ($step == 4 && $datatoexport)
     // Lot de donnees a exporter
     print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
     print '<td>';
-	$icon=preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
+	$icon = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
     print img_object($objexport->array_export_module[0]->getName(), $icon).' ';
     print $objexport->array_export_label[0];
     print '</td></tr>';
 
     // List of exported fields
     print '<tr><td>'.$langs->trans("ExportedFields").'</td>';
-    $list='';
-    foreach($array_selected as $code=>$value)
+    $list = '';
+    foreach ($array_selected as $code=>$value)
     {
-        $list.=(! empty($list)?', ':'');
-        $list.=$langs->trans($objexport->array_export_fields[0][$code]);
+        $list .= (!empty($list) ? ', ' : '');
+        $list .= $langs->trans($objexport->array_export_fields[0][$code]);
     }
     print '<td>'.$list.'</td>';
     print '</tr>';
@@ -927,20 +927,20 @@ if ($step == 4 && $datatoexport)
     if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
     {
     	print '<tr><td width="25%">'.$langs->trans("FilteredFields").'</td>';
-    	$list='';
-    	if (! empty($array_filtervalue))
+    	$list = '';
+    	if (!empty($array_filtervalue))
     	{
-    		foreach($array_filtervalue as $code=>$value)
+    		foreach ($array_filtervalue as $code=>$value)
     		{
     			if (isset($objexport->array_export_fields[0][$code]))
     			{
-    				$list.=($list?', ':'');
-    				if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list.=$langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'');
-    				else $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'";
+    				$list .= ($list ? ', ' : '');
+    				if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
+    				else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
     			}
     		}
     	}
-    	print '<td>'.(! empty($list)?$list:$langs->trans("None")).'</td>';
+    	print '<td>'.(!empty($list) ? $list : $langs->trans("None")).'</td>';
     	print '</tr>';
     }
 
@@ -950,11 +950,11 @@ if ($step == 4 && $datatoexport)
     print '<br>';
 
     // Select request if all fields are selected
-    $sqlmaxforexport=$objexport->build_sql(0, array(), array());
+    $sqlmaxforexport = $objexport->build_sql(0, array(), array());
 
     print '<div class="marginbottomonly"><span class="opacitymedium">'.$langs->trans("ChooseFieldsOrdersAndTitle").'</span></div>';
 
-    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
+    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
     print '<table class="noborder centpercent">';
     print '<tr class="liste_titre">';
     print '<td>'.$langs->trans("Entities").'</td>';
@@ -964,46 +964,46 @@ if ($step == 4 && $datatoexport)
     //print '<td>'.$langs->trans("FieldsTitle").'</td>';
     print '</tr>';
 
-    foreach($array_selected as $code=>$value)
+    foreach ($array_selected as $code=>$value)
     {
         print '<tr class="oddeven">';
 
-        $entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]);
-        $entityicon=strtolower(! empty($entitytoicon[$entity])?$entitytoicon[$entity]:$entity);
-        $entitylang=(! empty($entitytolang[$entity])?$entitytolang[$entity]:$entity);
+        $entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
+        $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
+        $entitylang = (!empty($entitytolang[$entity]) ? $entitytolang[$entity] : $entity);
 
         print '<td class="nowrap">';
         // If value of entityicon=entitylang='icon:Label'
-        $tmparray=explode(':', $entityicon);
-        if (count($tmparray) >=2)
+        $tmparray = explode(':', $entityicon);
+        if (count($tmparray) >= 2)
         {
-            $entityicon=$tmparray[0];
-            $entitylang=$tmparray[1];
+            $entityicon = $tmparray[0];
+            $entitylang = $tmparray[1];
         }
         print img_object('', $entityicon).' '.$langs->trans($entitylang);
         print '</td>';
 
-        $labelName=$objexport->array_export_fields[0][$code];
+        $labelName = $objexport->array_export_fields[0][$code];
 
-		$text=(empty($objexport->array_export_special[0][$code])?'':'<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code])?'':'</i>');
+		$text = (empty($objexport->array_export_special[0][$code]) ? '' : '<i>').$langs->trans($labelName).(empty($objexport->array_export_special[0][$code]) ? '' : '</i>');
 
-        $tablename=getablenamefromfield($code, $sqlmaxforexport);
-        $htmltext ='<b>'.$langs->trans("Name").':</b> '.$text.'<br>';
-        if (! empty($objexport->array_export_special[0][$code]))
+        $tablename = getablenamefromfield($code, $sqlmaxforexport);
+        $htmltext = '<b>'.$langs->trans("Name").':</b> '.$text.'<br>';
+        if (!empty($objexport->array_export_special[0][$code]))
         {
-            $htmltext.='<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
+            $htmltext .= '<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
         }
         else
         {
-            $htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
+            $htmltext .= '<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
         }
-        if (! empty($objexport->array_export_examplevalues[0][$code]))
+        if (!empty($objexport->array_export_examplevalues[0][$code]))
         {
-            $htmltext.=$langs->trans("SourceExample").': <b>'.$objexport->array_export_examplevalues[0][$code].'</b><br>';
+            $htmltext .= $langs->trans("SourceExample").': <b>'.$objexport->array_export_examplevalues[0][$code].'</b><br>';
         }
-        if (! empty($objexport->array_export_TypeFields[0][$code]))
+        if (!empty($objexport->array_export_TypeFields[0][$code]))
         {
-            $htmltext.=$langs->trans("Type").': <b>'.$objexport->array_export_TypeFields[0][$code].'</b><br>';
+            $htmltext .= $langs->trans("Type").': <b>'.$objexport->array_export_TypeFields[0][$code].'</b><br>';
         }
 
         print '<td>';
@@ -1056,7 +1056,7 @@ if ($step == 4 && $datatoexport)
         print '<input type="hidden" name="datatoexport" value="'.$datatoexport.'">';
         print '<input type="hidden" name="hexa" value="'.$hexa.'">';
 
-        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
+        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
         print '<table class="noborder centpercent">';
 		print '<tr class="liste_titre">';
 		print '<td>'.$langs->trans("ExportModelName").'</td>';
@@ -1070,10 +1070,10 @@ if ($step == 4 && $datatoexport)
 
         // List of existing export profils
     	$sql = "SELECT rowid, label";
-		$sql.= " FROM ".MAIN_DB_PREFIX."export_model";
-		$sql.= " WHERE type = '".$datatoexport."'";
-		if(empty($conf->global->EXPORTS_SHARE_MODELS))$sql.=" AND fk_user=".$user->id;
-		$sql.= " ORDER BY rowid";
+		$sql .= " FROM ".MAIN_DB_PREFIX."export_model";
+		$sql .= " WHERE type = '".$datatoexport."'";
+		if (empty($conf->global->EXPORTS_SHARE_MODELS))$sql .= " AND fk_user=".$user->id;
+		$sql .= " ORDER BY rowid";
 		$resql = $db->query($sql);
 		if ($resql)
 		{
@@ -1117,7 +1117,7 @@ if ($step == 5 && $datatoexport)
     llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones');
 
     $h = 0;
-    $stepoffset=0;
+    $stepoffset = 0;
 
     $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=1';
     $head[$h][1] = $langs->trans("Step")." 1";
@@ -1137,12 +1137,12 @@ if ($step == 5 && $datatoexport)
     }
 
     $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=4&datatoexport='.$datatoexport;
-    $head[$h][1] = $langs->trans("Step")." ".(3+$stepoffset);
+    $head[$h][1] = $langs->trans("Step")." ".(3 + $stepoffset);
     $h++;
 
     $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=5&datatoexport='.$datatoexport;
-    $head[$h][1] = $langs->trans("Step")." ".(4+$stepoffset);
-    $hselected=$h;
+    $head[$h][1] = $langs->trans("Step")." ".(4 + $stepoffset);
+    $hselected = $h;
     $h++;
 
     dol_fiche_head($head, $hselected, $langs->trans("NewExport"), -2);
@@ -1170,18 +1170,18 @@ if ($step == 5 && $datatoexport)
     // Lot de donnees a exporter
     print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
     print '<td>';
-	$icon=preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
+	$icon = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
     print img_object($objexport->array_export_module[0]->getName(), $icon).' ';
     print $objexport->array_export_label[0];
     print '</td></tr>';
 
     // List of exported fields
     print '<tr><td>'.$langs->trans("ExportedFields").'</td>';
-    $list='';
-    foreach($array_selected as $code=>$label)
+    $list = '';
+    foreach ($array_selected as $code=>$label)
     {
-        $list.=(! empty($list)?', ':'');
-        $list.=$langs->trans($objexport->array_export_fields[0][$code]);
+        $list .= (!empty($list) ? ', ' : '');
+        $list .= $langs->trans($objexport->array_export_fields[0][$code]);
     }
     print '<td>'.$list.'</td></tr>';
 
@@ -1189,20 +1189,20 @@ if ($step == 5 && $datatoexport)
     if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
     {
     	print '<tr><td>'.$langs->trans("FilteredFields").'</td>';
-    	$list='';
-    	if (! empty($array_filtervalue))
+    	$list = '';
+    	if (!empty($array_filtervalue))
     	{
-    		foreach($array_filtervalue as $code=>$value)
+    		foreach ($array_filtervalue as $code=>$value)
     		{
     			if (isset($objexport->array_export_fields[0][$code]))
     			{
-    				$list.=($list?', ':'');
-    				if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list.=$langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'');
-    				else $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'";
+    				$list .= ($list ? ', ' : '');
+    				if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
+    				else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
     			}
     		}
     	}
-    	print '<td>'.(! empty($list)?$list:'<span class="opacitymedium">'.$langs->trans("None").'</span>').'</td>';
+    	print '<td>'.(!empty($list) ? $list : '<span class="opacitymedium">'.$langs->trans("None").'</span>').'</td>';
     	print '</tr>';
     }
 
@@ -1213,32 +1213,32 @@ if ($step == 5 && $datatoexport)
 
     // List of available export formats
     $htmltabloflibs = '<table class="noborder centpercent">';
-    $htmltabloflibs.= '<tr class="liste_titre">';
-    $htmltabloflibs.= '<td>'.$langs->trans("AvailableFormats").'</td>';
-    $htmltabloflibs.= '<td>'.$langs->trans("LibraryUsed").'</td>';
-    $htmltabloflibs.= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
-    $htmltabloflibs.= '</tr>'."\n";
-
-    $liste=$objmodelexport->liste_modeles($db);
-    $listeall=$liste;
-    foreach($listeall as $key => $val)
+    $htmltabloflibs .= '<tr class="liste_titre">';
+    $htmltabloflibs .= '<td>'.$langs->trans("AvailableFormats").'</td>';
+    $htmltabloflibs .= '<td>'.$langs->trans("LibraryUsed").'</td>';
+    $htmltabloflibs .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
+    $htmltabloflibs .= '</tr>'."\n";
+
+    $liste = $objmodelexport->liste_modeles($db);
+    $listeall = $liste;
+    foreach ($listeall as $key => $val)
     {
     	if (preg_match('/__\(Disabled\)__/', $listeall[$key]))
     	{
-    		$listeall[$key]=preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $listeall[$key]);
+    		$listeall[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $listeall[$key]);
     		unset($liste[$key]);
     	}
 
-    	$htmltabloflibs.= '<tr class="oddeven">';
-    	$htmltabloflibs.= '<td>'.img_picto_common($key, $objmodelexport->getPictoForKey($key)).' ';
-	    $text=$objmodelexport->getDriverDescForKey($key);
-	    $label=$listeall[$key];
-	    $htmltabloflibs.= $form->textwithpicto($label, $text).'</td>';
-	    $htmltabloflibs.= '<td>'.$objmodelexport->getLibLabelForKey($key).'</td>';
-	    $htmltabloflibs.= '<td class="right">'.$objmodelexport->getLibVersionForKey($key).'</td>';
-	    $htmltabloflibs.= '</tr>'."\n";
+    	$htmltabloflibs .= '<tr class="oddeven">';
+    	$htmltabloflibs .= '<td>'.img_picto_common($key, $objmodelexport->getPictoForKey($key)).' ';
+	    $text = $objmodelexport->getDriverDescForKey($key);
+	    $label = $listeall[$key];
+	    $htmltabloflibs .= $form->textwithpicto($label, $text).'</td>';
+	    $htmltabloflibs .= '<td>'.$objmodelexport->getLibLabelForKey($key).'</td>';
+	    $htmltabloflibs .= '<td class="right">'.$objmodelexport->getLibVersionForKey($key).'</td>';
+	    $htmltabloflibs .= '</tr>'."\n";
     }
-    $htmltabloflibs.= '</table>';
+    $htmltabloflibs .= '</table>';
 
     print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NowClickToGenerateToBuildExportFile"), $htmltabloflibs, 1, 'help', '', 0, 2, 'helphonformat').'</span>';
     //print $htmltabloflibs;
@@ -1258,18 +1258,18 @@ if ($step == 5 && $datatoexport)
 	print '</table>';
 
 
-    if (! is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp);
+    if (!is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp);
 
     // Show existing generated documents
     // NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste
-    print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (! empty($_POST['model'])?$_POST['model']:'csv'), 1, 1, 0, 0, 0, '', '&nbsp;', '', '', '');
+    print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (!empty($_POST['model']) ? $_POST['model'] : 'csv'), 1, 1, 0, 0, 0, '', '&nbsp;', '', '', '');
 }
 
 llxFooter();
 
 $db->close();
 
-exit;	// don't know why but apache hangs with php 5.3.10-1ubuntu3.12 and apache 2.2.2 if i remove this exit or replace with return
+exit; // don't know why but apache hangs with php 5.3.10-1ubuntu3.12 and apache 2.2.2 if i remove this exit or replace with return
 
 
 /**
@@ -1281,16 +1281,16 @@ exit;	// don't know why but apache hangs with php 5.3.10-1ubuntu3.12 and apache
  */
 function getablenamefromfield($code, $sqlmaxforexport)
 {
-	$alias=preg_replace('/\.(.*)$/i', '', $code);         // Keep only 'Alias' and remove '.Fieldname'
-	$regexstring='/([a-zA-Z_]+) as '.preg_quote($alias).'[, \)]/i';
+	$alias = preg_replace('/\.(.*)$/i', '', $code); // Keep only 'Alias' and remove '.Fieldname'
+	$regexstring = '/([a-zA-Z_]+) as '.preg_quote($alias).'[, \)]/i';
 
-	$newsql=$sqlmaxforexport;
-	$newsql=preg_replace('/^(.*) FROM /i', '', $newsql);  // Remove part before the FROM
-	$newsql=preg_replace('/WHERE (.*)$/i', '', $newsql);	// Remove part after the WHERE so we have now only list of table aliases in a string. We must keep the ' ' before WHERE
+	$newsql = $sqlmaxforexport;
+	$newsql = preg_replace('/^(.*) FROM /i', '', $newsql); // Remove part before the FROM
+	$newsql = preg_replace('/WHERE (.*)$/i', '', $newsql); // Remove part after the WHERE so we have now only list of table aliases in a string. We must keep the ' ' before WHERE
 
 	if (preg_match($regexstring, $newsql, $reg))
 	{
-		return $reg[1];   // The tablename
+		return $reg[1]; // The tablename
 	}
 	else return '';
 }

+ 10 - 10
htdocs/exports/index.php

@@ -28,16 +28,16 @@ require_once DOL_DOCUMENT_ROOT.'/exports/class/export.class.php';
 $langs->load("exports");
 
 // Security check
-$result=restrictedArea($user, 'export');
+$result = restrictedArea($user, 'export');
 
-$export=new Export($db);
+$export = new Export($db);
 $export->load_arrays($user);
 
 /*
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader('', $langs->trans("ExportsArea"), 'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones');
 
@@ -59,7 +59,7 @@ print '<br>';
 
 // List of available export formats
 
-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
+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
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
 print '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
@@ -68,20 +68,20 @@ print '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
 print '</tr>';
 
 include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
-$model=new ModeleExports($db);
-$liste=$model->liste_modeles($db);    // This is not a static method for exports because method load non static properties
+$model = new ModeleExports($db);
+$liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties
 
-foreach($liste as $key => $val)
+foreach ($liste as $key => $val)
 {
     if (preg_match('/__\(Disabled\)__/', $liste[$key]))
     {
-    	$liste[$key]=preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
+    	$liste[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
     }
 
 	print '<tr class="oddeven">';
 	print '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
-	$text=$model->getDriverDescForKey($key);
-	$label=$liste[$key];
+	$text = $model->getDriverDescForKey($key);
+	$label = $liste[$key];
 	print '<td>'.$form->textwithpicto($label, $text).'</td>';
 	print '<td>'.$model->getLibLabelForKey($key).'</td>';
 	print '<td class="nowrap right">'.$model->getLibVersionForKey($key).'</td>';

+ 105 - 105
htdocs/fichinter/card-rec.php

@@ -37,43 +37,43 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
 
 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-if (! empty($conf->projet->enabled)) {
-	require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
-	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
+if (!empty($conf->projet->enabled)) {
+	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
 }
-if (! empty($conf->contrat->enabled)) {
+if (!empty($conf->contrat->enabled)) {
 	require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
-	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcontract.class.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php';
 }
 
 // Load translation files required by the page
-$langs->loadLangs(array("interventions","admin","compta","bills"));
+$langs->loadLangs(array("interventions", "admin", "compta", "bills"));
 
 // Security check
-$id=(GETPOST('fichinterid', 'int')?GETPOST('fichinterid', 'int'):GETPOST('id', 'int'));
-$action=GETPOST('action', 'alpha');
-if ($user->socid) $socid=$user->socid;
+$id = (GETPOST('fichinterid', 'int') ?GETPOST('fichinterid', 'int') : GETPOST('id', 'int'));
+$action = GETPOST('action', 'alpha');
+if ($user->socid) $socid = $user->socid;
 $objecttype = 'fichinter_rec';
 if ($action == "create" || $action == "add") $objecttype = '';
 $result = restrictedArea($user, 'ficheinter', $id, $objecttype);
 
 if ($page == -1)
-	$page = 0 ;
+	$page = 0;
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
-$offset = $limit * $page ;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$offset = $limit * $page;
 
 if ($sortorder == "")
-	$sortorder="DESC";
+	$sortorder = "DESC";
 
 if ($sortfield == "")
-	$sortfield="f.datec";
+	$sortfield = "f.datec";
 
 $object = new FichinterRec($db);
 $extrafields = new ExtraFields($db);
 
 
-$arrayfields=array(
+$arrayfields = array(
 	'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
 	's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
 	'f.fk_contrat'=>array('label'=>$langs->trans("Contract"), 'checked'=>1),
@@ -95,26 +95,26 @@ $arrayfields=array(
 
 // Create predefined intervention
 if ($action == 'add') {
-	if (! GETPOST('titre')) {
+	if (!GETPOST('titre')) {
 		setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors');
 		$action = "create";
 		$error++;
 	}
 
-	if (! GETPOST('socid')) {
+	if (!GETPOST('socid')) {
 		setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Customer")), null, 'errors');
 		$action = "create";
 		$error++;
 	}
 
 	// gestion des fréquences et des échéances
-	$frequency=GETPOST('frequency', 'int');
-	$reyear=GETPOST('reyear');
-	$remonth=GETPOST('remonth');
-	$reday=GETPOST('reday');
-	$rehour=GETPOST('rehour');
-	$remin=GETPOST('remin');
-	$nb_gen_max = (GETPOST('nb_gen_max', 'int')?GETPOST('nb_gen_max', 'int'):0);
+	$frequency = GETPOST('frequency', 'int');
+	$reyear = GETPOST('reyear');
+	$remonth = GETPOST('remonth');
+	$reday = GETPOST('reday');
+	$rehour = GETPOST('rehour');
+	$remin = GETPOST('remin');
+	$nb_gen_max = (GETPOST('nb_gen_max', 'int') ?GETPOST('nb_gen_max', 'int') : 0);
 	if (GETPOST('frequency')) {
 		if (empty($reyear) || empty($remonth) || empty($reday)) {
 			setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
@@ -128,8 +128,8 @@ if ($action == 'add') {
 		}
 	}
 
-	if (! $error) {
-		$object->id_origin		= $id;
+	if (!$error) {
+		$object->id_origin = $id;
 		$object->title			= GETPOST('titre', 'alpha');
 		$object->description	= GETPOST('description', 'alpha');
 		$object->socid			= GETPOST('socid', 'alpha');
@@ -160,19 +160,19 @@ if ($action == 'add') {
 
 	// on transfert les données de l'un vers l'autre
 	if ($object->socid > 0) {
-		$newinter->socid=$object->socid;
-		$newinter->fk_project=$object->fk_project;
-		$newinter->fk_contrat=$object->fk_contrat;
+		$newinter->socid = $object->socid;
+		$newinter->fk_project = $object->fk_project;
+		$newinter->fk_contrat = $object->fk_contrat;
 	} else {
-		$newinter->socid=GETPOST("socid");
+		$newinter->socid = GETPOST("socid");
 	}
 
-	$newinter->entity=$object->entity;
-	$newinter->duree=$object->duree;
+	$newinter->entity = $object->entity;
+	$newinter->duree = $object->duree;
 
-	$newinter->description=$object->description;
-	$newinter->note_private=$object->note_private;
-	$newinter->note_public=$object->note_public;
+	$newinter->description = $object->description;
+	$newinter->note_private = $object->note_private;
+	$newinter->note_public = $object->note_public;
 
 	// on créer un nouvelle intervention
 	$extrafields->fetch_name_optionals_label($newinter->table_element);
@@ -195,13 +195,13 @@ if ($action == 'add') {
 		exit;
 	} else {
 		setEventMessages($newinter->error, $newinter->errors, 'errors');
-		$action='';
+		$action = '';
 	}
 } elseif ($action == 'delete' && $user->rights->ficheinter->supprimer) {
 	// delete modele
 	$object->fetch($id);
 	$object->delete();
-	$id = 0 ;
+	$id = 0;
 	header('Location: '.$_SERVER["PHP_SELF"]);
 	exit;
 } elseif ($action == 'setfrequency' && $user->rights->ficheinter->creer) {
@@ -228,16 +228,16 @@ llxHeader('', $langs->trans("RepeatableInterventional"), 'ch-fichinter.html#s-fa
 
 $form = new Form($db);
 $companystatic = new Societe($db);
-if (! empty($conf->contrat->enabled)) {
+if (!empty($conf->contrat->enabled)) {
 	$contratstatic = new Contrat($db);
 }
-if (! empty($conf->projet->enabled)) {
+if (!empty($conf->projet->enabled)) {
 	$projectstatic = new Project($db);
 }
 
 $now = dol_now();
-$tmparray=dol_getdate($now);
-$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);   // Today is last second of current day
+$tmparray = dol_getdate($now);
+$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
 
 
 
@@ -247,7 +247,7 @@ $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['
 if ($action == 'create') {
 	print load_fiche_titre($langs->trans("CreateRepeatableIntervention"), '', 'fichinter');
 
-	$object = new Fichinter($db);   // Source invoice
+	$object = new Fichinter($db); // Source invoice
 	//$object = new Managementfichinter($db);   // Source invoice
 
 	if ($object->fetch($id, $ref) > 0) {
@@ -258,9 +258,9 @@ if ($action == 'create') {
 
 		dol_fiche_head();
 
-		$rowspan=4;
-		if (! empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++;
-		if (! empty($conf->contrat->enabled) && $object->fk_contrat > 0) $rowspan++;
+		$rowspan = 4;
+		if (!empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++;
+		if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) $rowspan++;
 
 		print '<table class="border centpercent">';
 
@@ -297,24 +297,24 @@ if ($action == 'create') {
 		}
 
 		// Project
-		if (! empty($conf->projet->enabled)) {
+		if (!empty($conf->projet->enabled)) {
 			$formproject = new FormProjets($db);
 			print "<tr><td>".$langs->trans("Project")."</td><td>";
-			$projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project;
+			$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
 
 			$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
 			print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id;
 			print '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?action=create';
-			print '&socid='.$object->thirdparty->id.(!empty($id)?'&id='.$id:'').'">';
+			print '&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '').'">';
 			print $langs->trans("AddProject").'</a>';
 			print "</td></tr>";
 		}
 
 		// Contrat
-		if (! empty($conf->contrat->enabled)) {
+		if (!empty($conf->contrat->enabled)) {
 			$formcontract = new FormContract($db);
 			print "<tr><td>".$langs->trans("Contract")."</td><td>";
-			$contractid = GETPOST('contractid')?GETPOST('contractid'):$object->fk_contract;
+			$contractid = GETPOST('contractid') ?GETPOST('contractid') : $object->fk_contract;
 			$numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid, 'contracttid');
 			print "</td></tr>";
 		}
@@ -334,7 +334,7 @@ if ($action == 'create') {
 		print $form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'));
 		print "</td><td>";
 		print '<input type="text" name="frequency" value="'.GETPOST('frequency', 'int').'" size="4">&nbsp;';
-		print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m'));
+		print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm'));
 		print "</td></tr>";
 
 		// First date of execution for cron
@@ -370,10 +370,10 @@ if ($action == 'create') {
 		print '<tr><td colspan="3">';
 
 		$sql = 'SELECT l.rowid, l.description, l.duree';
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinterdet as l";
-		$sql.= " WHERE l.fk_fichinter= ".$object->id;
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinterdet as l";
+		$sql .= " WHERE l.fk_fichinter= ".$object->id;
 		//$sql.= " AND l.fk_product is null ";
-		$sql.= " ORDER BY l.rang";
+		$sql .= " ORDER BY l.rang";
 
 		$result = $db->query($sql);
 		if ($result) {
@@ -467,44 +467,44 @@ if ($action == 'create') {
 			// Intervention card
 			$linkback = '<a href="card-rec.php">'.$langs->trans("BackToList").'</a>';
 
-			$morehtmlref='<div class="refidno">';
+			$morehtmlref = '<div class="refidno">';
 			// Thirdparty
 
-			$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+			$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
 			// Project
-			if (! empty($conf->projet->enabled)) {
+			if (!empty($conf->projet->enabled)) {
 				$formproject = new FormProjets($db);
 				$langs->load("projects");
-				$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+				$morehtmlref .= '<br>'.$langs->trans('Project').' ';
 				if ($user->rights->ficheinter->creer) {
 					if ($action != 'classify') {
-						$morehtmlref.='<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">';
-						$morehtmlref.=img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
+						$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">';
+						$morehtmlref .= img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
 					}
 					if ($action == 'classify') {
-						$morehtmlref.= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
-						$morehtmlref.= '<input type="hidden" name="action" value="classin">';
-						$morehtmlref.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-                        $morehtmlref.= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
-						$morehtmlref.= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
-						$morehtmlref.= '</form>';
+						$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+						$morehtmlref .= '<input type="hidden" name="action" value="classin">';
+						$morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+                        $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+						$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+						$morehtmlref .= '</form>';
 					} else {
-                        $morehtmlref.= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+                        $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
 					}
 				} else {
-					if (! empty($object->fk_project)) {
+					if (!empty($object->fk_project)) {
 						$proj = new Project($db);
 						$proj->fetch($object->fk_project);
-						$morehtmlref.= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'"';
-						$morehtmlref.= 'title="'.$langs->trans('ShowProject').'">';
-						$morehtmlref.= $proj->ref;
-						$morehtmlref.= '</a>';
+						$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'"';
+						$morehtmlref .= 'title="'.$langs->trans('ShowProject').'">';
+						$morehtmlref .= $proj->ref;
+						$morehtmlref .= '</a>';
 					} else {
-						$morehtmlref.= '';
+						$morehtmlref .= '';
 					}
 				}
 			}
-			$morehtmlref.='</div>';
+			$morehtmlref .= '</div>';
 
 			dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
 
@@ -527,7 +527,7 @@ if ($action == 'create') {
 			print '<tr><td>'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($object->description)."</td></tr>";
 
 			// Contract
-			if (! empty($conf->contrat->enabled)) {
+			if (!empty($conf->contrat->enabled)) {
 				$langs->load('contracts');
 				print '<tr>';
 				print '<td>';
@@ -543,7 +543,7 @@ if ($action == 'create') {
 				print '</tr></table>';
 				print '</td><td>';
 				if ($action == 'contrat') {
-					$formcontract= new Formcontract($db);
+					$formcontract = new Formcontract($db);
                     $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1);
 				} else {
 					if ($object->fk_contrat) {
@@ -578,18 +578,18 @@ if ($action == 'create') {
 			print '</td>';
 			if ($action != 'editfrequency' && $user->rights->ficheinter->creer) {
 				print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editfrequency&amp;id='.$id.'">';
-				print img_edit($langs->trans('Edit'), 1) . '</a></td>';
+				print img_edit($langs->trans('Edit'), 1).'</a></td>';
 			}
 			print '</tr></table>';
 			print '</td><td>';
 			if ($action == 'editfrequency') {
-				print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?id=' . $object->id.'">';
+				print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
 				print '<input type="hidden" name="action" value="setfrequency">';
 				print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 				print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
 				print '<tr><td>';
 				print '<input type="text" name="frequency" value="'.$object->frequency.'" size="5">&nbsp;';
-				print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m'));
+				print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm'));
 				print '</td>';
 				print '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
 				print '</tr></table></form>';
@@ -603,7 +603,7 @@ if ($action == 'create') {
 
 			// Date when
 			print '<tr><td>';
-			if ( $user->rights->ficheinter->creer && ($action == 'date_when' || $object->frequency > 0)) {
+			if ($user->rights->ficheinter->creer && ($action == 'date_when' || $object->frequency > 0)) {
 				print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day');
 			} else {
 				print $langs->trans("NextDateToExecution");
@@ -624,7 +624,7 @@ if ($action == 'create') {
 
 			print '</td><td>';
 			if ($action == 'nb_gen_max' || $object->frequency > 0) {
-				print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer);
+				print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer);
 			}
 			else
 				print '';
@@ -647,7 +647,7 @@ if ($action == 'create') {
 				// Nb of generation already done
 				print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>';
 				print '<td>';
-				print $object->nb_gen_done?$object->nb_gen_done:'0';
+				print $object->nb_gen_done ? $object->nb_gen_done : '0';
 				print '</td>';
 				print '</tr>';
 
@@ -692,13 +692,13 @@ if ($action == 'create') {
 			while ($i < $num) {
 				// Show product and description
 				if (isset($object->lines[$i]->product_type))
-					$type=$object->lines[$i]->product_type;
+					$type = $object->lines[$i]->product_type;
 				else
 					$object->lines[$i]->fk_product_type;
 				// Try to enhance type detection using date_start and date_end for free lines when type
 				// was not saved.
-				if (! empty($objp->date_start)) $type=1;
-				if (! empty($objp->date_end)) $type=1;
+				if (!empty($objp->date_start)) $type = 1;
+				if (!empty($objp->date_end)) $type = 1;
 
 				// Show line
 				print '<tr class="oddeven">';
@@ -738,24 +738,24 @@ if ($action == 'create') {
 		 *  List mode
 		 */
 		$sql = "SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title,";
-		$sql.= " f.duree, f.fk_contrat, f.fk_projet as fk_project, f.frequency, f.nb_gen_done, f.nb_gen_max,";
-		$sql.= " f.date_last_gen, f.date_when, f.datec";
+		$sql .= " f.duree, f.fk_contrat, f.fk_projet as fk_project, f.frequency, f.nb_gen_done, f.nb_gen_max,";
+		$sql .= " f.date_last_gen, f.date_when, f.datec";
 
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter_rec as f";
-		$sql.= " , ".MAIN_DB_PREFIX."societe as s ";
-		if (! $user->rights->societe->client->voir && ! $socid) {
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter_rec as f";
+		$sql .= " , ".MAIN_DB_PREFIX."societe as s ";
+		if (!$user->rights->societe->client->voir && !$socid) {
 			$sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 		}
-		$sql.= " WHERE f.fk_soc = s.rowid";
-		$sql.= " AND f.entity = ".$conf->entity;
+		$sql .= " WHERE f.fk_soc = s.rowid";
+		$sql .= " AND f.entity = ".$conf->entity;
 		if ($socid)	$sql .= " AND s.rowid = ".$socid;
-		if (! $user->rights->societe->client->voir && ! $socid) {
+		if (!$user->rights->societe->client->voir && !$socid) {
 			$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 		}
 		if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
 		if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
-		if ($search_frequency == '1') $sql.= ' AND f.frequency > 0';
-		if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)';
+		if ($search_frequency == '1') $sql .= ' AND f.frequency > 0';
+		if ($search_frequency == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
 
 
 		//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
@@ -784,10 +784,10 @@ if ($action == 'create') {
 			print '<tr class="liste_titre">';
             print_liste_field_titre("Ref", $_SERVER['PHP_SELF'], "f.titre", "", "", 'width="200px"', $sortfield, $sortorder, 'left ');
             print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "s.nom", "", "", 'width="200px"', $sortfield, $sortorder, 'left ');
-            if (! empty($conf->contrat->enabled)) {
+            if (!empty($conf->contrat->enabled)) {
                 print_liste_field_titre("Contract", $_SERVER['PHP_SELF'], "f.fk_contrat", "", "", 'width="100px"', $sortfield, $sortorder, 'left ');
             }
-            if (! empty($conf->projet->enabled)) {
+            if (!empty($conf->projet->enabled)) {
                 print_liste_field_titre("Project", $_SERVER['PHP_SELF'], "f.fk_project", "", "", 'width="100px"', $sortfield, $sortorder, 'left ');
             }
             print_liste_field_titre("Duration", $_SERVER['PHP_SELF'], 'f.duree', '', '', 'width="50px"', $sortfield, $sortorder, 'right ');
@@ -811,22 +811,22 @@ if ($action == 'create') {
 					print img_object($langs->trans("ShowIntervention"), "intervention").' '.$objp->title;
 					print "</a></td>\n";
 					if ($objp->socid) {
-						$companystatic->id=$objp->socid;
-						$companystatic->name=$objp->name;
+						$companystatic->id = $objp->socid;
+						$companystatic->name = $objp->name;
 						print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
 					} else {
 						print '<td>'.$langs->trans("None").'</td>';
 					}
 
-					if (! empty($conf->contrat->enabled)) {
+					if (!empty($conf->contrat->enabled)) {
 						print '<td>';
-						if ($objp->fk_contrat >0) {
+						if ($objp->fk_contrat > 0) {
 							$contratstatic->fetch($objp->fk_contrat);
 							print $contratstatic->getNomUrl(1);
 						}
 						print '</td>';
 					}
-					if (! empty($conf->projet->enabled)) {
+					if (!empty($conf->projet->enabled)) {
 						print '<td>';
 						if ($objp->fk_project > 0) {
 							$projectstatic->fetch($objp->fk_project);
@@ -837,15 +837,15 @@ if ($action == 'create') {
 
 					print '<td class=right>'.convertSecondToTime($objp->duree).'</td>';
 
-					print '<td class="center">'.yn($objp->frequency?1:0).'</td>';
+					print '<td class="center">'.yn($objp->frequency ? 1 : 0).'</td>';
 
 					print '<td class="center">';
 					if ($objp->frequency) {
-						print $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') ;
+						print $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '');
 						print '</td>';
 
 						print '<td class="center">';
-						print dol_print_date($db->jdate($objp->date_last_gen), 'day') ;
+						print dol_print_date($db->jdate($objp->date_last_gen), 'day');
 						print '</td>';
 
 						print '<td class="center">';

File diff suppressed because it is too large
+ 188 - 188
htdocs/fichinter/card.php


+ 81 - 81
htdocs/fichinter/index.php

@@ -27,8 +27,8 @@
 
 require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
-require_once DOL_DOCUMENT_ROOT .'/fichinter/class/fichinter.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
 
 if (!$user->rights->ficheinter->lire) accessforbidden();
 
@@ -41,7 +41,7 @@ $hookmanager->initHooks(array('interventionindex'));
 $langs->load("interventions");
 
 // Security check
-$socid=GETPOST('socid', 'int');
+$socid = GETPOST('socid', 'int');
 if ($user->socid > 0)
 {
 	$action = '';
@@ -54,10 +54,10 @@ if ($user->socid > 0)
  * View
  */
 
-$fichinterstatic=new Fichinter($db);
+$fichinterstatic = new Fichinter($db);
 $form = new Form($db);
 $formfile = new FormFile($db);
-$help_url="EN:ModuleFichinters|FR:Module_Fiche_Interventions|ES:Módulo_FichaInterventiones";
+$help_url = "EN:ModuleFichinters|FR:Module_Fiche_Interventions|ES:Módulo_FichaInterventiones";
 
 llxHeader("", $langs->trans("Interventions"), $help_url);
 
@@ -65,10 +65,10 @@ print load_fiche_titre($langs->trans("InterventionsArea"));
 
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
 {
     // Search ficheinter
-    $var=false;
+    $var = false;
     print '<form method="post" action="'.DOL_URL_ROOT.'/fichinter/list.php">';
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     print '<div class="div-table-responsive-no-min">';
@@ -85,25 +85,25 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
  */
 
 $sql = "SELECT count(f.rowid), f.fk_statut";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-$sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
-$sql.= " AND f.fk_soc = s.rowid";
-if ($user->socid) $sql.=' AND f.fk_soc = '.$user->socid;
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " GROUP BY f.fk_statut";
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
+$sql .= " AND f.fk_soc = s.rowid";
+if ($user->socid) $sql .= ' AND f.fk_soc = '.$user->socid;
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " GROUP BY f.fk_statut";
 $resql = $db->query($sql);
 if ($resql)
 {
     $num = $db->num_rows($resql);
     $i = 0;
 
-    $total=0;
-    $totalinprocess=0;
-    $dataseries=array();
-    $vals=array();
-    $bool=false;
+    $total = 0;
+    $totalinprocess = 0;
+    $dataseries = array();
+    $vals = array();
+    $bool = false;
     // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not)
     while ($i < $num)
     {
@@ -112,12 +112,12 @@ if ($resql)
         {
             //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
             {
-                $bool=(! empty($row[2])?true:false);
-                if (! isset($vals[$row[1].$bool])) $vals[$row[1].$bool]=0;
-                $vals[$row[1].$bool]+=$row[0];
-                $totalinprocess+=$row[0];
+                $bool = (!empty($row[2]) ?true:false);
+                if (!isset($vals[$row[1].$bool])) $vals[$row[1].$bool] = 0;
+                $vals[$row[1].$bool] += $row[0];
+                $totalinprocess += $row[0];
             }
-            $total+=$row[0];
+            $total += $row[0];
         }
         $i++;
     }
@@ -125,13 +125,13 @@ if ($resql)
     print '<div class="div-table-responsive-no-min">';
     print '<table class="noborder nohover centpercent">';
     print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Interventions").'</th></tr>'."\n";
-    $listofstatus=array(0,1,2);
-    $bool=false;
+    $listofstatus = array(0, 1, 2);
+    $bool = false;
     foreach ($listofstatus as $status)
     {
-        $dataseries[]=array($fichinterstatic->LibStatut($status, $bool, 1), (isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0));
-        if ($status==3 && ! $bool) $bool=true;
-        else $bool=false;
+        $dataseries[] = array($fichinterstatic->LibStatut($status, $bool, 1), (isset($vals[$status.$bool]) ? (int) $vals[$status.$bool] : 0));
+        if ($status == 3 && !$bool) $bool = true;
+        else $bool = false;
     }
     if ($conf->use_javascript_ajax)
     {
@@ -145,25 +145,25 @@ if ($resql)
         $dolgraph->SetType(array('pie'));
         $dolgraph->setWidth('100%');
         $dolgraph->draw('idgraphstatus');
-        print $dolgraph->show($total?0:1);
-        $data=array('series'=>$dataseries);
+        print $dolgraph->show($total ? 0 : 1);
+        $data = array('series'=>$dataseries);
 
         print '</td></tr>';
     }
-    $bool=false;
+    $bool = false;
     foreach ($listofstatus as $status)
     {
-        if (! $conf->use_javascript_ajax)
+        if (!$conf->use_javascript_ajax)
         {
             print '<tr class="oddeven">';
             print '<td>'.$fichinterstatic->LibStatut($status, $bool, 0).'</td>';
-            print '<td class="right"><a href="list.php?viewstatut='.$status.'">'.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' ';
+            print '<td class="right"><a href="list.php?viewstatut='.$status.'">'.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' ';
             print $fichinterstatic->LibStatut($status, $bool, 3);
             print '</a>';
             print '</td>';
             print "</tr>\n";
-            if ($status==3 && ! $bool) $bool=true;
-            else $bool=false;
+            if ($status == 3 && !$bool) $bool = true;
+            else $bool = false;
         }
     }
     //if ($totalinprocess != $total)
@@ -180,19 +180,19 @@ else
 /*
  * Draft orders
  */
-if (! empty($conf->ficheinter->enabled))
+if (!empty($conf->ficheinter->enabled))
 {
 	$sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
-	$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
-	$sql.= " AND f.fk_soc = s.rowid";
-	$sql.= " AND f.fk_statut = 0";
-	if ($socid) $sql.= " AND f.fk_soc = ".$socid;
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-
-	$resql=$db->query($sql);
+	$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
+	$sql .= " AND f.fk_soc = s.rowid";
+	$sql .= " AND f.fk_statut = 0";
+	if ($socid) $sql .= " AND f.fk_soc = ".$socid;
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
         print '<div class="div-table-responsive-no-min">';
@@ -222,26 +222,26 @@ if (! empty($conf->ficheinter->enabled))
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
 
-$max=5;
+$max = 5;
 
 /*
  * Last modified interventions
  */
 
 $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as datem,";
-$sql.= " s.nom as name, s.rowid as socid";
-$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
-$sql.= " ".MAIN_DB_PREFIX."societe as s";
-if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
-$sql.= " AND f.fk_soc = s.rowid";
+$sql .= " s.nom as name, s.rowid as socid";
+$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
+$sql .= " ".MAIN_DB_PREFIX."societe as s";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
+$sql .= " AND f.fk_soc = s.rowid";
 //$sql.= " AND c.fk_statut > 2";
 if ($socid) $sql .= " AND f.fk_soc = ".$socid;
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " ORDER BY f.tms DESC";
-$sql.= $db->plimit($max, 0);
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " ORDER BY f.tms DESC";
+$sql .= $db->plimit($max, 0);
 
-$resql=$db->query($sql);
+$resql = $db->query($sql);
 if ($resql)
 {
     print '<div class="div-table-responsive-no-min">';
@@ -260,8 +260,8 @@ if ($resql)
 			print '<tr class="oddeven">';
 			print '<td width="20%" class="nowrap">';
 
-			$fichinterstatic->id=$obj->rowid;
-			$fichinterstatic->ref=$obj->ref;
+			$fichinterstatic->id = $obj->rowid;
+			$fichinterstatic->ref = $obj->ref;
 
 			print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 			print '<td width="96" class="nobordernopadding nowrap">';
@@ -273,9 +273,9 @@ if ($resql)
 			print '</td>';
 
 			print '<td width="16" class="right nobordernopadding hideonsmartphone">';
-			$filename=dol_sanitizeFileName($obj->ref);
-			$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
-			$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
+			$filename = dol_sanitizeFileName($obj->ref);
+			$filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
+			$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
 			print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
 			print '</td></tr></table>';
 
@@ -297,20 +297,20 @@ else dol_print_error($db);
  * interventions to process
  */
 
-if (! empty($conf->ficheinter->enabled))
+if (!empty($conf->ficheinter->enabled))
 {
 	$sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid";
-	$sql.=" FROM ".MAIN_DB_PREFIX."fichinter as f";
-	$sql.= ", ".MAIN_DB_PREFIX."societe as s";
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-	$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
-	$sql.= " AND f.fk_soc = s.rowid";
-	$sql.= " AND f.fk_statut = 1";
-	if ($socid) $sql.= " AND f.fk_soc = ".$socid;
-	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-	$sql.= " ORDER BY f.rowid DESC";
-
-	$resql=$db->query($sql);
+	$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
+	$sql .= " AND f.fk_soc = s.rowid";
+	$sql .= " AND f.fk_statut = 1";
+	if ($socid) $sql .= " AND f.fk_soc = ".$socid;
+	if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+	$sql .= " ORDER BY f.rowid DESC";
+
+	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
@@ -329,8 +329,8 @@ if (! empty($conf->ficheinter->enabled))
 				print '<tr class="oddeven">';
 				print '<td class="nowrap" width="20%">';
 
-				$fichinterstatic->id=$obj->rowid;
-				$fichinterstatic->ref=$obj->ref;
+				$fichinterstatic->id = $obj->rowid;
+				$fichinterstatic->ref = $obj->ref;
 
 				print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 				print '<td width="96" class="nobordernopadding nowrap">';
@@ -342,9 +342,9 @@ if (! empty($conf->ficheinter->enabled))
 				print '</td>';
 
 				print '<td width="16" class="right nobordernopadding hideonsmartphone">';
-				$filename=dol_sanitizeFileName($obj->ref);
-				$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
-				$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
+				$filename = dol_sanitizeFileName($obj->ref);
+				$filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
+				$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
 				print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
 				print '</td></tr></table>';
 

+ 231 - 231
htdocs/fourn/commande/dispatch.php

@@ -31,19 +31,19 @@
  */
 
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_order/modules_commandefournisseur.php';
-require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
-require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.dispatch.class.php';
-require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
-if (! empty($conf->projet->enabled))
-	require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php';
+require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+if (!empty($conf->projet->enabled))
+	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks","receptions"));
+$langs->loadLangs(array("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks", "receptions"));
 
-if (! empty($conf->productbatch->enabled))
+if (!empty($conf->productbatch->enabled))
 	$langs->load('productbatch');
 
 	// Security check
@@ -68,7 +68,7 @@ if ($_GET["projectid"])
 
 $object = new CommandeFournisseur($db);
 
-if ($id > 0 || ! empty($ref)) {
+if ($id > 0 || !empty($ref)) {
 	$result = $object->fetch($id, $ref);
 	if ($result < 0) {
 		setEventMessages($object->error, $object->errors, 'errors');
@@ -84,26 +84,26 @@ if ($id > 0 || ! empty($ref)) {
  * Actions
  */
 
-$parameters=array();
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
-if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))))
+if ($action == 'checkdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))))
 {
-	$error=0;
+	$error = 0;
 	$supplierorderdispatch = new CommandeFournisseurDispatch($db);
 
 	$db->begin();
 
 	$result = $supplierorderdispatch->fetch($lineid);
-	if (! $result)
+	if (!$result)
 	{
 		$error++;
 		setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
 		$action = '';
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$result = $supplierorderdispatch->setStatut(1);
 		if ($result < 0) {
@@ -113,16 +113,16 @@ if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED
 		}
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$result = $object->calcAndSetStatusDispatch($user);
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-			$error ++;
+			$error++;
 			$action = '';
 		}
 	}
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 	}
@@ -132,40 +132,40 @@ if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED
 	}
 }
 
-if ($action == 'uncheckdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))))
+if ($action == 'uncheckdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))))
 {
-	$error=0;
+	$error = 0;
 	$supplierorderdispatch = new CommandeFournisseurDispatch($db);
 
 	$db->begin();
 
 	$result = $supplierorderdispatch->fetch($lineid);
-	if (! $result)
+	if (!$result)
 	{
 		$error++;
 		setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
 		$action = '';
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$result = $supplierorderdispatch->setStatut(0);
 		if ($result < 0) {
 			setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
-			$error ++;
+			$error++;
 			$action = '';
 		}
 	}
-	if (! $error)
+	if (!$error)
 	{
 		$result = $object->calcAndSetStatusDispatch($user);
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-			$error ++;
+			$error++;
 			$action = '';
 		}
 	}
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 	}
@@ -175,40 +175,40 @@ if ($action == 'uncheckdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANC
 	}
 }
 
-if ($action == 'denydispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))))
+if ($action == 'denydispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))))
 {
-	$error=0;
+	$error = 0;
 	$supplierorderdispatch = new CommandeFournisseurDispatch($db);
 
 	$db->begin();
 
 	$result = $supplierorderdispatch->fetch($lineid);
-	if (! $result)
+	if (!$result)
 	{
 		$error++;
 		setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
 		$action = '';
 	}
 
-	if (! $error)
+	if (!$error)
 	{
 		$result = $supplierorderdispatch->setStatut(2);
 		if ($result < 0) {
 			setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
-			$error ++;
+			$error++;
 			$action = '';
 		}
 	}
-	if (! $error)
+	if (!$error)
 	{
 		$result = $object->calcAndSetStatusDispatch($user);
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-			$error ++;
+			$error++;
 			$action = '';
 		}
 	}
-	if (! $error)
+	if (!$error)
 	{
 		$db->commit();
 	}
@@ -229,54 +229,54 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
 		// without batch module enabled
 		if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
 		{
-			$pos ++;
+			$pos++;
 
 			// $numline=$reg[2] + 1; // line of product
 			$numline = $pos;
-			$prod = "product_" . $reg[1] . '_' . $reg[2];
-			$qty = "qty_" . $reg[1] . '_' . $reg[2];
-			$ent = "entrepot_" . $reg[1] . '_' . $reg[2];
-			$pu = "pu_" . $reg[1] . '_' . $reg[2]; // This is unit price including discount
-			$fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2];
+			$prod = "product_".$reg[1].'_'.$reg[2];
+			$qty = "qty_".$reg[1].'_'.$reg[2];
+			$ent = "entrepot_".$reg[1].'_'.$reg[2];
+			$pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount
+			$fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2];
 
-			if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
+			if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 				if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
-					$dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]);
-					if (! empty($dto)) {
-						$unit_price = price2num(GETPOST("pu_" . $reg[1]) * (100 - $dto) / 100, 'MU');
+					$dto = GETPOST("dto_".$reg[1].'_'.$reg[2]);
+					if (!empty($dto)) {
+						$unit_price = price2num(GETPOST("pu_".$reg[1]) * (100 - $dto) / 100, 'MU');
 					}
-					$saveprice = "saveprice_" . $reg[1] . '_' . $reg[2];
+					$saveprice = "saveprice_".$reg[1].'_'.$reg[2];
 				}
 			}
 
 			// We ask to move a qty
 			if (GETPOST($qty) != 0) {
-				if (! (GETPOST($ent, 'int') > 0)) {
-					dol_syslog('No dispatch for line ' . $key . ' as no warehouse was chosen.');
-					$text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline);
+				if (!(GETPOST($ent, 'int') > 0)) {
+					dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
+					$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
 					setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
-					$error ++;
+					$error++;
 				}
 
-				if (! $error) {
+				if (!$error) {
 					$result = $object->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger);
 					if ($result < 0) {
 						setEventMessages($object->error, $object->errors, 'errors');
-						$error ++;
+						$error++;
 					}
 
-					if (! $error && ! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
+					if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 						if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
-							$dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]);
+							$dto = GETPOST("dto_".$reg[1].'_'.$reg[2]);
 							//update supplier price
 							if (isset($_POST[$saveprice])) {
 								// TODO Use class
-								$sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price";
-								$sql .= " SET unitprice='" . GETPOST($pu) . "'";
-								$sql .= ", price=" . GETPOST($pu) . "*quantity";
-								$sql .= ", remise_percent='" . $dto . "'";
-								$sql .= " WHERE fk_soc=" . $object->socid;
-								$sql .= " AND fk_product=" . GETPOST($prod, 'int');
+								$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
+								$sql .= " SET unitprice='".GETPOST($pu)."'";
+								$sql .= ", price=".GETPOST($pu)."*quantity";
+								$sql .= ", remise_percent='".$dto."'";
+								$sql .= " WHERE fk_soc=".$object->socid;
+								$sql .= " AND fk_product=".GETPOST($prod, 'int');
 
 								$resql = $db->query($sql);
 							}
@@ -288,58 +288,58 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
 		// with batch module enabled
 		if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg))
 		{
-			$pos ++;
+			$pos++;
 
 			// eat-by date dispatch
 			// $numline=$reg[2] + 1; // line of product
 			$numline = $pos;
-			$prod = 'product_batch_' . $reg[1] . '_' . $reg[2];
-			$qty = 'qty_' . $reg[1] . '_' . $reg[2];
-			$ent = 'entrepot_' . $reg[1] . '_' . $reg[2];
-			$pu = 'pu_' . $reg[1] . '_' . $reg[2];
-			$fk_commandefourndet = 'fk_commandefourndet_' . $reg[1] . '_' . $reg[2];
-			$lot = 'lot_number_' . $reg[1] . '_' . $reg[2];
-			$dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_' . $reg[1] . '_' . $reg[2] . 'month'], $_POST['dluo_' . $reg[1] . '_' . $reg[2] . 'day'], $_POST['dluo_' . $reg[1] . '_' . $reg[2] . 'year']);
-			$dDLC = dol_mktime(12, 0, 0, $_POST['dlc_' . $reg[1] . '_' . $reg[2] . 'month'], $_POST['dlc_' . $reg[1] . '_' . $reg[2] . 'day'], $_POST['dlc_' . $reg[1] . '_' . $reg[2] . 'year']);
+			$prod = 'product_batch_'.$reg[1].'_'.$reg[2];
+			$qty = 'qty_'.$reg[1].'_'.$reg[2];
+			$ent = 'entrepot_'.$reg[1].'_'.$reg[2];
+			$pu = 'pu_'.$reg[1].'_'.$reg[2];
+			$fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2];
+			$lot = 'lot_number_'.$reg[1].'_'.$reg[2];
+			$dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']);
+			$dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']);
 
-			$fk_commandefourndet = 'fk_commandefourndet_' . $reg[1] . '_' . $reg[2];
+			$fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2];
 
 			// We ask to move a qty
 			if (GETPOST($qty) > 0) {
-				if (! (GETPOST($ent, 'int') > 0)) {
-					dol_syslog('No dispatch for line ' . $key . ' as no warehouse was chosen.');
-					$text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline) . '-' . ($reg[1] + 1);
+				if (!(GETPOST($ent, 'int') > 0)) {
+					dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
+					$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline).'-'.($reg[1] + 1);
 					setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
-					$error ++;
+					$error++;
 				}
 
-				if (! (GETPOST($lot, 'alpha') || $dDLUO || $dDLC)) {
-					dol_syslog('No dispatch for line ' . $key . ' as serial/eat-by/sellby date are not set');
-					$text = $langs->transnoentities('atleast1batchfield') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline) . '-' . ($reg[1] + 1);
+				if (!(GETPOST($lot, 'alpha') || $dDLUO || $dDLC)) {
+					dol_syslog('No dispatch for line '.$key.' as serial/eat-by/sellby date are not set');
+					$text = $langs->transnoentities('atleast1batchfield').', '.$langs->transnoentities('Line').' '.($numline).'-'.($reg[1] + 1);
 					setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
-					$error ++;
+					$error++;
 				}
 
-				if (! $error) {
+				if (!$error) {
 					$result = $object->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger);
 					if ($result < 0) {
 						setEventMessages($object->error, $object->errors, 'errors');
-						$error ++;
+						$error++;
 					}
 				}
 			}
 		}
 	}
 
-	if (! $error) {
-		$result = $object->calcAndSetStatusDispatch($user, GETPOST('closeopenorder')?1:0, GETPOST('comment'));
+	if (!$error) {
+		$result = $object->calcAndSetStatusDispatch($user, GETPOST('closeopenorder') ? 1 : 0, GETPOST('comment'));
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-			$error ++;
+			$error++;
 		}
 	}
 
-	if (! $notrigger && ! $error) {
+	if (!$notrigger && !$error) {
 		global $conf, $langs, $user;
 		// Call trigger
 
@@ -348,14 +348,14 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
 
 		if ($result < 0) {
 			setEventMessages($object->error, $object->errors, 'errors');
-			$error ++;
+			$error++;
 		}
 	}
 
-	if ($result >= 0 && ! $error) {
+	if ($result >= 0 && !$error) {
 		$db->commit();
 
-		header("Location: dispatch.php?id=" . $id);
+		header("Location: dispatch.php?id=".$id);
 		exit();
 	} else {
 		$db->rollback();
@@ -374,10 +374,10 @@ $formproduct = new FormProduct($db);
 $warehouse_static = new Entrepot($db);
 $supplierorderdispatch = new CommandeFournisseurDispatch($db);
 
-$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
+$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
 llxHeader('', $langs->trans("Order"), $help_url, '', 0, 0, array('/fourn/js/lib_dispatch.js'));
 
-if ($id > 0 || ! empty($ref)) {
+if ($id > 0 || !empty($ref)) {
 	$soc = new Societe($db);
 	$soc->fetch($object->socid);
 
@@ -392,49 +392,49 @@ if ($id > 0 || ! empty($ref)) {
 
 	// Supplier order card
 
-	$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
+	$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
 
-	$morehtmlref='<div class="refidno">';
+	$morehtmlref = '<div class="refidno">';
 	// Ref supplier
-	$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
-	$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
+	$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
+	$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
 	// Thirdparty
-	$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+	$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
 	// Project
-	if (! empty($conf->projet->enabled))
+	if (!empty($conf->projet->enabled))
 	{
 	    $langs->load("projects");
-	    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+	    $morehtmlref .= '<br>'.$langs->trans('Project').' ';
 	    if ($user->rights->fournisseur->commande->creer)
 	    {
 	        if ($action != 'classify') {
 	            //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
-				$morehtmlref.=' : ';
+				$morehtmlref .= ' : ';
             }
 	        if ($action == 'classify') {
                 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
-                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
-                $morehtmlref.='<input type="hidden" name="action" value="classin">';
-                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
-                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
-                $morehtmlref.='</form>';
+                $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+                $morehtmlref .= '<input type="hidden" name="action" value="classin">';
+                $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+                $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+                $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+                $morehtmlref .= '</form>';
             } else {
-                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
             }
 	    } else {
-	        if (! empty($object->fk_project)) {
+	        if (!empty($object->fk_project)) {
 	            $proj = new Project($db);
 	            $proj->fetch($object->fk_project);
-	            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
-	            $morehtmlref.=$proj->ref;
-	            $morehtmlref.='</a>';
+	            $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
+	            $morehtmlref .= $proj->ref;
+	            $morehtmlref .= '</a>';
 	        } else {
-	            $morehtmlref.='';
+	            $morehtmlref .= '';
 	        }
 	    }
 	}
-	$morehtmlref.='</div>';
+	$morehtmlref .= '</div>';
 
 
 	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -447,20 +447,20 @@ if ($id > 0 || ! empty($ref)) {
 
 	// Date
 	if ($object->methode_commande_id > 0) {
-		print '<tr><td class="titlefield">' . $langs->trans("Date") . '</td><td>';
+		print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>';
 		if ($object->date_commande) {
-			print dol_print_date($object->date_commande, "dayhour") . "\n";
+			print dol_print_date($object->date_commande, "dayhour")."\n";
 		}
 		print "</td></tr>";
 
 		if ($object->methode_commande) {
-			print '<tr><td>' . $langs->trans("Method") . '</td><td>' . $object->getInputMethod() . '</td></tr>';
+			print '<tr><td>'.$langs->trans("Method").'</td><td>'.$object->getInputMethod().'</td></tr>';
 		}
 	}
 
 	// Author
-	print '<tr><td class="titlefield">' . $langs->trans("AuthorRequest") . '</td>';
-	print '<td>' . $author->getNomUrl(1, '', 0, 0, 0) . '</td>';
+	print '<tr><td class="titlefield">'.$langs->trans("AuthorRequest").'</td>';
+	print '<td>'.$author->getNomUrl(1, '', 0, 0, 0).'</td>';
 	print '</tr>';
 
     $parameters = array();
@@ -474,7 +474,7 @@ if ($id > 0 || ! empty($ref)) {
 	print '<br>';
 
 	$disabled = 1;
-	if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+	if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
 		$disabled = 0;
 
 	// Line of orders
@@ -488,11 +488,11 @@ if ($id > 0 || ! empty($ref)) {
 		$entrepot = new Entrepot($db);
 		$listwarehouses = $entrepot->list_array(1);
 
-		if(empty($conf->reception->enabled))print '<form method="POST" action="dispatch.php?id=' . $object->id . '">';
+		if (empty($conf->reception->enabled))print '<form method="POST" action="dispatch.php?id='.$object->id.'">';
         else print '<form method="post" action="'.dol_buildpath('/reception/card.php', 1).'?originid='.$object->id.'&origin=supplierorder">';
 
-		print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
-		if(empty($conf->reception->enabled))print '<input type="hidden" name="action" value="dispatch">';
+		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+		if (empty($conf->reception->enabled))print '<input type="hidden" name="action" value="dispatch">';
 		else print '<input type="hidden" name="action" value="create">';
 
 		print '<div class="div-table-responsive-no-min">';
@@ -501,9 +501,9 @@ if ($id > 0 || ! empty($ref)) {
 		// Set $products_dispatched with qty dispatched for each product id
 		$products_dispatched = array();
 		$sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
-		$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd";
-		$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
-		$sql .= " WHERE cfd.fk_commande = " . $object->id;
+		$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
+		$sql .= " WHERE cfd.fk_commande = ".$object->id;
 		$sql .= " GROUP BY l.rowid, cfd.fk_product";
 
 		$resql = $db->query($sql);
@@ -512,7 +512,7 @@ if ($id > 0 || ! empty($ref)) {
 			$i = 0;
 
 			if ($num) {
-				while ( $i < $num ) {
+				while ($i < $num) {
 					$objd = $db->fetch_object($resql);
 					$products_dispatched[$objd->rowid] = price2num($objd->qty, 5);
 					$i++;
@@ -535,9 +535,9 @@ if ($id > 0 || ! empty($ref)) {
         if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
         $sql .= $hookmanager->resPrint;
 
-		$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l";
-		$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid";
-		$sql .= " WHERE l.fk_commande = " . $object->id;
+		$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid";
+		$sql .= " WHERE l.fk_commande = ".$object->id;
 		if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
 			$sql .= " AND l.product_type = 0";
 
@@ -563,8 +563,8 @@ if ($id > 0 || ! empty($ref)) {
 			if ($num) {
 				print '<tr class="liste_titre">';
 
-				print '<td>' . $langs->trans("Description") . '</td>';
-				if (! empty($conf->productbatch->enabled))
+				print '<td>'.$langs->trans("Description").'</td>';
+				if (!empty($conf->productbatch->enabled))
 				{
 					print '<td class="dispatch_batch_number_title">'.$langs->trans("batch_number").'</td>';
 					print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
@@ -576,21 +576,21 @@ if ($id > 0 || ! empty($ref)) {
 					print '<td></td>';
 					print '<td></td>';
 				}
-				print '<td class="right">' . $langs->trans("SupplierRef") . '</td>';
-				print '<td class="right">' . $langs->trans("QtyOrdered") . '</td>';
-				print '<td class="right">' . $langs->trans("QtyDispatchedShort") . '</td>';
-				print '<td class="right">' . $langs->trans("QtyToDispatchShort") . '</td>';
+				print '<td class="right">'.$langs->trans("SupplierRef").'</td>';
+				print '<td class="right">'.$langs->trans("QtyOrdered").'</td>';
+				print '<td class="right">'.$langs->trans("QtyDispatchedShort").'</td>';
+				print '<td class="right">'.$langs->trans("QtyToDispatchShort").'</td>';
 				print '<td width="32"></td>';
 
-				if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
+				if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 					if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
-						print '<td class="right">' . $langs->trans("Price") . '</td>';
-						print '<td class="right">' . $langs->trans("ReductionShort") . ' (%)</td>';
-						print '<td class="right">' . $langs->trans("UpdatePrice") . '</td>';
+						print '<td class="right">'.$langs->trans("Price").'</td>';
+						print '<td class="right">'.$langs->trans("ReductionShort").' (%)</td>';
+						print '<td class="right">'.$langs->trans("UpdatePrice").'</td>';
 					}
 				}
 
-				print '<td align="right">' . $langs->trans("Warehouse") . '</td>';
+				print '<td align="right">'.$langs->trans("Warehouse").'</td>';
 
                 // Enable hooks to append additional columns
                 $parameters = array();
@@ -606,18 +606,18 @@ if ($id > 0 || ! empty($ref)) {
 				print "</tr>\n";
 			}
 
-			$nbfreeproduct = 0;		// Nb of lins of free products/services
-			$nbproduct = 0;			// Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default)
+			$nbfreeproduct = 0; // Nb of lins of free products/services
+			$nbproduct = 0; // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default)
 									// or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on.
 
-			while ( $i < $num ) {
+			while ($i < $num) {
 				$objp = $db->fetch_object($resql);
 
 				// On n'affiche pas les produits libres
-				if (! $objp->fk_product > 0) {
+				if (!$objp->fk_product > 0) {
 					$nbfreeproduct++;
 				} else {
-					$remaintodispatch = price2num($objp->qty - (( float ) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched
+					$remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched
 					if ($remaintodispatch < 0)
 						$remaintodispatch = 0;
 
@@ -627,19 +627,19 @@ if ($id > 0 || ! empty($ref)) {
 						// To show detail cref and description value, we must make calculation by cref
 						// print ($objp->cref?' ('.$objp->cref.')':'');
 						// if ($objp->description) print '<br>'.nl2br($objp->description);
-						$suffix = '_0_' . $i;
+						$suffix = '_0_'.$i;
 
 						print "\n";
-						print '<!-- Line to dispatch ' . $suffix . ' -->' . "\n";
+						print '<!-- Line to dispatch '.$suffix.' -->'."\n";
 						// hidden fields for js function
-						print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $objp->qty . '">';
-						print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched[$objp->rowid] . '">';
+						print '<input id="qty_ordered'.$suffix.'" type="hidden" value="'.$objp->qty.'">';
+						print '<input id="qty_dispatched'.$suffix.'" type="hidden" value="'.(float) $products_dispatched[$objp->rowid].'">';
 						print '<tr class="oddeven">';
 
-						$linktoprod = '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp->fk_product . '">' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . '</a>';
-						$linktoprod .= ' - ' . $objp->label . "\n";
+						$linktoprod = '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.'</a>';
+						$linktoprod .= ' - '.$objp->label."\n";
 
-						if (! empty($conf->productbatch->enabled)) {
+						if (!empty($conf->productbatch->enabled)) {
 							if ($objp->tobatch) {
 								print '<td>';
 								print $linktoprod;
@@ -665,25 +665,25 @@ if ($id > 0 || ! empty($ref)) {
 
 						// Define unit price for PMP calculation
 						$up_ht_disc = $objp->subprice;
-						if (! empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP))
+						if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP))
 							$up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU');
 
 						// Supplier ref
 						print '<td class="right">'.$objp->sref.'</td>';
 
 						// Qty ordered
-						print '<td class="right">' . $objp->qty . '</td>';
+						print '<td class="right">'.$objp->qty.'</td>';
 
 						// Already dispatched
-						print '<td class="right">' . $products_dispatched[$objp->rowid] . '</td>';
+						print '<td class="right">'.$products_dispatched[$objp->rowid].'</td>';
 
-						if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
+						if (!empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
 							$type = 'batch';
 							print '<td class="right">';
-							print '</td>';     // Qty to dispatch
+							print '</td>'; // Qty to dispatch
 							print '<td>';
 							//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
-							print '</td>';     // Dispatch column
+							print '</td>'; // Dispatch column
 							print '<td></td>'; // Warehouse column
 
                             // Enable hooks to append additional columns
@@ -704,42 +704,42 @@ if ($id > 0 || ! empty($ref)) {
 
 							print '</tr>';
 
-							print '<tr class="oddeven" name="' . $type . $suffix . '">';
+							print '<tr class="oddeven" name="'.$type.$suffix.'">';
 							print '<td>';
-							print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp->rowid . '">';
-							print '<input name="product_batch' . $suffix . '" type="hidden" value="' . $objp->fk_product . '">';
+							print '<input name="fk_commandefourndet'.$suffix.'" type="hidden" value="'.$objp->rowid.'">';
+							print '<input name="product_batch'.$suffix.'" type="hidden" value="'.$objp->fk_product.'">';
 
 							print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
-							if (! empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested !
+							if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested !
 							{
-							    print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu' . $suffix . '" type="text" value="' . price2num($up_ht_disc, 'MU') . '">';
+							    print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu'.$suffix.'" type="text" value="'.price2num($up_ht_disc, 'MU').'">';
 							}
 							else
 							{
-							    print '<input class="maxwidth75" name="pu' . $suffix . '" type="hidden" value="' . price2num($up_ht_disc, 'MU') . '">';
+							    print '<input class="maxwidth75" name="pu'.$suffix.'" type="hidden" value="'.price2num($up_ht_disc, 'MU').'">';
 							}
 
 							print '</td>';
 
 							print '<td>';
-							print '<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number' . $suffix . '" name="lot_number' . $suffix . '" value="' . GETPOST('lot_number' . $suffix) . '">';
+							print '<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.GETPOST('lot_number'.$suffix).'">';
 							print '</td>';
 							print '<td class="nowraponall">';
-							$dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year'));
-							print $form->selectDate($dlcdatesuffix, 'dlc' . $suffix, '', '', 1, '');
+							$dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year'));
+							print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, '');
 							print '</td>';
 							print '<td class="nowraponall">';
-							$dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo' . $suffix . 'month'), GETPOST('dluo' . $suffix . 'day'), GETPOST('dluo' . $suffix . 'year'));
-							print $form->selectDate($dluodatesuffix, 'dluo' . $suffix, '', '', 1, '');
+							$dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year'));
+							print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, '');
 							print '</td>';
 							print '<td colspan="3">&nbsp</td>'; // Supplier ref + Qty ordered + qty already dispatched
 						} else {
 							$type = 'dispatch';
 							print '<td class="right">';
-							print '</td>';     // Qty to dispatch
+							print '</td>'; // Qty to dispatch
 							print '<td>';
 							//print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
-							print '</td>';      // Dispatch column
+							print '</td>'; // Dispatch column
 							print '<td></td>'; // Warehouse column
 
                             // Enable hooks to append additional columns
@@ -760,19 +760,19 @@ if ($id > 0 || ! empty($ref)) {
 
 							print '</tr>';
 
-							print '<tr class="oddeven" name="' . $type . $suffix . '">';
+							print '<tr class="oddeven" name="'.$type.$suffix.'">';
 							print '<td colspan="7">';
-							print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp->rowid . '">';
-							print '<input name="product' . $suffix . '" type="hidden" value="' . $objp->fk_product . '">';
+							print '<input name="fk_commandefourndet'.$suffix.'" type="hidden" value="'.$objp->rowid.'">';
+							print '<input name="product'.$suffix.'" type="hidden" value="'.$objp->fk_product.'">';
 
 							print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
-							if (! empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested !
+							if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested !
 							{
-							    print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu' . $suffix . '" type="text" value="' . price2num($up_ht_disc, 'MU') . '">';
+							    print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu'.$suffix.'" type="text" value="'.price2num($up_ht_disc, 'MU').'">';
 							}
 							else
 							{
-							    print '<input class="maxwidth75" name="pu' . $suffix . '" type="hidden" value="' . price2num($up_ht_disc, 'MU') . '">';
+							    print '<input class="maxwidth75" name="pu'.$suffix.'" type="hidden" value="'.price2num($up_ht_disc, 'MU').'">';
 							}
 
 							print '</td>';
@@ -819,9 +819,9 @@ if ($id > 0 || ! empty($ref)) {
 						// Warehouse
 						print '<td class="right">';
 						if (count($listwarehouses) > 1) {
-							print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
+							print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
 						} elseif (count($listwarehouses) == 1) {
-							print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
+							print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
 						} else {
 							$langs->load("errors");
 							print $langs->trans("ErrorNoWarehouseDefined");
@@ -864,7 +864,7 @@ if ($id > 0 || ! empty($ref)) {
 			// modified by hook
 			if (empty($reshook))
 			{
-                if (empty($conf->reception->enabled)){
+                if (empty($conf->reception->enabled)) {
                     print $langs->trans("Comment").' : ';
                     print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
                     print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
@@ -873,9 +873,9 @@ if ($id > 0 || ! empty($ref)) {
 
                     print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
                 }
-                empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive");
+                empty($conf->reception->enabled) ? $dispatchBt = $langs->trans("DispatchVerb") : $dispatchBt = $langs->trans("Receive");
 
-                print '<br><input type="submit" class="button" name="dispatch" value="' . dol_escape_htmltag($dispatchBt). '"';
+                print '<br><input type="submit" class="button" name="dispatch" value="'.dol_escape_htmltag($dispatchBt).'"';
                 if (count($listwarehouses) <= 0)
 					print ' disabled';
 				print '>';
@@ -884,12 +884,12 @@ if ($id > 0 || ! empty($ref)) {
 		}
 
 		// Message if nothing to dispatch
-		if (! $nbproduct) {
+		if (!$nbproduct) {
 		    print "<br>\n";
 		    if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED))
-				print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>';		// No predefined line at all
+				print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>'; // No predefined line at all
 			else
-				print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>';	// No predefined line that remain to be dispatched.
+				print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched.
 		}
 
 		print '</form>';
@@ -902,12 +902,12 @@ if ($id > 0 || ! empty($ref)) {
 	$sql = "SELECT p.ref, p.label,";
 	$sql .= " e.rowid as warehouse_id, e.ref as entrepot,";
 	$sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec";
-	if($conf->reception->enabled)$sql.=" ,cfd.fk_reception, r.date_delivery";
-	$sql .= " FROM " . MAIN_DB_PREFIX . "product as p,";
-	$sql .= " " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd";
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e ON cfd.fk_entrepot = e.rowid";
-	if($conf->reception->enabled)$sql.=" LEFT JOIN " . MAIN_DB_PREFIX . "reception as r ON cfd.fk_reception = r.rowid";
-	$sql .= " WHERE cfd.fk_commande = " . $object->id;
+	if ($conf->reception->enabled)$sql .= " ,cfd.fk_reception, r.date_delivery";
+	$sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
+	$sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
+	if ($conf->reception->enabled)$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid";
+	$sql .= " WHERE cfd.fk_commande = ".$object->id;
 	$sql .= " AND cfd.fk_product = p.rowid";
 	$sql .= " ORDER BY cfd.rowid ASC";
 
@@ -925,26 +925,26 @@ if ($id > 0 || ! empty($ref)) {
 			print '<table id="dispatch_received_products" class="noborder centpercent">';
 
 			print '<tr class="liste_titre">';
-			if($conf->reception->enabled)print '<td>' . $langs->trans("Reception") . '</td>';
-
-			print '<td>' . $langs->trans("Product") . '</td>';
-			print '<td>' . $langs->trans("DateCreation") . '</td>';
-			print '<td>' . $langs->trans("DateDeliveryPlanned") . '</td>';
-			if (! empty($conf->productbatch->enabled)) {
-				print '<td class="dispatch_batch_number_title">' . $langs->trans("batch_number") . '</td>';
-				print '<td class="dispatch_dluo_title">' . $langs->trans("EatByDate") . '</td>';
-				print '<td class="dispatch_dlc_title">' . $langs->trans("SellByDate") . '</td>';
+			if ($conf->reception->enabled)print '<td>'.$langs->trans("Reception").'</td>';
+
+			print '<td>'.$langs->trans("Product").'</td>';
+			print '<td>'.$langs->trans("DateCreation").'</td>';
+			print '<td>'.$langs->trans("DateDeliveryPlanned").'</td>';
+			if (!empty($conf->productbatch->enabled)) {
+				print '<td class="dispatch_batch_number_title">'.$langs->trans("batch_number").'</td>';
+				print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
+				print '<td class="dispatch_dlc_title">'.$langs->trans("SellByDate").'</td>';
 			}
-			print '<td class="right">' . $langs->trans("QtyDispatched") . '</td>';
+			print '<td class="right">'.$langs->trans("QtyDispatched").'</td>';
 			print '<td></td>';
-			print '<td>' . $langs->trans("Warehouse") . '</td>';
-			print '<td>' . $langs->trans("Comment") . '</td>';
+			print '<td>'.$langs->trans("Warehouse").'</td>';
+			print '<td>'.$langs->trans("Comment").'</td>';
 
 			// Status
-			if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) {
-				print '<td class="center" colspan="2">' . $langs->trans("Status") . '</td>';
+			if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) {
+				print '<td class="center" colspan="2">'.$langs->trans("Status").'</td>';
 			}
-			elseif(!empty($conf->reception->enabled)) {
+			elseif (!empty($conf->reception->enabled)) {
 				print '<td class="center"></td>';
 			}
 
@@ -952,14 +952,14 @@ if ($id > 0 || ! empty($ref)) {
 
 			print "</tr>\n";
 
-			while ( $i < $num ) {
+			while ($i < $num) {
 				$objp = $db->fetch_object($resql);
 
-				print "<tr " . $bc[$var] . ">";
+				print "<tr ".$bc[$var].">";
 
-				if(!empty($conf->reception->enabled) ){
+				if (!empty($conf->reception->enabled)) {
 					print '<td>';
-					if (!empty($objp->fk_reception)){
+					if (!empty($objp->fk_reception)) {
 						$reception = new Reception($db);
 						$reception->fetch($objp->fk_reception);
 						print $reception->getNomUrl(1);
@@ -969,20 +969,20 @@ if ($id > 0 || ! empty($ref)) {
 				}
 
 				print '<td>';
-				print '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp->fk_product . '">' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . '</a>';
-				print ' - ' . $objp->label;
+				print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.'</a>';
+				print ' - '.$objp->label;
 				print "</td>\n";
 				print '<td>'.dol_print_date($db->jdate($objp->datec), 'day').'</td>';
 				print '<td>'.dol_print_date($db->jdate($objp->date_delivery), 'day').'</td>';
 
-				if (! empty($conf->productbatch->enabled)) {
-					print '<td class="dispatch_batch_number">' . $objp->batch . '</td>';
-					print '<td class="dispatch_dluo">' . dol_print_date($db->jdate($objp->eatby), 'day') . '</td>';
-					print '<td class="dispatch_dlc">' . dol_print_date($db->jdate($objp->sellby), 'day') . '</td>';
+				if (!empty($conf->productbatch->enabled)) {
+					print '<td class="dispatch_batch_number">'.$objp->batch.'</td>';
+					print '<td class="dispatch_dluo">'.dol_print_date($db->jdate($objp->eatby), 'day').'</td>';
+					print '<td class="dispatch_dlc">'.dol_print_date($db->jdate($objp->sellby), 'day').'</td>';
 				}
 
 				// Qty
-				print '<td class="right">' . $objp->qty . '</td>';
+				print '<td class="right">'.$objp->qty.'</td>';
 				print '<td>&nbsp;</td>';
 
 				// Warehouse
@@ -993,10 +993,10 @@ if ($id > 0 || ! empty($ref)) {
 				print '</td>';
 
 				// Comment
-				print '<td class="tdoverflowmax300" style="white-space: pre;">' . $objp->comment . '</td>';
+				print '<td class="tdoverflowmax300" style="white-space: pre;">'.$objp->comment.'</td>';
 
 				// Status
-				if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) {
+				if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) {
 					print '<td class="right">';
 					$supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status);
 					// print $supplierorderdispatch->status;
@@ -1005,36 +1005,36 @@ if ($id > 0 || ! empty($ref)) {
 
 					// Add button to check/uncheck disaptching
 					print '<td class="center">';
-					if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))
+					if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))
 					{
 						if (empty($objp->status)) {
-							print '<a class="button buttonRefused" href="#">' . $langs->trans("Approve") . '</a>';
-							print '<a class="button buttonRefused" href="#">' . $langs->trans("Deny") . '</a>';
+							print '<a class="button buttonRefused" href="#">'.$langs->trans("Approve").'</a>';
+							print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
 						} else {
-							print '<a class="button buttonRefused" href="#">' . $langs->trans("Disapprove") . '</a>';
-							print '<a class="button buttonRefused" href="#">' . $langs->trans("Deny") . '</a>';
+							print '<a class="button buttonRefused" href="#">'.$langs->trans("Disapprove").'</a>';
+							print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
 						}
 					} else {
 						$disabled = '';
 						if ($object->statut == 5)
 							$disabled = 1;
 						if (empty($objp->status)) {
-							print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>';
-							print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=denydispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Deny") . '</a>';
+							print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>';
+							print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
 						}
 						if ($objp->status == 1) {
-							print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=uncheckdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Reinit") . '</a>';
-							print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=denydispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Deny") . '</a>';
+							print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Reinit").'</a>';
+							print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
 						}
 						if ($objp->status == 2) {
-							print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=uncheckdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Reinit") . '</a>';
-							print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>';
+							print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Reinit").'</a>';
+							print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>';
 						}
 					}
 					print '</td>';
-				} elseif(!empty($conf->reception->enabled)) {
+				} elseif (!empty($conf->reception->enabled)) {
 					print '<td class="right">';
-					if(!empty($reception->id)){
+					if (!empty($reception->id)) {
 						print $reception->getLibStatut(5);
 					}
 					print '</td>';
@@ -1044,7 +1044,7 @@ if ($id > 0 || ! empty($ref)) {
 
 				print "</tr>\n";
 
-				$i ++;
+				$i++;
 			}
 			$db->free($resql);
 

+ 178 - 178
htdocs/fourn/facture/paiement.php

@@ -47,19 +47,19 @@ $optioncss = GETPOST('optioncss', 'alpha');
 
 $facid		= GETPOST('facid', 'int');
 $socid		= GETPOST('socid', 'int');
-$accountid	= GETPOST('accountid', 'int');
-$day		= GETPOST('day', 'int');
+$accountid = GETPOST('accountid', 'int');
+$day = GETPOST('day', 'int');
 $month		= GETPOST('month', 'int');
-$year		= GETPOST('year', 'int');
+$year = GETPOST('year', 'int');
 
-$search_ref=GETPOST("search_ref", "alpha");
-$search_account=GETPOST("search_account", "int");
-$search_paymenttype=GETPOST("search_paymenttype");
-$search_amount=GETPOST("search_amount", 'alpha');    // alpha because we must be able to search on "< x"
-$search_company=GETPOST("search_company", 'alpha');
-$search_payment_num=GETPOST('search_payment_num', 'alpha');
+$search_ref = GETPOST("search_ref", "alpha");
+$search_account = GETPOST("search_account", "int");
+$search_paymenttype = GETPOST("search_paymenttype");
+$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x"
+$search_company = GETPOST("search_company", 'alpha');
+$search_payment_num = GETPOST('search_payment_num', 'alpha');
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');
@@ -67,15 +67,15 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortorder) $sortorder="DESC";
-if (! $sortfield) $sortfield="p.rowid";
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = "p.rowid";
 
 $amounts = array();
-$amountsresttopay=array();
-$addwarning=0;
+$amountsresttopay = array();
+$addwarning = 0;
 
-$multicurrency_amounts=array();
-$multicurrency_amountsresttopay=array();
+$multicurrency_amounts = array();
+$multicurrency_amountsresttopay = array();
 
 // Security check
 if ($user->socid > 0)
@@ -94,7 +94,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
 
 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
 
-$arrayfields=array();
+$arrayfields = array();
 
 
 
@@ -104,25 +104,25 @@ $arrayfields=array();
 
 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_ref="";
-    $search_account="";
-    $search_amount="";
-    $search_paymenttype="";
-    $search_payment_num="";
-    $search_company="";
-    $day='';
-    $year='';
-    $month='';
-    $search_array_options=array();
+    $search_ref = "";
+    $search_account = "";
+    $search_amount = "";
+    $search_paymenttype = "";
+    $search_payment_num = "";
+    $search_company = "";
+    $day = '';
+    $year = '';
+    $month = '';
+    $search_array_options = array();
 }
 
-$parameters=array('socid'=>$socid);
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
+$parameters = array('socid'=>$socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
 if (empty($reshook))
 {
-	if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
+	if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes'))
 	{
 	    $error = 0;
 
@@ -132,7 +132,7 @@ if (empty($reshook))
 	    $atleastonepaymentnotnull = 0;
 
 	    // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
-	    $tmpinvoice=new FactureFournisseur($db);
+	    $tmpinvoice = new FactureFournisseur($db);
 	    foreach ($_POST as $key => $value)
 	    {
 	        if (substr($key, 0, 7) == 'amount_')
@@ -140,16 +140,16 @@ if (empty($reshook))
 	            $cursorfacid = substr($key, 7);
 	            $amounts[$cursorfacid] = price2num(trim(GETPOST($key)));
 	            $totalpayment = $totalpayment + $amounts[$cursorfacid];
-	            if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
-	            $result=$tmpinvoice->fetch($cursorfacid);
+	            if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
+	            $result = $tmpinvoice->fetch($cursorfacid);
 	            if ($result <= 0) dol_print_error($db);
-	            $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
+	            $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
 	            if ($amounts[$cursorfacid])
 	            {
 		            // Check amount
 		            if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])))
 		            {
-		                $addwarning=1;
+		                $addwarning = 1;
 		                $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
 		            }
 		            // Check date
@@ -161,23 +161,23 @@ if (empty($reshook))
 		            }
 	            }
 
-	            $formquestion[$i++]=array('type' => 'hidden','name' => $key,  'value' => $_POST[$key]);
+	            $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]);
 	        }
 			elseif (substr($key, 0, 21) == 'multicurrency_amount_')
 			{
 				$cursorfacid = substr($key, 21);
 	            $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key)));
 	            $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
-	            if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++;
-	            $result=$tmpinvoice->fetch($cursorfacid);
+	            if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++;
+	            $result = $tmpinvoice->fetch($cursorfacid);
 	            if ($result <= 0) dol_print_error($db);
-	            $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1));
+	            $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1));
 	            if ($multicurrency_amounts[$cursorfacid])
 	            {
 		            // Check amount
 		            if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid])))
 		            {
-		                $addwarning=1;
+		                $addwarning = 1;
 		                $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
 		            }
 		            // Check date
@@ -189,7 +189,7 @@ if (empty($reshook))
 		            }
 	            }
 
-	            $formquestion[$i++]=array('type' => 'hidden','name' => $key,  'value' => GETPOST($key, 'int'));
+	            $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int'));
 			}
 	    }
 
@@ -200,7 +200,7 @@ if (empty($reshook))
 	        $error++;
 	    }
 
-	    if (! empty($conf->banque->enabled))
+	    if (!empty($conf->banque->enabled))
 	    {
 	        // If bank module is on, account is required to enter a payment
 	        if (GETPOST('accountid') <= 0)
@@ -248,7 +248,7 @@ if (empty($reshook))
 	 */
 	if ($action == 'confirm_paiement' && $confirm == 'yes')
 	{
-	    $error=0;
+	    $error = 0;
 
 	    $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
 
@@ -279,7 +279,7 @@ if (empty($reshook))
         //var_dump($multicurrency_amounts);
         //exit;
 
-	    if (! $error)
+	    if (!$error)
 	    {
 	        $db->begin();
 
@@ -289,14 +289,14 @@ if (empty($reshook))
 	        // Creation de la ligne paiement
 	        $paiement = new PaiementFourn($db);
 	        $paiement->datepaye     = $datepaye;
-	        $paiement->amounts      = $amounts;   // Array of amounts
+	        $paiement->amounts      = $amounts; // Array of amounts
 	        $paiement->multicurrency_amounts = $multicurrency_amounts;
 	        $paiement->paiementid   = $_POST['paiementid'];
 	        $paiement->num_paiement = $_POST['num_paiement'];
 	        $paiement->note         = $_POST['comment'];
-	        if (! $error)
+	        if (!$error)
 	        {
-	            $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty);
+	            $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty);
 	            if ($paiement_id < 0)
 	            {
 	            	setEventMessages($paiement->error, $paiement->errors, 'errors');
@@ -304,9 +304,9 @@ if (empty($reshook))
 	            }
 	        }
 
-	        if (! $error)
+	        if (!$error)
 	        {
-	            $result=$paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', '');
+	            $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', '');
 	            if ($result < 0)
 	            {
 	            	setEventMessages($paiement->error, $paiement->errors, 'errors');
@@ -314,19 +314,19 @@ if (empty($reshook))
 	            }
 	        }
 
-	        if (! $error)
+	        if (!$error)
 	        {
 	            $db->commit();
 
 	            // If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card
-	            $invoiceid=0;
+	            $invoiceid = 0;
 	            foreach ($paiement->amounts as $key => $amount)
 	            {
 	                $facid = $key;
 	                if (is_numeric($amount) && $amount <> 0)
 	                {
-	                    if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment
-	                    else $invoiceid=$facid;
+	                    if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment
+	                    else $invoiceid = $facid;
 	                }
 	            }
 	            if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid;
@@ -347,10 +347,10 @@ if (empty($reshook))
  * View
  */
 
-$form=new Form($db);
-$formother=new FormOther($db);
+$form = new Form($db);
+$formother = new FormOther($db);
 
-$supplierstatic=new Societe($db);
+$supplierstatic = new Societe($db);
 $invoicesupplierstatic = new FactureFournisseur($db);
 
 llxHeader('', $langs->trans('ListPayment'));
@@ -360,17 +360,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
     $object = new FactureFournisseur($db);
     $result = $object->fetch($facid);
 
-    $datefacture=dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
-    $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture);
+    $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+    $dateinvoice = ($datefacture == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datefacture);
 
     $sql = 'SELECT s.nom as name, s.rowid as socid,';
-    $sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
+    $sql .= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
     if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
-    $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
+    $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
     if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-    $sql.= ' WHERE f.fk_soc = s.rowid';
-    $sql.= ' AND f.rowid = '.$facid;
-    if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+    $sql .= ' WHERE f.fk_soc = s.rowid';
+    $sql .= ' AND f.rowid = '.$facid;
+    if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
     $resql = $db->query($sql);
     if ($resql)
     {
@@ -383,7 +383,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
             print load_fiche_titre($langs->trans('DoPayment'));
 
             // Add realtime total information
-            if (! empty($conf->use_javascript_ajax))
+            if (!empty($conf->use_javascript_ajax))
             {
             	print "\n".'<script type="text/javascript" language="javascript">';
             	print '$(document).ready(function () {
@@ -470,64 +470,64 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
             print '<table class="border centpercent">';
 
             print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans('Company').'</td><td>';
-            $supplierstatic->id=$obj->socid;
-            $supplierstatic->name=$obj->name;
+            $supplierstatic->id = $obj->socid;
+            $supplierstatic->name = $obj->name;
             print $supplierstatic->getNomUrl(1, 'supplier');
             print '</td></tr>';
             print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
             print $form->selectDate($dateinvoice, '', '', '', 0, "addpaiement", 1, 1, 0, '', '', $object->date);
             print '</td></tr>';
             print '<tr><td class="fieldrequired">'.$langs->trans('PaymentMode').'</td><td>';
-            $form->select_types_paiements(empty($_POST['paiementid'])?$obj->fk_mode_reglement:$_POST['paiementid'], 'paiementid');
+            $form->select_types_paiements(empty($_POST['paiementid']) ? $obj->fk_mode_reglement : $_POST['paiementid'], 'paiementid');
             print '</td>';
-            if (! empty($conf->banque->enabled))
+            if (!empty($conf->banque->enabled))
             {
                 print '<tr><td class="fieldrequired">'.$langs->trans('Account').'</td><td>';
-                $form->select_comptes(empty($accountid)?$obj->fk_account:$accountid, 'accountid', 0, '', 2);
+                $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid, 'accountid', 0, '', 2);
                 print '</td></tr>';
             }
             else
             {
                 print '<tr><td>&nbsp;</td></tr>';
             }
-            print '<tr><td>'.$langs->trans('Numero').'</td><td><input name="num_paiement" type="text" value="'.(empty($_POST['num_paiement'])?'':$_POST['num_paiement']).'"></td></tr>';
+            print '<tr><td>'.$langs->trans('Numero').'</td><td><input name="num_paiement" type="text" value="'.(empty($_POST['num_paiement']) ? '' : $_POST['num_paiement']).'"></td></tr>';
             print '<tr><td>'.$langs->trans('Comments').'</td>';
             print '<td class="tdtop">';
-            print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>';
+            print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.(empty($_POST['comment']) ? '' : $_POST['comment']).'</textarea></td></tr>';
             print '</table>';
             dol_fiche_end();
 
 
-			$parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
-			$reshook=$hookmanager->executeHooks('paymentsupplierinvoices', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
-			$error=$hookmanager->error; $errors=$hookmanager->errors;
+			$parameters = array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
+			$reshook = $hookmanager->executeHooks('paymentsupplierinvoices', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+			$error = $hookmanager->error; $errors = $hookmanager->errors;
 			if (empty($reshook))
 			{
 				/*
 	             * All unpayed supplier invoices
 	             */
 	            $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,';
-	            $sql.= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
-	            $sql.= ' f.datef as df, f.date_lim_reglement as dlr,';
-	            $sql.= ' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
-	            $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
-	            $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
-	            $sql.= " WHERE f.entity = ".$conf->entity;
-	            $sql.= ' AND f.fk_soc = '.$object->socid;
-	            $sql.= ' AND f.paye = 0';
-	            $sql.= ' AND f.fk_statut = 1';  // Statut=0 => non validee, Statut=2 => annulee
+	            $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
+	            $sql .= ' f.datef as df, f.date_lim_reglement as dlr,';
+	            $sql .= ' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
+	            $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
+	            $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
+	            $sql .= " WHERE f.entity = ".$conf->entity;
+	            $sql .= ' AND f.fk_soc = '.$object->socid;
+	            $sql .= ' AND f.paye = 0';
+	            $sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validee, Statut=2 => annulee
 	            if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE)
 	            {
-	                $sql .= ' AND f.type IN (0,1,3,5)';	// Standard invoice, replacement, deposit, situation
+	                $sql .= ' AND f.type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
 	            }
 	            else
 	            {
-	                $sql .= ' AND f.type = 2';		// If paying back a credit note, we show all credit notes
+	                $sql .= ' AND f.type = 2'; // If paying back a credit note, we show all credit notes
 	            }
                 // Group by because we have a total
-	            $sql.= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef, f.date_lim_reglement';
+	            $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef, f.date_lim_reglement';
 	            // Sort invoices by date and serial number: the older one comes first
-	            $sql.= ' ORDER BY f.datef ASC, f.ref ASC';
+	            $sql .= ' ORDER BY f.datef ASC, f.ref ASC';
 
 	            $resql = $db->query($sql);
 	            if ($resql)
@@ -538,7 +538,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 	                    $i = 0;
 	                    print '<br>';
 
-	                    if (!empty($conf->use_javascript_ajax)){
+	                    if (!empty($conf->use_javascript_ajax)) {
 							//Add js for AutoFill
 							print "\n".'<script type="text/javascript" language="javascript">';
 							print ' $(document).ready(function () {';
@@ -550,7 +550,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 						}
 
                         print '<div class="div-table-responsive-no-min">';
-                        print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
+                        print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 						print '<tr class="liste_titre">';
 	                    print '<td>'.$langs->trans('Invoice').'</td>';
@@ -568,36 +568,36 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 						if (!empty($conf->multicurrency->enabled)) print '<td class="center">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
 	                    print '</tr>';
 
-	                    $total=0;
-	                    $total_ttc=0;
-	                    $totalrecu=0;
+	                    $total = 0;
+	                    $total_ttc = 0;
+	                    $totalrecu = 0;
 	                    while ($i < $num)
 	                    {
 	                        $objp = $db->fetch_object($resql);
 
-	                        $sign=1;
-	                        if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign=-1;
+	                        $sign = 1;
+	                        if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1;
 
-	                        $invoice=new FactureFournisseur($db);
+	                        $invoice = new FactureFournisseur($db);
 	                        $invoice->fetch($objp->facid);
 
-	                        $invoicesupplierstatic->ref=$objp->ref;
-	                        $invoicesupplierstatic->id=$objp->facid;
+	                        $invoicesupplierstatic->ref = $objp->ref;
+	                        $invoicesupplierstatic->id = $objp->facid;
 
 	                        $paiement = $invoice->getSommePaiement();
-	                        $creditnotes=$invoice->getSumCreditNotesUsed();
-	                        $deposits=$invoice->getSumDepositsUsed();
-	                        $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT');
-	                        $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
+	                        $creditnotes = $invoice->getSumCreditNotesUsed();
+	                        $deposits = $invoice->getSumDepositsUsed();
+	                        $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
+	                        $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
 
 	                        // Multicurrency Price
 	                        if (!empty($conf->multicurrency->enabled))
 	                        {
 	                        	$multicurrency_payment = $invoice->getSommePaiement(1);
-	                        	$multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1);
-	                        	$multicurrency_deposits=$invoice->getSumDepositsUsed(1);
-	                        	$multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
-	                        	$multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
+	                        	$multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
+	                        	$multicurrency_deposits = $invoice->getSumDepositsUsed(1);
+	                        	$multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
+	                        	$multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
 	                        }
 
 	                        print '<tr class="oddeven">';
@@ -697,7 +697,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 							print "</td>";
 
 							// Multicurrency Price
-							if (! empty($conf->multicurrency->enabled))
+							if (!empty($conf->multicurrency->enabled))
 							{
 								print '<td class="right">';
 
@@ -724,11 +724,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 							}
 
 							print "</tr>\n";
-	                        $total+=$objp->total_ht;
-	                        $total_ttc+=$objp->total_ttc;
-	                        $totalrecu+=$objp->am;
-							$totalrecucreditnote+=$creditnotes;
-							$totalrecudeposits+=$deposits;
+	                        $total += $objp->total_ht;
+	                        $total_ttc += $objp->total_ttc;
+	                        $totalrecu += $objp->am;
+							$totalrecucreditnote += $creditnotes;
+							$totalrecudeposits += $deposits;
 	                        $i++;
 	                    }
 	                    if ($i > 1)
@@ -746,7 +746,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 							if ($totalrecudeposits) print '+'.price($totalrecudeposits);
 							print	'</b></td>';
 							print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
-	                        print '<td class="center" id="result" style="font-weight: bold;"></td>';		// Autofilled
+	                        print '<td class="center" id="result" style="font-weight: bold;"></td>'; // Autofilled
 							if (!empty($conf->multicurrency->enabled)) print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
 	                        print "</tr>\n";
 	                    }
@@ -772,17 +772,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
             // Form to confirm payment
 	        if ($action == 'add_paiement')
 	        {
-	            $preselectedchoice=$addwarning?'no':'yes';
+	            $preselectedchoice = $addwarning ? 'no' : 'yes';
 
 	            print '<br>';
-	            if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment', price($totalpayment), $langs->trans("Currency".$conf->currency));
+	            if (!empty($totalpayment)) $text = $langs->trans('ConfirmSupplierPayment', price($totalpayment), $langs->trans("Currency".$conf->currency));
 				if (!empty($multicurrency_totalpayment))
 				{
-					$text.='<br>'.$langs->trans('ConfirmSupplierPayment', price($multicurrency_totalpayment), $langs->trans("paymentInInvoiceCurrency"));
+					$text .= '<br>'.$langs->trans('ConfirmSupplierPayment', price($multicurrency_totalpayment), $langs->trans("paymentInInvoiceCurrency"));
 				}
 	            if (GETPOST('closepaidinvoices'))
 	            {
-	                $text.='<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
+	                $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
 	                print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
 	            }
 	            print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('PayedSuppliersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
@@ -799,47 +799,47 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
  */
 if (empty($action) || $action == 'list')
 {
-    $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+    $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
     $sortfield = GETPOST("sortfield", 'alpha');
     $sortorder = GETPOST("sortorder", 'alpha');
-    $page=GETPOST("page", 'int');
+    $page = GETPOST("page", 'int');
     if (empty($page) || $page == -1) { $page = 0; }
-    $offset = $limit * $page ;
+    $offset = $limit * $page;
     $pageprev = $page - 1;
     $pagenext = $page + 1;
-    if (! $sortorder) $sortorder='DESC';
-    if (! $sortfield) $sortfield='p.datep';
+    if (!$sortorder) $sortorder = 'DESC';
+    if (!$sortfield) $sortfield = 'p.datep';
 
     $sql = 'SELECT p.rowid as pid, p.datep as dp, p.amount as pamount, p.num_paiement,';
-    $sql.= ' s.rowid as socid, s.nom as name,';
-    $sql.= ' c.code as paiement_type, c.libelle as paiement_libelle,';
-    $sql.= ' ba.rowid as bid, ba.label,';
+    $sql .= ' s.rowid as socid, s.nom as name,';
+    $sql .= ' c.code as paiement_type, c.libelle as paiement_libelle,';
+    $sql .= ' ba.rowid as bid, ba.label,';
     if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,';
-    $sql.= ' SUM(f.amount)';
-    $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
-    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
-    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
-    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
-    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
-    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
-    $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
+    $sql .= ' SUM(f.amount)';
+    $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
+    $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
+    $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
+    $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
+    $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
+    $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
+    $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
     if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-    $sql.= " WHERE f.entity = ".$conf->entity;
-    if (!$user->rights->societe->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+    $sql .= " WHERE f.entity = ".$conf->entity;
+    if (!$user->rights->societe->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
     if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid;
-    $sql.= dolSqlDateFilter('p.datep', $day, $month, $year);
+    $sql .= dolSqlDateFilter('p.datep', $day, $month, $year);
     if ($search_ref)       		    $sql .= natural_search('p.rowid', $search_ref);
-    if ($search_account > 0)      	$sql .=" AND b.fk_account=".$search_account;
-    if ($search_paymenttype != "")  $sql .=" AND c.code='".$db->escape($search_paymenttype)."'";
+    if ($search_account > 0)      	$sql .= " AND b.fk_account=".$search_account;
+    if ($search_paymenttype != "")  $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
     if ($search_payment_num != '')  $sql .= natural_search('p.num_paiement', $search_payment_num);
     if ($search_amount)      		$sql .= natural_search('p.amount', $search_amount, 1);
     if ($search_company)     		$sql .= natural_search('s.nom', $search_company);
     include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
-    $sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label";
+    $sql .= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label";
     if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
     // Add where from extra fields
 
-    $sql.= $db->order($sortfield, $sortorder);
+    $sql .= $db->order($sortfield, $sortorder);
 
     $nbtotalofrecords = '';
     if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -853,7 +853,7 @@ if (empty($action) || $action == 'list')
         }
     }
 
-    $sql.= $db->plimit($limit+1, $offset);
+    $sql .= $db->plimit($limit + 1, $offset);
 
     $resql = $db->query($sql);
     if ($resql)
@@ -861,21 +861,21 @@ if (empty($action) || $action == 'list')
         $num = $db->num_rows($resql);
         $i = 0;
 
-        $param='';
-        if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
-        if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
-        if ($day)                   $param.=($day?"&day=".urlencode($day):"");
-        if ($month)                 $param.=($month?"&month=".urlencode($month):"");
-        if ($year)                  $param.=($year?"&year=".urlencode($year):"");
-        if ($search_ref)            $param.=($search_ref?"&search_ref=".urlencode($search_ref):"");
-        if ($search_company)        $param.=($search_company?"&search_company=".urlencode($search_company):"");
-        if ($search_amount != '')   $param.=($search_amount?"&search_amount=".urlencode($search_amount):"");
-        if ($search_payment_num)    $param.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):"");
-    	if ($optioncss != '')       $param.='&optioncss='.urlencode($optioncss);
+        $param = '';
+        if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
+        if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
+        if ($day)                   $param .= ($day ? "&day=".urlencode($day) : "");
+        if ($month)                 $param .= ($month ? "&month=".urlencode($month) : "");
+        if ($year)                  $param .= ($year ? "&year=".urlencode($year) : "");
+        if ($search_ref)            $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : "");
+        if ($search_company)        $param .= ($search_company ? "&search_company=".urlencode($search_company) : "");
+        if ($search_amount != '')   $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : "");
+        if ($search_payment_num)    $param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : "");
+    	if ($optioncss != '')       $param .= '&optioncss='.urlencode($optioncss);
     	// Add $param from extra fields
     	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
 
-    	$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
+    	$massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
 
         print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit);
 
@@ -888,10 +888,10 @@ if (empty($action) || $action == 'list')
         print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
         print '<input type="hidden" name="page" value="'.$page.'">';
 
-        $moreforfilter='';
+        $moreforfilter = '';
 
-        $parameters=array();
-        $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters);    // Note that $action and $object may have been modified by hook
+        $parameters = array();
+        $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
     	if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
     	else $moreforfilter = $hookmanager->resPrint;
 
@@ -902,11 +902,11 @@ if (empty($action) || $action == 'list')
             print '</div>';
         }
 
-        $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
-        $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
+        $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
+        $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
 
         print '<div class="div-table-responsive">';
-        print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
+        print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
         // Lines for filters fields
         print '<tr class="liste_titre_filter">';
@@ -914,9 +914,9 @@ if (empty($action) || $action == 'list')
         print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
         print '</td>';
         print '<td class="liste_titre center">';
-        if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
+        if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
         print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
-        $formother->select_year($year?$year:-1, 'year', 1, 20, 5);
+        $formother->select_year($year ? $year : -1, 'year', 1, 20, 5);
         print '</td>';
         print '<td class="liste_titre">';
         print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
@@ -927,7 +927,7 @@ if (empty($action) || $action == 'list')
         print '<td class="liste_titre">';
         print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
         print '</td>';
-        if (! empty($conf->banque->enabled))
+        if (!empty($conf->banque->enabled))
         {
             print '<td class="liste_titre">';
 	        $form->select_comptes($search_account, 'search_account', 0, '', 1);
@@ -937,7 +937,7 @@ if (empty($action) || $action == 'list')
         print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
         print '</td>';
         print '<td class="liste_titre maxwidthsearch">';
-        $searchpicto=$form->showFilterAndCheckAddButtons(0);
+        $searchpicto = $form->showFilterAndCheckAddButtons(0);
         print $searchpicto;
         print '</td>';
         print "</tr>\n";
@@ -948,21 +948,21 @@ if (empty($action) || $action == 'list')
         print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
         print_liste_field_titre("Type", $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
         print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "p.num_paiement", "", $param, "", $sortfield, $sortorder);
-        if (! empty($conf->banque->enabled))
+        if (!empty($conf->banque->enabled))
         {
             print_liste_field_titre("Account", $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
         }
         print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
 
-        $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
-        $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters);    // Note that $action and $object may have been modified by hook
+        $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
+        $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
         print $hookmanager->resPrint;
 
         print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
         print "</tr>\n";
 
         $i = 0;
-        $totalarray=array();
+        $totalarray = array();
         while ($i < min($num, $limit))
         {
             $objp = $db->fetch_object($resql);
@@ -971,44 +971,44 @@ if (empty($action) || $action == 'list')
 
             // Ref payment
             print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$objp->pid.'">'.img_object($langs->trans('ShowPayment'), 'payment').' '.$objp->pid.'</a></td>';
-            if (! $i) $totalarray['nbfield']++;
+            if (!$i) $totalarray['nbfield']++;
 
             // Date
             $dateformatforpayment = 'day';
-            if (! empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment='dayhour';
+            if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour';
             print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->dp), $dateformatforpayment)."</td>\n";
-            if (! $i) $totalarray['nbfield']++;
+            if (!$i) $totalarray['nbfield']++;
 
             // Thirdparty
             print '<td>';
             if ($objp->socid) print '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'), 'company').' '.dol_trunc($objp->name, 32).'</a>';
             else print '&nbsp;';
             print '</td>';
-            if (! $i) $totalarray['nbfield']++;
+            if (!$i) $totalarray['nbfield']++;
 
             // Type
-            $payment_type = $langs->trans("PaymentType".$objp->paiement_type)!=("PaymentType".$objp->paiement_type)?$langs->trans("PaymentType".$objp->paiement_type):$objp->paiement_libelle;
+            $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
             print '<td>'.$payment_type.' '.dol_trunc($objp->num_paiement, 32)."</td>\n";
-            if (! $i) $totalarray['nbfield']++;
+            if (!$i) $totalarray['nbfield']++;
 
             // Payment number
             print '<td>'.$objp->num_paiement.'</td>';
-            if (! $i) $totalarray['nbfield']++;
+            if (!$i) $totalarray['nbfield']++;
 
             // Account
-            if (! empty($conf->banque->enabled))
+            if (!empty($conf->banque->enabled))
             {
                 print '<td>';
 	            if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).'</a>';
     	        else print '&nbsp;';
         	    print '</td>';
-            	if (! $i) $totalarray['nbfield']++;
+            	if (!$i) $totalarray['nbfield']++;
             }
 
             // Amount
             print '<td class="right">'.price($objp->pamount).'</td>';
-            if (! $i) $totalarray['nbfield']++;
-            $totalarray['pos'][7]='amount';
+            if (!$i) $totalarray['nbfield']++;
+            $totalarray['pos'][7] = 'amount';
             $totalarray['val']['amount'] += $objp->pamount;
 
             // Ref invoice
@@ -1019,7 +1019,7 @@ if (empty($action) || $action == 'list')
             print '</td>';*/
 
 			print '<td></td>';
-			if (! $i) $totalarray['nbfield']++;
+			if (!$i) $totalarray['nbfield']++;
 
             print '</tr>';
             $i++;

+ 33 - 33
htdocs/holiday/month_report.php

@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 $langs->loadLangs(array("holiday"));
 
 // Security check
-$socid=0;
+$socid = 0;
 if ($user->socid > 0)	// Protection if external user
 {
 	//$socid = $user->socid;
@@ -52,7 +52,7 @@ $html = new Form($db);
 $formother = new FormOther($db);
 $holidaystatic = new Holiday($db);
 
-$listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));
+$listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
 
 llxHeader('', $langs->trans('CPTitreMenu'));
 
@@ -62,10 +62,10 @@ print load_fiche_titre($langs->trans('MenuReportMonth'), '', 'title_hrm');
 // Selection filter
 print '<div class="tabBar">';
 
-print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
+print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
 
-$search_month = GETPOST("remonth", 'int')?GETPOST("remonth", 'int'):date("m", time());
-$search_year = GETPOST("reyear", 'int')?GETPOST("reyear", 'int'):date("Y", time());
+$search_month = GETPOST("remonth", 'int') ?GETPOST("remonth", 'int') : date("m", time());
+$search_year = GETPOST("reyear", 'int') ?GETPOST("reyear", 'int') : date("Y", time());
 
 $year_month = sprintf("%04d", $search_year).'-'.sprintf("%02d", $search_month);
 
@@ -83,7 +83,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."holiday cp";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid";
 $sql .= " WHERE cp.rowid > 0";
-$sql .= " AND cp.statut = 3";		// Approved
+$sql .= " AND cp.statut = 3"; // Approved
 $sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')";
 $sql .= " ORDER BY u.lastname, cp.date_debut";
 
@@ -105,16 +105,16 @@ print '<div class="div-table-responsive">';
 print '<table class="noborder centpercent">';
 
 print '<tr class="liste_titre">';
-print '<td>' . $langs->trans('Ref') . '</td>';
-print '<td>' . $langs->trans('Employee') . '</td>';
-print '<td>' . $langs->trans('Type') . '</td>';
-print '<td class="center">' . $langs->trans('DateDebCP') . '</td>';
-print '<td class="center">' . $langs->trans('DateFinCP') . '</td>';
-print '<td class="right">' . $langs->trans('NbUseDaysCPShort') . '</td>';
-print '<td class="center">' . $langs->trans('DateStartInMonth') . '</td>';
-print '<td class="center">' . $langs->trans('DateEndInMonth') . '</td>';
-print '<td class="right">' . $langs->trans('NbUseDaysCPShortInMonth') . '</td>';
-print '<td class="maxwidth300">' . $langs->trans('DescCP') . '</td>';
+print '<td>'.$langs->trans('Ref').'</td>';
+print '<td>'.$langs->trans('Employee').'</td>';
+print '<td>'.$langs->trans('Type').'</td>';
+print '<td class="center">'.$langs->trans('DateDebCP').'</td>';
+print '<td class="center">'.$langs->trans('DateFinCP').'</td>';
+print '<td class="right">'.$langs->trans('NbUseDaysCPShort').'</td>';
+print '<td class="center">'.$langs->trans('DateStartInMonth').'</td>';
+print '<td class="center">'.$langs->trans('DateEndInMonth').'</td>';
+print '<td class="right">'.$langs->trans('NbUseDaysCPShortInMonth').'</td>';
+print '<td class="maxwidth300">'.$langs->trans('DescCP').'</td>';
 print '</tr>';
 
 if ($num == 0)
@@ -134,8 +134,8 @@ else
         $tmpstart = dol_getdate($date_start);
         $tmpend = dol_getdate($date_end);
 
-        $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning';
-        $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon';
+        $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
+        $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
 
         $halfdayinmonth = $obj->halfday;
         $starthalfdayinmonth = $starthalfday;
@@ -150,42 +150,42 @@ else
         {
             $date_start_inmonth = dol_get_first_day($search_year, $search_month, true);
             $starthalfdayinmonth = 'morning';
-            if ($halfdayinmonth ==  2) $halfdayinmonth=1;
-            if ($halfdayinmonth == -1) $halfdayinmonth=0;
+            if ($halfdayinmonth == 2) $halfdayinmonth = 1;
+            if ($halfdayinmonth == -1) $halfdayinmonth = 0;
         }
         if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month)
         {
             $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1);
             $endhalfdayinmonth = 'afternoon';
-            if ($halfdayinmonth ==  2) $halfdayinmonth=-1;
-            if ($halfdayinmonth ==  1) $halfdayinmonth=0;
+            if ($halfdayinmonth == 2) $halfdayinmonth = -1;
+            if ($halfdayinmonth == 1) $halfdayinmonth = 0;
         }
 
         // Leave request
-        $holidaystatic->id=$obj->rowid;
-        $holidaystatic->ref=$obj->rowid;
+        $holidaystatic->id = $obj->rowid;
+        $holidaystatic->ref = $obj->rowid;
 
         print '<tr class="oddeven">';
         print '<td>';
         print $holidaystatic->getNomUrl(1, 1);
         print '</td>';
-        print '<td>' . $user->getFullName($langs) . '</td>';
-        print '<td>' . $obj->label . '</td>';
-        print '<td class="center">' . dol_print_date($db->jdate($obj->date_debut), 'day');
+        print '<td>'.$user->getFullName($langs).'</td>';
+        print '<td>'.$obj->label.'</td>';
+        print '<td class="center">'.dol_print_date($db->jdate($obj->date_debut), 'day');
         print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
         print '</td>';
-        print '<td class="center">' . dol_print_date($db->jdate($obj->date_fin), 'day');
+        print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day');
         print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
         print '</td>';
-        print '<td class="right">' . num_open_day($date_start, $date_end, 0, 1, $obj->halfday) . '</td>';
-        print '<td class="center">' . dol_print_date($date_start_inmonth, 'day');
+        print '<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).'</td>';
+        print '<td class="center">'.dol_print_date($date_start_inmonth, 'day');
         print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).')</span>';
         print '</td>';
-        print '<td class="center">' . dol_print_date($date_end_inmonth, 'day');
+        print '<td class="center">'.dol_print_date($date_end_inmonth, 'day');
         print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).')</span>';
         print '</td>';
-        print '<td class="right">' . num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth) . '</td>';
-        print '<td class="maxwidth300">' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . '</td>';
+        print '<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).'</td>';
+        print '<td class="maxwidth300">'.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'</td>';
         print '</tr>';
     }
 }

+ 14 - 14
htdocs/hrm/admin/admin_hrm.php

@@ -27,13 +27,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 // Load translation files required by the page
 $langs->loadLangs(array('admin', 'hrm'));
 
-if (! $user->admin)
+if (!$user->admin)
 	accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 
 // Other parameters HRM_*
-$list = array (
+$list = array(
 		'HRM_EMAIL_EXTERNAL_SERVICE'   // To prevent your public accountant for example
 );
 
@@ -46,12 +46,12 @@ if ($action == 'update') {
 	foreach ($list as $constname) {
 		$constvalue = GETPOST($constname, 'alpha');
 
-		if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
-			$error ++;
+		if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
+			$error++;
 		}
 	}
 
-	if (! $error) {
+	if (!$error) {
 		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 	} else {
 		setEventMessages($langs->trans("Error"), null, 'errors');
@@ -68,35 +68,35 @@ $form = new Form($db);
 dol_htmloutput_mesg($mesg);
 
 // Subheader
-$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("HRMSetup"), $linkback);
 
 // Configuration header
 $head = hrm_admin_prepare_head();
 
-print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="update">';
 
 dol_fiche_head($head, 'parameters', $langs->trans("HRM"), -1, "user");
 
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
-print '<td colspan="3">' . $langs->trans('Journaux') . '</td>';
+print '<td colspan="3">'.$langs->trans('Journaux').'</td>';
 print "</tr>\n";
 
 foreach ($list as $key) {
-	$var = ! $var;
+	$var = !$var;
 
-	print '<tr ' . $bc[$var] . ' class="value">';
+	print '<tr '.$bc[$var].' class="value">';
 
 	// Param
 	$label = $langs->trans($key);
-	print '<td width="50%"><label for="' . $key . '">' . $label . '</label></td>';
+	print '<td width="50%"><label for="'.$key.'">'.$label.'</label></td>';
 
 	// Value
 	print '<td>';
-	print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
+	print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
 	print '</td></tr>';
 }
 
@@ -104,7 +104,7 @@ print "</table>\n";
 
 dol_fiche_end();
 
-print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
+print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
 
 print '</form>';
 

File diff suppressed because it is too large
+ 247 - 247
htdocs/imports/import.php


+ 54 - 54
htdocs/margin/checkMargins.php

@@ -24,10 +24,10 @@
  * \brief Check margins
  */
 require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
-require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
 
 // Load translation files required by the page
 $langs->loadLangs(array('companies', 'bills', 'products', 'margins'));
@@ -35,12 +35,12 @@ $langs->loadLangs(array('companies', 'bills', 'products', 'margins'));
 $action     = GETPOST('action', 'alpha');
 $massaction = GETPOST('massaction', 'alpha');
 $toselect   = GETPOST('toselect', 'array');
-$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'margindetail';   // To manage different context of search
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'margindetail'; // To manage different context of search
 $backtopage = GETPOST('backtopage', 'alpha');
 $optioncss  = GETPOST('optioncss', 'alpha');
 
 // Load variable for pagination
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST('sortfield', 'alpha');
 $sortorder = GETPOST('sortorder', 'alpha');
 $page = GETPOST('page', 'int');
@@ -48,8 +48,8 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortorder) $sortorder = "DESC";
-if (! $sortfield) $sortfield = 'f.ref';
+if (!$sortorder) $sortorder = "DESC";
+if (!$sortfield) $sortfield = 'f.ref';
 
 $startdate = $enddate = '';
 
@@ -59,7 +59,7 @@ $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('endda
 $search_ref = GETPOST('search_ref', 'alpha');
 
 // Security check
-$result=restrictedArea($user, 'margins');
+$result = restrictedArea($user, 'margins');
 
 // Both test are required to be compatible with all browsers
 if (GETPOST("button_search_x") || GETPOST("button_search")) {
@@ -73,11 +73,11 @@ if (GETPOST("button_search_x") || GETPOST("button_search")) {
  * Actions
  */
 
-if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
-if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
+if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
 
-$parameters=array();
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
 if (empty($reshook))
@@ -93,10 +93,10 @@ if (empty($reshook))
                 $tmp_array = explode('_', $key);
                 if (count($tmp_array) > 0) {
                     $invoicedet_id = $tmp_array[1];
-                    if (! empty($invoicedet_id)) {
-                        $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet';
-                        $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\'';
-                        $sql .= ' WHERE rowid=' . $invoicedet_id;
+                    if (!empty($invoicedet_id)) {
+                        $sql = 'UPDATE '.MAIN_DB_PREFIX.'facturedet';
+                        $sql .= ' SET buy_price_ht=\''.price2num($value).'\'';
+                        $sql .= ' WHERE rowid='.$invoicedet_id;
                         $result = $db->query($sql);
                         if (!$result) {
                             setEventMessages($db->lasterror, null, 'errors');
@@ -110,8 +110,8 @@ if (empty($reshook))
     // Purge search criteria
     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_ref='';
-        $search_array_options=array();
+        $search_ref = '';
+        $search_array_options = array();
     }
 
     // Mass actions
@@ -145,34 +145,34 @@ llxHeader('', $title);
 
 // print load_fiche_titre($text);
 
-$param='';
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
-if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
-if ($search_ref != '')   $param.='&search_ref='.urlencode($search_ref);
-if (! empty($startdate)) $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int');
-if (! empty($enddate))   $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int');
-if ($optioncss != '')    $param.='&optioncss='.$optioncss;
+$param = '';
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
+if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
+if ($search_ref != '')   $param .= '&search_ref='.urlencode($search_ref);
+if (!empty($startdate)) $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int').'&startdateday='.GETPOST('startdateday', 'int').'&startdateyear='.GETPOST('startdateyear', 'int');
+if (!empty($enddate))   $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int').'&enddateday='.GETPOST('enddateday', 'int').'&enddateyear='.GETPOST('enddateyear', 'int');
+if ($optioncss != '')    $param .= '&optioncss='.$optioncss;
 
 // Show tabs
 $head = marges_prepare_head($user);
 $picto = 'margin';
 
-print '<form method="post" name="sel" action="' . $_SERVER['PHP_SELF'] . '">';
+print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
 
 dol_fiche_head($head, $langs->trans('checkMargins'), $title, 0, $picto);
 
 print '<table class="border centpercent">';
 
-print '<tr><td class="titlefield">' . $langs->trans('DateStart') . ' (' . $langs->trans("DateValidation") . ')</td>';
+print '<tr><td class="titlefield">'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')</td>';
 print '<td>';
 print $form->selectDate($startdate, 'startdate', '', '', 1, "sel", 1, 1);
 print '</td>';
-print '<td>' . $langs->trans('DateEnd') . ' (' . $langs->trans("DateValidation") . ')</td>';
+print '<td>'.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')</td>';
 print '<td>';
 print $form->selectDate($enddate, 'enddate', '', '', 1, "sel", 1, 1);
 print '</td>';
 print '<td style="text-align: center;">';
-print '<input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Refresh')) . '" name="button_search" />';
+print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Refresh')).'" name="button_search" />';
 print '</td>';
 print '</tr>';
 print "</table>";
@@ -180,22 +180,22 @@ print "</table>";
 dol_fiche_end();
 
 
-$arrayfields=array();
-$massactionbutton='';
+$arrayfields = array();
+$massactionbutton = '';
 
 $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
 
 $sql = "SELECT";
 $sql .= " f.ref, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty";
 $sql .= " ,d.fk_product";
-$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f ";
-$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as d  ON d.fk_facture = f.rowid";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid";
-$sql .= " WHERE f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
-$sql .= " AND f.entity IN (" . getEntity('invoice') . ") ";
-if (! empty($startdate)) $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'";
-if (! empty($enddate))   $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'";
-if ($search_ref) $sql.=natural_search('f.ref', $search_ref);
+$sql .= " FROM ".MAIN_DB_PREFIX."facture as f ";
+$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d  ON d.fk_facture = f.rowid";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
+$sql .= " WHERE f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")";
+$sql .= " AND f.entity IN (".getEntity('invoice').") ";
+if (!empty($startdate)) $sql .= " AND f.datef >= '".$db->idate($startdate)."'";
+if (!empty($enddate))   $sql .= " AND f.datef <= '".$db->idate($enddate)."'";
+if ($search_ref) $sql .= natural_search('f.ref', $search_ref);
 $sql .= " AND d.buy_price_ht IS NOT NULL";
 $sql .= $db->order($sortfield, $sortorder);
 
@@ -211,7 +211,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
 	}
 }
 
-$sql .= $db->plimit($limit+1, $offset);
+$sql .= $db->plimit($limit + 1, $offset);
 
 $result = $db->query($sql);
 if ($result) {
@@ -221,19 +221,19 @@ if ($result) {
 	print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
 
 	if ($conf->global->MARGIN_TYPE == "1")
-	    $labelcostprice='BuyingPrice';
+	    $labelcostprice = 'BuyingPrice';
 	else   // value is 'costprice' or 'pmp'
-	    $labelcostprice='CostPrice';
+	    $labelcostprice = 'CostPrice';
 
-	$moreforfilter='';
+	$moreforfilter = '';
 
-	$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
+	$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
 	//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
 	//if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
-	$selectedfields='';
+	$selectedfields = '';
 
     print '<div class="div-table-responsive">';
-    print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
+    print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 	print '<tr class="liste_titre liste_titre_search">';
 	print '<td><input type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
@@ -243,7 +243,7 @@ if ($result) {
 	print '<td></td>';
 	print '<td></td>';
     print '<td class="liste_titre" align="middle">';
-    $searchpitco=$form->showFilterButtons();
+    $searchpitco = $form->showFilterButtons();
     print $searchpitco;
     print '</td>';
 	print "</tr>\n";
@@ -258,7 +258,7 @@ if ($result) {
 	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
 	print "</tr>\n";
 
-    $i=0;
+    $i = 0;
 	while ($i < min($num, $limit))
 	{
 	    $objp = $db->fetch_object($result);
@@ -273,7 +273,7 @@ if ($result) {
 		}
 		print '</td>';
 		print '<td>';
-		if (! empty($objp->fk_product)) {
+		if (!empty($objp->fk_product)) {
 			$result_inner = $productstatic->fetch($objp->fk_product);
 			if ($result_inner < 0) {
 				setEventMessages($productstatic->error, null, 'errors');
@@ -290,7 +290,7 @@ if ($result) {
 		print price($objp->subprice);
 		print '</td>';
 		print '<td class="right">';
-		print '<input type="text" name="buyingprice_' . $objp->invoicedetid . '" id="buyingprice_' . $objp->invoicedetid . '" size="6" value="' . price($objp->buy_price_ht) . '" class="right flat">';
+		print '<input type="text" name="buyingprice_'.$objp->invoicedetid.'" id="buyingprice_'.$objp->invoicedetid.'" size="6" value="'.price($objp->buy_price_ht).'" class="right flat">';
 		print '</td>';
 		print '<td class="right">';
 		print $objp->qty;
@@ -302,7 +302,7 @@ if ($result) {
 
 		print "</tr>\n";
 
-		$i ++;
+		$i++;
 	}
 
 	print "</table>";
@@ -313,8 +313,8 @@ if ($result) {
 }
 
 
-print '<div class="center">' . "\n";
-print '<input type="submit" class="button" name="button_updatemagins" id="button_updatemagins" value="' . $langs->trans("Update") . '">';
+print '<div class="center">'."\n";
+print '<input type="submit" class="button" name="button_updatemagins" id="button_updatemagins" value="'.$langs->trans("Update").'">';
 print '</div>';
 
 print '</form>';

+ 76 - 76
htdocs/margin/customerMargins.php

@@ -36,7 +36,7 @@ $socid = GETPOST('socid', 'int');
 $TSelectedProducts = GETPOST('products', 'array');
 $TSelectedCats = GETPOST('categories', 'array');
 
-if (! empty($user->socid)) $socid=$user->socid;
+if (!empty($user->socid)) $socid = $user->socid;
 $result = restrictedArea($user, 'societe', '', '');
 $result = restrictedArea($user, 'margins');
 
@@ -44,7 +44,7 @@ $result = restrictedArea($user, 'margins');
 $mesg = '';
 
 // Load variable for pagination
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST('sortfield', 'alpha');
 $sortorder = GETPOST('sortorder', 'alpha');
 $page = GETPOST('page', 'int');
@@ -52,15 +52,15 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortfield) $sortfield="s.nom"; // Set here default search field
-if (! $sortorder) $sortorder="ASC";
+if (!$sortfield) $sortfield = "s.nom"; // Set here default search field
+if (!$sortorder) $sortorder = "ASC";
 
-$startdate=$enddate='';
+$startdate = $enddate = '';
 
 if (!empty($_POST['startdatemonth']))
-  $startdate  = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
+  $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
 if (!empty($_POST['enddatemonth']))
-  $enddate  = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
+  $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
 
 
 /*
@@ -68,19 +68,19 @@ if (!empty($_POST['enddatemonth']))
  */
 
 $companystatic = new Societe($db);
-$invoicestatic=new Facture($db);
+$invoicestatic = new Facture($db);
 
 $form = new Form($db);
 
 llxHeader('', $langs->trans("Margins").' - '.$langs->trans("Clients"));
 
-$text=$langs->trans("Margins");
+$text = $langs->trans("Margins");
 //print load_fiche_titre($text);
 
 // Show tabs
-$head=marges_prepare_head($user);
-$titre=$langs->trans("Margins");
-$picto='margin';
+$head = marges_prepare_head($user);
+$titre = $langs->trans("Margins");
+$picto = 'margin';
 
 
 print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
@@ -102,8 +102,8 @@ if ($socid > 0) {
 		print '</td></tr>';
 
 		$client = true;
-		if (! $sortorder) $sortorder="DESC";
-		if (! $sortfield) $sortfield="f.datef";
+		if (!$sortorder) $sortorder = "DESC";
+		if (!$sortfield) $sortfield = "f.datef";
 	}
 }
 else {
@@ -115,18 +115,18 @@ else {
 
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
-if (! $sortorder) $sortorder="ASC";
-if (! $sortfield)
+if (!$sortorder) $sortorder = "ASC";
+if (!$sortfield)
 {
 	if ($client)
 	{
-		$sortfield="f.datef";
-		$sortorder="DESC";
+		$sortfield = "f.datef";
+		$sortorder = "DESC";
 	}
 	else
 	{
-	    $sortfield="s.nom";
-	    $sortorder="ASC";
+	    $sortfield = "s.nom";
+	    $sortorder = "ASC";
 	}
 }
 
@@ -134,7 +134,7 @@ if (! $sortfield)
 $TRes = $form->select_produits_list('', '', '', 20, 0, '', 1, 2, 1, 0, '', 1);
 
 $TProducts = array();
-foreach($TRes as $prod) {
+foreach ($TRes as $prod) {
 	$TProducts[$prod['key']] = $prod['label'];
 }
 
@@ -178,14 +178,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
 print '</td></tr>';
 
 // Margin Rate
-if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
+if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
 	print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
 	print '<span id="marginRate"></span>'; // set by jquery (see below)
 	print '</td></tr>';
 }
 
 // Mark Rate
-if (! empty($conf->global->DISPLAY_MARK_RATES)) {
+if (!empty($conf->global->DISPLAY_MARK_RATES)) {
 	print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
 	print '<span id="markRate"></span>'; // set by jquery (see below)
 	print '</td></tr>';
@@ -200,44 +200,44 @@ print '</form>';
 $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
 
 $sql = "SELECT";
-$sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
-if ($client) $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
-$sql.= " sum(d.total_ht) as selling_price,";
+$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
+if ($client) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
+$sql .= " sum(d.total_ht) as selling_price,";
 // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this)
-$sql.= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
-$sql.= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-$sql.= ", ".MAIN_DB_PREFIX."facture as f";
-$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
-if(! empty($TSelectedCats)) {
+$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
+$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
+$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
+$sql .= ", ".MAIN_DB_PREFIX."facture as f";
+$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
+if (!empty($TSelectedCats)) {
 	$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product';
 }
 
-if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE f.fk_soc = s.rowid";
-if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
-if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
-$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
-$sql.= ' AND s.entity IN ('.getEntity('societe').')';
-$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
-$sql.= " AND d.fk_facture = f.rowid";
-$sql.= " AND (d.product_type = 0 OR d.product_type = 1)";
-if(! empty($TSelectedProducts)) {
-	$sql .= ' AND d.fk_product IN ('.implode(',', $TSelectedProducts) . ')';
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= " WHERE f.fk_soc = s.rowid";
+if ($socid > 0) $sql .= ' AND s.rowid = '.$socid;
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")";
+$sql .= ' AND s.entity IN ('.getEntity('societe').')';
+$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
+$sql .= " AND d.fk_facture = f.rowid";
+$sql .= " AND (d.product_type = 0 OR d.product_type = 1)";
+if (!empty($TSelectedProducts)) {
+	$sql .= ' AND d.fk_product IN ('.implode(',', $TSelectedProducts).')';
 }
-if(! empty($TSelectedCats)) {
-	$sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats) . ')';
+if (!empty($TSelectedCats)) {
+	$sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')';
 }
 if (!empty($startdate))
-$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
+$sql .= " AND f.datef >= '".$db->idate($startdate)."'";
 if (!empty($enddate))
-$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
+$sql .= " AND f.datef <= '".$db->idate($enddate)."'";
 $sql .= " AND d.buy_price_ht IS NOT NULL";
 if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
 $sql .= " AND d.buy_price_ht <> 0";
-if ($client) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut";
-else $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client";
-$sql.=$db->order($sortfield, $sortorder);
+if ($client) $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut";
+else $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client";
+$sql .= $db->order($sortfield, $sortorder);
 // TODO: calculate total to display then restore pagination
 //$sql.= $db->plimit($conf->liste_limit +1, $offset);
 
@@ -251,15 +251,15 @@ if ($result)
 	print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
 
 	if ($conf->global->MARGIN_TYPE == "1")
-	    $labelcostprice='BuyingPrice';
+	    $labelcostprice = 'BuyingPrice';
 	else   // value is 'costprice' or 'pmp'
-	    $labelcostprice='CostPrice';
+	    $labelcostprice = 'CostPrice';
 
 	$i = 0;
 	print "<table class=\"noborder\" width=\"100%\">";
 
 	print '<tr class="liste_titre">';
-	if (! empty($client)) {
+	if (!empty($client)) {
   		print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&amp;socid=".$socid, '', $sortfield, $sortorder);
   		print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&amp;socid=".$socid, 'align="center"', $sortfield, $sortorder);
 	}
@@ -268,9 +268,9 @@ if ($result)
 	print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder);
 	print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder);
 	print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder);
-	if (! empty($conf->global->DISPLAY_MARGIN_RATES))
+	if (!empty($conf->global->DISPLAY_MARGIN_RATES))
 		print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder);
-	if (! empty($conf->global->DISPLAY_MARK_RATES))
+	if (!empty($conf->global->DISPLAY_MARK_RATES))
 		print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder);
 	print "</tr>\n";
 
@@ -291,39 +291,39 @@ if ($result)
 
 			if ($marge < 0)
 			{
-				$marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ;
-				$markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ;
+				$marginRate = ($pa != 0) ?-1 * (100 * $marge / $pa) : '';
+				$markRate = ($pv != 0) ?-1 * (100 * $marge / $pv) : '';
 			}
 			else
 			{
-				$marginRate = ($pa != 0)?(100 * $marge / $pa):'' ;
-				$markRate = ($pv != 0)?(100 * $marge / $pv):'' ;
+				$marginRate = ($pa != 0) ? (100 * $marge / $pa) : '';
+				$markRate = ($pv != 0) ? (100 * $marge / $pv) : '';
 			}
 
 			print '<tr class="oddeven">';
 			if ($client) {
 		        print '<td>';
-				$invoicestatic->id=$objp->facid;
-				$invoicestatic->ref=$objp->ref;
+				$invoicestatic->id = $objp->facid;
+				$invoicestatic->ref = $objp->ref;
 				print $invoicestatic->getNomUrl(1);
 				print "</td>\n";
 				print "<td class=\"center\">";
 				print dol_print_date($db->jdate($objp->datef), 'day')."</td>";
 		  	}
 		  	else {
-				$companystatic->id=$objp->socid;
-				$companystatic->name=$objp->name;
-				$companystatic->client=$objp->client;
+				$companystatic->id = $objp->socid;
+				$companystatic->name = $objp->name;
+				$companystatic->client = $objp->client;
 		   		print "<td>".$companystatic->getNomUrl(1, 'margin')."</td>\n";
 		  	}
 
 			print "<td class=\"right\">".price($pv, null, null, null, null, $rounding)."</td>\n";
 			print "<td class=\"right\">".price($pa, null, null, null, null, $rounding)."</td>\n";
 			print "<td class=\"right\">".price($marge, null, null, null, null, $rounding)."</td>\n";
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
-				print "<td class=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
-			if (! empty($conf->global->DISPLAY_MARK_RATES))
-				print "<td class=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES))
+				print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
+			if (!empty($conf->global->DISPLAY_MARK_RATES))
+				print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
 			print "</tr>\n";
 
 			$i++;
@@ -342,8 +342,8 @@ if ($result)
 	}
 	else
 	{*/
-		$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
-		$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
+		$marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : '';
+		$markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : '';
 	//}
 
 	print '<tr class="liste_total">';
@@ -355,10 +355,10 @@ if ($result)
 	print "<td class=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
 	print "<td class=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
 	print "<td class=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n";
-	if (! empty($conf->global->DISPLAY_MARGIN_RATES))
-		print "<td class=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
-	if (! empty($conf->global->DISPLAY_MARK_RATES))
-		print "<td class=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
+	if (!empty($conf->global->DISPLAY_MARGIN_RATES))
+		print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
+	if (!empty($conf->global->DISPLAY_MARK_RATES))
+		print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
 	print "</tr>\n";
 
     print "</table>";
@@ -377,8 +377,8 @@ $(document).ready(function() {
 	});*/
 
 	$("#totalMargin").html("'.price($totalMargin, null, null, null, null, $rounding).'");
-	$("#marginRate").html("'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%").'");
-	$("#markRate").html("'.(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%").'");
+	$("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%").'");
+	$("#markRate").html("'.(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%").'");
 });
 </script>
 ';

+ 29 - 29
htdocs/modulebuilder/admin/setup.php

@@ -21,9 +21,9 @@
  *  \brief      Page setup for modulebuilder module
  */
 require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 
-global $conf,$langs,$user, $db;
+global $conf, $langs, $user, $db;
 $langs->loadLangs(array("admin", "other", "modulebuilder"));
 
 if (!$user->admin || empty($conf->modulebuilder->enabled))
@@ -35,16 +35,16 @@ $backtopage = GETPOST('backtopage', 'alpha');
 /*
  * Actions
  */
-if ($action=="update")
+if ($action == "update")
 {
-    $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity);
-    $res2=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity);
-    $res3=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity);
-    $res4=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity);
-    $res5=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity);
-    $res6=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity);
-    $res7=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity);
-    $res8=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity);
+    $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity);
+    $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity);
+    $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity);
+    $res4 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity);
+    $res5 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity);
+    $res6 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity);
+    $res7 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity);
+    $res8 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity);
     if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0) {
         setEventMessages('ErrorFailedToSaveDate', null, 'errors');
         $db->rollback();
@@ -63,7 +63,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) {
         $values = implode(',', $values);
 
     if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
-        header("Location: " . $_SERVER["PHP_SELF"]);
+        header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
     } else {
         dol_print_error($db);
@@ -73,7 +73,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) {
 if (preg_match('/del_(.*)/', $action, $reg)) {
     $code = $reg[1];
     if (dolibarr_del_const($db, $code, 0) > 0) {
-        Header("Location: " . $_SERVER["PHP_SELF"]);
+        Header("Location: ".$_SERVER["PHP_SELF"]);
         exit;
     } else {
         dol_print_error($db);
@@ -89,27 +89,27 @@ $form = new Form($db);
 
 llxHeader('', $langs->trans("ModulebuilderSetup"));
 
-$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php') . '">' . $langs->trans("BackToModuleList") . '</a>';
+$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="update">';
 
-print load_fiche_titre($langs->trans("ModuleSetup") . ' ' . $langs->trans('Modulebuilder'), $linkback);
+print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('Modulebuilder'), $linkback);
 
 if (GETPOST('withtab', 'alpha')) {
     dol_fiche_head($head, 'modulebuilder', '', -1);
 }
 
-print '<span class="opacitymedium">' . $langs->trans("ModuleBuilderDesc") . "</span><br>\n";
+print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc")."</span><br>\n";
 
 print '<br>';
 
 print '<table class="noborder centpercent">';
 
 print '<tr class="liste_titre">';
-print '<td style="width: 30%">' . $langs->trans("Key") . '</td>';
-print '<td>' . $langs->trans("Value") . '</td>';
+print '<td style="width: 30%">'.$langs->trans("Key").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
 print "</tr>\n";
 
 
@@ -118,49 +118,49 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
 	// What is use cas of this 2 options ?
 
 	print '<tr class="oddeven">';
-	print '<td>' . $langs->trans("UseAboutPage") . '</td>';
+	print '<td>'.$langs->trans("UseAboutPage").'</td>';
 	print '<td class="center">';
 	if ($conf->use_javascript_ajax) {
 	    print ajax_constantonoff('MODULEBUILDER_USE_ABOUT');
 	} else {
 	    if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) {
-	        print '<a href="' . $_SERVER['PHP_SELF'] . '?action=set_MODULEBUILDER_USE_ABOUT">' . img_picto($langs->trans("Disabled"), 'off') . '</a>';
+	        print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MODULEBUILDER_USE_ABOUT">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
 	    } else {
-	        print '<a href="' . $_SERVER['PHP_SELF'] . '?action=del_MODULEBUILDER_USE_ABOUT">' . img_picto($langs->trans("Enabled"), 'on') . '</a>';
+	        print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MODULEBUILDER_USE_ABOUT">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
 	    }
 	}
 	print '</td></tr>';
 
     print '<tr class="oddeven">';
-    print '<td class="tdtop">' . $langs->trans("UseSpecificEditorName") . '</td>';
+    print '<td class="tdtop">'.$langs->trans("UseSpecificEditorName").'</td>';
     print '<td>';
     print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_NAME" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME.'">';
     print '</td>';
     print '</tr>';
 
     print '<tr class="oddeven">';
-    print '<td class="tdtop">' . $langs->trans("UseSpecificEditorURL") . '</td>';
+    print '<td class="tdtop">'.$langs->trans("UseSpecificEditorURL").'</td>';
     print '<td>';
     print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_URL" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL.'">';
     print '</td>';
     print '</tr>';
 
     print '<tr class="oddeven">';
-    print '<td class="tdtop">' . $langs->trans("UseSpecificFamily") . '</td>';
+    print '<td class="tdtop">'.$langs->trans("UseSpecificFamily").'</td>';
     print '<td>';
     print '<input type="text" name="MODULEBUILDER_SPECIFIC_FAMILY" value="'.$conf->global->MODULEBUILDER_SPECIFIC_FAMILY.'">';
     print '</td>';
     print '</tr>';
 
     print '<tr class="oddeven">';
-    print '<td class="tdtop">' . $langs->trans("UseSpecificAuthor") . '</td>';
+    print '<td class="tdtop">'.$langs->trans("UseSpecificAuthor").'</td>';
     print '<td>';
     print '<input type="text" name="MODULEBUILDER_SPECIFIC_AUTHOR" value="'.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR.'">';
     print '</td>';
     print '</tr>';
 
     print '<tr class="oddeven">';
-    print '<td class="tdtop">' . $langs->trans("UseSpecificVersion") . '</td>';
+    print '<td class="tdtop">'.$langs->trans("UseSpecificVersion").'</td>';
     print '<td>';
     print '<input type="text" name="MODULEBUILDER_SPECIFIC_VERSION" value="'.$conf->global->MODULEBUILDER_SPECIFIC_VERSION.'">';
     print '</td>';
@@ -168,14 +168,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
 }
 
 print '<tr class="oddeven">';
-print '<td class="tdtop">' . $langs->trans("UseSpecificReadme") . '</td>';
+print '<td class="tdtop">'.$langs->trans("UseSpecificReadme").'</td>';
 print '<td>';
 print '<textarea class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.$conf->global->MODULEBUILDER_SPECIFIC_README.'</textarea>';
 print '</td>';
 print '</tr>';
 
 print '<tr class="oddeven">';
-print '<td class="tdtop">' . $langs->trans("AsciiToHtmlConverter") . '</td>';
+print '<td class="tdtop">'.$langs->trans("AsciiToHtmlConverter").'</td>';
 print '<td>';
 print '<input type="text" name="MODULEBUILDER_ASCIIDOCTOR" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTOR.'">';
 print ' '.$langs->trans("Example").': asciidoc, asciidoctor';
@@ -183,7 +183,7 @@ print '</td>';
 print '</tr>';
 
 print '<tr class="oddeven">';
-print '<td class="tdtop">' . $langs->trans("AsciiToPdfConverter") . '</td>';
+print '<td class="tdtop">'.$langs->trans("AsciiToPdfConverter").'</td>';
 print '<td>';
 print '<input type="text" name="MODULEBUILDER_ASCIIDOCTORPDF" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTORPDF.'">';
 print ' '.$langs->trans("Example").': asciidoctor-pdf';

+ 20 - 20
htdocs/modulebuilder/template/admin/setup.php

@@ -23,23 +23,23 @@
  */
 
 // Load Dolibarr environment
-$res=0;
+$res = 0;
 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
-while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
 // Try main.inc.php using relative path
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
 
 global $langs, $user;
 
 // Libraries
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
 require_once '../lib/mymodule.lib.php';
 //require_once "../class/myclass.class.php";
 
@@ -47,15 +47,15 @@ require_once '../lib/mymodule.lib.php';
 $langs->loadLangs(array("admin", "mymodule@mymodule"));
 
 // Access control
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
 // Parameters
 $action = GETPOST('action', 'alpha');
 $backtopage = GETPOST('backtopage', 'alpha');
 
-$arrayofparameters=array(
-	'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1),
-	'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1)
+$arrayofparameters = array(
+	'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
+	'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
 );
 
 
@@ -79,7 +79,7 @@ $page_name = "MyModuleSetup";
 llxHeader('', $langs->trans($page_name));
 
 // Subheader
-$linkback = '<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
 
 print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule');
 
@@ -100,12 +100,12 @@ if ($action == 'edit')
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-	foreach($arrayofparameters as $key => $val)
+	foreach ($arrayofparameters as $key => $val)
 	{
 		print '<tr class="oddeven"><td>';
 		$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
 		print $form->textwithpicto($langs->trans($key), $tooltiphelp);
-		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
+		print '</td><td><input name="'.$key.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>';
 	}
 	print '</table>';
 
@@ -118,17 +118,17 @@ if ($action == 'edit')
 }
 else
 {
-	if (! empty($arrayofparameters))
+	if (!empty($arrayofparameters))
 	{
 		print '<table class="noborder centpercent">';
 		print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
-		foreach($arrayofparameters as $key => $val)
+		foreach ($arrayofparameters as $key => $val)
 		{
 			print '<tr class="oddeven"><td>';
 			$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
 			print $form->textwithpicto($langs->trans($key), $tooltiphelp);
-			print '</td><td>' . $conf->global->$key . '</td></tr>';
+			print '</td><td>'.$conf->global->$key.'</td></tr>';
 		}
 
 		print '</table>';

+ 18 - 18
htdocs/opensurvey/wizard/create_survey.php

@@ -99,19 +99,19 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre"))
 		}
 	}
 
-	if (! $testdate) {
+	if (!$testdate) {
 		setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("ExpireDate")), null, 'errors');
 	}
 
 	if ($titre && $testdate)
 	{
-		if (! empty($creation_sondage_date))
+		if (!empty($creation_sondage_date))
 		{
 			header("Location: choix_date.php");
 			exit();
 		}
 
-		if (! empty($creation_sondage_autre))
+		if (!empty($creation_sondage_autre))
 		{
 			header("Location: choix_autre.php");
 			exit();
@@ -128,8 +128,8 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre"))
 
 $form = new Form($db);
 
-$arrayofjs=array();
-$arrayofcss=array('/opensurvey/css/style.css');
+$arrayofjs = array();
+$arrayofcss = array('/opensurvey/css/style.css');
 llxHeader('', $langs->trans("OpenSurvey"), '', "", 0, 0, $arrayofjs, $arrayofcss);
 
 print load_fiche_titre($langs->trans("CreatePoll").' (1 / 2)');
@@ -142,22 +142,22 @@ dol_fiche_head();
 // Affichage des différents champs textes a remplir
 print '<table class="border centpercent">'."\n";
 
-print '<tr><td class="titlefieldcreate fieldrequired">'. $langs->trans("PollTitle") .'</td><td><input type="text" name="titre" size="40" maxlength="80" value="'.$_SESSION["titre"].'"></td>'."\n";
-if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre')))
+print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("PollTitle").'</td><td><input type="text" name="titre" size="40" maxlength="80" value="'.$_SESSION["titre"].'"></td>'."\n";
+if (!$_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre')))
 {
 	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors');
 }
 
 print '</tr>'."\n";
-print '<tr><td>'. $langs->trans("Description") .'</td><td>';
-$doleditor=new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%');
+print '<tr><td>'.$langs->trans("Description").'</td><td>';
+$doleditor = new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%');
 $doleditor->Create(0, '');
 print '</td>'."\n";
 print '</tr>'."\n";
 
-print '<tr><td class="fieldrequired">'.  $langs->trans("ExpireDate")  .'</td><td>';
+print '<tr><td class="fieldrequired">'.$langs->trans("ExpireDate").'</td><td>';
 
-print $form->selectDate($champdatefin?$champdatefin:-1, 'champdatefin', '', '', '', "add", 1, 0);
+print $form->selectDate($champdatefin ? $champdatefin : -1, 'champdatefin', '', '', '', "add", 1, 0);
 
 print '</tr>'."\n";
 print '</table>'."\n";
@@ -173,16 +173,16 @@ print '<br>'."\n";
 
 // Check or not
 
-if ($_SESSION["mailsonde"]) $cochemail="checked";
+if ($_SESSION["mailsonde"]) $cochemail = "checked";
 
-print '<input type="checkbox" name="mailsonde" '.$cochemail.'> '. $langs->trans("ToReceiveEMailForEachVote") .'<br>'."\n";
+print '<input type="checkbox" name="mailsonde" '.$cochemail.'> '.$langs->trans("ToReceiveEMailForEachVote").'<br>'."\n";
 
 if ($_SESSION['allow_comments']) $allow_comments = 'checked';
-if (isset($_POST['allow_comments'])) $allow_comments=GETPOST('allow_comments')?'checked':'';
+if (isset($_POST['allow_comments'])) $allow_comments = GETPOST('allow_comments') ? 'checked' : '';
 print '<input type="checkbox" name="allow_comments" '.$allow_comments.'"> '.$langs->trans('CanComment').'<br>'."\n";
 
 if ($_SESSION['allow_spy']) $allow_spy = 'checked';
-if (isset($_POST['allow_spy'])) $allow_spy=GETPOST('allow_spy')?'checked':'';
+if (isset($_POST['allow_spy'])) $allow_spy = GETPOST('allow_spy') ? 'checked' : '';
 print '<input type="checkbox" name="allow_spy" '.$allow_spy.'> '.$langs->trans('CanSeeOthersVote').'<br>'."\n";
 
 if (GETPOST('choix_sondage'))
@@ -190,15 +190,15 @@ if (GETPOST('choix_sondage'))
 	if (GETPOST('choix_sondage') == 'date') print '<input type="hidden" name="creation_sondage_date" value="date">';
 	else print '<input type="hidden" name="creation_sondage_autre" value="autre">';
 	print '<input type="hidden" name="choix_sondage" value="'.GETPOST('choix_sondage').'">';
-	print '<br><input type="submit" class="button" name="submit" value="'.$langs->trans("CreatePoll").' ('.(GETPOST('choix_sondage') == 'date'?$langs->trans("TypeDate"):$langs->trans("TypeClassic")).')">';
+	print '<br><input type="submit" class="button" name="submit" value="'.$langs->trans("CreatePoll").' ('.(GETPOST('choix_sondage') == 'date' ? $langs->trans("TypeDate") : $langs->trans("TypeClassic")).')">';
 }
 else
 {
 	// Show image to selecte between date survey or other survey
 	print '<br><table>'."\n";
-	print '<tr><td>'. $langs->trans("CreateSurveyDate") .'</td><td></td> '."\n";
+	print '<tr><td>'.$langs->trans("CreateSurveyDate").'</td><td></td> '."\n";
 	print '<td><input type="image" name="creation_sondage_date" value="'.$langs->trans('CreateSurveyDate').'" src="../img/calendar-32.png"></td></tr>'."\n";
-	print '<tr><td>'. $langs->trans("CreateSurveyStandard") .'</td><td></td> '."\n";
+	print '<tr><td>'.$langs->trans("CreateSurveyStandard").'</td><td></td> '."\n";
 	print '<td><input type="image" name="creation_sondage_autre" value="'.$langs->trans('CreateSurveyStandard').'" src="../img/chart-32.png"></td></tr>'."\n";
 	print '</table>'."\n";
 }

+ 135 - 135
htdocs/projet/activity/index.php

@@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 
 $search_project_user = GETPOST('search_project_user', 'int');
-$mine = GETPOST('mode', 'aZ09')=='mine' ? 1 : 0;
+$mine = GETPOST('mode', 'aZ09') == 'mine' ? 1 : 0;
 if ($search_project_user == $user->id) $mine = 1;
 
 // Security check
-$socid=0;
-if ($user->socid > 0) $socid=$user->socid;
+$socid = 0;
+if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'projet', $projectid);
 if (!$user->rights->projet->lire) accessforbidden();
 
@@ -54,36 +54,36 @@ $langs->load("projects");
  */
 
 $now = dol_now();
-$tmp=dol_getdate($now);
-$day=$tmp['mday'];
-$month=$tmp['mon'];
-$year=$tmp['year'];
-
-$projectstatic=new Project($db);
-$taskstatic=new Task($db);
-$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);  // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project
-$taskstatic=new Task($db);
-$tasktmp=new Task($db);
-
-$title=$langs->trans("Activities");
+$tmp = dol_getdate($now);
+$day = $tmp['mday'];
+$month = $tmp['mon'];
+$year = $tmp['year'];
+
+$projectstatic = new Project($db);
+$taskstatic = new Task($db);
+$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project
+$taskstatic = new Task($db);
+$tasktmp = new Task($db);
+
+$title = $langs->trans("Activities");
 //if ($mine) $title=$langs->trans("MyActivities");
 
 llxHeader("", $title);
 
 
 // Title for combo list see all projects
-$titleall=$langs->trans("AllAllowedProjects");
-if (! empty($user->rights->projet->all->lire) && ! $socid) $titleall=$langs->trans("AllProjects");
-else $titleall=$langs->trans("AllAllowedProjects").'<br><br>';
+$titleall = $langs->trans("AllAllowedProjects");
+if (!empty($user->rights->projet->all->lire) && !$socid) $titleall = $langs->trans("AllProjects");
+else $titleall = $langs->trans("AllAllowedProjects").'<br><br>';
 
 
-$morehtml='';
-$morehtml.='<form name="projectform">';
-$morehtml.='<SELECT name="mode">';
-$morehtml.='<option name="all" value="all"'.($mine?'':' selected').'>'.$titleall.'</option>';
-$morehtml.='<option name="mine" value="'.$user->id.'"'.(($search_project_user == $user->id)?' selected':'').'>'.$langs->trans("ProjectsImContactFor").'</option>';
-$morehtml.='</SELECT>';
-$morehtml.='<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">';
+$morehtml = '';
+$morehtml .= '<form name="projectform">';
+$morehtml .= '<SELECT name="mode">';
+$morehtml .= '<option name="all" value="all"'.($mine ? '' : ' selected').'>'.$titleall.'</option>';
+$morehtml .= '<option name="mine" value="'.$user->id.'"'.(($search_project_user == $user->id) ? ' selected' : '').'>'.$langs->trans("ProjectsImContactFor").'</option>';
+$morehtml .= '</SELECT>';
+$morehtml .= '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">';
 
 print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'project', 0, $morehtml);
 //print load_fiche_titre($title, '', 'project');
@@ -91,7 +91,7 @@ print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'proje
 if ($mine) print $langs->trans("MyTasksDesc").'<br><br>';
 else
 {
-	if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksDesc").'<br><br>';
+	if ($user->rights->projet->all->lire && !$socid) print $langs->trans("TasksDesc").'<br><br>';
 	else print $langs->trans("TasksPublicDesc").'<br><br>';
 }
 
@@ -99,12 +99,12 @@ else
 print '<div class="fichecenter"><div class="fichethirdleft">';
 
 
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
 {
     // Search project
-    if (! empty($conf->projet->enabled) && $user->rights->projet->lire)
+    if (!empty($conf->projet->enabled) && $user->rights->projet->lire)
     {
-    	$listofsearchfields['search_task']=array('text'=>'Task');
+    	$listofsearchfields['search_task'] = array('text'=>'Task');
     }
 
     if (count($listofsearchfields))
@@ -113,8 +113,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
     	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
         print '<div class="div-table-responsive-no-min">';
     	print '<table class="noborder nohover centpercent">';
-    	$i=0;
-    	foreach($listofsearchfields as $key => $value)
+    	$i = 0;
+    	foreach ($listofsearchfields as $key => $value)
     	{
     		if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
     		print '<tr '.$bc[false].'>';
@@ -140,30 +140,30 @@ print '<td width="50%" class="right">'.$langs->trans("Time").'</td>';
 print "</tr>\n";
 
 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
-$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
-$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
-$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
-$sql.= " WHERE t.fk_projet = p.rowid";
-$sql.= " AND p.entity = ".$conf->entity;
-$sql.= " AND tt.fk_task = t.rowid";
-$sql.= " AND tt.fk_user = ".$user->id;
-$sql.= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
-$sql.= " AND p.rowid in (".$projectsListId.")";
-$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public";
+$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
+$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
+$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+$sql .= " WHERE t.fk_projet = p.rowid";
+$sql .= " AND p.entity = ".$conf->entity;
+$sql .= " AND tt.fk_task = t.rowid";
+$sql .= " AND tt.fk_user = ".$user->id;
+$sql .= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
+$sql .= " AND p.rowid in (".$projectsListId.")";
+$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
 
 $resql = $db->query($sql);
-if ( $resql )
+if ($resql)
 {
-	$total=0;
+	$total = 0;
 
 	while ($row = $db->fetch_object($resql))
 	{
 		print '<tr class="oddeven">';
 		print '<td>';
-		$projectstatic->id=$row->rowid;
-		$projectstatic->ref=$row->ref;
-		$projectstatic->title=$row->title;
-		$projectstatic->public=$row->public;
+		$projectstatic->id = $row->rowid;
+		$projectstatic->ref = $row->ref;
+		$projectstatic->title = $row->title;
+		$projectstatic->public = $row->public;
 		print $projectstatic->getNomUrl(1, '', 1);
 		print '</td>';
 		print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
@@ -197,30 +197,30 @@ print '<td class="right">'.$langs->trans("Time").'</td>';
 print "</tr>\n";
 
 $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
-$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
-$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
-$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
-$sql.= " WHERE t.fk_projet = p.rowid";
-$sql.= " AND p.entity = ".$conf->entity;
-$sql.= " AND tt.fk_task = t.rowid";
-$sql.= " AND tt.fk_user = ".$user->id;
-$sql.= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'";
-$sql.= " AND p.rowid in (".$projectsListId.")";
-$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public";
+$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
+$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
+$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+$sql .= " WHERE t.fk_projet = p.rowid";
+$sql .= " AND p.entity = ".$conf->entity;
+$sql .= " AND tt.fk_task = t.rowid";
+$sql .= " AND tt.fk_user = ".$user->id;
+$sql .= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'";
+$sql .= " AND p.rowid in (".$projectsListId.")";
+$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
 
 $resql = $db->query($sql);
-if ( $resql )
+if ($resql)
 {
-	$total=0;
+	$total = 0;
 
 	while ($row = $db->fetch_object($resql))
 	{
 		print '<tr class="oddeven">';
 		print '<td>';
-		$projectstatic->id=$row->rowid;
-		$projectstatic->ref=$row->ref;
-		$projectstatic->title=$row->title;
-		$projectstatic->public=$row->public;
+		$projectstatic->id = $row->rowid;
+		$projectstatic->ref = $row->ref;
+		$projectstatic->title = $row->title;
+		$projectstatic->public = $row->public;
 		print $projectstatic->getNomUrl(1, '', 1);
 		print '</td>';
 		print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
@@ -304,7 +304,7 @@ if ($db->type != 'pgsql')
 */
 
 /* Affichage de la liste des projets du mois */
-if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
+if (!empty($conf->global->PROJECT_TASK_TIME_MONTH))
 {
     print '<div class="div-table-responsive-no-min">';
     print '<table class="noborder centpercent">';
@@ -314,27 +314,27 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
     print "</tr>\n";
 
     $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
-    $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
-    $sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
-    $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
-    $sql.= " WHERE t.fk_projet = p.rowid";
-    $sql.= " AND p.entity = ".$conf->entity;
-    $sql.= " AND tt.fk_task = t.rowid";
-    $sql.= " AND tt.fk_user = ".$user->id;
-	$sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
-    $sql.= " AND p.rowid in (".$projectsListId.")";
-    $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public";
+    $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
+    $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
+    $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+    $sql .= " WHERE t.fk_projet = p.rowid";
+    $sql .= " AND p.entity = ".$conf->entity;
+    $sql .= " AND tt.fk_task = t.rowid";
+    $sql .= " AND tt.fk_user = ".$user->id;
+	$sql .= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
+    $sql .= " AND p.rowid in (".$projectsListId.")";
+    $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
 
     $resql = $db->query($sql);
-    if ( $resql )
+    if ($resql)
     {
     	while ($row = $db->fetch_object($resql))
     	{
     		print '<tr class="oddeven">';
     		print '<td>';
-    		$projectstatic->id=$row->rowid;
-    		$projectstatic->ref=$row->ref;
-    		$projectstatic->title=$row->title;
+    		$projectstatic->id = $row->rowid;
+    		$projectstatic->ref = $row->ref;
+    		$projectstatic->title = $row->title;
     		print $projectstatic->getNomUrl(1, '', 1);
     		print '</td>';
     		print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
@@ -355,7 +355,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
 }
 
 /* Affichage de la liste des projets de l'annee */
-if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
+if (!empty($conf->global->PROJECT_TASK_TIME_YEAR))
 {
     print '<div class="div-table-responsive-no-min">';
 	print '<br><table class="noborder centpercent">';
@@ -365,28 +365,28 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
 	print "</tr>\n";
 
 	$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
-	$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
-	$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
-	$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
-	$sql.= " WHERE t.fk_projet = p.rowid";
-	$sql.= " AND p.entity = ".$conf->entity;
-	$sql.= " AND tt.fk_task = t.rowid";
-	$sql.= " AND tt.fk_user = ".$user->id;
-	$sql.= " AND YEAR(task_date) = '".strftime("%Y", $now)."'";
-	$sql.= " AND p.rowid in (".$projectsListId.")";
-	$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public";
+	$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
+	$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
+	$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+	$sql .= " WHERE t.fk_projet = p.rowid";
+	$sql .= " AND p.entity = ".$conf->entity;
+	$sql .= " AND tt.fk_task = t.rowid";
+	$sql .= " AND tt.fk_user = ".$user->id;
+	$sql .= " AND YEAR(task_date) = '".strftime("%Y", $now)."'";
+	$sql .= " AND p.rowid in (".$projectsListId.")";
+	$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
 
 	$resql = $db->query($sql);
-	if ( $resql )
+	if ($resql)
 	{
 		while ($row = $db->fetch_object($resql))
 		{
 			print '<tr class="oddeven">';
 			print '<td>';
-			$projectstatic->id=$row->rowid;
-			$projectstatic->ref=$row->ref;
-			$projectstatic->title=$row->title;
-			$projectstatic->public=$row->public;
+			$projectstatic->id = $row->rowid;
+			$projectstatic->ref = $row->ref;
+			$projectstatic->title = $row->title;
+			$projectstatic->public = $row->public;
 			print $projectstatic->getNomUrl(1, '', 1);
 			print '</td>';
 			print '<td class="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
@@ -406,72 +406,72 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
     print '</div>';
 }
 
-if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA))
+if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA))
 {
     // Get id of types of contacts for projects (This list never contains a lot of elements)
-    $listofprojectcontacttype=array();
+    $listofprojectcontacttype = array();
     $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
-    $sql.= " WHERE ctc.element = '" . $projectstatic->element . "'";
-    $sql.= " AND ctc.source = 'internal'";
+    $sql .= " WHERE ctc.element = '".$projectstatic->element."'";
+    $sql .= " AND ctc.source = 'internal'";
     $resql = $db->query($sql);
     if ($resql)
     {
-        while($obj = $db->fetch_object($resql))
+        while ($obj = $db->fetch_object($resql))
         {
-            $listofprojectcontacttype[$obj->rowid]=$obj->code;
+            $listofprojectcontacttype[$obj->rowid] = $obj->code;
         }
     }
     else dol_print_error($db);
-    if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0';    // To avoid sql syntax error if not found
+    if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
     // Get id of types of contacts for tasks (This list never contains a lot of elements)
-    $listoftaskcontacttype=array();
+    $listoftaskcontacttype = array();
     $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
-    $sql.= " WHERE ctc.element = '" . $taskstatic->element . "'";
-    $sql.= " AND ctc.source = 'internal'";
+    $sql .= " WHERE ctc.element = '".$taskstatic->element."'";
+    $sql .= " AND ctc.source = 'internal'";
     $resql = $db->query($sql);
     if ($resql)
     {
-        while($obj = $db->fetch_object($resql))
+        while ($obj = $db->fetch_object($resql))
         {
-            $listoftaskcontacttype[$obj->rowid]=$obj->code;
+            $listoftaskcontacttype[$obj->rowid] = $obj->code;
         }
     }
     else dol_print_error($db);
-    if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0';         // To avoid sql syntax error if not found
+    if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found
 
 
 	// Tasks for all resources of all opened projects and time spent for each task/resource
 	// This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
     // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list
 
-	$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
+	$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
 
 	$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,";
-	$sql.= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
-	$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
+	$sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
+	$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
 	if ($mine)
 	{
-	    $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ect";
+	    $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect";
 	}
-	$sql.= " WHERE p.entity IN (".getEntity('project').")";
-	if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";  // project i have permission on
+	$sql .= " WHERE p.entity IN (".getEntity('project').")";
+	if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on
 	if ($mine)     // this may duplicate record if we are contact twice
 	{
-        $sql.= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id;
+        $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id;
 	}
-	if ($socid)	$sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
-	$sql.= " AND p.fk_statut=1";
-	$sql.= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
-	$sql.= " ORDER BY t.dateo desc, t.rowid desc, t.datee";
-	$sql.= $db->plimit($max+1);	// We want more to know if we have more than limit
+	if ($socid)	$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
+	$sql .= " AND p.fk_statut=1";
+	$sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
+	$sql .= " ORDER BY t.dateo desc, t.rowid desc, t.datee";
+	$sql .= $db->plimit($max + 1); // We want more to know if we have more than limit
 
 	dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG);
 	$resql = $db->query($sql);
-	if ( $resql )
+	if ($resql)
 	{
 		$num = $db->num_rows($resql);
 		$i = 0;
@@ -483,7 +483,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
 		print '<tr class="liste_titre">';
 		//print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
 		print '<th>'.$langs->trans('OpenedProjects').'</th>';
-		if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '<th>'.$langs->trans('OpportunityStatus').'</th>';
+		if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '<th>'.$langs->trans('OpportunityStatus').'</th>';
 		print '<th>'.$langs->trans('Task').'</th>';
 		print '<th class="center">'.$langs->trans('DateStart').'</th>';
 		print '<th class="center">'.$langs->trans('DateEnd').'</th>';
@@ -511,11 +511,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
 			$taskstatic->dateo = $db->jdate($obj->dateo);
 			$taskstatic->datee = $db->jdate($obj->datee);
 
-			$username='';
+			$username = '';
 			if ($obj->userid && $userstatic->id != $obj->userid)	// We have a user and it is not last loaded user
 			{
-				$result=$userstatic->fetch($obj->userid);
-				if (! $result) $userstatic->id=0;
+				$result = $userstatic->fetch($obj->userid);
+				if (!$result) $userstatic->id = 0;
 			}
 			if ($userstatic->id) $username = $userstatic->getNomUrl(0, 0);
 
@@ -524,7 +524,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
 			print '<td>';
 			print $projectstatic->getNomUrl(1, '', 0, '', '<br>');
 			print '</td>';
-			if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+			if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 			{
 				print '<td>';
 				$code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code');
@@ -532,7 +532,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
 				print '</td>';
 			}
 			print '<td>';
-			if (! empty($obj->taskid))
+			if (!empty($obj->taskid))
 			{
 				$tasktmp->id = $obj->taskid;
 				$tasktmp->ref = $obj->ref;
@@ -552,18 +552,18 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
 			print convertSecondToTime($obj->timespent, 'allhourmin');
 			print '</a></td>';
 			print '<td class="right">';
-			if (! empty($obj->taskid))
+			if (!empty($obj->taskid))
 			{
 				if (empty($obj->planned_workload) > 0) {
 					$percentcompletion = $langs->trans("WorkloadNotDefined");
 				} else {
-					$percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%';
+					$percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).'%';
 				}
 			}
 			print $percentcompletion;
 			print '</td>';
 			print '<td class="right">';
-			print ($obj->taskid>0)?$obj->progress.'%':'';
+			print ($obj->taskid > 0) ? $obj->progress.'%' : '';
 			print '</td>';
 			print "</tr>\n";
 
@@ -572,8 +572,8 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
 
 		if ($num > $max)
 		{
-			$colspan=6;
-			if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++;
+			$colspan = 6;
+			if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++;
 			print '<tr><td colspan="'.$colspan.'">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>';
 		}
 

File diff suppressed because it is too large
+ 203 - 203
htdocs/projet/card.php


+ 28 - 28
htdocs/projet/comment.php

@@ -37,23 +37,23 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array('projects', 'companies'));
 
-$id=GETPOST('id', 'int');
-$idcomment=GETPOST('idcomment', 'int');
-$ref=GETPOST("ref", 'alpha', 1);          // task ref
-$objectref=GETPOST("taskref", 'alpha');    // task ref
-$action=GETPOST('action', 'alpha');
-$confirm=GETPOST('confirm', 'alpha');
-$withproject=GETPOST('withproject', 'int');
-$project_ref=GETPOST('project_ref', 'alpha');
-$planned_workload=((GETPOST('planned_workloadhour', 'int')!='' || GETPOST('planned_workloadmin', 'int')!='') ? (GETPOST('planned_workloadhour', 'int')>0?GETPOST('planned_workloadhour', 'int')*3600:0) + (GETPOST('planned_workloadmin', 'int')>0?GETPOST('planned_workloadmin', 'int')*60:0) : '');
+$id = GETPOST('id', 'int');
+$idcomment = GETPOST('idcomment', 'int');
+$ref = GETPOST("ref", 'alpha', 1); // task ref
+$objectref = GETPOST("taskref", 'alpha'); // task ref
+$action = GETPOST('action', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
+$withproject = GETPOST('withproject', 'int');
+$project_ref = GETPOST('project_ref', 'alpha');
+$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : '');
 
 // Security check
-$socid=0;
+$socid = 0;
 //if ($user->socid > 0) $socid = $user->socid;    // For external user, no check is done on company because readability is managed by public status of project and assignement.
-if (! $user->rights->projet->lire) accessforbidden();
+if (!$user->rights->projet->lire) accessforbidden();
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('projectcard','globalcard'));
+$hookmanager->initHooks(array('projectcard', 'globalcard'));
 
 $extrafields = new ExtraFields($db);
 $object = new Project($db);
@@ -62,18 +62,18 @@ $object = new Project($db);
 $extrafields->fetch_name_optionals_label($object->table_element);
 
 // Load object
-if ($id > 0 || ! empty($ref))
+if ($id > 0 || !empty($ref))
 {
-	$ret = $object->fetch($id, $ref);	// If we create project, ref may be defined into POST but record does not yet exists into database
+	$ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
 	if ($ret > 0) {
 		$object->fetch_thirdparty();
-		if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
-		$id=$object->id;
+		if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
+		$id = $object->id;
 	}
 }
 
 // include comment actions
-include DOL_DOCUMENT_ROOT . '/core/actions_comments.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
 
 /*
  * View
@@ -95,21 +95,21 @@ $param = ($mode == 'mine' ? '&mode=mine' : '');
 
 // Project card
 
-$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
 $morehtmlref = '<div class="refidno">';
 // Title
 $morehtmlref .= $object->title;
 // Thirdparty
 if ($object->thirdparty->id > 0) {
-	$morehtmlref .= '<br>' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
+	$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
 }
 $morehtmlref .= '</div>';
 
 // Define a complementary filter for search of next/prev ref.
-if (! $user->rights->projet->all->lire) {
+if (!$user->rights->projet->all->lire) {
 	$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
-	$object->next_prev_filter = " rowid in (" . (count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")";
+	$object->next_prev_filter = " rowid in (".(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
 }
 
 dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -121,21 +121,21 @@ print '<div class="underbanner clearboth"></div>';
 print '<table class="border centpercent">';
 
 // Visibility
-print '<tr><td class="titlefield">' . $langs->trans("Visibility") . '</td><td>';
+print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
 if ($object->public) print $langs->trans('SharedProject');
 else
 	print $langs->trans('PrivateProject');
 print '</td></tr>';
 
 // Date start - end
-print '<tr><td>' . $langs->trans("DateStart") . ' - ' . $langs->trans("DateEnd") . '</td><td>';
+print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
 print dol_print_date($object->date_start, 'day');
 $end = dol_print_date($object->date_end, 'day');
-if ($end) print ' - ' . $end;
+if ($end) print ' - '.$end;
 print '</td></tr>';
 
 // Budget
-print '<tr><td>' . $langs->trans("Budget") . '</td><td>';
+print '<tr><td>'.$langs->trans("Budget").'</td><td>';
 if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
 print '</td></tr>';
 
@@ -153,13 +153,13 @@ print '<div class="underbanner clearboth"></div>';
 print '<table class="border centpercent">';
 
 // Description
-print '<td class="titlefield tdtop">' . $langs->trans("Description") . '</td><td>';
+print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
 print nl2br($object->description);
 print '</td></tr>';
 
 // Categories
 if ($conf->categorie->enabled) {
-	print '<tr><td class="valignmiddle">' . $langs->trans("Categories") . '</td><td>';
+	print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
 	print $form->showCategories($object->id, 'project', 1);
 	print "</td></tr>";
 }
@@ -182,7 +182,7 @@ dol_fiche_end();
 print '<br>';
 
 // Include comment tpl view
-include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_comment.tpl.php';
+include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
 
 // End of page
 llxFooter();

+ 29 - 29
htdocs/projet/graph_opportunities.inc.php

@@ -1,14 +1,14 @@
 <?php
-if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 {
 	$sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount";
-	$sql.= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."c_lead_status as cls";
-	$sql.= " WHERE p.entity IN (".getEntity('project').")";
-	$sql.= " AND p.fk_opp_status = cls.rowid";
-	$sql.= " AND p.fk_statut = 1";     // Opend projects only
-	if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
-	if ($socid)	$sql.= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
-	$sql.= " GROUP BY p.fk_opp_status, cls.code";
+	$sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."c_lead_status as cls";
+	$sql .= " WHERE p.entity IN (".getEntity('project').")";
+	$sql .= " AND p.fk_opp_status = cls.rowid";
+	$sql .= " AND p.fk_statut = 1"; // Opend projects only
+	if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")";
+	if ($socid)	$sql .= "  AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
+	$sql .= " GROUP BY p.fk_opp_status, cls.code";
 	$resql = $db->query($sql);
 
 	if ($resql)
@@ -16,13 +16,13 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 	    $num = $db->num_rows($resql);
 	    $i = 0;
 
-	    $totalnb=0;
-	    $totaloppnb=0;
-	    $totalamount=0;
-	    $ponderated_opp_amount=0;
-	    $valsnb=array();
-	    $valsamount=array();
-	    $dataseries=array();
+	    $totalnb = 0;
+	    $totaloppnb = 0;
+	    $totalamount = 0;
+	    $ponderated_opp_amount = 0;
+	    $valsnb = array();
+	    $valsamount = array();
+	    $dataseries = array();
 	    // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
 	    while ($i < $num)
 	    {
@@ -31,17 +31,17 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 	        {
 	            //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
 	            {
-	                $valsnb[$obj->opp_status]=$obj->nb;
-	                $valsamount[$obj->opp_status]=$obj->opp_amount;
-	                $totalnb+=$obj->nb;
-	                if ($obj->opp_status) $totaloppnb+=$obj->nb;
-				if (! in_array($obj->code, array('WON', 'LOST')))
+	                $valsnb[$obj->opp_status] = $obj->nb;
+	                $valsamount[$obj->opp_status] = $obj->opp_amount;
+	                $totalnb += $obj->nb;
+	                if ($obj->opp_status) $totaloppnb += $obj->nb;
+				if (!in_array($obj->code, array('WON', 'LOST')))
 	                {
-					$totalamount+=$obj->opp_amount;
-					$ponderated_opp_amount+=$obj->ponderated_opp_amount;
+					$totalamount += $obj->opp_amount;
+					$ponderated_opp_amount += $obj->ponderated_opp_amount;
 				}
 	            }
-	            $total+=$row[0];
+	            $total += $row[0];
 	        }
 	        $i++;
 	    }
@@ -52,24 +52,24 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 		print '<div class="div-table-responsive-no-min">';
 	    print '<table class="noborder nohover centpercent">';
 	    print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("OpportunitiesStatusForOpenedProjects").'</th></tr>'."\n";
-	    $listofstatus=array_keys($listofoppstatus);
+	    $listofstatus = array_keys($listofoppstatus);
 	    foreach ($listofstatus as $status)
 	    {
 	    	$labelStatus = '';
 
 			$code = dol_getIdFromCode($db, $status, 'c_lead_status', 'rowid', 'code');
 	        if ($code) $labelStatus = $langs->trans("OppStatus".$code);
-	        if (empty($labelStatus)) $labelStatus=$listofopplabel[$status];
+	        if (empty($labelStatus)) $labelStatus = $listofopplabel[$status];
 
 	        //$labelStatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')';
 	        //$labelStatus .= ' - '.price2num($listofoppstatus[$status]).'%';
 
-	        $dataseries[]=array($labelStatus, (isset($valsamount[$status])?(float) $valsamount[$status]:0));
-	        if (! $conf->use_javascript_ajax)
+	        $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0));
+	        if (!$conf->use_javascript_ajax)
 	        {
 	            print '<tr class="oddeven">';
 	            print '<td>'.$labelStatus.'</td>';
-	            print '<td class="right"><a href="list.php?statut='.$status.'">'.price((isset($valsamount[$status])?(float) $valsamount[$status]:0), 0, '', 1, -1, -1, $conf->currency).'</a></td>';
+	            print '<td class="right"><a href="list.php?statut='.$status.'">'.price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency).'</a></td>';
 	            print "</tr>\n";
 	        }
 	    }
@@ -86,7 +86,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 	        $dolgraph->setWidth('100%');
 	        $dolgraph->SetHeight(180);
 	        $dolgraph->draw('idgraphstatus');
-	        print $dolgraph->show($totaloppnb?0:1);
+	        print $dolgraph->show($totaloppnb ? 0 : 1);
 
 	        print '</td></tr>';
 	    }

+ 83 - 83
htdocs/projet/stats/index.php

@@ -28,26 +28,26 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/projet/class/projectstats.class.php';
 
 // Security check
-if (! $user->rights->projet->lire)
+if (!$user->rights->projet->lire)
 	accessforbidden();
 
 
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
 
-$userid=GETPOST('userid', 'int');
-$socid=GETPOST('socid', 'int');
+$userid = GETPOST('userid', 'int');
+$socid = GETPOST('socid', 'int');
 // Security check
 if ($user->socid > 0)
 {
 	$action = '';
 	$socid = $user->socid;
 }
-$nowyear=strftime("%Y", dol_now());
-$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
+$nowyear = strftime("%Y", dol_now());
+$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
 //$startyear=$year-2;
-$startyear=$year-1;
-$endyear=$year;
+$startyear = $year - 1;
+$endyear = $year;
 
 // Load translation files required by the page
 $langs->loadLangs(array('companies', 'projects'));
@@ -57,59 +57,59 @@ $langs->loadLangs(array('companies', 'projects'));
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
-$includeuserlist=array();
+$includeuserlist = array();
 
 
 llxHeader('', $langs->trans('Projects'));
 
-$title=$langs->trans("ProjectsStatistics");
-$dir=$conf->projet->dir_output.'/temp';
+$title = $langs->trans("ProjectsStatistics");
+$dir = $conf->projet->dir_output.'/temp';
 
 print load_fiche_titre($title, '', 'project');
 
 dol_mkdir($dir);
 
 
-$stats_project= new ProjectStats($db);
-if (!empty($userid) && $userid!=-1) $stats_project->userid=$userid;
-if (!empty($socid)  && $socid!=-1) $stats_project->socid=$socid;
-if (!empty($year)) $stats_project->year=$year;
+$stats_project = new ProjectStats($db);
+if (!empty($userid) && $userid != -1) $stats_project->userid = $userid;
+if (!empty($socid) && $socid != -1) $stats_project->socid = $socid;
+if (!empty($year)) $stats_project->year = $year;
 
 
 
-if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 {
 	$data1 = $stats_project->getAllProjectByStatus();
-	if (!is_array($data1) && $data1<0) {
+	if (!is_array($data1) && $data1 < 0) {
 		setEventMessages($stats_project->error, null, 'errors');
 	}
 	if (empty($data1))
 	{
-		$showpointvalue=0;
-		$nocolor=1;
-		$data1=array(array(0=>$langs->trans("None"),1=>1));
+		$showpointvalue = 0;
+		$nocolor = 1;
+		$data1 = array(array(0=>$langs->trans("None"), 1=>1));
 	}
 
-	$filenamenb = $conf->project->dir_output . "/stats/projectbystatus.png";
-	$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projectbystatus.png';
+	$filenamenb = $conf->project->dir_output."/stats/projectbystatus.png";
+	$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=projectstats&amp;file=projectbystatus.png';
 	$px = new DolGraph();
 	$mesg = $px->isGraphKo();
 	if (empty($mesg)) {
-		$i=0;$tot=count($data1);$legend=array();
+		$i = 0; $tot = count($data1); $legend = array();
 		while ($i <= $tot)
 		{
-			$data1[$i][0]=$data1[$i][0];	// Required to avoid error "Could not draw pie with labels contained inside canvas"
-			$legend[]=$data1[$i][0];
+			$data1[$i][0] = $data1[$i][0]; // Required to avoid error "Could not draw pie with labels contained inside canvas"
+			$legend[] = $data1[$i][0];
 			$i++;
 		}
 		$px->SetData($data1);
 		unset($data1);
 
 		if ($nocolor)
-		$px->SetDataColor(array (
-					array (
+		$px->SetDataColor(array(
+					array(
 							220,
 							220,
 							220
@@ -125,12 +125,12 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 			$px->SetShading(3);
 			$px->SetHorizTickIncrement(1);
 			$px->SetCssPrefix("cssboxes");
-			$px->SetType(array (
+			$px->SetType(array(
 					'pie'
 			));
 			$px->SetTitle($langs->trans('OpportunitiesStatusForProjects'));
-			$result=$px->draw($filenamenb, $fileurlnb);
-		if ($result<0) {
+			$result = $px->draw($filenamenb, $fileurlnb);
+		if ($result < 0) {
 			setEventMessages($px->error, null, 'errors');
 		}
 	} else {
@@ -144,18 +144,18 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 $data = $stats_project->getNbByMonthWithPrevYear($endyear, $startyear);
 //var_dump($data);
 
-$filenamenb = $conf->project->dir_output . "/stats/projectnbprevyear-".$year.".png";
-$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projectnbprevyear-'.$year.'.png';
+$filenamenb = $conf->project->dir_output."/stats/projectnbprevyear-".$year.".png";
+$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=projectstats&amp;file=projectnbprevyear-'.$year.'.png';
 
 $px1 = new DolGraph();
 $mesg = $px1->isGraphKo();
-if (! $mesg)
+if (!$mesg)
 {
 	$px1->SetData($data);
-	$i=$startyear;$legend=array();
+	$i = $startyear; $legend = array();
 	while ($i <= $endyear)
 	{
-		$legend[]=$i;
+		$legend[] = $i;
 		$i++;
 	}
 	$px1->SetLegend($legend);
@@ -165,32 +165,32 @@ if (! $mesg)
 	$px1->SetYLabel($langs->trans("ProjectNbProject"));
 	$px1->SetShading(3);
 	$px1->SetHorizTickIncrement(1);
-	$px1->mode='depth';
+	$px1->mode = 'depth';
 	$px1->SetTitle($langs->trans("ProjectNbProjectByMonth"));
 
 	$px1->draw($filenamenb, $fileurlnb);
 }
 
 
-if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 {
 	// Build graphic amount of object
 	$data = $stats_project->getAmountByMonthWithPrevYear($endyear, $startyear);
 	//var_dump($data);
 	// $data = array(array('Lib',val1,val2,val3),...)
 
-	$filenamenb = $conf->project->dir_output . "/stats/projectamountprevyear-".$year.".png";
-	$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projectamountprevyear-'.$year.'.png';
+	$filenamenb = $conf->project->dir_output."/stats/projectamountprevyear-".$year.".png";
+	$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=projectstats&amp;file=projectamountprevyear-'.$year.'.png';
 
 	$px2 = new DolGraph();
 	$mesg = $px2->isGraphKo();
-	if (! $mesg)
+	if (!$mesg)
 	{
 		$px2->SetData($data);
-		$i=$startyear;$legend=array();
+		$i = $startyear; $legend = array();
 		while ($i <= $endyear)
 		{
-			$legend[]=$i;
+			$legend[] = $i;
 			$i++;
 		}
 		$px2->SetLegend($legend);
@@ -201,32 +201,32 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 		$px2->SetYLabel($langs->trans("ProjectOppAmountOfProjectsByMonth"));
 		$px2->SetShading(3);
 		$px2->SetHorizTickIncrement(1);
-		$px2->mode='depth';
+		$px2->mode = 'depth';
 		$px2->SetTitle($langs->trans("ProjectOppAmountOfProjectsByMonth"));
 
 		$px2->draw($filenamenb, $fileurlnb);
 	}
 }
 
-if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 {
 	// Build graphic with transformation rate
 	$data = $stats_project->getWeightedAmountByMonthWithPrevYear($endyear, $startyear, 0, 0);
 	//var_dump($data);
 	// $data = array(array('Lib',val1,val2,val3),...)
 
-	$filenamenb = $conf->project->dir_output . "/stats/projecttransrateprevyear-".$year.".png";
-	$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projecttransrateprevyear-'.$year.'.png';
+	$filenamenb = $conf->project->dir_output."/stats/projecttransrateprevyear-".$year.".png";
+	$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=projectstats&amp;file=projecttransrateprevyear-'.$year.'.png';
 
 	$px3 = new DolGraph();
 	$mesg = $px3->isGraphKo();
-	if (! $mesg)
+	if (!$mesg)
 	{
 		$px3->SetData($data);
-		$i=$startyear;$legend=array();
+		$i = $startyear; $legend = array();
 		while ($i <= $endyear)
 		{
-			$legend[]=$i;
+			$legend[] = $i;
 			$i++;
 		}
 		$px3->SetLegend($legend);
@@ -237,7 +237,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 		$px3->SetYLabel($langs->trans("ProjectWeightedOppAmountOfProjectsByMonth"));
 		$px3->SetShading(3);
 		$px3->SetHorizTickIncrement(1);
-		$px3->mode='depth';
+		$px3->mode = 'depth';
 		$px3->SetTitle($langs->trans("ProjectWeightedOppAmountOfProjectsByMonth"));
 
 		$px3->draw($filenamenb, $fileurlnb);
@@ -246,20 +246,20 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 
 
 // Show array
-$stats_project->year=0;
+$stats_project->year = 0;
 $data_all_year = $stats_project->getAllByYear();
 
-if (!empty($year)) $stats_project->year=$year;
-$arrayyears=array();
-foreach($data_all_year as $val) {
-	$arrayyears[$val['year']]=$val['year'];
+if (!empty($year)) $stats_project->year = $year;
+$arrayyears = array();
+foreach ($data_all_year as $val) {
+	$arrayyears[$val['year']] = $val['year'];
 }
-if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
+if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
 
 
-$h=0;
+$h = 0;
 $head = array();
-$head[$h][0] = DOL_URL_ROOT . '/projet/stats/index.php';
+$head[$h][0] = DOL_URL_ROOT.'/projet/stats/index.php';
 $head[$h][1] = $langs->trans("ByMonthYear");
 $head[$h][2] = 'byyear';
 $h++;
@@ -285,8 +285,8 @@ print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist);
 print '</td></tr>';*/
 // Year
 print '<tr><td>'.$langs->trans("Year").'</td><td>';
-if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year;
-if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear;
+if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
+if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
 arsort($arrayyears);
 print $form->selectarray('year', $arrayyears, $year, 0);
 print '</td></tr>';
@@ -300,7 +300,7 @@ print '<table class="noborder centpercent">';
 print '<tr class="liste_titre" height="24">';
 print '<td class="center">'.$langs->trans("Year").'</td>';
 print '<td class="right">'.$langs->trans("NbOfProjects").'</td>';
-if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 {
 	print '<td class="right">'.$langs->trans("OpportunityAmountShort").'</td>';
 	print '<td class="right">'.$langs->trans("OpportunityAmountAverageShort").'</td>';
@@ -308,17 +308,17 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 }
 print '</tr>';
 
-$oldyear=0;
+$oldyear = 0;
 foreach ($data_all_year as $val)
 {
 	$year = $val['year'];
-	while ($year && $oldyear > $year+1)
+	while ($year && $oldyear > $year + 1)
 	{	// If we have empty year
 		$oldyear--;
 
 		print '<tr class="oddeven" height="24">';
-		print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.'</a></td>';
-		if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+		print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$oldyear.'</a></td>';
+		if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 		{
 			print '<td class="right">0</td>';
 			print '<td class="right">0</td>';
@@ -329,16 +329,16 @@ foreach ($data_all_year as $val)
 	}
 
 	print '<tr class="oddeven" height="24">';
-	print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.'</a></td>';
+	print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>';
 	print '<td class="right">'.$val['nb'].'</td>';
-	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+	if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 	{
-		print '<td class="right">'.($val['total']?price(price2num($val['total'], 'MT'), 1):'0').'</td>';
-		print '<td class="right">'.($val['avg']?price(price2num($val['avg'], 'MT'), 1):'0').'</td>';
-		print '<td class="right">'.($val['weighted']?price(price2num($val['weighted'], 'MT'), 1):'0').'</td>';
+		print '<td class="right">'.($val['total'] ?price(price2num($val['total'], 'MT'), 1) : '0').'</td>';
+		print '<td class="right">'.($val['avg'] ?price(price2num($val['avg'], 'MT'), 1) : '0').'</td>';
+		print '<td class="right">'.($val['weighted'] ?price(price2num($val['weighted'], 'MT'), 1) : '0').'</td>';
 	}
 	print '</tr>';
-	$oldyear=$year;
+	$oldyear = $year;
 }
 
 print '</table>';
@@ -346,21 +346,21 @@ print '</div>';
 
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
-$stringtoshow.= '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
+$stringtoshow .= '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
 if ($mesg) { print $mesg; }
 else {
-	$stringtoshow.= $px1->show();
-	$stringtoshow.= "<br>\n";
-	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+	$stringtoshow .= $px1->show();
+	$stringtoshow .= "<br>\n";
+	if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
 	{
-		$stringtoshow.= $px->show();
-		$stringtoshow.= "<br>\n";
-		$stringtoshow.= $px2->show();
-		$stringtoshow.= "<br>\n";
-		$stringtoshow.= $px3->show();
+		$stringtoshow .= $px->show();
+		$stringtoshow .= "<br>\n";
+		$stringtoshow .= $px2->show();
+		$stringtoshow .= "<br>\n";
+		$stringtoshow .= $px3->show();
 	}
 }
-$stringtoshow.= '</td></tr></table>';
+$stringtoshow .= '</td></tr></table>';
 
 print $stringtoshow;
 

+ 42 - 42
htdocs/projet/tasks/stats/index.php

@@ -28,26 +28,26 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/projet/class/taskstats.class.php';
 
 // Security check
-if (! $user->rights->projet->lire)
+if (!$user->rights->projet->lire)
 	accessforbidden();
 
 
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
 
-$userid=GETPOST('userid', 'int');
-$socid=GETPOST('socid', 'int');
+$userid = GETPOST('userid', 'int');
+$socid = GETPOST('socid', 'int');
 // Security check
 if ($user->socid > 0)
 {
 	$action = '';
 	$socid = $user->socid;
 }
-$nowyear=strftime("%Y", dol_now());
-$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
+$nowyear = strftime("%Y", dol_now());
+$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
 //$startyear=$year-2;
-$startyear=$year-1;
-$endyear=$year;
+$startyear = $year - 1;
+$endyear = $year;
 
 // Load translation files required by the page
 $langs->loadlangs(array('companies', 'projects'));
@@ -57,25 +57,25 @@ $langs->loadlangs(array('companies', 'projects'));
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
-$includeuserlist=array();
+$includeuserlist = array();
 
 
 llxHeader('', $langs->trans('Tasks'));
 
-$title=$langs->trans("TasksStatistics");
-$dir=$conf->projet->dir_output.'/temp';
+$title = $langs->trans("TasksStatistics");
+$dir = $conf->projet->dir_output.'/temp';
 
 print load_fiche_titre($title, '', 'project');
 
 dol_mkdir($dir);
 
 
-$stats_tasks= new TaskStats($db);
-if (!empty($userid) && $userid!=-1) $stats_tasks->userid=$userid;
-if (!empty($socid)  && $socid!=-1) $stats_tasks->socid=$socid;
-if (!empty($year)) $stats_tasks->year=$year;
+$stats_tasks = new TaskStats($db);
+if (!empty($userid) && $userid != -1) $stats_tasks->userid = $userid;
+if (!empty($socid) && $socid != -1) $stats_tasks->socid = $socid;
+if (!empty($year)) $stats_tasks->year = $year;
 
 
 
@@ -84,18 +84,18 @@ if (!empty($year)) $stats_tasks->year=$year;
 $data = $stats_tasks->getNbByMonthWithPrevYear($endyear, $startyear);
 //var_dump($data);
 
-$filenamenb = $conf->project->dir_output . "/stats/tasknbprevyear-".$year.".png";
-$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=taskstats&amp;file=tasknbprevyear-'.$year.'.png';
+$filenamenb = $conf->project->dir_output."/stats/tasknbprevyear-".$year.".png";
+$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=taskstats&amp;file=tasknbprevyear-'.$year.'.png';
 
 $px1 = new DolGraph();
 $mesg = $px1->isGraphKo();
-if (! $mesg)
+if (!$mesg)
 {
 	$px1->SetData($data);
-	$i=$startyear;$legend=array();
+	$i = $startyear; $legend = array();
 	while ($i <= $endyear)
 	{
-		$legend[]=$i;
+		$legend[] = $i;
 		$i++;
 	}
 	$px1->SetLegend($legend);
@@ -105,7 +105,7 @@ if (! $mesg)
 	$px1->SetYLabel($langs->trans("ProjectNbTask"));
 	$px1->SetShading(3);
 	$px1->SetHorizTickIncrement(1);
-	$px1->mode='depth';
+	$px1->mode = 'depth';
 	$px1->SetTitle($langs->trans("ProjectNbTaskByMonth"));
 
 	$px1->draw($filenamenb, $fileurlnb);
@@ -113,20 +113,20 @@ if (! $mesg)
 
 
 // Show array
-$stats_tasks->year=0;
+$stats_tasks->year = 0;
 $data_all_year = $stats_tasks->getAllByYear();
 
-if (!empty($year)) $stats_tasks->year=$year;
-$arrayyears=array();
-foreach($data_all_year as $val) {
-	$arrayyears[$val['year']]=$val['year'];
+if (!empty($year)) $stats_tasks->year = $year;
+$arrayyears = array();
+foreach ($data_all_year as $val) {
+	$arrayyears[$val['year']] = $val['year'];
 }
-if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
+if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
 
 
-$h=0;
+$h = 0;
 $head = array();
-$head[$h][0] = DOL_URL_ROOT . '/projet/tasks/stats/index.php?mode='.$mode;
+$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/stats/index.php?mode='.$mode;
 $head[$h][1] = $langs->trans("ByMonthYear");
 $head[$h][2] = 'byyear';
 $h++;
@@ -153,8 +153,8 @@ print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist);
 print '</td></tr>';*/
 // Year
 print '<tr><td>'.$langs->trans("Year").'</td><td>';
-if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year;
-if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear;
+if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
+if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
 arsort($arrayyears);
 print $form->selectarray('year', $arrayyears, $year, 0);
 print '</td></tr>';
@@ -171,25 +171,25 @@ print '<td class="center">'.$langs->trans("Year").'</td>';
 print '<td class="right">'.$langs->trans("NbOfTasks").'</td>';
 print '</tr>';
 
-$oldyear=0;
+$oldyear = 0;
 foreach ($data_all_year as $val)
 {
 	$year = $val['year'];
-	while ($year && $oldyear > $year+1)
+	while ($year && $oldyear > $year + 1)
 	{	// If we have empty year
 		$oldyear--;
 
 		print '<tr class="oddeven" height="24">';
-		print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.'</a></td>';
+		print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$oldyear.'</a></td>';
 		print '<td class="right">0</td>';
 		print '</tr>';
 	}
 
 	print '<tr class="oddeven" height="24">';
-	print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.'</a></td>';
+	print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>';
 	print '<td class="right">'.$val['nb'].'</td>';
 	print '</tr>';
-	$oldyear=$year;
+	$oldyear = $year;
 }
 
 print '</table>';
@@ -197,13 +197,13 @@ print '</div>';
 
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
-$stringtoshow.= '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
+$stringtoshow .= '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
 if ($mesg) { print $mesg; }
 else {
-	$stringtoshow.= $px1->show();
-	$stringtoshow.= "<br>\n";
+	$stringtoshow .= $px1->show();
+	$stringtoshow .= "<br>\n";
 }
-$stringtoshow.= '</td></tr></table>';
+$stringtoshow .= '</td></tr></table>';
 
 print $stringtoshow;
 

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